Commit b0b802d7 authored by Tsutomu Itoh's avatar Tsutomu Itoh Committed by Chris Mason

Btrfs: return error code to caller when btrfs_previous_item fails

The error code is returned instead of calling BUG_ON when
btrfs_previous_item returns the error.
Signed-off-by: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 27160b6b
...@@ -949,14 +949,14 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, ...@@ -949,14 +949,14 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
if (ret > 0) { if (ret > 0) {
ret = btrfs_previous_item(root, path, key.objectid, ret = btrfs_previous_item(root, path, key.objectid,
BTRFS_DEV_EXTENT_KEY); BTRFS_DEV_EXTENT_KEY);
BUG_ON(ret); if (ret)
goto out;
leaf = path->nodes[0]; leaf = path->nodes[0];
btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
extent = btrfs_item_ptr(leaf, path->slots[0], extent = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_dev_extent); struct btrfs_dev_extent);
BUG_ON(found_key.offset > start || found_key.offset + BUG_ON(found_key.offset > start || found_key.offset +
btrfs_dev_extent_length(leaf, extent) < start); btrfs_dev_extent_length(leaf, extent) < start);
ret = 0;
} else if (ret == 0) { } else if (ret == 0) {
leaf = path->nodes[0]; leaf = path->nodes[0];
extent = btrfs_item_ptr(leaf, path->slots[0], extent = btrfs_item_ptr(leaf, path->slots[0],
...@@ -969,6 +969,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, ...@@ -969,6 +969,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
ret = btrfs_del_item(trans, root, path); ret = btrfs_del_item(trans, root, path);
BUG_ON(ret); BUG_ON(ret);
out:
btrfs_free_path(path); btrfs_free_path(path);
return ret; return ret;
} }
......
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