Btrfs-progs: debug-tree, add option to dump a single tree
Very often while debugging filesystems with many subvolumes and/or snapshots, specially when they are large, I want to see only the content of one of the trees. So this change just adds an option to btrfs-debug-tree to allow to specify the id of the tree we're interesting in dumping to stdout. Example: btrfs-debug-tree -t 257 /dev/sdc Will only dump the tree of the first snapshot or subvolume that was created. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
fd518cfcb1
commit
602aac5dbf
|
@ -41,6 +41,8 @@ static int print_usage(void)
|
||||||
fprintf(stderr, "\t-u : print info of uuid tree only\n");
|
fprintf(stderr, "\t-u : print info of uuid tree only\n");
|
||||||
fprintf(stderr, "\t-b block_num : print info of the specified block"
|
fprintf(stderr, "\t-b block_num : print info of the specified block"
|
||||||
" only\n");
|
" only\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
"\t-t tree_id : print only the tree with the given id\n");
|
||||||
fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
|
fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -136,12 +138,13 @@ int main(int ac, char **av)
|
||||||
int root_backups = 0;
|
int root_backups = 0;
|
||||||
u64 block_only = 0;
|
u64 block_only = 0;
|
||||||
struct btrfs_root *tree_root_scan;
|
struct btrfs_root *tree_root_scan;
|
||||||
|
u64 tree_id = 0;
|
||||||
|
|
||||||
radix_tree_init();
|
radix_tree_init();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int c;
|
int c;
|
||||||
c = getopt(ac, av, "deb:rRu");
|
c = getopt(ac, av, "deb:rRut:");
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
@ -164,6 +167,9 @@ int main(int ac, char **av)
|
||||||
case 'b':
|
case 'b':
|
||||||
block_only = arg_strtou64(optarg);
|
block_only = arg_strtou64(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
tree_id = arg_strtou64(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print_usage();
|
print_usage();
|
||||||
}
|
}
|
||||||
|
@ -208,7 +214,7 @@ int main(int ac, char **av)
|
||||||
goto close_root;
|
goto close_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(extent_only || uuid_tree_only)) {
|
if (!(extent_only || uuid_tree_only || tree_id)) {
|
||||||
if (roots_only) {
|
if (roots_only) {
|
||||||
printf("root tree: %llu level %d\n",
|
printf("root tree: %llu level %d\n",
|
||||||
(unsigned long long)info->tree_root->node->start,
|
(unsigned long long)info->tree_root->node->start,
|
||||||
|
@ -268,6 +274,8 @@ again:
|
||||||
0);
|
0);
|
||||||
if (!extent_buffer_uptodate(buf))
|
if (!extent_buffer_uptodate(buf))
|
||||||
goto next;
|
goto next;
|
||||||
|
if (tree_id && found_key.objectid != tree_id)
|
||||||
|
goto next;
|
||||||
|
|
||||||
switch(found_key.objectid) {
|
switch(found_key.objectid) {
|
||||||
case BTRFS_ROOT_TREE_OBJECTID:
|
case BTRFS_ROOT_TREE_OBJECTID:
|
||||||
|
|
Loading…
Reference in New Issue