]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: support computing btheight for all cursor types
authorDarrick J. Wong <djwong@kernel.org>
Wed, 18 May 2022 02:48:12 +0000 (22:48 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 18 May 2022 02:48:12 +0000 (22:48 -0400)
Add the special magic btree type value 'all' to the btheight command so
that we can display information about all known btree types at once.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/btheight.c
man/man8/xfs_db.8

index 8aa17c895bb7b4acb775b0cbb95e0ce817cd66f9..e4cd4edabe8d9d676d039d57dfa4baeb7ef1ed61 100644 (file)
@@ -57,7 +57,7 @@ btheight_help(void)
 "   -w min -- Show only the worst case scenario.\n"
 "\n"
 " Supported btree types:\n"
-"   "
+"   all "
 ));
        for (i = 0, m = maps; i < ARRAY_SIZE(maps); i++, m++)
                printf("%s ", m->tag);
@@ -107,7 +107,7 @@ calc_height(
 
 static int
 construct_records_per_block(
-       char            *tag,
+       const char      *tag,
        int             blocksize,
        unsigned int    *records_per_block)
 {
@@ -235,7 +235,7 @@ out:
 
 static void
 report(
-       char                    *tag,
+       const char              *tag,
        unsigned int            report_what,
        unsigned long long      nr_records,
        unsigned int            blocksize)
@@ -297,6 +297,19 @@ _("%s: worst case per %u-byte block: %u records (leaf) / %u keyptrs (node)\n"),
        }
 }
 
+static void
+report_all(
+       unsigned int            report_what,
+       unsigned long long      nr_records,
+       unsigned int            blocksize)
+{
+       struct btmap            *m;
+       int                     i;
+
+       for (i = 0, m = maps; i < ARRAY_SIZE(maps); i++, m++)
+               report(m->tag, report_what, nr_records, blocksize);
+}
+
 static int
 btheight_f(
        int             argc,
@@ -366,6 +379,13 @@ _("The smallest block size this command will consider is 128 bytes.\n"));
                return 0;
        }
 
+       for (i = optind; i < argc; i++) {
+               if (!strcmp(argv[i], "all")) {
+                       report_all(report_what, nr_records, blocksize);
+                       return 0;
+               }
+       }
+
        for (i = optind; i < argc; i++)
                report(argv[i], report_what, nr_records, blocksize);
 
index 587274957de39ee974eac69668b3afa0489cf32f..55ac3487fca62aa41beacb51d39680eb31db973e 100644 (file)
@@ -420,6 +420,9 @@ The supported btree types are:
 .IR refcountbt ,
 and
 .IR rmapbt .
+The magic value
+.I all
+can be used to walk through all btree types.
 
 Options are as follows:
 .RS 1.0i