]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: adjust_nr_zones for zoned file system on conventional devices
authorChristoph Hellwig <hch@lst.de>
Thu, 18 Dec 2025 16:09:32 +0000 (17:09 +0100)
committerAndrey Albershteyn <aalbersh@kernel.org>
Fri, 19 Dec 2025 14:01:29 +0000 (15:01 +0100)
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>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
mkfs/xfs_mkfs.c

index 8db51217016eb056f9e2324b5ccf749e2d7249dc..b34407725f76df1ae3b73feadc60801a77d93f14 100644 (file)
@@ -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"),