]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_repair: checking rt free space metadata must happen during phase 4
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Oct 2024 00:03:33 +0000 (17:03 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:05 +0000 (15:45 -0700)
Back in the really old days, xfs_repair would generate the new free
space information for the realtime section during phase 5, and write the
contents to the rtbitmap and summary files during phase 6.  This was ok
because the incore information isn't used until phase 6.

Then I changed the behavior to check the generated information against
what was on disk and complain about the discrepancies.  Unfortunately,
there was a subtle flaw here -- for a non -n run, we'll have regenerated
the AG metadata before we actually check the rt free space information.
If the AG btree regeneration should clobber one of the old rtbitmap or
summary blocks, this will be reported as a corruption even though
nothing's wrong.

Move check_rtmetadata to the end of phase 4 so that this doesn't happen.

Cc: <linux-xfs@vger.kernel.org> # v5.19.0
Fixes: f2e388616d7491 ("xfs_repair: check free rt extent count")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
repair/phase4.c
repair/phase5.c
repair/xfs_repair.c

index 5e5d8c3c7d9b9624ca5ba061f77227bb5227b340..071f20ed736e4b323a96a182c28bab3fdcbeb299 100644 (file)
@@ -401,4 +401,11 @@ phase4(xfs_mount_t *mp)
         */
        quotino_check(mp);
        quota_sb_check(mp);
+
+       /* Check the rt metadata before we rebuild */
+       if (mp->m_sb.sb_rblocks)  {
+               do_log(
+               _("        - generate realtime summary info and bitmap...\n"));
+               check_rtmetadata(mp);
+       }
 }
index d18ec095b0524ba24467656e0176e87630b74772..9207da7172c05bd26e4eadedf6cecdc60f7cab7f 100644 (file)
@@ -694,12 +694,6 @@ phase5(xfs_mount_t *mp)
        free(sb_ifree_ag);
        free(sb_fdblocks_ag);
 
-       if (mp->m_sb.sb_rblocks)  {
-               do_log(
-               _("        - generate realtime summary info and bitmap...\n"));
-               check_rtmetadata(mp);
-       }
-
        do_log(_("        - reset superblock...\n"));
 
        /*
index e325d61f10367ef410bcde8649abad2ea6c0a4b7..3ade85bbcbb7fd771b2b807d1dd49f7675431eb9 100644 (file)
@@ -1318,9 +1318,6 @@ main(int argc, char **argv)
 
        if (no_modify) {
                printf(_("No modify flag set, skipping phase 5\n"));
-
-               if (mp->m_sb.sb_rblocks > 0)
-                       check_rtmetadata(mp);
        } else {
                phase5(mp);
        }