Permalink
Browse files

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

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information...
1 parent ff91b18 commit b670b9285efb2cd5b8a1668d6e80727d03e2a3d2 @chrismason-xx chrismason-xx committed Oct 27, 2011
Showing with 28 additions and 9 deletions.
  1. +28 −9 debug-tree.c
View
@@ -76,14 +76,15 @@ int main(int ac, char **av)
int slot;
int extent_only = 0;
int device_only = 0;
+ int roots_only = 0;
u64 block_only = 0;
struct btrfs_root *tree_root_scan;
radix_tree_init();
while(1) {
int c;
- c = getopt(ac, av, "deb:");
+ c = getopt(ac, av, "deb:r");
if (c < 0)
break;
switch(c) {
@@ -93,6 +94,9 @@ int main(int ac, char **av)
case 'd':
device_only = 1;
break;
+ case 'r':
+ roots_only = 1;
+ break;
case 'b':
block_only = atoll(optarg);
break;
@@ -134,13 +138,22 @@ int main(int ac, char **av)
}
if (!extent_only) {
- printf("root tree\n");
- btrfs_print_tree(root->fs_info->tree_root,
- root->fs_info->tree_root->node, 1);
+ if (roots_only) {
+ printf("root tree: %llu level %d\n",
+ (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");
- btrfs_print_tree(root->fs_info->chunk_root,
- root->fs_info->chunk_root->node, 1);
+ printf("chunk tree\n");
+ btrfs_print_tree(root->fs_info->chunk_root,
+ root->fs_info->chunk_root->node, 1);
+ }
}
tree_root_scan = root->fs_info->tree_root;
@@ -253,8 +266,14 @@ int main(int ac, char **av)
} else if (!skip) {
printf(" tree ");
btrfs_print_key(&disk_key);
- printf(" \n");
- btrfs_print_tree(tree_root_scan, buf, 1);
+ if (roots_only) {
+ 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]++;

0 comments on commit b670b92

Please sign in to comment.