summaryrefslogtreecommitdiff
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2021-12-02 10:30:37 +0000
committerDavid Sterba <dsterba@suse.com>2022-01-07 14:18:23 +0100
commite5e1c1741b3de3f8d06fe4b700d83709a7da0610 (patch)
tree7e1a181626dce483bb124133e562a175d75c846b /fs/btrfs/ctree.c
parente2e58d0f8dc55533c24fc7b3e101092f571b4a43 (diff)
btrfs: remove useless condition check before splitting leaf
When inserting a key, we check if the write_lock_level is less than 1, and if so we set it to 1, release the path and retry the tree traversal. However that is unnecessary, because when ins_len is greater than 0, we know that write_lock_level can never be less than 1. The logic to retry is also buggy, because in case ins_len was decremented, due to an exact key match and the search is not meant for item extension (path->search_for_extension is 0), we retry without incrementing ins_len, which would make the next retry decrement it again by the same amount. So remove the check for write_lock_level being less than 1 and add an assertion to assert it's always >= 1. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index f12172cb6c35..0e81f1847941 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1969,11 +1969,7 @@ skip_leaf_search:
ins_len -= sizeof(struct btrfs_item);
}
if (ins_len > 0 && leaf_free_space < ins_len) {
- if (write_lock_level < 1) {
- write_lock_level = 1;
- btrfs_release_path(p);
- goto again;
- }
+ ASSERT(write_lock_level >= 1);
err = split_leaf(trans, root, key,
p, ins_len, ret == 0);