Commit 850a8cdf authored by Wang Shilong's avatar Wang Shilong Committed by Josef Bacik

Btrfs: switch to btrfs_previous_extent_item()

Since we have introduced btrfs_previous_extent_item() to search previous
extent item, just switch into it.
Signed-off-by: default avatarWang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: default avatarFilipe Manana <fdmanana@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
parent f88ba6a2
...@@ -1325,38 +1325,13 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, ...@@ -1325,38 +1325,13 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
if (ret < 0) if (ret < 0)
return ret; return ret;
while (1) { ret = btrfs_previous_extent_item(fs_info->extent_root, path, 0);
u32 nritems; if (ret) {
if (path->slots[0] == 0) { if (ret > 0)
btrfs_set_path_blocking(path); ret = -ENOENT;
ret = btrfs_prev_leaf(fs_info->extent_root, path); return ret;
if (ret != 0) {
if (ret > 0) {
pr_debug("logical %llu is not within "
"any extent\n", logical);
ret = -ENOENT;
}
return ret;
}
} else {
path->slots[0]--;
}
nritems = btrfs_header_nritems(path->nodes[0]);
if (nritems == 0) {
pr_debug("logical %llu is not within any extent\n",
logical);
return -ENOENT;
}
if (path->slots[0] == nritems)
path->slots[0]--;
btrfs_item_key_to_cpu(path->nodes[0], found_key,
path->slots[0]);
if (found_key->type == BTRFS_EXTENT_ITEM_KEY ||
found_key->type == BTRFS_METADATA_ITEM_KEY)
break;
} }
btrfs_item_key_to_cpu(path->nodes[0], found_key, path->slots[0]);
if (found_key->type == BTRFS_METADATA_ITEM_KEY) if (found_key->type == BTRFS_METADATA_ITEM_KEY)
size = fs_info->extent_root->leafsize; size = fs_info->extent_root->leafsize;
else if (found_key->type == BTRFS_EXTENT_ITEM_KEY) else if (found_key->type == BTRFS_EXTENT_ITEM_KEY)
......
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