]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use a union for i_cowextsize and i_flushiter
authorChristoph Hellwig <hch@lst.de>
Wed, 30 Jun 2021 22:34:41 +0000 (18:34 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 Jun 2021 22:34:41 +0000 (18:34 -0400)
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 <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_inode.h
libxfs/xfs_inode_buf.c

index d7168d087705b14d841554653ca50a099dd3a306..9c3d296b93f9ee4d8264c63890e0ed7030d66047 100644 (file)
@@ -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 */
index 252ff3d631bbcb2a94609e02ba457f9582d836cf..d1937384ba1b299d9e99d98476952611c90a3318 100644 (file)
@@ -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)