All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: inspect-dump-tree: add '-f|--follow' options to print all children tree blocks for '-b'
@ 2018-03-14  1:05 Qu Wenruo
  2018-03-19 18:44 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2018-03-14  1:05 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

When debuging with "btrfs inspect dump-tree", it's not that handy if we
want to iterate all child tree blocks starting from a specified block.

-b can only print a single block, while without -b "btrfs inspect dump-tree"
will need extra tree roots fulfilled to continue, which is not possible
for some damaged filesystem.

Add a new option '-f|--follow' to iterate a sub-tree starting from block
specified by '-b|--block', so we would have less limitation.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 Documentation/btrfs-inspect-internal.asciidoc |  2 ++
 cmds-inspect-dump-tree.c                      | 10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Documentation/btrfs-inspect-internal.asciidoc b/Documentation/btrfs-inspect-internal.asciidoc
index e072a943f825..04cf81b93b8a 100644
--- a/Documentation/btrfs-inspect-internal.asciidoc
+++ b/Documentation/btrfs-inspect-internal.asciidoc
@@ -87,6 +87,8 @@ the respective tree root block offset
 print only the uuid tree information, empty output if the tree does not exist
 -b <block_num>::::
 print info of the specified block only
+-f|--follow::::
+use with '-b', print all children tree blocks of '<block_num>'
 -t <tree_id>::::
 print only the tree with the specified ID, where the ID can be numerical or
 common name in a flexible human readable form
diff --git a/cmds-inspect-dump-tree.c b/cmds-inspect-dump-tree.c
index df44bb635c9c..5eb9ca34b99a 100644
--- a/cmds-inspect-dump-tree.c
+++ b/cmds-inspect-dump-tree.c
@@ -198,6 +198,7 @@ const char * const cmd_inspect_dump_tree_usage[] = {
 	"-u|--uuid              print only the uuid tree",
 	"-b|--block <block_num> print info from the specified block only",
 	"-t|--tree <tree_id>    print only tree with the given id (string or number)",
+	"-f|--follow            use with '-b', to show all children tree blocks of <block_num>",
 	NULL
 };
 
@@ -223,6 +224,7 @@ int cmd_inspect_dump_tree(int argc, char **argv)
 	u64 block_only = 0;
 	struct btrfs_root *tree_root_scan;
 	u64 tree_id = 0;
+	bool follow = false;
 
 	while (1) {
 		int c;
@@ -234,10 +236,11 @@ int cmd_inspect_dump_tree(int argc, char **argv)
 			{ "uuid", no_argument, NULL, 'u'},
 			{ "block", required_argument, NULL, 'b'},
 			{ "tree", required_argument, NULL, 't'},
+			{ "follow", no_argument, NULL, 'f'},
 			{ NULL, 0, NULL, 0 }
 		};
 
-		c = getopt_long(argc, argv, "deb:rRut:", long_options, NULL);
+		c = getopt_long(argc, argv, "deb:rRut:f", long_options, NULL);
 		if (c < 0)
 			break;
 		switch (c) {
@@ -286,6 +289,9 @@ int cmd_inspect_dump_tree(int argc, char **argv)
 			}
 			break;
 			}
+		case 'f':
+			follow = true;
+			break;
 		default:
 			usage(cmd_inspect_dump_tree_usage);
 		}
@@ -324,7 +330,7 @@ int cmd_inspect_dump_tree(int argc, char **argv)
 				(unsigned long long)block_only);
 			goto close_root;
 		}
-		btrfs_print_tree(root, leaf, 0);
+		btrfs_print_tree(root, leaf, follow);
 		free_extent_buffer(leaf);
 		goto close_root;
 	}
-- 
2.16.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs-progs: inspect-dump-tree: add '-f|--follow' options to print all children tree blocks for '-b'
  2018-03-14  1:05 [PATCH] btrfs-progs: inspect-dump-tree: add '-f|--follow' options to print all children tree blocks for '-b' Qu Wenruo
