aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2014-07-28 14:34:35 -0400
committerChris Mason <clm@fb.com>2014-09-17 16:37:55 -0400
commit24cdc847d9842bdfd85a005ebc39050bcbc7acba (patch)
tree5565771ecb17b466504cf550e7336d1becd6e0f7 /fs/btrfs/ctree.c
parentd1b00a4711d5b953b13ccc859bc30c447c96860e (diff)
Btrfs: unlock nodes earlier when inserting items in a btree
In ctree.c:setup_items_for_insert(), we can unlock all nodes in our path before we process the leaf (shift items and data, adjust data offsets, etc). This allows for better btree concurrency, as we're often holding a write lock on at least the node at level 1. Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 263145b27155..bd0ae3ec76ff 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -4738,6 +4738,12 @@ void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
4738 int slot; 4738 int slot;
4739 struct btrfs_map_token token; 4739 struct btrfs_map_token token;
4740 4740
4741 if (path->slots[0] == 0) {
4742 btrfs_cpu_key_to_disk(&disk_key, cpu_key);
4743 fixup_low_keys(root, path, &disk_key, 1);
4744 }
4745 btrfs_unlock_up_safe(path, 1);
4746
4741 btrfs_init_map_token(&token); 4747 btrfs_init_map_token(&token);
4742 4748
4743 leaf = path->nodes[0]; 4749 leaf = path->nodes[0];
@@ -4798,12 +4804,6 @@ void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
4798 } 4804 }
4799 4805
4800 btrfs_set_header_nritems(leaf, nritems + nr); 4806 btrfs_set_header_nritems(leaf, nritems + nr);
4801
4802 if (slot == 0) {
4803 btrfs_cpu_key_to_disk(&disk_key, cpu_key);
4804 fixup_low_keys(root, path, &disk_key, 1);
4805 }
4806 btrfs_unlock_up_safe(path, 1);
4807 btrfs_mark_buffer_dirty(leaf); 4807 btrfs_mark_buffer_dirty(leaf);
4808 4808
4809 if (btrfs_leaf_free_space(root, leaf) < 0) { 4809 if (btrfs_leaf_free_space(root, leaf) < 0) {