]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: only validate summary counts on primary superblock
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)
Source kernel commit: 1f31c98d650ca342e2f54cb17c4554ad110c5a11

Skip the summary counter checks for secondary superblocks and inprogress
primary superblocks because mkfs has always written those out with
zeroed summary counters.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_sb.c

index 35b4dadeb51028f98c5c06b9e7c18a3a49dec06d..37207d9c5806c5a05c6f94281b3c661722aed978 100644 (file)
@@ -145,6 +145,7 @@ xfs_validate_sb_read(
 STATIC int
 xfs_validate_sb_write(
        struct xfs_mount        *mp,
+       struct xfs_buf          *bp,
        struct xfs_sb           *sbp)
 {
        /*
@@ -152,10 +153,15 @@ xfs_validate_sb_write(
         * the superblock.  We skip this in the read validator because there
         * could be newer superblocks in the log and if the values are garbage
         * even after replay we'll recalculate them at the end of log mount.
+        *
+        * mkfs has traditionally written zeroed counters to inprogress and
+        * secondary superblocks, so allow this usage to continue because
+        * we never read counters from such superblocks.
         */
-       if (sbp->sb_fdblocks > sbp->sb_dblocks ||
-           !xfs_verify_icount(mp, sbp->sb_icount) ||
-           sbp->sb_ifree > sbp->sb_icount) {
+       if (XFS_BUF_ADDR(bp) == XFS_SB_DADDR && !sbp->sb_inprogress &&
+           (sbp->sb_fdblocks > sbp->sb_dblocks ||
+            !xfs_verify_icount(mp, sbp->sb_icount) ||
+            sbp->sb_ifree > sbp->sb_icount)) {
                xfs_warn(mp, "SB summary counter sanity check failed");
                return -EFSCORRUPTED;
        }
@@ -700,7 +706,7 @@ xfs_sb_write_verify(
        error = xfs_validate_sb_common(mp, bp, &sb);
        if (error)
                goto out_error;
-       error = xfs_validate_sb_write(mp, &sb);
+       error = xfs_validate_sb_write(mp, bp, &sb);
        if (error)
                goto out_error;