@ 2018-03-19 18:44 ` David Sterba
  2018-03-20  5:19   ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2018-03-19 18:44 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs, dsterba

On Wed, Mar 14, 2018 at 09:05:38AM +0800, Qu Wenruo wrote:
> When debuging with "btrfs inspect dump-tree", it's not that handy if we
> want to iterate all child tree blocks starting from a specified block.
> 
> -b can only print a single block, while without -b "btrfs inspect dump-tree"
> will need extra tree roots fulfilled to continue, which is not possible
> for some damaged filesystem.
> 
> Add a new option '-f|--follow' to iterate a sub-tree starting from block
> specified by '-b|--block', so we would have less limitation.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

I've dropped the shot option for now and updated the changelog. While
'-f' is probably a good choice, I'd postpone adding that if we want to
use it for other purposes.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs-progs: inspect-dump-tree: add '-f|--follow' options to print all children tree blocks for '-b'
  2018-03-19 18:44 ` David Sterba
@ 2018-03-20  5:19   ` Qu Wenruo
  2018-03-21 16:00     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2018-03-20  5:19 UTC (permalink / raw)
  To: dsterba, Qu Wenruo, linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 1198 bytes --]



On 2018年03月20日 02:44, David Sterba wrote:
> On Wed, Mar 14, 2018 at 09:05:38AM +0800, Qu Wenruo wrote:
>> When debuging with "btrfs inspect dump-tree", it's not that handy if we
>> want to iterate all child tree blocks starting from a specified block.
>>
>> -b can only print a single block, while without -b "btrfs inspect dump-tree"
>> will need extra tree roots fulfilled to continue, which is not possible
>> for some damaged filesystem.
>>
>> Add a new option '-f|--follow' to iterate a sub-tree starting from block
>> specified by '-b|--block', so we would have less limitation.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
> 
> I've dropped the shot option for now and updated the changelog. While
> '-f' is probably a good choice, I'd postpone adding that if we want to
> use it for other purposes.

I'm fine with this.

Just curious if this means we should also double check the short option
usage or this is just for "-f"?

Thanks,
Qu


> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs-progs: inspect-dump-tree: add '-f|--follow' options to print all children tree blocks for '-b'
  2018-03-20  5:19   ` Qu Wenruo
@ 2018-03-21 16:00     ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2018-03-21 16:00 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: dsterba, Qu Wenruo, linux-btrfs

On Tue, Mar 20, 2018 at 01:19:21PM +0800, Qu Wenruo wrote:
> 
> 
> On 2018年03月20日 02:44, David Sterba wrote:
> > On Wed, Mar 14, 2018 at 09:05:38AM +0800, Qu Wenruo wrote:
> >> When debuging with "btrfs inspect dump-tree", it's not that handy if we
> >> want to iterate all child tree blocks starting from a specified block.
> >>
> >> -b can only print a single block, while without -b "btrfs inspect dump-tree"
> >> will need extra tree roots fulfilled to continue, which is not possible
> >> for some damaged filesystem.
> >>
> >> Add a new option '-f|--follow' to iterate a sub-tree starting from block
> >> specified by '-b|--block', so we would have less limitation.
> >>
> >> Signed-off-by: Qu Wenruo <wqu@suse.com>
> > 
> > I've dropped the shot option for now and updated the changelog. While
> > '-f' is probably a good choice, I'd postpone adding that if we want to
> > use it for other purposes.
> 
> I'm fine with this.
> 
> Just curious if this means we should also double check the short option
> usage or this is just for "-f"?

You don't need to add a short option from the beginning, this can be
added later when we can decide by the usage if it's worth.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-21 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14  1:05 [PATCH] btrfs-progs: inspect-dump-tree: add '-f|--follow' options to print all children tree blocks for '-b' Qu Wenruo
2018-03-19 18:44 ` David Sterba
2018-03-20  5:19   ` Qu Wenruo
2018-03-21 16:00     ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.