]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: support xchk_xref_is_used_rt_space on zoned file systems
authorChristoph Hellwig <hch@lst.de>
Thu, 15 Aug 2024 16:12:33 +0000 (18:12 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 5 Nov 2024 08:29:53 +0000 (09:29 +0100)
Space usage is tracked by the rmap, which already is separately
cross-reference.  But on top of that we have the write pointer and can
do a basic sanity check here that the block is not beyond the write
pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/rtbitmap.c

index 0f0a5485e9da0176e29bba5fe35489a359676486..0e7d16d665f8ae6eeeb6cbd7d1bc16aa93bf3607 100644 (file)
@@ -273,15 +273,22 @@ xchk_xref_is_used_rt_space(
        xfs_extlen_t            len)
 {
        struct xfs_rtgroup      *rtg = sc->sr.rtg;
-       struct xfs_inode        *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
        xfs_rtxnum_t            startext;
        xfs_rtxnum_t            endext;
-       bool                    is_free;
+       bool                    is_free = true;
        int                     error;
 
        if (xchk_skip_xref(sc->sm))
                return;
 
+       if (xfs_has_zoned(sc->mp)) {
+               if (xfs_rtb_to_rgbno(sc->mp, rtbno) >= rtg->rtg_write_pointer) {
+                       xchk_ino_xref_set_corrupt(sc,
+                                       rtg->rtg_inodes[XFS_RTGI_RMAP]->i_ino);
+               }
+               return;
+       }
+
        startext = xfs_rtb_to_rtx(sc->mp, rtbno);
        endext = xfs_rtb_to_rtx(sc->mp, rtbno + len - 1);
        error = xfs_rtalloc_extent_is_free(rtg, sc->tp, startext,
@@ -289,5 +296,6 @@ xchk_xref_is_used_rt_space(
        if (!xchk_should_check_xref(sc, &error, NULL))
                return;
        if (is_free)
-               xchk_ino_xref_set_corrupt(sc, rbmip->i_ino);
+               xchk_ino_xref_set_corrupt(sc,
+                               rtg->rtg_inodes[XFS_RTGI_BITMAP]->i_ino);
 }