btrfs-debug-tree: add -r option to print only the roots

Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Chris Mason 2011-10-27 17:42:26 -04:00
parent ff91b185f7
commit b670b9285e
1 changed files with 28 additions and 9 deletions

View File

@ -76,6 +76,7 @@ int main(int ac, char **av)
int slot; int slot;
int extent_only = 0; int extent_only = 0;
int device_only = 0; int device_only = 0;
int roots_only = 0;
u64 block_only = 0; u64 block_only = 0;
struct btrfs_root *tree_root_scan; struct btrfs_root *tree_root_scan;
@ -83,7 +84,7 @@ int main(int ac, char **av)
while(1) { while(1) {
int c; int c;
c = getopt(ac, av, "deb:"); c = getopt(ac, av, "deb:r");
if (c < 0) if (c < 0)
break; break;
switch(c) { switch(c) {
@ -93,6 +94,9 @@ int main(int ac, char **av)
case 'd': case 'd':
device_only = 1; device_only = 1;
break; break;
case 'r':
roots_only = 1;
break;
case 'b': case 'b':
block_only = atoll(optarg); block_only = atoll(optarg);
break; break;
@ -134,13 +138,22 @@ int main(int ac, char **av)
} }
if (!extent_only) { if (!extent_only) {
printf("root tree\n"); if (roots_only) {
btrfs_print_tree(root->fs_info->tree_root, printf("root tree: %llu level %d\n",
root->fs_info->tree_root->node, 1); (unsigned long long)root->fs_info->tree_root->node->start,
btrfs_header_level(root->fs_info->tree_root->node));
printf("chunk tree: %llu level %d\n",
(unsigned long long)root->fs_info->chunk_root->node->start,
btrfs_header_level(root->fs_info->chunk_root->node));
} else {
printf("root tree\n");
btrfs_print_tree(root->fs_info->tree_root,
root->fs_info->tree_root->node, 1);
printf("chunk tree\n"); printf("chunk tree\n");
btrfs_print_tree(root->fs_info->chunk_root, btrfs_print_tree(root->fs_info->chunk_root,
root->fs_info->chunk_root->node, 1); root->fs_info->chunk_root->node, 1);
}
} }
tree_root_scan = root->fs_info->tree_root; tree_root_scan = root->fs_info->tree_root;
@ -253,8 +266,14 @@ again:
} else if (!skip) { } else if (!skip) {
printf(" tree "); printf(" tree ");
btrfs_print_key(&disk_key); btrfs_print_key(&disk_key);
printf(" \n"); if (roots_only) {
btrfs_print_tree(tree_root_scan, buf, 1); printf(" %llu level %d\n",
(unsigned long long)buf->start,
btrfs_header_level(buf));
} else {
printf(" \n");
btrfs_print_tree(tree_root_scan, buf, 1);
}
} }
} }
path.slots[0]++; path.slots[0]++;