Message ID | 20250414053629.360672-31-hch@lst.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/43] xfs: generalize the freespace and reserved blocks handling | expand |
On Mon, Apr 14, 2025 at 07:36:13AM +0200, Christoph Hellwig wrote: > 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 <hch@lst.de> Pretty straightforward, thanks for taking the time to disentangle this! :) Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > mkfs/xfs_mkfs.c | 67 +++++++++++++++++++++++++++---------------------- > 1 file changed, 37 insertions(+), 30 deletions(-) > > diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c > index ec82e05bf4e4..13b746b365e1 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, > -- > 2.47.2 > >
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index ec82e05bf4e4..13b746b365e1 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,
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 <hch@lst.de> --- mkfs/xfs_mkfs.c | 67 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 30 deletions(-)