From 0bbd407cbbd5746ac2f0f3ec4d89087276cf7510 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 28 Sep 2018 09:44:34 +0800 Subject: btrfs-progs: print-tree: Introduce --bfs and --dfs options Originally print-tree uses depth first search to print trees. This works fine until we reach 3 level trees (root node level is 2). For tall trees whose root level is 2 or higher, DFS will mix nodes and leaves like the following example: Level 2 A / \ Level 1 B C / | | \ Level 0 D E F G DFS will cause the following output sequence: A B D E C F G Which in term of node/leave is: N N L L N L L Such mixed node/leave result is sometimes hard for human to read. This patch will introduce 2 new options, --bfs and --dfs. --dfs: keeps the original output sequence, and to keep things compatible it's the default behavior. --bfs: uses breadth-first search, and will cause better output sequence like: A B C D E F G Which in term of node/leave is: N N N L L L L Much better sorted and may become default in the future. Reviewed-by: Nikolay Borisov Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- Documentation/btrfs-inspect-internal.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Documentation') diff --git a/Documentation/btrfs-inspect-internal.asciidoc b/Documentation/btrfs-inspect-internal.asciidoc index e2db6466..381497d2 100644 --- a/Documentation/btrfs-inspect-internal.asciidoc +++ b/Documentation/btrfs-inspect-internal.asciidoc @@ -89,6 +89,12 @@ print only the uuid tree information, empty output if the tree does not exist print info of the specified block only --follow:::: use with '-b', print all children tree blocks of '' +--dfs:::: +use depth-first search to print trees. (default) the nodes and leaves are +intermixed in the output +--bfs:::: +use breadth-first search to print trees. the nodes are printed before all +leaves -t :::: print only the tree with the specified ID, where the ID can be numerical or common name in a flexible human readable form -- cgit v1.2.3