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>
This commit is contained in:
parent
0417341e6b
commit
3444a97255
@ -2429,6 +2429,19 @@ static int submit_one_bio(int rw, struct bio *bio, int mirror_num,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int merge_bio(struct extent_io_tree *tree, struct page *page,
|
||||||
|
unsigned long offset, size_t size, struct bio *bio,
|
||||||
|
unsigned long bio_flags)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
if (tree->ops && tree->ops->merge_bio_hook)
|
||||||
|
ret = tree->ops->merge_bio_hook(page, offset, size, bio,
|
||||||
|
bio_flags);
|
||||||
|
BUG_ON(ret < 0);
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int submit_extent_page(int rw, struct extent_io_tree *tree,
|
static int submit_extent_page(int rw, struct extent_io_tree *tree,
|
||||||
struct page *page, sector_t sector,
|
struct page *page, sector_t sector,
|
||||||
size_t size, unsigned long offset,
|
size_t size, unsigned long offset,
|
||||||
@ -2457,9 +2470,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
|
|||||||
sector;
|
sector;
|
||||||
|
|
||||||
if (prev_bio_flags != bio_flags || !contig ||
|
if (prev_bio_flags != bio_flags || !contig ||
|
||||||
(tree->ops && tree->ops->merge_bio_hook &&
|
merge_bio(tree, page, offset, page_size, bio, bio_flags) ||
|
||||||
tree->ops->merge_bio_hook(page, offset, page_size, bio,
|
|
||||||
bio_flags)) ||
|
|
||||||
bio_add_page(bio, page, page_size, offset) < page_size) {
|
bio_add_page(bio, page, page_size, offset) < page_size) {
|
||||||
ret = submit_one_bio(rw, bio, mirror_num,
|
ret = submit_one_bio(rw, bio, mirror_num,
|
||||||
prev_bio_flags);
|
prev_bio_flags);
|
||||||
|
@ -1425,10 +1425,11 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
|
|||||||
map_length = length;
|
map_length = length;
|
||||||
ret = btrfs_map_block(map_tree, READ, logical,
|
ret = btrfs_map_block(map_tree, READ, logical,
|
||||||
&map_length, NULL, 0);
|
&map_length, NULL, 0);
|
||||||
|
/* Will always return 0 or 1 with map_multi == NULL */
|
||||||
|
BUG_ON(ret < 0);
|
||||||
if (map_length < length + size)
|
if (map_length < length + size)
|
||||||
return 1;
|
return 1;
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user