Commit 48b9ac68 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

xfs: support xchk_xref_is_used_rt_space on zoned file systems



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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
parent 1cf4554e
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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);
}