]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove the di_version field from struct icdinode
authorChristoph Hellwig <hch@lst.de>
Sat, 2 May 2020 03:33:22 +0000 (23:33 -0400)
committerEric Sandeen <sandeen@redhat.com>
Sat, 2 May 2020 03:33:22 +0000 (23:33 -0400)
Source kernel commit: 6471e9c5e7a109a952be8e3e80b8d9e262af239d

We know the version is 3 if on a v5 file system.   For earlier file
systems formats we always upgrade the remaining v1 inodes to v2 and
thus only use v2 inodes.  Use the xfs_sb_version_has_large_dinode
helper to check if we deal with small or large dinodes, and thus
remove the need for the di_version field in struct icdinode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/check.c
libxfs/util.c
libxfs/xfs_inode_buf.c
libxfs/xfs_inode_buf.h
repair/phase6.c

index 9485da43ef45ba81a09cd2aa5105ac326943c540..c9bafa8e3f6058ceb0b9318bd42cd552eb2ecc7b 100644 (file)
@@ -2707,6 +2707,8 @@ process_inode(
                "dev", "local", "extents", "btree", "uuid"
        };
 
+       /* xfs_inode_from_disk expects to have an mp to work with */
+       xino.i_mount = mp;
        libxfs_inode_from_disk(&xino, dip);
 
        ino = XFS_AGINO_TO_INO(mp, be32_to_cpu(agf->agf_seqno), agino);
@@ -2723,10 +2725,10 @@ process_inode(
                error++;
                return;
        }
-       if (!libxfs_dinode_good_version(&mp->m_sb, xino.i_d.di_version)) {
+       if (!libxfs_dinode_good_version(&mp->m_sb, dip->di_version)) {
                if (isfree || v)
                        dbprintf(_("bad version number %#x for inode %lld\n"),
-                               xino.i_d.di_version, ino);
+                               dip->di_version, ino);
                error++;
                return;
        }
index 975bfa267d4edb4d0c9b10eb5bdb341fca6e34a8..73aa547e6015bc2f3bf4d0e4dbcc16da3f0f2892 100644 (file)
@@ -260,20 +260,6 @@ libxfs_ialloc(
        ip->i_d.di_projid = pip ? 0 : fsx->fsx_projid;
        xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD);
 
