]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: check free rt extent count
authorDarrick J. Wong <djwong@kernel.org>
Wed, 13 Jul 2022 22:20:56 +0000 (17:20 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 13 Jul 2022 22:20:56 +0000 (17:20 -0500)
Check the superblock's free rt extent count against what we observed.
This increases the runtime and memory usage, but we can now report
undercounting frextents as a result of a logging bug in the kernel.
Note that repair has always fixed the undercount, but it no longer does
that silently.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/phase5.c
repair/protos.h
repair/rt.c
repair/xfs_repair.c

index 74b1dcb93b9e8bc5ed170f8f0cd3862844124a97..273f51a8c3209d2612b660044147cf4c3294e2b2 100644 (file)
@@ -602,6 +602,14 @@ inject_lost_extent(
        return -libxfs_trans_commit(tp);
 }
 
+void
+check_rtmetadata(
+       struct xfs_mount        *mp)
+{
+       rtinit(mp);
+       generate_rtinfo(mp, btmcompute, sumcompute);
+}
+
 void
 phase5(xfs_mount_t *mp)
 {
@@ -671,8 +679,7 @@ phase5(xfs_mount_t *mp)
        if (mp->m_sb.sb_rblocks)  {
                do_log(
                _("        - generate realtime summary info and bitmap...\n"));
-               rtinit(mp);
-               generate_rtinfo(mp, btmcompute, sumcompute);
+               check_rtmetadata(mp);
        }
 
        do_log(_("        - reset superblock...\n"));
index 83734e8501c4fbec960cbc859445d8ada5db213d..03ebae14138f241ca9141ba7656518992b67d8f6 100644 (file)
@@ -36,6 +36,7 @@ void  phase1(struct xfs_mount *);
 void   phase2(struct xfs_mount *, int);
 void   phase3(struct xfs_mount *, int);
 void   phase4(struct xfs_mount *);
+void   check_rtmetadata(struct xfs_mount *mp);
 void   phase5(struct xfs_mount *);
 void   phase6(struct xfs_mount *);
 void   phase7(struct xfs_mount *, int);
index d663a01d57ff0efc371caf86b0c0f0b1c9f35a8b..3a065f4b98ef18070be7428173712b5bf03649b8 100644 (file)
@@ -111,6 +111,11 @@ generate_rtinfo(xfs_mount_t        *mp,
                sumcompute[offs]++;
        }
 
+       if (mp->m_sb.sb_frextents != sb_frextents) {
+               do_warn(_("sb_frextents %" PRIu64 ", counted %" PRIu64 "\n"),
+                               mp->m_sb.sb_frextents, sb_frextents);
+       }
+
        return(0);
 }
 
index de8617bae97c112eb342127c93119222f8dd01f5..d08b0cecbc1ef07366cc0bbf904bb095e5e21c1b 100644 (file)
@@ -1174,9 +1174,12 @@ main(int argc, char **argv)
        phase4(mp);
        phase_end(4);
 
-       if (no_modify)
+       if (no_modify) {
                printf(_("No modify flag set, skipping phase 5\n"));
-       else {
+
+               if (mp->m_sb.sb_rblocks > 0)
+                       check_rtmetadata(mp);
+       } else {
                phase5(mp);
        }
        phase_end(5);