If extent tree is corrupted then open_ctree without OPEN_CTREE_NO_BLOCK_GROUPS does fail preventing use of btrfs-map-logical at all. Also even if we can't find extent it still can be useful to get physical offset which could be correct.
Signed-off-by: Dāvis Mosāns <davis...@gmail.com> --- btrfs-map-logical.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c index 24c81b8d..d121a8c4 100644 --- a/btrfs-map-logical.c +++ b/btrfs-map-logical.c @@ -261,7 +261,7 @@ int main(int argc, char **argv) radix_tree_init(); cache_tree_init(&root_cache); - root = open_ctree(dev, 0, 0); + root = open_ctree(dev, 0, OPEN_CTREE_NO_BLOCK_GROUPS); if (!root) { fprintf(stderr, "Open ctree failed\n"); free(output_file); @@ -298,6 +298,9 @@ int main(int argc, char **argv) errno = -ret; fprintf(stderr, "Failed to find extent at [%llu,%llu): %m\n", cur_logical, cur_logical + cur_len); + fprintf(stderr, "Trying a guess!\n"); + print_mapping_info(root->fs_info, logical, bytes); + goto out_close_fd; } /* @@ -358,6 +361,8 @@ int main(int argc, char **argv) if (!found) { fprintf(stderr, "No extent found at range [%llu,%llu)\n", logical, logical + bytes); + fprintf(stderr, "Trying a guess!\n"); + print_mapping_info(root->fs_info, logical, bytes); } out_close_fd: if (output_file && out_fd != 1) -- 2.30.2