Skip to contentSkip to conversation

btrfs-progs: For btrfs-map-logical proceed even with some extent corruption

PATCH New Dāvis Mosāns 1 participant 1 message Mar 22, 2021 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: For btrfs-map-logical proceed even with some extent corruption

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.

---
 btrfs-map-logical.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
btrfs-map-logical.c +6 -1
index 24c81b8d..d121a8c4 100644
@@ -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)
Signature · 1 line
2.30.2