aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-06-17 14:23:02 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-07-01 08:52:32 -0400
commit0b08851fdaa5f9f74357345d7be44ea584665d5f (patch)
tree87c77c227f9c104ee7ed15a59ad28fd8bebe704d /fs
parentbdf7c00e8f56386dd1df545b37cf59d55ce4216d (diff)
Btrfs: optimize reada_for_balance
This patch does two things. First we no longer explicitly read in the blocks we're trying to readahead. For things like balance_level we may never actually use the blocks so this just adds uneeded latency, and balance_level and split_node will both read in the blocks they care about explicitly so if the blocks need to be waited on it will be done there. Secondly we no longer drop the path if we do readahead, we just set the path blocking before we call reada_for_balance() and then we're good to go. Hopefully this will cut down on the number of re-searches. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.c46
1 files changed, 9 insertions, 37 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index c85cde761248..c32d03dff4fc 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2178,12 +2178,8 @@ static void reada_for_search(struct btrfs_root *root,
2178 } 2178 }
2179} 2179}
2180 2180
2181/* 2181static noinline void reada_for_balance(struct btrfs_root *root,
2182 * returns -EAGAIN if it had to drop the path, or zero if everything was in 2182 struct btrfs_path *path, int level)
2183 * cache
2184 */
2185static noinline int reada_for_balance(struct btrfs_root *root,
2186 struct btrfs_path *path, int level)
2187{ 2183{
2188 int slot; 2184 int slot;
2189 int nritems; 2185 int nritems;
@@ -2192,12 +2188,11 @@ static noinline int reada_for_balance(struct btrfs_root *root,
2192 u64 gen; 2188 u64 gen;
2193 u64 block1 = 0; 2189 u64 block1 = 0;
2194 u64 block2 = 0; 2190 u64 block2 = 0;
2195 int ret = 0;
2196 int blocksize; 2191 int blocksize;
2197 2192
2198 parent = path->nodes[level + 1]; 2193 parent = path->nodes[level + 1];
2199 if (!parent) 2194 if (!parent)
2200 return 0; 2195 return;
2201 2196
2202 nritems = btrfs_header_nritems(parent); 2197 nritems = btrfs_header_nritems(parent);
2203 slot = path->slots[level + 1]; 2198 slot = path->slots[level + 1];
@@ -2224,28 +2219,11 @@ static noinline int reada_for_balance(struct btrfs_root *root,
2224 block2 = 0; 2219 block2 = 0;
2225 free_extent_buffer(eb); 2220 free_extent_buffer(eb);
2226 } 2221 }
2227 if (block1 || block2) {
2228 ret = -EAGAIN;
2229
2230 /* release the whole path */
2231 btrfs_release_path(path);
2232 2222
2233 /* read the blocks */ 2223 if (block1)
2234 if (block1) 2224 readahead_tree_block(root, block1, blocksize, 0);
2235 readahead_tree_block(root, block1, blocksize, 0); 2225 if (block2)
2236 if (block2) 2226 readahead_tree_block(root, block2, blocksize, 0);
2237 readahead_tree_block(root, block2, blocksize, 0);
2238
2239 if (block1) {
2240 eb = read_tree_block(root, block1, blocksize, 0);
2241 free_extent_buffer(eb);
2242 }
2243 if (block2) {
2244 eb = read_tree_block(root, block2, blocksize, 0);
2245 free_extent_buffer(eb);
2246 }
2247 }
2248 return ret;
2249} 2227}
2250 2228
2251 2229
@@ -2441,11 +2419,8 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
2441 goto again; 2419 goto again;
2442 } 2420 }
2443 2421
2444 sret = reada_for_balance(root, p, level);
2445 if (sret)
2446 goto again;
2447
2448 btrfs_set_path_blocking(p); 2422 btrfs_set_path_blocking(p);
2423 reada_for_balance(root, p, level);
2449 sret = split_node(trans, root, p, level); 2424 sret = split_node(trans, root, p, level);
2450 btrfs_clear_path_blocking(p, NULL, 0); 2425 btrfs_clear_path_blocking(p, NULL, 0);
2451 2426
@@ -2465,11 +2440,8 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
2465 goto again; 2440 goto again;
2466 } 2441 }
2467 2442
2468 sret = reada_for_balance(root, p, level);
2469 if (sret)
2470 goto again;
2471
2472 btrfs_set_path_blocking(p); 2443 btrfs_set_path_blocking(p);
2444 reada_for_balance(root, p, level);
2473 sret = balance_level(trans, root, p, level); 2445 sret = balance_level(trans, root, p, level);
2474 btrfs_clear_path_blocking(p, NULL, 0); 2446 btrfs_clear_path_blocking(p, NULL, 0);
2475 2447