aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2011-10-03 23:23:13 -0400
committerDavid Sterba <dsterba@suse.cz>2012-03-21 20:45:33 -0400
commit3444a97255de907f32562741fb6d104620b9fce3 (patch)
tree6ef2b2cb582a6331e30175ce0d4da7503059f88f
parent0417341e6bd93e2a2ceac0e57409706803b335e5 (diff)
btrfs: Factor out tree->ops->merge_bio_hook call
In submit_extent_page, there's a visually noisy if statement that, in the midst of other conditions, does the tree dependency for tree->ops and tree->ops->merge_bio_hook before calling it, and then another condition afterwards. If an error is returned from merge_bio_hook, there's no way to catch it. It's considered a routine "1" return value instead of a failure. This patch factors out the dependency check into a new local merge_bio routine and BUG's on an error. The if statement is less noisy as a side- effect. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
-rw-r--r--fs/btrfs/extent_io.c17
-rw-r--r--fs/btrfs/inode.c5
2 files changed, 17 insertions, 5 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a4a7a18cdd3d..c342e923ea41 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2429,6 +2429,19 @@ static int submit_one_bio(int rw, struct bio *bio, int mirror_num,
2429 return ret; 2429 return ret;
2430} 2430}
2431 2431
2432static int merge_bio(struct extent_io_tree *tree, struct page *page,
2433 unsigned long offset, size_t size, struct bio *bio,
2434 unsigned long bio_flags)
2435{
2436 int ret = 0;
2437 if (tree->ops && tree->ops->merge_bio_hook)
2438 ret = tree->ops->merge_bio_hook(page, offset, size, bio,
2439 bio_flags);
2440 BUG_ON(ret < 0);
2441 return ret;
2442
2443}
2444
2432static int submit_extent_page(int rw, struct extent_io_tree *tree, 2445static int submit_extent_page(int rw, struct extent_io_tree *tree,
2433 struct page *page, sector_t sector, 2446 struct page *page, sector_t sector,
2434 size_t size, unsigned long offset, 2447 size_t size, unsigned long offset,
@@ -2457,9 +2470,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
2457 sector; 2470 sector;
2458 2471
2459 if (prev_bio_flags != bio_flags || !contig || 2472 if (prev_bio_flags != bio_flags || !contig ||
2460 (tree->ops && tree->ops->merge_bio_hook && 2473 merge_bio(tree, page, offset, page_size, bio, bio_flags) ||
2461 tree->ops->merge_bio_hook(page, offset, page_size, bio,
2462 bio_flags)) ||
2463 bio_add_page(bio, page, page_size, offset) < page_size) { 2474 bio_add_page(bio, page, page_size, offset) < page_size) {
2464 ret = submit_one_bio(rw, bio, mirror_num, 2475 ret = submit_one_bio(rw, bio, mirror_num,
2465 prev_bio_flags); 2476 prev_bio_flags);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f0dfd7de0205..ad1e88d25031 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1425,10 +1425,11 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
1425 map_length = length; 1425 map_length = length;
1426 ret = btrfs_map_block(map_tree, READ, logical, 1426 ret = btrfs_map_block(map_tree, READ, logical,
1427 &map_length, NULL, 0); 1427 &map_length, NULL, 0);
1428 1428 /* Will always return 0 or 1 with map_multi == NULL */
1429 BUG_ON(ret < 0);
1429 if (map_length < length + size) 1430 if (map_length < length + size)
1430 return 1; 1431 return 1;
1431 return ret; 1432 return 0;
1432} 1433}
1433 1434
1434/* 1435/*