diff options
-rw-r--r-- | fs/btrfs/ctree.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 11f9a1848c7b..a57507aa6702 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -3613,6 +3613,19 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root | |||
3613 | if (left_nritems == 0) | 3613 | if (left_nritems == 0) |
3614 | goto out_unlock; | 3614 | goto out_unlock; |
3615 | 3615 | ||
3616 | if (path->slots[0] == left_nritems && !empty) { | ||
3617 | /* Key greater than all keys in the leaf, right neighbor has | ||
3618 | * enough room for it and we're not emptying our leaf to delete | ||
3619 | * it, therefore use right neighbor to insert the new item and | ||
3620 | * no need to touch/dirty our left leaft. */ | ||
3621 | btrfs_tree_unlock(left); | ||
3622 | free_extent_buffer(left); | ||
3623 | path->nodes[0] = right; | ||
3624 | path->slots[0] = 0; | ||
3625 | path->slots[1]++; | ||
3626 | return 0; | ||
3627 | } | ||
3628 | |||
3616 | return __push_leaf_right(trans, root, path, min_data_size, empty, | 3629 | return __push_leaf_right(trans, root, path, min_data_size, empty, |
3617 | right, free_space, left_nritems, min_slot); | 3630 | right, free_space, left_nritems, min_slot); |
3618 | out_unlock: | 3631 | out_unlock: |