aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@gmail.com>2013-10-18 10:42:56 -0400
committerChris Mason <chris.mason@fusionio.com>2013-11-11 22:03:53 -0500
commit55994887082d6e9b3d31b55fc5be158fd97eadbc (patch)
treef98021a7c4cb1bc6a9c12aa0f6d1754cabf1e6c2 /fs
parentcab45e22da48b523665b3566f43527a2fead1d1e (diff)
Btrfs: optimize extent item search in run_delayed_extent_op
Instead of doing another extent tree search if the first search failed to find a metadata item, check if the previous item in the leaf is an extent item and use it if it is, otherwise do the second tree search for an extent item. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/extent-tree.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index a807acc9a63e..4595a65db729 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2130,15 +2130,28 @@ again:
2130 } 2130 }
2131 if (ret > 0) { 2131 if (ret > 0) {
2132 if (metadata) { 2132 if (metadata) {
2133 btrfs_release_path(path); 2133 if (path->slots[0] > 0) {
2134 metadata = 0; 2134 path->slots[0]--;
2135 btrfs_item_key_to_cpu(path->nodes[0], &key,
2136 path->slots[0]);
2137 if (key.objectid == node->bytenr &&
2138 key.type == BTRFS_EXTENT_ITEM_KEY &&
2139 key.offset == node->num_bytes)
2140 ret = 0;
2141 }
2142 if (ret > 0) {
2143 btrfs_release_path(path);
2144 metadata = 0;
2135 2145
2136 key.offset = node->num_bytes; 2146 key.objectid = node->bytenr;
2137 key.type = BTRFS_EXTENT_ITEM_KEY; 2147 key.offset = node->num_bytes;
2138 goto again; 2148 key.type = BTRFS_EXTENT_ITEM_KEY;
2149 goto again;
2150 }
2151 } else {
2152 err = -EIO;
2153 goto out;
2139 } 2154 }
2140 err = -EIO;
2141 goto out;
2142 } 2155 }
2143 2156
2144 leaf = path->nodes[0]; 2157 leaf = path->nodes[0];