Commit 982d2616 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Carlos Maiolino
Browse files

xfs: validate that zoned RT devices are zone aligned



Garbage collection assumes all zones contain the full amount of blocks.
Mkfs already ensures this happens, but make the kernel check it as well
to avoid getting into trouble due to fuzzers or mkfs bugs.

Fixes: 2167eaab ("xfs: define the zoned on-disk format")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Cc: stable@vger.kernel.org # v6.15
Signed-off-by: default avatarCarlos Maiolino <cem@kernel.org>
parent 8dc15b7a
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -301,6 +301,21 @@ xfs_validate_rt_geometry(
	    sbp->sb_rbmblocks != xfs_expected_rbmblocks(sbp))
		return false;

	if (xfs_sb_is_v5(sbp) &&
	    (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED)) {
		uint32_t		mod;

		/*
		 * Zoned RT devices must be aligned to the RT group size,
		 * because garbage collection assumes that all zones have the
		 * same size to avoid insane complexity if that weren't the
		 * case.
		 */
		div_u64_rem(sbp->sb_rextents, sbp->sb_rgextents, &mod);
		if (mod)
			return false;
	}

	return true;
}