From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: validate that zoned RT devices are zone aligned
Date: Wed, 10 Dec 2025 08:48:59 -0800 [thread overview]
Message-ID: <20251210164859.GB7725@frogsfrogsfrogs> (raw)
In-Reply-To: <20251210142305.3660710-1-hch@lst.de>
On Wed, Dec 10, 2025 at 03:23:05PM +0100, Christoph Hellwig wrote:
> Garbage collection assumes all zones contain the full amount of blocks.
> Mkfs already ensures this happens, but make the kernel check it as well
mkfs doesn't enforce that when you're creating a zoned filesystem on
non-zoned storage:
# mkfs.xfs -r rtdev=/dev/sda,zoned=1 -f /dev/sdf
meta-data=/dev/sdf isize=512 agcount=4, agsize=1298176 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=0 bigtime=1 inobtcount=1 nrext64=1
= exchange=1 metadir=1
data = bsize=4096 blocks=5192704, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =/dev/sda extsz=4096 blocks=5192704, rtextents=5192704
= rgcount=80 rgsize=65536 extents
= zoned=1 start=0 reserved=0
5192704 isn't congruent with 65536, and we get a runt rtgroup at the
end:
# mount /dev/sdf /opt -o rtdev=/dev/sda
# xfs_io -c 'rginfo' /opt | tail -n 20
RTG: 76
Length: 65536
Sick: 0x0
Checked: 0x0
Flags: 0x0
RTG: 77
Length: 65536
Sick: 0x0
Checked: 0x0
Flags: 0x0
RTG: 78
Length: 65536
Sick: 0x0
Checked: 0x0
Flags: 0x0
RTG: 79
Length: 15360
Sick: 0x0
Checked: 0x0
Flags: 0x0
rtgroup 79 is clearly a runt group.
(The mkfs enforcement does work if you have an actual zoned storage
device since mkfs complains about changes in the zone sizes.)
> to avoid getting into trouble due to fuzzers or mkfs bugs.
>
> Fixes: 2167eaabe2fa ("xfs: define the zoned on-disk format")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
How many filesystems are there in the wild with rump rtgroups? My first
thought was "why not pretend the runt rtgroup doesn't exist?" but then
that creates all sorts of weirdness where you have a 778M rt volume on a
disk with 256M rtgroups, but then we ignore the 10M of space and you can
never get to it.
Given that runt zoned rtgroups can exist in the wild, how hard would it
be to fix zonegc?
--D
> ---
> fs/xfs/libxfs/xfs_sb.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index cdd16dd805d7..db5231f846ea 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -301,6 +301,19 @@ 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 rtgroup size, because
> + * garbage collection can't deal with rump RT groups.
> + */
> + div_u64_rem(sbp->sb_rextents, sbp->sb_rgextents, &mod);
> + if (mod)
> + return false;
> + }
> +
> return true;
> }
>
> --
> 2.47.3
>
>
next prev parent reply other threads:[~2025-12-10 16:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 14:23 [PATCH] xfs: validate that zoned RT devices are zone aligned Christoph Hellwig
2025-12-10 16:48 ` Darrick J. Wong [this message]
2025-12-10 16:54 ` Christoph Hellwig
2025-12-10 19:18 ` Darrick J. Wong
2025-12-11 5:04 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251210164859.GB7725@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox