Commit 9652480b authored by Yan's avatar Yan Committed by Chris Mason

Fix path slots selection in btrfs_search_forward

We should decrease the found slot by one as btrfs_search_slot does
when bin_search return 1 and node level > 0.
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 445dceb7
...@@ -2992,6 +2992,7 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, ...@@ -2992,6 +2992,7 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
struct extent_buffer *cur; struct extent_buffer *cur;
struct btrfs_key found_key; struct btrfs_key found_key;
int slot; int slot;
int sret;
u32 nritems; u32 nritems;
int level; int level;
int ret = 1; int ret = 1;
...@@ -3009,7 +3010,7 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, ...@@ -3009,7 +3010,7 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
while(1) { while(1) {
nritems = btrfs_header_nritems(cur); nritems = btrfs_header_nritems(cur);
level = btrfs_header_level(cur); level = btrfs_header_level(cur);
bin_search(cur, min_key, level, &slot); sret = bin_search(cur, min_key, level, &slot);
/* at level = 0, we're done, setup the path and exit */ /* at level = 0, we're done, setup the path and exit */
if (level == 0) { if (level == 0) {
...@@ -3018,6 +3019,8 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, ...@@ -3018,6 +3019,8 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
btrfs_item_key_to_cpu(cur, &found_key, slot); btrfs_item_key_to_cpu(cur, &found_key, slot);
goto out; goto out;
} }
if (sret && slot > 0)
slot--;
/* /*
* check this node pointer against the cache_only and * check this node pointer against the cache_only and
* min_trans parameters. If it isn't in cache or is too * min_trans parameters. If it isn't in cache or is too
......
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