path: root/btrfs-find-root.c
diff options
authorQu Wenruo <>2015-08-25 10:44:56 +0800
committerDavid Sterba <>2015-08-31 19:25:13 +0200
commit3eb8836424fd363fd7b4dda5cc602ed0040c3f8a (patch)
tree2a1f0d915321837882585ab4ff2871776b74ed12 /btrfs-find-root.c
parent96fbc6a146ba2b7356112d99ede54cf362797990 (diff)
btrfs-progs: find-root: Output matched root when searching all roots
[Bug] When given '-a' option, btrfs-find-root will output all possible tree roots but the exact matched one. [Reason] Result printing skipes the exact match one, as it will normally be shown before the alternative ones. But when '-a' is given, that's not the case. [Fix] Just show the exact match one for search all case. Reported-by: Marc Merlin <> Signed-off-by: Qu Wenruo <> Signed-off-by: David Sterba <>
Diffstat (limited to 'btrfs-find-root.c')
1 files changed, 6 insertions, 1 deletions
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index 1cb3085d..01b36036 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -109,6 +109,9 @@ static void print_one_result(struct cache_extent *tree_block,
tree_block->start, generation, level);
if (unsure)
printf("but we are unsure about the correct generation/level\n");
+ else if (level == filter->match_level &&
+ generation == filter->match_gen)
+ printf("and it matches superblock\n");
printf("but generation/level doesn't match, want gen: %llu level: %u\n",
filter->match_gen, filter->match_level);
@@ -129,8 +132,10 @@ static void print_find_root_result(struct cache_tree *result,
struct btrfs_find_root_gen_cache, cache);
level = gen_cache->highest_level;
generation = cache->start;
+ /* For exact found one, skip it as it's output before */
if (level == filter->match_level &&
- generation == filter->match_gen)
+ generation == filter->match_gen &&
+ !filter->search_all)
for (tree_block = last_cache_extent(&gen_cache->eb_tree);
tree_block; tree_block = prev_cache_extent(tree_block))