Skip to content

Commit 982d261

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
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: 2167eaa ("xfs: define the zoned on-disk format") Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Cc: stable@vger.kernel.org # v6.15 Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 8dc15b7 commit 982d261

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

fs/xfs/libxfs/xfs_sb.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,21 @@ xfs_validate_rt_geometry(
301301
sbp->sb_rbmblocks != xfs_expected_rbmblocks(sbp))
302302
return false;
303303

304+
if (xfs_sb_is_v5(sbp) &&
305+
(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED)) {
306+
uint32_t mod;
307+
308+
/*
309+
* Zoned RT devices must be aligned to the RT group size,
310+
* because garbage collection assumes that all zones have the
311+
* same size to avoid insane complexity if that weren't the
312+
* case.
313+
*/
314+
div_u64_rem(sbp->sb_rextents, sbp->sb_rgextents, &mod);
315+
if (mod)
316+
return false;
317+
}
318+
304319
return true;
305320
}
306321

0 commit comments

Comments
 (0)