Commit 355808c2 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba

btrfs: ->submit_bio_hook error push-up

This pushes failures from the submit_bio_hook callbacks,
btrfs_submit_bio_hook and btree_submit_bio_hook into the callers, including
callers of submit_one_bio where it catches the failures with BUG_ON.

It also pushes up through the ->readpage_io_failed_hook to
end_bio_extent_writepage where the error is already caught with BUG_ON.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
parent 3444a972
...@@ -847,9 +847,9 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, ...@@ -847,9 +847,9 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
{ {
int ret; int ret;
ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info, ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info, bio, 1);
bio, 1); if (ret)
BUG_ON(ret); return ret;
if (!(rw & REQ_WRITE)) { if (!(rw & REQ_WRITE)) {
/* /*
......
...@@ -2199,6 +2199,7 @@ int end_extent_writepage(struct page *page, int err, u64 start, u64 end) ...@@ -2199,6 +2199,7 @@ int end_extent_writepage(struct page *page, int err, u64 start, u64 end)
/* Writeback already completed */ /* Writeback already completed */
if (ret == 0) if (ret == 0)
return 1; return 1;
BUG_ON(ret < 0);
} }
if (!uptodate) { if (!uptodate) {
...@@ -2351,6 +2352,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err) ...@@ -2351,6 +2352,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
if (ret == 0) if (ret == 0)
goto error_handled; goto error_handled;
} }
BUG_ON(ret < 0);
} }
if (uptodate) { if (uptodate) {
...@@ -2402,8 +2404,8 @@ btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs, ...@@ -2402,8 +2404,8 @@ btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
return bio; return bio;
} }
static int submit_one_bio(int rw, struct bio *bio, int mirror_num, static int __must_check submit_one_bio(int rw, struct bio *bio,
unsigned long bio_flags) int mirror_num, unsigned long bio_flags)
{ {
int ret = 0; int ret = 0;
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
...@@ -2474,6 +2476,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree, ...@@ -2474,6 +2476,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
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);
BUG_ON(ret < 0);
bio = NULL; bio = NULL;
} else { } else {
return 0; return 0;
...@@ -2494,8 +2497,10 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree, ...@@ -2494,8 +2497,10 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
if (bio_ret) if (bio_ret)
*bio_ret = bio; *bio_ret = bio;
else else {
ret = submit_one_bio(rw, bio, mirror_num, bio_flags); ret = submit_one_bio(rw, bio, mirror_num, bio_flags);
BUG_ON(ret < 0);
}
return ret; return ret;
} }
...@@ -2707,8 +2712,10 @@ int extent_read_full_page(struct extent_io_tree *tree, struct page *page, ...@@ -2707,8 +2712,10 @@ int extent_read_full_page(struct extent_io_tree *tree, struct page *page,
ret = __extent_read_full_page(tree, page, get_extent, &bio, mirror_num, ret = __extent_read_full_page(tree, page, get_extent, &bio, mirror_num,
&bio_flags); &bio_flags);
if (bio) if (bio) {
ret = submit_one_bio(READ, bio, mirror_num, bio_flags); ret = submit_one_bio(READ, bio, mirror_num, bio_flags);
BUG_ON(ret < 0);
}
return ret; return ret;
} }
...@@ -3126,10 +3133,14 @@ static int extent_write_cache_pages(struct extent_io_tree *tree, ...@@ -3126,10 +3133,14 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
static void flush_epd_write_bio(struct extent_page_data *epd) static void flush_epd_write_bio(struct extent_page_data *epd)
{ {
if (epd->bio) { if (epd->bio) {
int rw = WRITE;
int ret;
if (epd->sync_io) if (epd->sync_io)
submit_one_bio(WRITE_SYNC, epd->bio, 0, 0); rw = WRITE_SYNC;
else
submit_one_bio(WRITE, epd->bio, 0, 0); ret = submit_one_bio(rw, epd->bio, 0, 0);
BUG_ON(ret < 0);
epd->bio = NULL; epd->bio = NULL;
} }
} }
...@@ -3245,8 +3256,10 @@ int extent_readpages(struct extent_io_tree *tree, ...@@ -3245,8 +3256,10 @@ int extent_readpages(struct extent_io_tree *tree,
page_cache_release(page); page_cache_release(page);
} }
BUG_ON(!list_empty(pages)); BUG_ON(!list_empty(pages));
if (bio) if (bio) {
submit_one_bio(READ, bio, 0, bio_flags); int ret = submit_one_bio(READ, bio, 0, bio_flags);
BUG_ON(ret < 0);
}
return 0; return 0;
} }
...@@ -4075,8 +4088,10 @@ int read_extent_buffer_pages(struct extent_io_tree *tree, ...@@ -4075,8 +4088,10 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
} }
} }
if (bio) if (bio) {
submit_one_bio(READ, bio, mirror_num, bio_flags); err = submit_one_bio(READ, bio, mirror_num, bio_flags);
BUG_ON(err < 0);
}
if (ret || wait != WAIT_COMPLETE) if (ret || wait != WAIT_COMPLETE)
return ret; return ret;
......
...@@ -1488,7 +1488,8 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, ...@@ -1488,7 +1488,8 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
metadata = 2; metadata = 2;
ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata); ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata);
BUG_ON(ret); if (ret)
return ret;
if (!(rw & REQ_WRITE)) { if (!(rw & REQ_WRITE)) {
if (bio_flags & EXTENT_BIO_COMPRESSED) { if (bio_flags & EXTENT_BIO_COMPRESSED) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment