Linux XFS filesystem development
 help / color / mirror / Atom feed
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: improve RT geometry validation
Date: Thu, 7 May 2026 10:17:58 -0700	[thread overview]
Message-ID: <20260507171758.GJ7751@frogsfrogsfrogs> (raw)
In-Reply-To: <20260507052543.1305129-1-hch@lst.de>

On Thu, May 07, 2026 at 07:25:35AM +0200, Christoph Hellwig wrote:
> Make sure the rtgcount is plausible for the given RT group size.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_sb.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index 47322adb7690..c0354f43704f 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -302,17 +302,25 @@ xfs_validate_rt_geometry(
>  		return false;
>  
>  	if (xfs_sb_is_v5(sbp) &&
> -	    (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED)) {
> +	    (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR)) {
> +		uint64_t		nr_rgs;
>  		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.
> +		 * Check that the number of rgcounts is plausible for the RG
> +		 * size.
> +		 */
> +		nr_rgs = div_u64_rem(sbp->sb_rextents, sbp->sb_rgextents, &mod);
> +		if (nr_rgs != sbp->sb_rgcount + !!mod)
> +			return false;

Isn't this already covered by xfs_validate_sb_rtgroups?


	groups = howmany_64(sbp->sb_rextents, sbp->sb_rgextents);
	if (groups != sbp->sb_rgcount) {
		xfs_warn(mp,
"Realtime groups (%u) do not cover the entire rt section; need (%llu) groups.",
				sbp->sb_rgcount, groups);
		return -EINVAL;
	}

> +
> +		/*
> +		 * 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)
> +		if ((sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED) &&
> +		    mod > 0)
>  			return false;

And shouldn't this be in xfs_validate_sb_zoned?

Or do you want this in xfs_validate_rt_geometry because that's what
xfs_repair calls to check the superblock?

--D

  parent reply	other threads:[~2026-05-07 17:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <wV6uRtt8Mdv0dR-Ory4pMu4E-SDYDmUrTwaPRauY7S4lM07r4ogMmp38xxeF3FNG3X_E46ujDJHX94Lq_Oe-Vg==@protonmail.internalid>
2026-05-07  5:25 ` [PATCH] xfs: improve RT geometry validation Christoph Hellwig
2026-05-07 12:17   ` Carlos Maiolino
2026-05-07 17:17   ` Darrick J. Wong [this message]
2026-05-08  8:16     ` Christoph Hellwig
2026-05-09  0:54       ` Darrick J. Wong

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=20260507171758.GJ7751@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