Re: [PATCH 33/43] xfs: support xchk_xref_is_used_rt_space on zoned file systems

Darrick J. Wong
2024-12-13T22:49:12Z

On Wed, Dec 11, 2024 at 09:54:58AM +0100, Christoph Hellwig wrote:
> 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

cross-referenced

> 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 | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c
> index e8c776a34c1d..d5ff8609dbfb 100644
> --- a/fs/xfs/scrub/rtbitmap.c
> +++ b/fs/xfs/scrub/rtbitmap.c
> @@ -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);

rbmip is already the return value from rtg_bitmap()

--D

> }
> --
> 2.45.2
>
>