]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add a new xfs_sb_version_has_v3inode helper
authorChristoph Hellwig <hch@lst.de>
Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)
committerEric Sandeen <sandeen@redhat.com>
Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)
Source kernel commit: b81b79f4eda2ea98ae5695c0b6eb384c8d90b74d

Add a new wrapper to check if a file system supports the v3 inode format
with a larger dinode core.  Previously we used xfs_sb_version_hascrc for
that, which is technically correct but a little confusing to read.

Also move xfs_dinode_good_version next to xfs_sb_version_has_v3inode
so that we have one place that documents the superblock version to
inode version relationship.

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/xfs_format.h
libxfs/xfs_ialloc.c
libxfs/xfs_inode_buf.c
libxfs/xfs_inode_buf.h
libxfs/xfs_trans_resv.c
repair/dinode.c
repair/prefetch.c

index 125c5c7880ea9b1e321cd7fba2cb2aba3c20a454..bb66135a29de00ea40b17f0a8e9748d4a45b8de5 100644 (file)
@@ -2723,7 +2723,7 @@ process_inode(
                error++;
                return;
        }
-       if (!libxfs_dinode_good_version(mp, xino.i_d.di_version)) {
+       if (!libxfs_dinode_good_version(&mp->m_sb, xino.i_d.di_version)) {
                if (isfree || v)
                        dbprintf(_("bad version number %#x for inode %lld\n"),
                                xino.i_d.di_version, ino);
index 09fd5d23bbeef4eaf0baf5967a118baf9e0daab9..f00012c05e1ffdaee0db4b9872cd4eada81970e4 100644 (file)
@@ -497,6 +497,23 @@ static inline bool xfs_sb_version_hascrc(struct xfs_sb *sbp)
        return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
 }
 
+/*
+ * v5 file systems support V3 inodes only, earlier file systems support
+ * v2 and v1 inodes.
+ */
+static inline bool xfs_sb_version_has_v3inode(struct xfs_sb *sbp)
+{
+       return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
+}
+
+static inline bool xfs_dinode_good_version(struct xfs_sb *sbp,
+               uint8_t version)
+{
+       if (xfs_sb_version_has_v3inode(sbp))
+               return version == 3;
+       return version == 1 || version == 2;
+}
+
 static inline bool xfs_sb_version_has_pquotino(struct xfs_sb *sbp)
 {
        return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
index 616256b44560b44682820a923b57d824b023dc90..fd102ab37fc791353075ffbe0705345f8ddf7e53 100644 (file)
@@ -299,7 +299,7 @@ xfs_ialloc_inode_init(
         * That means for v3 inode we log the entire buffer rather than just the
         * inode cores.
         */
-       if (xfs_sb_version_hascrc(&mp->m_sb)) {
+       if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
                version = 3;
                ino = XFS_AGINO_TO_INO(mp, agno, XFS_AGB_TO_AGINO(mp, agbno));
 
@@ -2867,7 +2867,7 @@ xfs_ialloc_setup_geometry(
         * cannot change the behavior.
         */
        igeo->inode_cluster_size_raw = XFS_INODE_BIG_CLUSTER_SIZE;
-       if (xfs_sb_version_hascrc(&mp->m_sb)) {
+       if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
                int     new_size = igeo->inode_cluster_size_raw;
 
                new_size *= mp->m_sb.sb_inodesize / XFS_DINODE_MIN_SIZE;
index 64651d4ed408c7d46d9591e1f0e7a4961d836773..496aadc0ba15c30306f6a8221a05eee7e0793c41 100644 (file)
@@ -41,17 +41,6 @@ xfs_inobp_check(
 }
 #endif
 
-bool
-xfs_dinode_good_version(
-       struct xfs_mount *mp,
-       __u8            version)
-{
-       if (xfs_sb_version_hascrc(&mp->m_sb))
-               return version == 3;
-
-       return version == 1 || version == 2;
-}
-
 /*
  * If we are doing readahead on an inode buffer, we might be in log recovery
  * reading an inode allocation buffer that hasn't yet been replayed, and hence
@@ -90,7 +79,7 @@ xfs_inode_buf_verify(
                dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog));
                unlinked_ino = be32_to_cpu(dip->di_next_unlinked);
                di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
-                       xfs_dinode_good_version(mp, dip->di_version) &&
+                       xfs_dinode_good_version(&mp->m_sb, dip->di_version) &&
                        xfs_verify_agino_or_null(mp, agno, unlinked_ino);
                if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
                                                XFS_ERRTAG_ITOBP_INOTOBP))) {
@@ -451,7 +440,7 @@ xfs_dinode_verify(
 
        /* Verify v3 integrity information first */
        if (dip->di_version >= 3) {
-               if (!xfs_sb_version_hascrc(&mp->m_sb))
+               if (!xfs_sb_version_has_v3inode(&mp->m_sb))
                        return __this_address;
                if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
                                      XFS_DINODE_CRC_OFF))
@@ -626,7 +615,7 @@ xfs_iread(
 
        /* shortcut IO on inode allocation if possible */
        if ((iget_flags & XFS_IGET_CREATE) &&
-           xfs_sb_version_hascrc(&mp->m_sb) &&
+           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;
index 2683e1e2c4a69f94921bed12c0625f67c31031f1..66de5964045c33d65425ff7cac83b73a7c64a5f4 100644 (file)
@@ -59,8 +59,6 @@ void  xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
 void   xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
                               struct xfs_dinode *to);
 
-bool   xfs_dinode_good_version(struct xfs_mount *mp, __u8 version);
-
 #if defined(DEBUG)
 void   xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
 #else
index 5f3279d47f807d698d33d2af0edb76230eab6739..9ce7d8f99f3f303af1c7f4f32441404d78f89fa5 100644 (file)
@@ -186,7 +186,7 @@ xfs_calc_inode_chunk_res(
                               XFS_FSB_TO_B(mp, 1));
        if (alloc) {
                /* icreate tx uses ordered buffers */
-               if (xfs_sb_version_hascrc(&mp->m_sb))
+               if (xfs_sb_version_has_v3inode(&mp->m_sb))
                        return res;
                size = XFS_FSB_TO_B(mp, 1);
        }
index 8da224db4e7a48059b0b8227720ee9736b1a0b8f..3367c40ee5f02b3f7fc340c012fd65d7f4a81f65 100644 (file)
@@ -2317,7 +2317,7 @@ process_dinode_int(xfs_mount_t *mp,
                }
        }
 
-       if (!libxfs_dinode_good_version(mp, dino->di_version)) {
+       if (!libxfs_dinode_good_version(&mp->m_sb, dino->di_version)) {
                retval = 1;
                if (!uncertain)
                        do_warn(_("bad version number 0x%x on inode %" PRIu64 "%c"),
index 2b7ac36f4f6b105d837d491be266c3dfa1c35820..2eff6e07cf9a0dda50c5ea8087cf49934e6abe3d 100644 (file)
@@ -438,7 +438,7 @@ pf_read_inode_dirs(
                if (be16_to_cpu(dino->di_magic) != XFS_DINODE_MAGIC)
                        continue;
 
-               if (!libxfs_dinode_good_version(mp, dino->di_version))
+               if (!libxfs_dinode_good_version(&mp->m_sb, dino->di_version))
                        continue;
 
                if (be64_to_cpu(dino->di_size) <= XFS_DFORK_DSIZE(dino, mp))