From: Christoph Hellwig Date: Wed, 30 Jun 2021 22:34:41 +0000 (-0400) Subject: xfs: use a union for i_cowextsize and i_flushiter X-Git-Tag: v5.13.0-rc0~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc1d7a098a31c0244fec4cacda62fab17a196736;p=thirdparty%2Fxfsprogs-dev.git xfs: use a union for i_cowextsize and i_flushiter Source kernel commit: ee7b83fd365e32beaa405d60b8c42f42ec5f42c2 The i_cowextsize field is only used for v3 inodes, and the i_flushiter field is only used for v1/v2 inodes. Use a union to pack the inode a littler better after adding a few missing guards around their usage. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/include/xfs_inode.h b/include/xfs_inode.h index d7168d087..9c3d296b9 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -82,8 +82,11 @@ typedef struct xfs_inode { xfs_rfsblock_t i_nblocks; /* # of direct & btree blocks */ prid_t i_projid; /* owner's project id */ xfs_extlen_t i_extsize; /* basic/minimum extent size */ - xfs_extlen_t i_cowextsize; /* basic cow extent size */ - uint16_t i_flushiter; /* incremented on flush */ + /* cowextsize is only used for v3 inodes, flushiter for v1/2 */ + union { + xfs_extlen_t i_cowextsize; /* basic cow extent size */ + uint16_t i_flushiter; /* incremented on flush */ + }; struct xfs_icdinode i_d; /* most of ondisk inode */ xfs_extnum_t i_cnextents; /* # of extents in cow fork */ diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 252ff3d63..d1937384b 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -190,7 +190,8 @@ xfs_inode_from_disk( * inode. If the inode is unused, mode is zero and we shouldn't mess * with the uninitialized part of it. */ - ip->i_flushiter = be16_to_cpu(from->di_flushiter); + if (!xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) + ip->i_flushiter = be16_to_cpu(from->di_flushiter); inode->i_generation = be32_to_cpu(from->di_gen); inode->i_mode = be16_to_cpu(from->di_mode); if (!inode->i_mode)