mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-14 09:40:47 +00:00
btrfs-progs: add print support for the block group tree
Add the appropriate support to the print tree and dump tree code to spit out the block group tree. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9ee6cc78a8
commit
cab7570ccc
@ -83,8 +83,14 @@ out:
|
||||
|
||||
static void print_old_roots(struct btrfs_super_block *super)
|
||||
{
|
||||
const char *extent_tree_str = "extent root";
|
||||
struct btrfs_root_backup *backup;
|
||||
int i;
|
||||
bool extent_tree_v2 = (btrfs_super_incompat_flags(super) &
|
||||
BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2);
|
||||
|
||||
if (extent_tree_v2)
|
||||
extent_tree_str = "block group root";
|
||||
|
||||
for (i = 0; i < BTRFS_NUM_BACKUP_ROOTS; i++) {
|
||||
backup = super->super_roots + i;
|
||||
@ -93,7 +99,7 @@ static void print_old_roots(struct btrfs_super_block *super)
|
||||
(unsigned long long)btrfs_backup_tree_root_gen(backup),
|
||||
(unsigned long long)btrfs_backup_tree_root(backup));
|
||||
|
||||
printf("\t\textent root gen %llu block %llu\n",
|
||||
printf("\t\t%s gen %llu block %llu\n", extent_tree_str,
|
||||
(unsigned long long)btrfs_backup_extent_root_gen(backup),
|
||||
(unsigned long long)btrfs_backup_extent_root(backup));
|
||||
|
||||
@ -510,6 +516,11 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
|
||||
info->log_root_tree->node->start,
|
||||
btrfs_header_level(
|
||||
info->log_root_tree->node));
|
||||
if (info->block_group_root)
|
||||
printf("block group tree: %llu level %d\n",
|
||||
info->block_group_root->node->start,
|
||||
btrfs_header_level(
|
||||
info->block_group_root->node));
|
||||
} else {
|
||||
if (info->tree_root->node) {
|
||||
printf("root tree\n");
|
||||
@ -528,6 +539,12 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
|
||||
btrfs_print_tree(info->log_root_tree->node,
|
||||
BTRFS_PRINT_TREE_FOLLOW | print_mode);
|
||||
}
|
||||
|
||||
if (info->block_group_root) {
|
||||
printf("block group tree\n");
|
||||
btrfs_print_tree(info->block_group_root->node,
|
||||
BTRFS_PRINT_TREE_FOLLOW | print_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
tree_root_scan = info->tree_root;
|
||||
@ -573,6 +590,17 @@ again:
|
||||
goto close_root;
|
||||
}
|
||||
|
||||
if (tree_id && tree_id == BTRFS_BLOCK_GROUP_TREE_OBJECTID) {
|
||||
if (!info->block_group_root) {
|
||||
error("cannot print block group tree, invalid pointer");
|
||||
goto close_root;
|
||||
}
|
||||
printf("block group tree\n");
|
||||
btrfs_print_tree(info->block_group_root->node,
|
||||
BTRFS_PRINT_TREE_FOLLOW | print_mode);
|
||||
goto close_root;
|
||||
}
|
||||
|
||||
key.offset = 0;
|
||||
key.objectid = 0;
|
||||
key.type = BTRFS_ROOT_ITEM_KEY;
|
||||
|
@ -1872,8 +1872,14 @@ static int empty_backup(struct btrfs_root_backup *backup)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void print_root_backup(struct btrfs_root_backup *backup)
|
||||
static void print_root_backup(struct btrfs_root_backup *backup,
|
||||
bool extent_tree_v2)
|
||||
{
|
||||
const char *extent_tree_str = "backup_extent_root";
|
||||
|
||||
if (extent_tree_v2)
|
||||
extent_tree_str = "backup_block_group_root";
|
||||
|
||||
printf("\t\tbackup_tree_root:\t%llu\tgen: %llu\tlevel: %d\n",
|
||||
btrfs_backup_tree_root(backup),
|
||||
btrfs_backup_tree_root_gen(backup),
|
||||
@ -1882,7 +1888,8 @@ static void print_root_backup(struct btrfs_root_backup *backup)
|
||||
btrfs_backup_chunk_root(backup),
|
||||
btrfs_backup_chunk_root_gen(backup),
|
||||
btrfs_backup_chunk_root_level(backup));
|
||||
printf("\t\tbackup_extent_root:\t%llu\tgen: %llu\tlevel: %d\n",
|
||||
printf("\t\t%s:\t%llu\tgen: %llu\tlevel: %d\n",
|
||||
extent_tree_str,
|
||||
btrfs_backup_extent_root(backup),
|
||||
btrfs_backup_extent_root_gen(backup),
|
||||
btrfs_backup_extent_root_level(backup));
|
||||
@ -1894,7 +1901,7 @@ static void print_root_backup(struct btrfs_root_backup *backup)
|
||||
btrfs_backup_dev_root(backup),
|
||||
btrfs_backup_dev_root_gen(backup),
|
||||
btrfs_backup_dev_root_level(backup));
|
||||
printf("\t\tbackup_csum_root:\t%llu\tgen: %llu\tlevel: %d\n",
|
||||
printf("\t\tcsum_root:\t%llu\tgen: %llu\tlevel: %d\n",
|
||||
btrfs_backup_csum_root(backup),
|
||||
btrfs_backup_csum_root_gen(backup),
|
||||
btrfs_backup_csum_root_level(backup));
|
||||
@ -1912,12 +1919,14 @@ static void print_backup_roots(struct btrfs_super_block *sb)
|
||||
{
|
||||
struct btrfs_root_backup *backup;
|
||||
int i;
|
||||
bool extent_tree_v2 = (btrfs_super_incompat_flags(sb) &
|
||||
BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2);
|
||||
|
||||
for (i = 0; i < BTRFS_NUM_BACKUP_ROOTS; i++) {
|
||||
backup = sb->super_roots + i;
|
||||
if (!empty_backup(backup)) {
|
||||
printf("\tbackup %d:\n", i);
|
||||
print_root_backup(backup);
|
||||
print_root_backup(backup, extent_tree_v2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2034,6 +2043,12 @@ void btrfs_print_superblock(struct btrfs_super_block *sb, int full)
|
||||
(unsigned long long)btrfs_super_cache_generation(sb));
|
||||
printf("uuid_tree_generation\t%llu\n",
|
||||
(unsigned long long)btrfs_super_uuid_tree_generation(sb));
|
||||
printf("block_group_root\t%llu\n",
|
||||
(unsigned long long)btrfs_super_block_group_root(sb));
|
||||
printf("block_group_root_generation\t%llu\n",
|
||||
(unsigned long long)btrfs_super_block_group_root_generation(sb));
|
||||
printf("block_group_root_level\t%llu\n",
|
||||
(unsigned long long)btrfs_super_block_group_root_level(sb));
|
||||
|
||||
uuid_unparse(sb->dev_item.uuid, buf);
|
||||
printf("dev_item.uuid\t\t%s\n", buf);
|
||||
|
Loading…
Reference in New Issue
Block a user