diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-06-17 13:44:48 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-07-01 08:52:32 -0400 |
commit | bdf7c00e8f56386dd1df545b37cf59d55ce4216d (patch) | |
tree | f8fbe2f4b5c5dbd9c6b9a4d79bd3e729a874e7ec /fs/btrfs/ctree.c | |
parent | fdf8e2ea3cba9ef03087482b11258d844d6cbea3 (diff) |
Btrfs: optimize read_block_for_search
This patch does two things, first it only does one call to
btrfs_buffer_uptodate() with the gen specified instead of once with 0 and then
again with gen specified. The other thing is to call btrfs_read_buffer() on the
buffer we've found instead of dropping it and then calling read_tree_block().
This will keep us from doing yet another radix tree lookup for a buffer we've
already found. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 1c9dc71089ce..c85cde761248 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -2359,35 +2359,28 @@ read_block_for_search(struct btrfs_trans_handle *trans, | |||
2359 | tmp = btrfs_find_tree_block(root, blocknr, blocksize); | 2359 | tmp = btrfs_find_tree_block(root, blocknr, blocksize); |
2360 | if (tmp) { | 2360 | if (tmp) { |
2361 | /* first we do an atomic uptodate check */ | 2361 | /* first we do an atomic uptodate check */ |
2362 | if (btrfs_buffer_uptodate(tmp, 0, 1) > 0) { | 2362 | if (btrfs_buffer_uptodate(tmp, gen, 1) > 0) { |
2363 | if (btrfs_buffer_uptodate(tmp, gen, 1) > 0) { | 2363 | *eb_ret = tmp; |
2364 | /* | 2364 | return 0; |
2365 | * we found an up to date block without | 2365 | } |
2366 | * sleeping, return | ||
2367 | * right away | ||
2368 | */ | ||
2369 | *eb_ret = tmp; | ||
2370 | return 0; | ||
2371 | } | ||
2372 | /* the pages were up to date, but we failed | ||
2373 | * the generation number check. Do a full | ||
2374 | * read for the generation number that is correct. | ||
2375 | * We must do this without dropping locks so | ||
2376 | * we can trust our generation number | ||
2377 | */ | ||
2378 | free_extent_buffer(tmp); | ||
2379 | btrfs_set_path_blocking(p); | ||
2380 | 2366 | ||
2381 | /* now we're allowed to do a blocking uptodate check */ | 2367 | /* the pages were up to date, but we failed |
2382 | tmp = read_tree_block(root, blocknr, blocksize, gen); | 2368 | * the generation number check. Do a full |
2383 | if (tmp && btrfs_buffer_uptodate(tmp, gen, 0) > 0) { | 2369 | * read for the generation number that is correct. |
2384 | *eb_ret = tmp; | 2370 | * We must do this without dropping locks so |
2385 | return 0; | 2371 | * we can trust our generation number |
2386 | } | 2372 | */ |
2387 | free_extent_buffer(tmp); | 2373 | btrfs_set_path_blocking(p); |
2388 | btrfs_release_path(p); | 2374 | |
2389 | return -EIO; | 2375 | /* now we're allowed to do a blocking uptodate check */ |
2376 | ret = btrfs_read_buffer(tmp, gen); | ||
2377 | if (!ret) { | ||
2378 | *eb_ret = tmp; | ||
2379 | return 0; | ||
2390 | } | 2380 | } |
2381 | free_extent_buffer(tmp); | ||
2382 | btrfs_release_path(p); | ||
2383 | return -EIO; | ||
2391 | } | 2384 | } |
2392 | 2385 | ||
2393 | /* | 2386 | /* |