]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: support xchk_xref_is_used_rt_space on zoned file systems
authorChristoph Hellwig <hch@lst.de>
Sun, 17 Nov 2024 06:35:44 +0000 (07:35 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Mar 2025 15:17:08 +0000 (08:17 -0700)
Space usage is tracked by the rmap, which already is separately
cross-referenced.  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>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
fs/xfs/scrub/rtbitmap.c

index e8c776a34c1df1a632278304bde8509ec2dba83b..d5ff8609dbfb41f986104baa84ad926c6ba87d55 100644 (file)
@@ -21,6 +21,7 @@
 #include "xfs_rmap.h"
 #include "xfs_rtrmap_btree.h"
 #include "xfs_exchmaps.h"
+#include "xfs_zone_alloc.h"
 #include "scrub/scrub.h"
 #include "scrub/common.h"
 #include "scrub/repair.h"
@@ -272,7 +273,6 @@ xchk_xref_is_used_rt_space(
        xfs_extlen_t            len)
 {
        struct xfs_rtgroup      *rtg = sc->sr.rtg;
-       struct xfs_inode        *rbmip = rtg_bitmap(rtg);
        xfs_rtxnum_t            startext;
        xfs_rtxnum_t            endext;
        bool                    is_free;
@@ -281,6 +281,13 @@ xchk_xref_is_used_rt_space(
        if (xchk_skip_xref(sc->sm))
                return;
 
+       if (xfs_has_zoned(sc->mp)) {
+               if (!xfs_zone_rgbno_is_valid(rtg,
+                               xfs_rtb_to_rgbno(sc->mp, rtbno) + len - 1))
+                       xchk_ino_xref_set_corrupt(sc, rtg_rmap(rtg)->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,
@@ -288,5 +295,5 @@ 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_bitmap(rtg)->i_ino);
 }