From af6c1650cf38395143157a674344e195d47c0517 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Fri, 19 Jul 2013 14:31:34 +0800 Subject: 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. Signed-off-by: Wang Shilong Signed-off-by: David Sterba Signed-off-by: Chris Mason --- btrfs-map-logical.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'btrfs-map-logical.c') diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c index b9635f77..fce65047 100644 --- a/btrfs-map-logical.c +++ b/btrfs-map-logical.c @@ -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++; -- cgit v1.2.3