From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v4 05/22] btrfs-progs: add print support for the block group tree
Date: Wed, 15 Dec 2021 14:59:31 -0500 [thread overview]
Message-ID: <8c38ca90cc4ec4b34a463004057b10346accc912.1639598278.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1639598278.git.josef@toxicpanda.com>
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>
---
cmds/inspect-dump-tree.c | 30 +++++++++++++++++++++++++++++-
kernel-shared/print-tree.c | 23 +++++++++++++++++++----
2 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/cmds/inspect-dump-tree.c b/cmds/inspect-dump-tree.c
index 6332b46d..daa7f925 100644
--- a/cmds/inspect-dump-tree.c
+++ b/cmds/inspect-dump-tree.c
@@ -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;
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 73f969c3..a612c3d9 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -1858,8 +1858,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),
@@ -1868,7 +1874,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));
@@ -1880,7 +1887,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));
@@ -1898,12 +1905,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);
}
}
}
@@ -2020,6 +2029,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);
--
2.26.3
next prev parent reply other threads:[~2021-12-15 20:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 19:59 [PATCH v4 00/22] btrfs-progs: extent tree v2 support, global roots Josef Bacik
2021-12-15 19:59 ` [PATCH v4 01/22] btrfs-progs: common: allow users to select extent-tree-v2 option Josef Bacik
2021-12-15 19:59 ` [PATCH v4 02/22] btrfs-progs: add definitions for the block group tree Josef Bacik
2021-12-15 19:59 ` [PATCH v4 03/22] btrfs-progs: add on disk pointers to global tree ids Josef Bacik
2021-12-15 19:59 ` [PATCH v4 04/22] btrfs-progs: add support for loading the block group root Josef Bacik
2021-12-15 19:59 ` Josef Bacik [this message]
2021-12-15 19:59 ` [PATCH v4 06/22] btrfs-progs: mkfs: use the btrfs_block_group_root helper Josef Bacik
2021-12-15 19:59 ` [PATCH v4 07/22] btrfs-progs: check-lowmem: " Josef Bacik
2021-12-15 19:59 ` [PATCH v4 08/22] btrfs-progs: handle no bg item in extent tree for free space tree Josef Bacik
2021-12-15 19:59 ` [PATCH v4 09/22] btrfs-progs: mkfs: add support for the block group tree Josef Bacik
2021-12-15 19:59 ` [PATCH v4 10/22] btrfs-progs: check: add block group tree support Josef Bacik
2021-12-15 19:59 ` [PATCH v4 11/22] btrfs-progs: qgroup-verify: scan extents based on block groups Josef Bacik
2021-12-15 19:59 ` [PATCH v4 12/22] btrfs-progs: check: make free space tree validation extent tree v2 aware Josef Bacik
2021-12-15 19:59 ` [PATCH v4 13/22] btrfs-progs: check: add helper to reinit the root based on a key Josef Bacik
2021-12-15 19:59 ` [PATCH v4 14/22] btrfs-progs: check: handle the block group tree properly Josef Bacik
2021-12-15 19:59 ` [PATCH v4 15/22] btrfs-progs: load the number of global roots into the fs_info Josef Bacik
2021-12-15 19:59 ` [PATCH v4 16/22] btrfs-progs: handle the per-block group global root id Josef Bacik
2021-12-15 19:59 ` [PATCH v4 17/22] btrfs-progs: add a btrfs_delete_and_free_root helper Josef Bacik
2021-12-15 19:59 ` [PATCH v4 18/22] btrfs-progs: make btrfs_clear_free_space_tree extent tree v2 aware Josef Bacik
2021-12-15 19:59 ` [PATCH v4 19/22] btrfs-progs: make btrfs_create_tree take a key for the root key Josef Bacik
2021-12-15 19:59 ` [PATCH v4 20/22] btrfs-progs: mkfs: set chunk_item_objectid properly for extent tree v2 Josef Bacik
2021-12-15 19:59 ` [PATCH v4 21/22] btrfs-progs: mkfs: create the global root's Josef Bacik
2021-12-15 19:59 ` [PATCH v4 22/22] btrfs-progs: check: don't do the root item check for extent tree v2 Josef Bacik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8c38ca90cc4ec4b34a463004057b10346accc912.1639598278.git.josef@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).