]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: improve rtbitmap discrepancy reporting
authorDarrick J. Wong <djwong@kernel.org>
Thu, 21 Nov 2024 00:24:34 +0000 (16:24 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:33 +0000 (18:01 -0800)
Improve the reporting of discrepancies in the realtime bitmap and
summary files by creating a separate helper function that will pinpoint
the exact (word) locations of mismatches.  This will help developers to
diagnose problems with the rtgroups feature and users to figure out
exactly what's bad in a filesystem.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
repair/rt.c

index 65d6a713f379d265ff3025797607007ac63fdaa1..a3378ef1dd0af2c72f531a6290770cc1da7f73a4 100644 (file)
@@ -131,6 +131,44 @@ _("couldn't allocate memory for incore realtime summary info.\n"));
        }
 }
 
+static void
+check_rtwords(
+       struct xfs_mount        *mp,
+       const char              *filename,
+       unsigned long long      bno,
+       void                    *ondisk,
+       void                    *incore)
+{
+       unsigned int            wordcnt = mp->m_blockwsize;
+       union xfs_rtword_raw    *o = ondisk, *i = incore;
+       int                     badstart = -1;
+       unsigned int            j;
+
+       if (memcmp(ondisk, incore, wordcnt << XFS_WORDLOG) == 0)
+               return;
+
+       for (j = 0; j < wordcnt; j++, o++, i++) {
+               if (o->old == i->old) {
+                       /* Report a range of inconsistency that just ended. */
+                       if (badstart >= 0)
+                               do_warn(
+ _("discrepancy in %s at dblock 0x%llx words 0x%x-0x%x/0x%x\n"),
+                                       filename, bno, badstart, j - 1, wordcnt);
+                       badstart = -1;
+                       continue;
+               }
+
+               if (badstart == -1)
+                       badstart = j;
+       }
+
+       if (badstart >= 0)
+               do_warn(
+ _("discrepancy in %s at dblock 0x%llx words 0x%x-0x%x/0x%x\n"),
+                                       filename, bno, badstart, wordcnt,
+                                       wordcnt);
+}
+
 static void
 check_rtfile_contents(
        struct xfs_mount        *mp,
@@ -203,9 +241,7 @@ check_rtfile_contents(
                        break;
                }
 
-               if (memcmp(bp->b_addr, buf, mp->m_blockwsize << XFS_WORDLOG))
-                       do_warn(_("discrepancy in %s at dblock 0x%llx\n"),
-                                       filename, (unsigned long long)bno);
+               check_rtwords(mp, filename, bno, bp->b_addr, buf);
 
                buf += XFS_FSB_TO_B(mp, map.br_blockcount);
                bno += map.br_blockcount;