Skip to contentSkip to conversation

reject non-zone aligned RT subvolumes v2

PATCH New Christoph Hellwig 1 participant 3 messages Dec 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

this rejects not-aligned zoned RT volumes in the SB verifier and in growfs.

Changes since v1:
- adjust a comment
- add stable Cc tags

#1 lore raw

PATCH 1/2 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 2167eaabe2fa ("xfs: define the zoned on-disk format")
Cc <[email protected]> # v6.15
---
 fs/xfs/libxfs/xfs_sb.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
fs/xfs/libxfs/xfs_sb.c +15 -0
index cdd16dd805d7..94c272a2ae26 100644
@@ -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;
 }
 
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/2 xfs: fix the zoned RT growfs check for zone alignment

In reply to Christoph Hellwig

The grofs code for zoned RT subvolums already tries to check for zone alignment, but gets it wrong by using the old instead of the new mount structure.

Fixes 01b71e64bb87 ("xfs: support growfs on zoned file systems")
Cc <[email protected]> # v6.15
---
 fs/xfs/xfs_rtalloc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
fs/xfs/xfs_rtalloc.c +8 -6
index 6907e871fa15..e063f4f2f2e6 100644
@@ -1255,12 +1255,10 @@ xfs_growfs_check_rtgeom(
 	min_logfsbs = min_t(xfs_extlen_t, xfs_log_calc_minimum_size(nmp),
 			nmp->m_rsumblocks * 2);
 
-	kfree(nmp);
-
 	trace_xfs_growfs_check_rtgeom(mp, min_logfsbs);
 
 	if (min_logfsbs > mp->m_sb.sb_logblocks)
-		return -EINVAL;
+		goto out_inval;
 
 	if (xfs_has_zoned(mp)) {
 		uint32_t	gblocks = mp->m_groups[XG_TYPE_RTG].blocks;
@@ -1268,16 +1266,20 @@ xfs_growfs_check_rtgeom(
 
 		if (rextsize != 1)
 			return -EINVAL;
-		div_u64_rem(mp->m_sb.sb_rblocks, gblocks, &rem);
+		div_u64_rem(nmp->m_sb.sb_rblocks, gblocks, &rem);
 		if (rem) {
 			xfs_warn(mp,
 "new RT volume size (%lld) not aligned to RT group size (%d)",
-				mp->m_sb.sb_rblocks, gblocks);
-			return -EINVAL;
+				nmp->m_sb.sb_rblocks, gblocks);
+			goto out_inval;
 		}
 	}
 
+	kfree(nmp);
 	return 0;
+out_inval:
+	kfree(nmp);
+	return -EINVAL;
 }
 
 /*
Signature · 1 line
2.47.3