-       /*
-        * We only support filesystems that understand v2 format inodes. So if
-        * this is currently an old format inode, then change the inode version
-        * number now.  This way we only do the conversion here rather than here
-        * and in the flush/logging code.
-        */
-       if (ip->i_d.di_version == 1) {
-               ip->i_d.di_version = 2;
-               /*
-                * old link count, projid_lo/hi field, pad field
-                * already zeroed
-                */
-       }
-
        if (pip && (VFS_I(pip)->i_mode & S_ISGID)) {
                VFS_I(ip)->i_gid = VFS_I(pip)->i_gid;
                if ((VFS_I(pip)->i_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
@@ -288,7 +274,7 @@ libxfs_ialloc(
        ip->i_d.di_dmstate = 0;
        ip->i_d.di_flags = pip ? 0 : xfs_flags2diflags(ip, fsx->fsx_xflags);
 
-       if (ip->i_d.di_version == 3) {
+       if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
                ASSERT(ip->i_d.di_ino == ino);
                ASSERT(uuid_equal(&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid));
                VFS_I(ip)->i_version = 1;
@@ -381,7 +367,6 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
 
        ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
                ip->i_d.di_nextents > ip->i_df.if_ext_max);
-       ASSERT(ip->i_d.di_version > 1);
 
        iip = ip->i_itemp;
        mp = ip->i_mount;
@@ -402,7 +387,7 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)
        ASSERT(ip->i_d.di_forkoff <= mp->m_sb.sb_inodesize);
 
        /* bump the change count on v3 inodes */
-       if (ip->i_d.di_version == 3)
+       if (xfs_sb_version_has_v3inode(&mp->m_sb))
                VFS_I(ip)->i_version++;
 
        /* Check the inline fork data before we write out. */
index 857e5ea63978c5ec1a9db387dcbf26416fe275af..b65cd0b1a21c597035f9378a18dd65de6e53bc84 100644 (file)
@@ -191,16 +191,14 @@ xfs_inode_from_disk(
        struct xfs_icdinode     *to = &ip->i_d;
        struct inode            *inode = VFS_I(ip);
 
-
        /*
         * Convert v1 inodes immediately to v2 inode format as this is the
         * minimum inode version format we support in the rest of the code.
+        * They will also be unconditionally written back to disk as v2 inodes.
         */
-       to->di_version = from->di_version;
-       if (to->di_version == 1) {
+       if (unlikely(from->di_version == 1)) {
                set_nlink(inode, be16_to_cpu(from->di_onlink));
                to->di_projid = 0;
-               to->di_version = 2;
        } else {
                set_nlink(inode, be32_to_cpu(from->di_nlink));
                to->di_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 |
@@ -238,7 +236,7 @@ xfs_inode_from_disk(
        to->di_dmstate  = be16_to_cpu(from->di_dmstate);
        to->di_flags    = be16_to_cpu(from->di_flags);
 
-       if (to->di_version == 3) {
+       if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
                inode_set_iversion_queried(inode,
                                           be64_to_cpu(from->di_changecount));
                to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec);
@@ -260,7 +258,6 @@ xfs_inode_to_disk(
        to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
        to->di_onlink = 0;
 
-       to->di_version = from->di_version;
        to->di_format = from->di_format;
        to->di_uid = cpu_to_be32(i_uid_read(inode));
        to->di_gid = cpu_to_be32(i_gid_read(inode));
@@ -289,7 +286,8 @@ xfs_inode_to_disk(
        to->di_dmstate = cpu_to_be16(from->di_dmstate);
        to->di_flags = cpu_to_be16(from->di_flags);
 
-       if (from->di_version == 3) {
+       if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
+               to->di_version = 3;
                to->di_changecount = cpu_to_be64(inode_peek_iversion(inode));
                to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec);
                to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec);
@@ -301,6 +299,7 @@ xfs_inode_to_disk(
                uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid);
                to->di_flushiter = 0;
        } else {
+               to->di_version = 2;
                to->di_flushiter = cpu_to_be16(from->di_flushiter);
        }
 }
@@ -618,7 +617,6 @@ xfs_iread(
            xfs_sb_version_has_v3inode(&mp->m_sb) &&
            !(mp->m_flags & XFS_MOUNT_IKEEP)) {
                VFS_I(ip)->i_generation = prandom_u32();
-               ip->i_d.di_version = 3;
                return 0;
        }
 
@@ -660,7 +658,6 @@ xfs_iread(
                 * Partial initialisation of the in-core inode. Just the bits
                 * that xfs_ialloc won't overwrite or relies on being correct.
                 */
-               ip->i_d.di_version = dip->di_version;
                VFS_I(ip)->i_generation = be32_to_cpu(dip->di_gen);
                ip->i_d.di_flushiter = be16_to_cpu(dip->di_flushiter);
 
@@ -674,7 +671,6 @@ xfs_iread(
                VFS_I(ip)->i_mode = 0;
        }
 
-       ASSERT(ip->i_d.di_version >= 2);
        ip->i_delayed_blks = 0;
 
        /*
index 66de5964045c33d65425ff7cac83b73a7c64a5f4..9b373dcf9e34d87553499eb74dac8e1f303bd385 100644 (file)
@@ -16,7 +16,6 @@ struct xfs_dinode;
  * format specific structures at the appropriate time.
  */
 struct xfs_icdinode {
-       int8_t          di_version;     /* inode version */
        int8_t          di_format;      /* format of di_c data */
        uint16_t        di_flushiter;   /* incremented on flush */
        uint32_t        di_projid;      /* owner's project id */
index beceea9a62362facaa3924aaea965faaa6a69c32..a938e802cd9db5923a20a221f009d5c7ecb55b94 100644 (file)
@@ -519,7 +519,6 @@ mk_rbmino(xfs_mount_t *mp)
        int             error;
        xfs_fileoff_t   bno;
        xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
-       int             vers;
        int             times;
        uint            blocks;
 
@@ -538,18 +537,16 @@ mk_rbmino(xfs_mount_t *mp)
                        error);
        }
 
-       vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
        memset(&ip->i_d, 0, sizeof(ip->i_d));
 
        VFS_I(ip)->i_mode = S_IFREG;
-       ip->i_d.di_version = vers;
        ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
        ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
 
        set_nlink(VFS_I(ip), 1);        /* account for sb ptr */
 
        times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
-       if (ip->i_d.di_version == 3) {
+       if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
                VFS_I(ip)->i_version = 1;
                ip->i_d.di_flags2 = 0;
                times |= XFS_ICHGTIME_CREATE;
@@ -765,7 +762,6 @@ mk_rsumino(xfs_mount_t *mp)
        int             nsumblocks;
        xfs_fileoff_t   bno;
        xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
-       int             vers;
        int             times;
        uint            blocks;
 
@@ -784,18 +780,16 @@ mk_rsumino(xfs_mount_t *mp)
                        error);
        }
 
-       vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
        memset(&ip->i_d, 0, sizeof(ip->i_d));
 
        VFS_I(ip)->i_mode = S_IFREG;
-       ip->i_d.di_version = vers;
        ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
        ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
 
        set_nlink(VFS_I(ip), 1);        /* account for sb ptr */
 
        times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
-       if (ip->i_d.di_version == 3) {
+       if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
                VFS_I(ip)->i_version = 1;
                ip->i_d.di_flags2 = 0;
                times |= XFS_ICHGTIME_CREATE;
@@ -870,7 +864,6 @@ mk_root_dir(xfs_mount_t *mp)
        int             error;
        const mode_t    mode = 0755;
        ino_tree_node_t *irec;
-       int             vers;
        int             times;
 
        ip = NULL;
@@ -887,18 +880,16 @@ mk_root_dir(xfs_mount_t *mp)
        /*
         * take care of the core -- initialization from xfs_ialloc()
         */
-       vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
        memset(&ip->i_d, 0, sizeof(ip->i_d));
 
        VFS_I(ip)->i_mode = mode|S_IFDIR;
-       ip->i_d.di_version = vers;
        ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
        ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
 
        set_nlink(VFS_I(ip), 2);        /* account for . and .. */
 
        times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD;
-       if (ip->i_d.di_version == 3) {
+       if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
                VFS_I(ip)->i_version = 1;
                ip->i_d.di_flags2 = 0;
                times |= XFS_ICHGTIME_CREATE;