Skip to content

Commit

Permalink
xfs: move the di_size field to struct xfs_inode
Browse files Browse the repository at this point in the history
In preparation of removing the historic icinode struct, move the on-disk
size field into the containing xfs_inode structure.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Darrick J. Wong committed Apr 7, 2021
1 parent ceaf603 commit 13d2c10
Show file tree
Hide file tree
Showing 29 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ xfs_bmap_last_offset(

/*
* Returns whether the selected fork of the inode has exactly one
* block or not. For the data fork we check this matches di_size,
* block or not. For the data fork we check this matches i_disk_size,
* implying the file's range is 0..bsize-1.
*/
int /* 1=>1 block, 0=>otherwise */
Expand Down
14 changes: 7 additions & 7 deletions fs/xfs/libxfs/xfs_dir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ xfs_dir_isempty(
xfs_dir2_sf_hdr_t *sfp;

ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
if (dp->i_d.di_size == 0) /* might happen during shutdown. */
if (dp->i_disk_size == 0) /* might happen during shutdown. */
return 1;
if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
if (dp->i_disk_size > XFS_IFORK_DSIZE(dp))
return 0;
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
return !sfp->count;
Expand Down Expand Up @@ -584,8 +584,8 @@ xfs_dir2_grow_inode(
xfs_fsize_t size; /* directory file (data) size */

size = XFS_FSB_TO_B(mp, bno + count);
if (size > dp->i_d.di_size) {
dp->i_d.di_size = size;
if (size > dp->i_disk_size) {
dp->i_disk_size = size;
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
}
}
Expand All @@ -608,7 +608,7 @@ xfs_dir2_isblock(
rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
if (XFS_IS_CORRUPT(args->dp->i_mount,
rval != 0 &&
args->dp->i_d.di_size != args->geo->blksize))
args->dp->i_disk_size != args->geo->blksize))
return -EFSCORRUPTED;
*vp = rval;
return 0;
Expand Down Expand Up @@ -687,7 +687,7 @@ xfs_dir2_shrink_inode(
/*
* If the block isn't the last one in the directory, we're done.
*/
if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
if (dp->i_disk_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
return 0;
bno = da;
if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) {
Expand All @@ -703,7 +703,7 @@ xfs_dir2_shrink_inode(
/*
* Set the size to the new last block.
*/
dp->i_d.di_size = XFS_FSB_TO_B(mp, bno);
dp->i_disk_size = XFS_FSB_TO_B(mp, bno);
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions fs/xfs/libxfs/xfs_dir2_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ xfs_dir2_leaf_to_block(
* been left behind during no-space-reservation operations.
* These will show up in the leaf bests table.
*/
while (dp->i_d.di_size > args->geo->blksize) {
while (dp->i_disk_size > args->geo->blksize) {
int hdrsz;

hdrsz = args->geo->data_entry_offset;
Expand Down Expand Up @@ -1097,13 +1097,13 @@ xfs_dir2_sf_to_block(
trace_xfs_dir2_sf_to_block(args);

ASSERT(ifp->if_flags & XFS_IFINLINE);
ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));

oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;

ASSERT(ifp->if_bytes == dp->i_d.di_size);
ASSERT(ifp->if_bytes == dp->i_disk_size);
ASSERT(ifp->if_u1.if_data != NULL);
ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
ASSERT(dp->i_df.if_nextents == 0);

/*
Expand All @@ -1115,7 +1115,7 @@ xfs_dir2_sf_to_block(

xfs_idata_realloc(dp, -ifp->if_bytes, XFS_DATA_FORK);
xfs_bmap_local_to_extents_empty(tp, dp, XFS_DATA_FORK);
dp->i_d.di_size = 0;
dp->i_disk_size = 0;

/*
* Add block 0 to the inode.
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_dir2_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ xfs_dir3_leaf_check_int(
/*
* XXX (dgc): This value is not restrictive enough.
* Should factor in the size of the bests table as well.
* We can deduce a value for that from di_size.
* We can deduce a value for that from i_disk_size.
*/
if (hdr->count > geo->leaf_max_ents)
return __this_address;
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_dir2_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ xfs_dir2_leaf_to_node(
leaf = lbp->b_addr;
ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
if (be32_to_cpu(ltp->bestcount) >
(uint)dp->i_d.di_size / args->geo->blksize) {
(uint)dp->i_disk_size / args->geo->blksize) {
xfs_buf_mark_corrupt(lbp);
return -EFSCORRUPTED;
}
Expand Down
46 changes: 23 additions & 23 deletions fs/xfs/libxfs/xfs_dir2_sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ xfs_dir2_block_to_sf(
ASSERT(dp->i_df.if_bytes == 0);
xfs_init_local_fork(dp, XFS_DATA_FORK, sfp, size);
dp->i_df.if_format = XFS_DINODE_FMT_LOCAL;
dp->i_d.di_size = size;
dp->i_disk_size = size;

logflags |= XFS_ILOG_DDATA;
xfs_dir2_sf_check(args);
Expand All @@ -367,7 +367,7 @@ xfs_dir2_sf_addname(
xfs_inode_t *dp; /* incore directory inode */
int error; /* error return value */
int incr_isize; /* total change in size */
int new_isize; /* di_size after adding name */
int new_isize; /* size after adding name */
int objchange; /* changing to 8-byte inodes */
xfs_dir2_data_aoff_t offset = 0; /* offset for new entry */
int pick; /* which algorithm to use */
Expand All @@ -379,11 +379,11 @@ xfs_dir2_sf_addname(
ASSERT(xfs_dir2_sf_lookup(args) == -ENOENT);
dp = args->dp;
ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
/*
* Compute entry (and change in) size.
*/
Expand All @@ -401,7 +401,7 @@ xfs_dir2_sf_addname(
objchange = 1;
}

new_isize = (int)dp->i_d.di_size + incr_isize;
new_isize = (int)dp->i_disk_size + incr_isize;
/*
* Won't fit as shortform any more (due to size),
* or the pick routine says it won't (due to offset values).
Expand Down Expand Up @@ -492,7 +492,7 @@ xfs_dir2_sf_addname_easy(
sfp->count++;
if (args->inumber > XFS_DIR2_MAX_SHORT_INUM)
sfp->i8count++;
dp->i_d.di_size = new_isize;
dp->i_disk_size = new_isize;
xfs_dir2_sf_check(args);
}

Expand All @@ -519,7 +519,7 @@ xfs_dir2_sf_addname_hard(
int nbytes; /* temp for byte copies */
xfs_dir2_data_aoff_t new_offset; /* next offset value */
xfs_dir2_data_aoff_t offset; /* current offset value */
int old_isize; /* previous di_size */
int old_isize; /* previous size */
xfs_dir2_sf_entry_t *oldsfep; /* entry in original dir */
xfs_dir2_sf_hdr_t *oldsfp; /* original shortform dir */
xfs_dir2_sf_entry_t *sfep; /* entry in new dir */
Expand All @@ -529,7 +529,7 @@ xfs_dir2_sf_addname_hard(
* Copy the old directory to the stack buffer.
*/
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
old_isize = (int)dp->i_d.di_size;
old_isize = (int)dp->i_disk_size;
buf = kmem_alloc(old_isize, 0);
oldsfp = (xfs_dir2_sf_hdr_t *)buf;
memcpy(oldsfp, sfp, old_isize);
Expand Down Expand Up @@ -586,7 +586,7 @@ xfs_dir2_sf_addname_hard(
memcpy(sfep, oldsfep, old_isize - nbytes);
}
kmem_free(buf);
dp->i_d.di_size = new_isize;
dp->i_disk_size = new_isize;
xfs_dir2_sf_check(args);
}

Expand Down Expand Up @@ -697,7 +697,7 @@ xfs_dir2_sf_check(
ASSERT(xfs_dir2_sf_get_ftype(mp, sfep) < XFS_DIR3_FT_MAX);
}
ASSERT(i8count == sfp->i8count);
ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size);
ASSERT((char *)sfep - (char *)sfp == dp->i_disk_size);
ASSERT(offset +
(sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
(uint)sizeof(xfs_dir2_block_tail_t) <= args->geo->blksize);
Expand Down Expand Up @@ -821,7 +821,7 @@ xfs_dir2_sf_create(
dp = args->dp;

ASSERT(dp != NULL);
ASSERT(dp->i_d.di_size == 0);
ASSERT(dp->i_disk_size == 0);
/*
* If it's currently a zero-length extent file,
* convert it to local format.
Expand Down Expand Up @@ -850,7 +850,7 @@ xfs_dir2_sf_create(
*/
xfs_dir2_sf_put_parent_ino(sfp, pino);
sfp->count = 0;
dp->i_d.di_size = size;
dp->i_disk_size = size;
xfs_dir2_sf_check(args);
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
return 0;
Expand Down Expand Up @@ -878,11 +878,11 @@ xfs_dir2_sf_lookup(
xfs_dir2_sf_check(args);

ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
/*
* Special case for .
*/
Expand Down Expand Up @@ -955,7 +955,7 @@ xfs_dir2_sf_removename(
trace_xfs_dir2_sf_removename(args);

ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
oldsize = (int)dp->i_d.di_size;
oldsize = (int)dp->i_disk_size;
ASSERT(oldsize >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_df.if_bytes == oldsize);
ASSERT(dp->i_df.if_u1.if_data != NULL);
Expand Down Expand Up @@ -995,7 +995,7 @@ xfs_dir2_sf_removename(
* Fix up the header and file size.
*/
sfp->count--;
dp->i_d.di_size = newsize;
dp->i_disk_size = newsize;
/*
* Reallocate, making it smaller.
*/
Expand Down Expand Up @@ -1054,11 +1054,11 @@ xfs_dir2_sf_replace(
trace_xfs_dir2_sf_replace(args);

ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
ASSERT(dp->i_df.if_bytes == dp->i_disk_size);
ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(sfp->i8count));

/*
* New inode number is large, and need to convert to 8-byte inodes.
Expand Down Expand Up @@ -1219,7 +1219,7 @@ xfs_dir2_sf_toino4(
* Clean up the inode.
*/
kmem_free(buf);
dp->i_d.di_size = newsize;
dp->i_disk_size = newsize;
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
}

Expand Down Expand Up @@ -1292,6 +1292,6 @@ xfs_dir2_sf_toino8(
* Clean up the inode.
*/
kmem_free(buf);
dp->i_d.di_size = newsize;
dp->i_disk_size = newsize;
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
}
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_inode_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ xfs_inode_from_disk(
inode->i_mtime = xfs_inode_from_disk_ts(from, from->di_mtime);
inode->i_ctime = xfs_inode_from_disk_ts(from, from->di_ctime);

to->di_size = be64_to_cpu(from->di_size);
ip->i_disk_size = be64_to_cpu(from->di_size);
to->di_nblocks = be64_to_cpu(from->di_nblocks);
to->di_extsize = be32_to_cpu(from->di_extsize);
to->di_forkoff = from->di_forkoff;
Expand Down Expand Up @@ -305,7 +305,7 @@ xfs_inode_to_disk(
to->di_gen = cpu_to_be32(inode->i_generation);
to->di_mode = cpu_to_be16(inode->i_mode);

to->di_size = cpu_to_be64(from->di_size);
to->di_size = cpu_to_be64(ip->i_disk_size);
to->di_nblocks = cpu_to_be64(from->di_nblocks);
to->di_extsize = cpu_to_be32(from->di_extsize);
to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
Expand Down
1 change: 0 additions & 1 deletion fs/xfs/libxfs/xfs_inode_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ struct xfs_dinode;
*/
struct xfs_icdinode {
uint16_t di_flushiter; /* incremented on flush */
xfs_fsize_t di_size; /* number of bytes in file */
xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */
xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_inode_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ xfs_iformat_data_fork(
case S_IFCHR:
case S_IFBLK:
case S_IFSOCK:
ip->i_d.di_size = 0;
ip->i_disk_size = 0;
inode->i_rdev = xfs_to_linux_dev_t(xfs_dinode_get_rdev(dip));
return 0;
case S_IFREG:
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/scrub/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ xchk_directory_leaf1_bestfree(
* There should be as many bestfree slots as there are dir data
* blocks that can fit under i_size.
*/
if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_d.di_size)) {
if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_disk_size)) {
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
goto out;
}
Expand Down Expand Up @@ -808,7 +808,7 @@ xchk_directory(
return -ENOENT;

/* Plausible size? */
if (sc->ip->i_d.di_size < xfs_dir2_sf_hdr_size(0)) {
if (sc->ip->i_disk_size < xfs_dir2_sf_hdr_size(0)) {
xchk_ino_set_corrupt(sc, sc->ip->i_ino);
goto out;
}
Expand All @@ -834,7 +834,7 @@ xchk_directory(
* Userspace usually asks for a 32k buffer, so we will too.
*/
bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
sc->ip->i_d.di_size);
sc->ip->i_disk_size);

/*
* Look up every name in this directory by hash.
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/scrub/parent.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ xchk_parent_count_parent_dentries(
* scanned.
*/
bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE,
parent->i_d.di_size);
parent->i_disk_size);
oldpos = 0;
while (true) {
error = xfs_readdir(sc->tp, parent, &spc.dc, bufsize);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/scrub/rtbitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ xchk_rtbitmap(
int error;

/* Is the size of the rtbitmap correct? */
if (sc->mp->m_rbmip->i_d.di_size !=
if (sc->mp->m_rbmip->i_disk_size !=
XFS_FSB_TO_B(sc->mp, sc->mp->m_sb.sb_rbmblocks)) {
xchk_ino_set_corrupt(sc, sc->mp->m_rbmip->i_ino);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/scrub/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ xchk_symlink(
if (!S_ISLNK(VFS_I(ip)->i_mode))
return -ENOENT;
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
len = ip->i_d.di_size;
len = ip->i_disk_size;

/* Plausible size? */
if (len > XFS_SYMLINK_MAXLEN || len <= 0) {
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ XFS_WPC(struct iomap_writepage_ctx *ctx)
static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
{
return ioend->io_offset + ioend->io_size >
XFS_I(ioend->io_inode)->i_d.di_size;
XFS_I(ioend->io_inode)->i_disk_size;
}

STATIC int
Expand Down Expand Up @@ -88,7 +88,7 @@ __xfs_setfilesize(

trace_xfs_setfilesize(ip, offset, size);

ip->i_d.di_size = isize;
ip->i_disk_size = isize;
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);

Expand Down
Loading

0 comments on commit 13d2c10

Please sign in to comment.