From: Christoph Hellwig Date: Mon, 14 Apr 2025 05:36:13 +0000 (+0200) Subject: xfs_mkfs: factor out a validate_rtgroup_geometry helper X-Git-Tag: v6.15.0~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b578151091ab6579383f2553b48270a87909dbbb;p=thirdparty%2Fxfsprogs-dev.git xfs_mkfs: factor out a validate_rtgroup_geometry helper Factor out the rtgroup geometry checks so that they can be easily reused for the upcoming zoned RT allocator support. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index acc926b1..4f63cff8 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3950,6 +3950,42 @@ out: cfg->rgcount = howmany(cfg->rtblocks, cfg->rgsize); } +static void +validate_rtgroup_geometry( + struct mkfs_params *cfg) +{ + if (cfg->rgsize > XFS_MAX_RGBLOCKS) { + fprintf(stderr, +_("realtime group size (%llu) must be less than the maximum (%u)\n"), + (unsigned long long)cfg->rgsize, + XFS_MAX_RGBLOCKS); + usage(); + } + + if (cfg->rgsize % cfg->rtextblocks != 0) { + fprintf(stderr, +_("realtime group size (%llu) not a multiple of rt extent size (%llu)\n"), + (unsigned long long)cfg->rgsize, + (unsigned long long)cfg->rtextblocks); + usage(); + } + + if (cfg->rgsize <= cfg->rtextblocks) { + fprintf(stderr, +_("realtime group size (%llu) must be at least two realtime extents\n"), + (unsigned long long)cfg->rgsize); + usage(); + } + + if (cfg->rgcount > XFS_MAX_RGNUMBER) { + fprintf(stderr, +_("realtime group count (%llu) must be less than the maximum (%u)\n"), + (unsigned long long)cfg->rgcount, + XFS_MAX_RGNUMBER); + usage(); + } +} + static void calculate_rtgroup_geometry( struct mkfs_params *cfg, @@ -4007,36 +4043,7 @@ _("rgsize (%s) not a multiple of fs blk size (%d)\n"), (cfg->rtblocks % cfg->rgsize != 0); } - if (cfg->rgsize > XFS_MAX_RGBLOCKS) { - fprintf(stderr, -_("realtime group size (%llu) must be less than the maximum (%u)\n"), - (unsigned long long)cfg->rgsize, - XFS_MAX_RGBLOCKS); - usage(); - } - - if (cfg->rgsize % cfg->rtextblocks != 0) { - fprintf(stderr, -_("realtime group size (%llu) not a multiple of rt extent size (%llu)\n"), - (unsigned long long)cfg->rgsize, - (unsigned long long)cfg->rtextblocks); - usage(); - } - - if (cfg->rgsize <= cfg->rtextblocks) { - fprintf(stderr, -_("realtime group size (%llu) must be at least two realtime extents\n"), - (unsigned long long)cfg->rgsize); - usage(); - } - - if (cfg->rgcount > XFS_MAX_RGNUMBER) { - fprintf(stderr, -_("realtime group count (%llu) must be less than the maximum (%u)\n"), - (unsigned long long)cfg->rgcount, - XFS_MAX_RGNUMBER); - usage(); - } + validate_rtgroup_geometry(cfg); if (cfg->rtextents) cfg->rtbmblocks = howmany(cfg->rgsize / cfg->rtextblocks,