mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-06 04:04:59 +00:00
Add skip-likely-huge print option
Add an option to skip printing structures that are likely to be so huge that the print output becomes completely unwieldly on large systems. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -597,7 +597,7 @@ format.
|
|||||||
.PD
|
.PD
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "print META-DEVICE"
|
.BI "print {-S|--skip-likely-huge} META-DEVICE"
|
||||||
.sp
|
.sp
|
||||||
Prints out all of the metadata in the file system. This makes no effort
|
Prints out all of the metadata in the file system. This makes no effort
|
||||||
to ensure that the structures are consistent as they're traversed and
|
to ensure that the structures are consistent as they're traversed and
|
||||||
@@ -607,6 +607,20 @@ output.
|
|||||||
.PD 0
|
.PD 0
|
||||||
.TP
|
.TP
|
||||||
.sp
|
.sp
|
||||||
|
.B "-S, --skip-likely-huge"
|
||||||
|
Skip printing structures that are likely to be very large. The
|
||||||
|
structures that are skipped tend to be global and whose size tends to be
|
||||||
|
related to the size of the volume. Examples of skipped structures include
|
||||||
|
the global fs items, srch files, and metadata and data
|
||||||
|
allocators. Similar structures that are not skipped are related to the
|
||||||
|
number of mounts and are maintained at a relatively reasonable size.
|
||||||
|
These include per-mount log trees, srch files, allocators, and the
|
||||||
|
metadata allocators used by server commits.
|
||||||
|
.sp
|
||||||
|
Skipping the larger structures limits the print output to a relatively
|
||||||
|
constant size rather than being a large multiple of the used metadata
|
||||||
|
space of the volume making the output much more useful for inspection.
|
||||||
|
.TP
|
||||||
.B "META-DEVICE"
|
.B "META-DEVICE"
|
||||||
The path to the metadata device for the filesystem whose metadata will be
|
The path to the metadata device for the filesystem whose metadata will be
|
||||||
printed. Since this command reads via the host's buffer cache, it may not
|
printed. Since this command reads via the host's buffer cache, it may not
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -989,9 +990,10 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno)
|
|||||||
|
|
||||||
struct print_args {
|
struct print_args {
|
||||||
char *meta_device;
|
char *meta_device;
|
||||||
|
bool skip_likely_huge;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int print_volume(int fd)
|
static int print_volume(int fd, struct print_args *args)
|
||||||
{
|
{
|
||||||
struct scoutfs_super_block *super = NULL;
|
struct scoutfs_super_block *super = NULL;
|
||||||
struct print_recursion_args pa;
|
struct print_recursion_args pa;
|
||||||
@@ -1041,23 +1043,26 @@ static int print_volume(int fd)
|
|||||||
ret = err;
|
ret = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < array_size(super->meta_alloc); i++) {
|
if (!args->skip_likely_huge) {
|
||||||
snprintf(str, sizeof(str), "meta_alloc[%u]", i);
|
for (i = 0; i < array_size(super->meta_alloc); i++) {
|
||||||
err = print_btree(fd, super, str, &super->meta_alloc[i].root,
|
snprintf(str, sizeof(str), "meta_alloc[%u]", i);
|
||||||
|
err = print_btree(fd, super, str, &super->meta_alloc[i].root,
|
||||||
|
print_alloc_item, NULL);
|
||||||
|
if (err && !ret)
|
||||||
|
ret = err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = print_btree(fd, super, "data_alloc", &super->data_alloc.root,
|
||||||
print_alloc_item, NULL);
|
print_alloc_item, NULL);
|
||||||
if (err && !ret)
|
if (err && !ret)
|
||||||
ret = err;
|
ret = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = print_btree(fd, super, "data_alloc", &super->data_alloc.root,
|
|
||||||
print_alloc_item, NULL);
|
|
||||||
if (err && !ret)
|
|
||||||
ret = err;
|
|
||||||
|
|
||||||
err = print_btree(fd, super, "srch_root", &super->srch_root,
|
err = print_btree(fd, super, "srch_root", &super->srch_root,
|
||||||
print_srch_root_item, NULL);
|
print_srch_root_item, NULL);
|
||||||
if (err && !ret)
|
if (err && !ret)
|
||||||
ret = err;
|
ret = err;
|
||||||
|
|
||||||
err = print_btree(fd, super, "logs_root", &super->logs_root,
|
err = print_btree(fd, super, "logs_root", &super->logs_root,
|
||||||
print_log_trees_item, NULL);
|
print_log_trees_item, NULL);
|
||||||
if (err && !ret)
|
if (err && !ret)
|
||||||
@@ -1065,19 +1070,23 @@ static int print_volume(int fd)
|
|||||||
|
|
||||||
pa.super = super;
|
pa.super = super;
|
||||||
pa.fd = fd;
|
pa.fd = fd;
|
||||||
err = print_btree_leaf_items(fd, super, &super->srch_root.ref,
|
if (!args->skip_likely_huge) {
|
||||||
print_srch_root_files, &pa);
|
err = print_btree_leaf_items(fd, super, &super->srch_root.ref,
|
||||||
if (err && !ret)
|
print_srch_root_files, &pa);
|
||||||
ret = err;
|
if (err && !ret)
|
||||||
|
ret = err;
|
||||||
|
}
|
||||||
err = print_btree_leaf_items(fd, super, &super->logs_root.ref,
|
err = print_btree_leaf_items(fd, super, &super->logs_root.ref,
|
||||||
print_log_trees_roots, &pa);
|
print_log_trees_roots, &pa);
|
||||||
if (err && !ret)
|
if (err && !ret)
|
||||||
ret = err;
|
ret = err;
|
||||||
|
|
||||||
err = print_btree(fd, super, "fs_root", &super->fs_root,
|
if (!args->skip_likely_huge) {
|
||||||
print_fs_item, NULL);
|
err = print_btree(fd, super, "fs_root", &super->fs_root,
|
||||||
if (err && !ret)
|
print_fs_item, NULL);
|
||||||
ret = err;
|
if (err && !ret)
|
||||||
|
ret = err;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(super);
|
free(super);
|
||||||
@@ -1098,7 +1107,7 @@ static int do_print(struct print_args *args)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = print_volume(fd);
|
ret = print_volume(fd, args);
|
||||||
close(fd);
|
close(fd);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
@@ -1108,6 +1117,9 @@ static int parse_opt(int key, char *arg, struct argp_state *state)
|
|||||||
struct print_args *args = state->input;
|
struct print_args *args = state->input;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case 'S':
|
||||||
|
args->skip_likely_huge = true;
|
||||||
|
break;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
if (!args->meta_device)
|
if (!args->meta_device)
|
||||||
args->meta_device = strdup_or_error(state, arg);
|
args->meta_device = strdup_or_error(state, arg);
|
||||||
@@ -1125,8 +1137,13 @@ static int parse_opt(int key, char *arg, struct argp_state *state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct argp_option options[] = {
|
||||||
|
{ "skip-likely-huge", 'S', NULL, 0, "Skip large structures to minimize output size"},
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static struct argp argp = {
|
static struct argp argp = {
|
||||||
NULL,
|
options,
|
||||||
parse_opt,
|
parse_opt,
|
||||||
"META-DEV",
|
"META-DEV",
|
||||||
"Print metadata structures"
|
"Print metadata structures"
|
||||||
|
|||||||
Reference in New Issue
Block a user