Skip to contentSkip to conversation

Btrfs-progs: make btrfs-map-logical handle error gracefully

PATCH New Wang Shilong 1 participant 1 message Jul 19, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs-progs: make btrfs-map-logical handle error gracefully

If an overflow logical address is passed(for example),the original code will cause segmentation, this is unfriendly to users,fix it.

---
 btrfs-map-logical.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
btrfs-map-logical.c +8 -1
index b9635f7..fce6504 100644
@@ -57,7 +57,14 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
 		ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
 				      eb->start, &length, &multi,
 				      mirror_num, NULL);
-		BUG_ON(ret);
+		if (ret) {
+			fprintf(info_file,
+				"Error: fails to map mirror%d logical %llu: %s\n",
+				mirror_num, (unsigned long long)eb->start,
+				strerror(-ret));
+			free_extent_buffer(eb);
+			return NULL;
+		}
 		device = multi->stripes[0].dev;
 		eb->fd = device->fd;
 		device->total_ios++;

-- 1.8.0.1