Commit 1fcbac58 authored by Yan Zheng's avatar Yan Zheng Committed by Chris Mason

Btrfs: find_free_dev_extent doesn't handle holes at the start of the device

find_free_dev_extent does not properly handle the case where
the device is not complete free, and there is a free extent
at the beginning of the device.
Signed-off-by: default avatarYan Zheng <zheng.yan@oracle.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 20736aba
...@@ -758,9 +758,13 @@ static noinline int find_free_dev_extent(struct btrfs_trans_handle *trans, ...@@ -758,9 +758,13 @@ static noinline int find_free_dev_extent(struct btrfs_trans_handle *trans,
ret = btrfs_search_slot(trans, root, &key, path, 0, 0); ret = btrfs_search_slot(trans, root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
goto error; goto error;
ret = btrfs_previous_item(root, path, 0, key.type); if (ret > 0) {
ret = btrfs_previous_item(root, path, key.objectid, key.type);
if (ret < 0) if (ret < 0)
goto error; goto error;
if (ret > 0)
start_found = 1;
}
l = path->nodes[0]; l = path->nodes[0];
btrfs_item_key_to_cpu(l, &key, path->slots[0]); btrfs_item_key_to_cpu(l, &key, path->slots[0]);
while (1) { while (1) {
......
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