Commit d7f27d07 authored by Josef Bacik's avatar Josef Bacik Committed by Greg Kroah-Hartman

Btrfs: remove BUG_ON()'s in btrfs_map_block

commit e042d1ec upstream.

btrfs_map_block can go horribly wrong in the face of fs corruption, lets agree
to not be assholes and panic at any possible chance things are all fucked up.
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
[ removed type casts ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b737cf51
......@@ -5289,7 +5289,15 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
stripe_nr = div64_u64(stripe_nr, stripe_len);
stripe_offset = stripe_nr * stripe_len;
BUG_ON(offset < stripe_offset);
if (offset < stripe_offset) {
btrfs_crit(fs_info, "stripe math has gone wrong, "
"stripe_offset=%llu, offset=%llu, start=%llu, "
"logical=%llu, stripe_len=%llu",
stripe_offset, offset, em->start, logical,
stripe_len);
free_extent_map(em);
return -EINVAL;
}
/* stripe_offset is the offset of this block in its stripe*/
stripe_offset = offset - stripe_offset;
......@@ -5528,7 +5536,13 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
&stripe_index);
mirror_num = stripe_index + 1;
}
BUG_ON(stripe_index >= map->num_stripes);
if (stripe_index >= map->num_stripes) {
btrfs_crit(fs_info, "stripe index math went horribly wrong, "
"got stripe_index=%u, num_stripes=%u",
stripe_index, map->num_stripes);
ret = -EINVAL;
goto out;
}
num_alloc_stripes = num_stripes;
if (dev_replace_is_ongoing) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment