aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/send.c
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@gmail.com>2014-01-24 12:42:09 -0500
committerChris Mason <clm@fb.com>2014-01-29 10:06:24 -0500
commit7fdd29d02e0ab595a857fe9c7b71e752ff665372 (patch)
treed4b38218d7c8ae8ee3a97e89b3025e2cef824eca /fs/btrfs/send.c
parent95def2ede1a9dd12b164932eaf5fefb67aefc41c (diff)
Btrfs: make send's file extent item search more efficient
Instead of looking for a file extent item, process it, release the path and do a btree search for the next file extent item, just process all file extent items in a leaf without intermediate btree searches. This way we save cpu and we're not blocking other tasks or affecting concurrency on the btree, because send's paths use the commit root and skip btree node/leaf locking. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/send.c')
-rw-r--r--fs/btrfs/send.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index c96e879bcb16..4d31f72bdf41 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4573,17 +4573,25 @@ static int process_all_extents(struct send_ctx *sctx)
4573 key.objectid = sctx->cmp_key->objectid; 4573 key.objectid = sctx->cmp_key->objectid;
4574 key.type = BTRFS_EXTENT_DATA_KEY; 4574 key.type = BTRFS_EXTENT_DATA_KEY;
4575 key.offset = 0; 4575 key.offset = 0;
4576 while (1) { 4576 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
4577 ret = btrfs_search_slot_for_read(root, &key, path, 1, 0); 4577 if (ret < 0)
4578 if (ret < 0) 4578 goto out;
4579 goto out;
4580 if (ret) {
4581 ret = 0;
4582 goto out;
4583 }
4584 4579
4580 while (1) {
4585 eb = path->nodes[0]; 4581 eb = path->nodes[0];
4586 slot = path->slots[0]; 4582 slot = path->slots[0];
4583
4584 if (slot >= btrfs_header_nritems(eb)) {
4585 ret = btrfs_next_leaf(root, path);
4586 if (ret < 0) {
4587 goto out;
4588 } else if (ret > 0) {
4589 ret = 0;
4590 break;
4591 }
4592 continue;
4593 }
4594
4587 btrfs_item_key_to_cpu(eb, &found_key, slot); 4595 btrfs_item_key_to_cpu(eb, &found_key, slot);
4588 4596
4589 if (found_key.objectid != key.objectid || 4597 if (found_key.objectid != key.objectid ||
@@ -4596,8 +4604,7 @@ static int process_all_extents(struct send_ctx *sctx)
4596 if (ret < 0) 4604 if (ret < 0)
4597 goto out; 4605 goto out;
4598 4606
4599 btrfs_release_path(path); 4607 path->slots[0]++;
4600 key.offset = found_key.offset + 1;
4601 } 4608 }
4602 4609
4603out: 4610out: