@@ -4668,8 +4668,8 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
* we didn't find a candidate key in this node, walk forward
* and find another one
*/
+ path->slots[level] = slot;
if (slot >= nritems) {
- path->slots[level] = slot;
sret = btrfs_find_next_key(root, path, min_key, level,
min_trans);
if (sret == 0) {
@@ -4679,7 +4679,6 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
goto out;
}
}
- path->slots[level] = slot;
if (level == path->lowest_level) {
ret = 0;
/* save our key for returning back */
This patch moves `path->slots[level] = slot` before the condition check to prevent duplicate assignment. Previously, the slot was set both inside and after the `slot >= nritems` block with no change in its value, which is unnecessary. Signed-off-by: Sun YangKai <sunk67188@gmail.com> --- fs/btrfs/ctree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)