]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs_mkfs: factor out a validate_rtgroup_geometry helper
authorChristoph Hellwig <hch@lst.de>
Thu, 10 Apr 2025 07:07:08 +0000 (09:07 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 14 Apr 2025 05:27:19 +0000 (07:27 +0200)
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

index ec82e05bf4e49d93d6e8a0818bd0d710f915156a..13b746b365e1bb0c53eae61cdb6c9996a2c55462 100644 (file)
@@ -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,