public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mkfs: adjust_nr_zones for zoned file system on conventional devices
@ 2025-12-18 16:09 Christoph Hellwig
  2025-12-19  2:10 ` Darrick J. Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2025-12-18 16:09 UTC (permalink / raw)
  To: aalbersh; +Cc: dlemoal, hans.holmberg, linux-xfs

When creating zoned file systems on conventional devices, mkfs doesn't
currently align the RT device size to the zone size, which can create
unmountable file systems.  Fix this by moving the rgcount modification
to account for reserved zoned and then calling adjust_nr_zones
unconditionally, and thus ensuring that the rtblocks and rtextents values
are guaranteed to always be a multiple of the zone size.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 mkfs/xfs_mkfs.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 8db51217016e..b34407725f76 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -4558,8 +4558,6 @@ adjust_nr_zones(
 		max_zones = DTOBT(cli->xi->rt.size, cfg->blocklog) /
 				cfg->rgsize;
 
-	if (!cli->rgcount)
-		cfg->rgcount += XFS_RESERVED_ZONES;
 	if (cfg->rgcount > max_zones) {
 		fprintf(stderr,
 _("Warning: not enough zones (%lu/%u) for backing requested rt size due to\n"
@@ -4652,9 +4650,9 @@ _("rgsize (%s) not a multiple of fs blk size (%d)\n"),
 		}
 	}
 
-	if (cli->rtsize || cli->rgcount)
-		adjust_nr_zones(cfg, cli, zt);
-
+	if (cli->rtsize)
+		cfg->rgcount += XFS_RESERVED_ZONES;
+	adjust_nr_zones(cfg, cli, zt);
 	if (cfg->rgcount < XFS_MIN_ZONES)  {
 		fprintf(stderr,
 _("realtime group count (%llu) must be greater than the minimum zone count (%u)\n"),
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mkfs: adjust_nr_zones for zoned file system on conventional devices
  2025-12-18 16:09 [PATCH] mkfs: adjust_nr_zones for zoned file system on conventional devices Christoph Hellwig
@ 2025-12-19  2:10 ` Darrick J. Wong
  2025-12-19  5:28   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2025-12-19  2:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: aalbersh, dlemoal, hans.holmberg, linux-xfs

On Thu, Dec 18, 2025 at 05:09:32PM +0100, Christoph Hellwig wrote:
> When creating zoned file systems on conventional devices, mkfs doesn't
> currently align the RT device size to the zone size, which can create
> unmountable file systems.  Fix this by moving the rgcount modification
> to account for reserved zoned and then calling adjust_nr_zones
> unconditionally, and thus ensuring that the rtblocks and rtextents values
> are guaranteed to always be a multiple of the zone size.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  mkfs/xfs_mkfs.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 8db51217016e..b34407725f76 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -4558,8 +4558,6 @@ adjust_nr_zones(
>  		max_zones = DTOBT(cli->xi->rt.size, cfg->blocklog) /
>  				cfg->rgsize;
>  
> -	if (!cli->rgcount)
> -		cfg->rgcount += XFS_RESERVED_ZONES;
>  	if (cfg->rgcount > max_zones) {
>  		fprintf(stderr,
>  _("Warning: not enough zones (%lu/%u) for backing requested rt size due to\n"
> @@ -4652,9 +4650,9 @@ _("rgsize (%s) not a multiple of fs blk size (%d)\n"),
>  		}
>  	}
>  
> -	if (cli->rtsize || cli->rgcount)
> -		adjust_nr_zones(cfg, cli, zt);
> -
> +	if (cli->rtsize)
> +		cfg->rgcount += XFS_RESERVED_ZONES;

Hrm.  So we're moving the XFS_RESERVED_ZONES addition code out of
adjust_nr_zones to here.  The conditional changes to rtsize because
previously the only way we'd do the addition is if !rgcount, which means
we were really only doing it if rtsize != 0.

And now that we always call adjust_nr_zones that part needed to be moved
up.

I think I understand what's going on here, so
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D


> +	adjust_nr_zones(cfg, cli, zt);
>  	if (cfg->rgcount < XFS_MIN_ZONES)  {
>  		fprintf(stderr,
>  _("realtime group count (%llu) must be greater than the minimum zone count (%u)\n"),
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mkfs: adjust_nr_zones for zoned file system on conventional devices
  2025-12-19  2:10 ` Darrick J. Wong
@ 2025-12-19  5:28   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2025-12-19  5:28 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, aalbersh, dlemoal, hans.holmberg, linux-xfs

On Thu, Dec 18, 2025 at 06:10:01PM -0800, Darrick J. Wong wrote:
> Hrm.  So we're moving the XFS_RESERVED_ZONES addition code out of
> adjust_nr_zones to here.  The conditional changes to rtsize because
> previously the only way we'd do the addition is if !rgcount, which means
> we were really only doing it if rtsize != 0.
> 
> And now that we always call adjust_nr_zones that part needed to be moved
> up.
> 
> I think I understand what's going on here, so

Yes.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-19  5:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 16:09 [PATCH] mkfs: adjust_nr_zones for zoned file system on conventional devices Christoph Hellwig
2025-12-19  2:10 ` Darrick J. Wong
2025-12-19  5:28   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox