From: Sun YangKai Date: Tue, 11 Mar 2025 08:13:14 +0000 (+0800) Subject: btrfs: avoid redundant path slot assignment in btrfs_search_forward() X-Git-Tag: v6.15-rc1~152^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0aaaf10ae9aef82bf6589ced2510ff4e249cb3af;p=thirdparty%2Fkernel%2Flinux.git btrfs: avoid redundant path slot assignment in btrfs_search_forward() Move path slot assignment 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 Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 5322df012c29d..a2e7979372ccd 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -4667,8 +4667,8 @@ find_next_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) { @@ -4678,7 +4678,6 @@ find_next_key: goto out; } } - path->slots[level] = slot; if (level == path->lowest_level) { ret = 0; /* Save our key for returning back. */