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<wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
Wang Shilong 2013-07-19 14:31:34 +08:00 committed by David Sterba
parent 44aa9dce55
commit af6c1650cf
1 changed files with 8 additions and 1 deletions

View File

@ -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++;