From: Filipe David Borba Manana <fdmanana@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Filipe David Borba Manana <fdmanana@gmail.com>
Subject: [PATCH] Btrfs-progs: debug-tree, add option to dump a single tree
Date: Fri, 23 May 2014 14:44:29 +0100 [thread overview]
Message-ID: <1400852669-2100-1-git-send-email-fdmanana@gmail.com> (raw)
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>
---
btrfs-debug-tree.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c
index cb6c106..36e1115 100644
--- a/btrfs-debug-tree.c
+++ b/btrfs-debug-tree.c
@@ -41,6 +41,8 @@ static int print_usage(void)
fprintf(stderr, "\t-u : print info of uuid tree only\n");
fprintf(stderr, "\t-b block_num : print info of the specified block"
" only\n");
+ fprintf(stderr,
+ "\t-t tree_id : print only the tree with the given id\n");
fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
exit(1);
}
@@ -136,12 +138,13 @@ int main(int ac, char **av)
int root_backups = 0;
u64 block_only = 0;
struct btrfs_root *tree_root_scan;
+ u64 tree_id = 0;
radix_tree_init();
while(1) {
int c;
- c = getopt(ac, av, "deb:rRu");
+ c = getopt(ac, av, "deb:rRut:");
if (c < 0)
break;
switch(c) {
@@ -164,6 +167,9 @@ int main(int ac, char **av)
case 'b':
block_only = arg_strtou64(optarg);
break;
+ case 't':
+ tree_id = arg_strtou64(optarg);
+ break;
default:
print_usage();
}
@@ -208,7 +214,7 @@ int main(int ac, char **av)
goto close_root;
}
- if (!(extent_only || uuid_tree_only)) {
+ if (!(extent_only || uuid_tree_only || tree_id)) {
if (roots_only) {
printf("root tree: %llu level %d\n",
(unsigned long long)info->tree_root->node->start,
@@ -268,6 +274,8 @@ again:
0);
if (!extent_buffer_uptodate(buf))
goto next;
+ if (tree_id && found_key.objectid != tree_id)
+ goto next;
switch(found_key.objectid) {
case BTRFS_ROOT_TREE_OBJECTID:
--
1.9.1
reply other threads:[~2014-05-23 12:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1400852669-2100-1-git-send-email-fdmanana@gmail.com \
--to=fdmanana@gmail.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).