aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/block_dev.c18
-rw-r--r--fs/btrfs/btrfs_inode.h3
-rw-r--r--fs/btrfs/check-integrity.c4
-rw-r--r--fs/btrfs/compression.c44
-rw-r--r--fs/btrfs/compression.h4
-rw-r--r--fs/btrfs/ctree.h6
-rw-r--r--fs/btrfs/disk-io.c75
-rw-r--r--fs/btrfs/disk-io.h12
-rw-r--r--fs/btrfs/extent_io.c23
-rw-r--r--fs/btrfs/extent_io.h6
-rw-r--r--fs/btrfs/file-item.c14
-rw-r--r--fs/btrfs/inode.c73
-rw-r--r--fs/btrfs/raid56.c16
-rw-r--r--fs/btrfs/scrub.c26
-rw-r--r--fs/btrfs/volumes.c11
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/crypto/bio.c2
-rw-r--r--fs/direct-io.c8
-rw-r--r--fs/ext4/page-io.c13
-rw-r--r--fs/ext4/readpage.c4
-rw-r--r--fs/f2fs/data.c10
-rw-r--r--fs/f2fs/segment.c2
-rw-r--r--fs/gfs2/lops.c8
-rw-r--r--fs/gfs2/meta_io.c2
-rw-r--r--fs/gfs2/ops_fstype.c4
-rw-r--r--fs/iomap.c4
-rw-r--r--fs/jfs/jfs_logmgr.c2
-rw-r--r--fs/jfs/jfs_metapage.c4
-rw-r--r--fs/mpage.c3
-rw-r--r--fs/nfs/blocklayout/blocklayout.c4
-rw-r--r--fs/nilfs2/segbuf.c2
-rw-r--r--fs/ocfs2/cluster/heartbeat.c6
-rw-r--r--fs/xfs/xfs_aops.c7
-rw-r--r--fs/xfs/xfs_buf.c7
34 files changed, 220 insertions, 209 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index c1dc393ad6b9..bcd8e16a34e1 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -262,8 +262,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
262 if (vecs != inline_vecs) 262 if (vecs != inline_vecs)
263 kfree(vecs); 263 kfree(vecs);
264 264
265 if (unlikely(bio.bi_error)) 265 if (unlikely(bio.bi_status))
266 return bio.bi_error; 266 return blk_status_to_errno(bio.bi_status);
267 return ret; 267 return ret;
268} 268}
269 269
@@ -288,16 +288,18 @@ static void blkdev_bio_end_io(struct bio *bio)
288 bool should_dirty = dio->should_dirty; 288 bool should_dirty = dio->should_dirty;
289 289
290 if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) { 290 if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) {
291 if (bio->bi_error && !dio->bio.bi_error) 291 if (bio->bi_status && !dio->bio.bi_status)
292 dio->bio.bi_error = bio->bi_error; 292 dio->bio.bi_status = bio->bi_status;
293 } else { 293 } else {
294 if (!dio->is_sync) { 294 if (!dio->is_sync) {
295 struct kiocb *iocb = dio->iocb; 295 struct kiocb *iocb = dio->iocb;
296 ssize_t ret = dio->bio.bi_error; 296 ssize_t ret;
297 297
298 if (likely(!ret)) { 298 if (likely(!dio->bio.bi_status)) {
299 ret = dio->size; 299 ret = dio->size;
300 iocb->ki_pos += ret; 300 iocb->ki_pos += ret;
301 } else {
302 ret = blk_status_to_errno(dio->bio.bi_status);
301 } 303 }
302 304
303 dio->iocb->ki_complete(iocb, ret, 0); 305 dio->iocb->ki_complete(iocb, ret, 0);
@@ -363,7 +365,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
363 365
364 ret = bio_iov_iter_get_pages(bio, iter); 366 ret = bio_iov_iter_get_pages(bio, iter);
365 if (unlikely(ret)) { 367 if (unlikely(ret)) {
366 bio->bi_error = -EIO; 368 bio->bi_status = BLK_STS_IOERR;
367 bio_endio(bio); 369 bio_endio(bio);
368 break; 370 break;
369 } 371 }
@@ -413,7 +415,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
413 __set_current_state(TASK_RUNNING); 415 __set_current_state(TASK_RUNNING);
414 416
415 if (!ret) 417 if (!ret)
416 ret = dio->bio.bi_error; 418 ret = blk_status_to_errno(dio->bio.bi_status);
417 if (likely(!ret)) 419 if (likely(!ret))
418 ret = dio->size; 420 ret = dio->size;
419 421
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index b8622e4d1744..d87ac27a5f2b 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -310,7 +310,8 @@ struct btrfs_dio_private {
310 * The original bio may be split to several sub-bios, this is 310 * The original bio may be split to several sub-bios, this is
311 * done during endio of sub-bios 311 * done during endio of sub-bios
312 */ 312 */
313 int (*subio_endio)(struct inode *, struct btrfs_io_bio *, int); 313 blk_status_t (*subio_endio)(struct inode *, struct btrfs_io_bio *,
314 blk_status_t);
314}; 315};
315 316
316/* 317/*
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index ab14c2e635ca..4ded1c3f92b8 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -2129,7 +2129,7 @@ static void btrfsic_bio_end_io(struct bio *bp)
2129 /* mutex is not held! This is not save if IO is not yet completed 2129 /* mutex is not held! This is not save if IO is not yet completed
2130 * on umount */ 2130 * on umount */
2131 iodone_w_error = 0; 2131 iodone_w_error = 0;
2132 if (bp->bi_error) 2132 if (bp->bi_status)
2133 iodone_w_error = 1; 2133 iodone_w_error = 1;
2134 2134
2135 BUG_ON(NULL == block); 2135 BUG_ON(NULL == block);
@@ -2143,7 +2143,7 @@ static void btrfsic_bio_end_io(struct bio *bp)
2143 if ((dev_state->state->print_mask & 2143 if ((dev_state->state->print_mask &
2144 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2144 BTRFSIC_PRINT_MASK_END_IO_BIO_BH))
2145 pr_info("bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n", 2145 pr_info("bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n",
2146 bp->bi_error, 2146 bp->bi_status,
2147 btrfsic_get_block_type(dev_state->state, block), 2147 btrfsic_get_block_type(dev_state->state, block),
2148 block->logical_bytenr, dev_state->name, 2148 block->logical_bytenr, dev_state->name,
2149 block->dev_bytenr, block->mirror_num); 2149 block->dev_bytenr, block->mirror_num);
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 10e6b282d09d..9ac55b266e78 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -155,7 +155,7 @@ static void end_compressed_bio_read(struct bio *bio)
155 unsigned long index; 155 unsigned long index;
156 int ret; 156 int ret;
157 157
158 if (bio->bi_error) 158 if (bio->bi_status)
159 cb->errors = 1; 159 cb->errors = 1;
160 160
161 /* if there are more bios still pending for this compressed 161 /* if there are more bios still pending for this compressed
@@ -268,7 +268,7 @@ static void end_compressed_bio_write(struct bio *bio)
268 struct page *page; 268 struct page *page;
269 unsigned long index; 269 unsigned long index;
270 270
271 if (bio->bi_error) 271 if (bio->bi_status)
272 cb->errors = 1; 272 cb->errors = 1;
273 273
274 /* if there are more bios still pending for this compressed 274 /* if there are more bios still pending for this compressed
@@ -287,7 +287,7 @@ static void end_compressed_bio_write(struct bio *bio)
287 cb->start, 287 cb->start,
288 cb->start + cb->len - 1, 288 cb->start + cb->len - 1,
289 NULL, 289 NULL,
290 bio->bi_error ? 0 : 1); 290 bio->bi_status ? 0 : 1);
291 cb->compressed_pages[0]->mapping = NULL; 291 cb->compressed_pages[0]->mapping = NULL;
292 292
293 end_compressed_writeback(inode, cb); 293 end_compressed_writeback(inode, cb);
@@ -320,7 +320,7 @@ out:
320 * This also checksums the file bytes and gets things ready for 320 * This also checksums the file bytes and gets things ready for
321 * the end io hooks. 321 * the end io hooks.
322 */ 322 */
323int btrfs_submit_compressed_write(struct inode *inode, u64 start, 323blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
324 unsigned long len, u64 disk_start, 324 unsigned long len, u64 disk_start,
325 unsigned long compressed_len, 325 unsigned long compressed_len,
326 struct page **compressed_pages, 326 struct page **compressed_pages,
@@ -335,13 +335,13 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
335 struct page *page; 335 struct page *page;
336 u64 first_byte = disk_start; 336 u64 first_byte = disk_start;
337 struct block_device *bdev; 337 struct block_device *bdev;
338 int ret; 338 blk_status_t ret;
339 int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; 339 int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
340 340
341 WARN_ON(start & ((u64)PAGE_SIZE - 1)); 341 WARN_ON(start & ((u64)PAGE_SIZE - 1));
342 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS); 342 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
343 if (!cb) 343 if (!cb)
344 return -ENOMEM; 344 return BLK_STS_RESOURCE;
345 refcount_set(&cb->pending_bios, 0); 345 refcount_set(&cb->pending_bios, 0);
346 cb->errors = 0; 346 cb->errors = 0;
347 cb->inode = inode; 347 cb->inode = inode;
@@ -358,7 +358,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
358 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS); 358 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS);
359 if (!bio) { 359 if (!bio) {
360 kfree(cb); 360 kfree(cb);
361 return -ENOMEM; 361 return BLK_STS_RESOURCE;
362 } 362 }
363 bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 363 bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
364 bio->bi_private = cb; 364 bio->bi_private = cb;
@@ -368,17 +368,17 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
368 /* create and submit bios for the compressed pages */ 368 /* create and submit bios for the compressed pages */
369 bytes_left = compressed_len; 369 bytes_left = compressed_len;
370 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) { 370 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) {
371 int submit = 0;
372
371 page = compressed_pages[pg_index]; 373 page = compressed_pages[pg_index];
372 page->mapping = inode->i_mapping; 374 page->mapping = inode->i_mapping;
373 if (bio->bi_iter.bi_size) 375 if (bio->bi_iter.bi_size)
374 ret = io_tree->ops->merge_bio_hook(page, 0, 376 submit = io_tree->ops->merge_bio_hook(page, 0,
375 PAGE_SIZE, 377 PAGE_SIZE,
376 bio, 0); 378 bio, 0);
377 else
378 ret = 0;
379 379
380 page->mapping = NULL; 380 page->mapping = NULL;
381 if (ret || bio_add_page(bio, page, PAGE_SIZE, 0) < 381 if (submit || bio_add_page(bio, page, PAGE_SIZE, 0) <
382 PAGE_SIZE) { 382 PAGE_SIZE) {
383 bio_get(bio); 383 bio_get(bio);
384 384
@@ -400,7 +400,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
400 400
401 ret = btrfs_map_bio(fs_info, bio, 0, 1); 401 ret = btrfs_map_bio(fs_info, bio, 0, 1);
402 if (ret) { 402 if (ret) {
403 bio->bi_error = ret; 403 bio->bi_status = ret;
404 bio_endio(bio); 404 bio_endio(bio);
405 } 405 }
406 406
@@ -434,7 +434,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
434 434
435 ret = btrfs_map_bio(fs_info, bio, 0, 1); 435 ret = btrfs_map_bio(fs_info, bio, 0, 1);
436 if (ret) { 436 if (ret) {
437 bio->bi_error = ret; 437 bio->bi_status = ret;
438 bio_endio(bio); 438 bio_endio(bio);
439 } 439 }
440 440
@@ -569,7 +569,7 @@ next:
569 * After the compressed pages are read, we copy the bytes into the 569 * After the compressed pages are read, we copy the bytes into the
570 * bio we were passed and then call the bio end_io calls 570 * bio we were passed and then call the bio end_io calls
571 */ 571 */
572int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, 572blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
573 int mirror_num, unsigned long bio_flags) 573 int mirror_num, unsigned long bio_flags)
574{ 574{
575 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 575 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -586,7 +586,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
586 u64 em_len; 586 u64 em_len;
587 u64 em_start; 587 u64 em_start;
588 struct extent_map *em; 588 struct extent_map *em;
589 int ret = -ENOMEM; 589 blk_status_t ret = BLK_STS_RESOURCE;
590 int faili = 0; 590 int faili = 0;
591 u32 *sums; 591 u32 *sums;
592 592
@@ -600,7 +600,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
600 PAGE_SIZE); 600 PAGE_SIZE);
601 read_unlock(&em_tree->lock); 601 read_unlock(&em_tree->lock);
602 if (!em) 602 if (!em)
603 return -EIO; 603 return BLK_STS_IOERR;
604 604
605 compressed_len = em->block_len; 605 compressed_len = em->block_len;
606 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS); 606 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
@@ -659,19 +659,19 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
659 refcount_set(&cb->pending_bios, 1); 659 refcount_set(&cb->pending_bios, 1);
660 660
661 for (pg_index = 0; pg_index < nr_pages; pg_index++) { 661 for (pg_index = 0; pg_index < nr_pages; pg_index++) {
662 int submit = 0;
663
662 page = cb->compressed_pages[pg_index]; 664 page = cb->compressed_pages[pg_index];
663 page->mapping = inode->i_mapping; 665 page->mapping = inode->i_mapping;
664 page->index = em_start >> PAGE_SHIFT; 666 page->index = em_start >> PAGE_SHIFT;
665 667
666 if (comp_bio->bi_iter.bi_size) 668 if (comp_bio->bi_iter.bi_size)
667 ret = tree->ops->merge_bio_hook(page, 0, 669 submit = tree->ops->merge_bio_hook(page, 0,
668 PAGE_SIZE, 670 PAGE_SIZE,
669 comp_bio, 0); 671 comp_bio, 0);
670 else
671 ret = 0;
672 672
673 page->mapping = NULL; 673 page->mapping = NULL;
674 if (ret || bio_add_page(comp_bio, page, PAGE_SIZE, 0) < 674 if (submit || bio_add_page(comp_bio, page, PAGE_SIZE, 0) <
675 PAGE_SIZE) { 675 PAGE_SIZE) {
676 bio_get(comp_bio); 676 bio_get(comp_bio);
677 677
@@ -697,7 +697,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
697 697
698 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0); 698 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
699 if (ret) { 699 if (ret) {
700 comp_bio->bi_error = ret; 700 comp_bio->bi_status = ret;
701 bio_endio(comp_bio); 701 bio_endio(comp_bio);
702 } 702 }
703 703
@@ -726,7 +726,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
726 726
727 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0); 727 ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
728 if (ret) { 728 if (ret) {
729 comp_bio->bi_error = ret; 729 comp_bio->bi_status = ret;
730 bio_endio(comp_bio); 730 bio_endio(comp_bio);
731 } 731 }
732 732
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 39ec43ab8df1..680d4265d601 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -48,12 +48,12 @@ int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start,
48 unsigned long total_out, u64 disk_start, 48 unsigned long total_out, u64 disk_start,
49 struct bio *bio); 49 struct bio *bio);
50 50
51int btrfs_submit_compressed_write(struct inode *inode, u64 start, 51blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
52 unsigned long len, u64 disk_start, 52 unsigned long len, u64 disk_start,
53 unsigned long compressed_len, 53 unsigned long compressed_len,
54 struct page **compressed_pages, 54 struct page **compressed_pages,
55 unsigned long nr_pages); 55 unsigned long nr_pages);
56int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, 56blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
57 int mirror_num, unsigned long bio_flags); 57 int mirror_num, unsigned long bio_flags);
58 58
59enum btrfs_compression_type { 59enum btrfs_compression_type {
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 643c70d2b2e6..d2da0a52d560 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3078,8 +3078,8 @@ int btrfs_find_name_in_ext_backref(struct btrfs_path *path,
3078struct btrfs_dio_private; 3078struct btrfs_dio_private;
3079int btrfs_del_csums(struct btrfs_trans_handle *trans, 3079int btrfs_del_csums(struct btrfs_trans_handle *trans,
3080 struct btrfs_fs_info *fs_info, u64 bytenr, u64 len); 3080 struct btrfs_fs_info *fs_info, u64 bytenr, u64 len);
3081int btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, u32 *dst); 3081blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, u32 *dst);
3082int btrfs_lookup_bio_sums_dio(struct inode *inode, struct bio *bio, 3082blk_status_t btrfs_lookup_bio_sums_dio(struct inode *inode, struct bio *bio,
3083 u64 logical_offset); 3083 u64 logical_offset);
3084int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, 3084int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
3085 struct btrfs_root *root, 3085 struct btrfs_root *root,
@@ -3094,7 +3094,7 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
3094int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, 3094int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
3095 struct btrfs_root *root, 3095 struct btrfs_root *root,
3096 struct btrfs_ordered_sum *sums); 3096 struct btrfs_ordered_sum *sums);
3097int btrfs_csum_one_bio(struct inode *inode, struct bio *bio, 3097blk_status_t btrfs_csum_one_bio(struct inode *inode, struct bio *bio,
3098 u64 file_start, int contig); 3098 u64 file_start, int contig);
3099int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, 3099int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
3100 struct list_head *list, int search_commit); 3100 struct list_head *list, int search_commit);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 8685d67185d0..46accc75ad5a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -87,7 +87,7 @@ struct btrfs_end_io_wq {
87 bio_end_io_t *end_io; 87 bio_end_io_t *end_io;
88 void *private; 88 void *private;
89 struct btrfs_fs_info *info; 89 struct btrfs_fs_info *info;
90 int error; 90 blk_status_t status;
91 enum btrfs_wq_endio_type metadata; 91 enum btrfs_wq_endio_type metadata;
92 struct list_head list; 92 struct list_head list;
93 struct btrfs_work work; 93 struct btrfs_work work;
@@ -131,7 +131,7 @@ struct async_submit_bio {
131 */ 131 */
132 u64 bio_offset; 132 u64 bio_offset;
133 struct btrfs_work work; 133 struct btrfs_work work;
134 int error; 134 blk_status_t status;
135}; 135};
136 136
137/* 137/*
@@ -799,7 +799,7 @@ static void end_workqueue_bio(struct bio *bio)
799 btrfs_work_func_t func; 799 btrfs_work_func_t func;
800 800
801 fs_info = end_io_wq->info; 801 fs_info = end_io_wq->info;
802 end_io_wq->error = bio->bi_error; 802 end_io_wq->status = bio->bi_status;
803 803
804 if (bio_op(bio) == REQ_OP_WRITE) { 804 if (bio_op(bio) == REQ_OP_WRITE) {
805 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) { 805 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) {
@@ -836,19 +836,19 @@ static void end_workqueue_bio(struct bio *bio)
836 btrfs_queue_work(wq, &end_io_wq->work); 836 btrfs_queue_work(wq, &end_io_wq->work);
837} 837}
838 838
839int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, 839blk_status_t btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
840 enum btrfs_wq_endio_type metadata) 840 enum btrfs_wq_endio_type metadata)
841{ 841{
842 struct btrfs_end_io_wq *end_io_wq; 842 struct btrfs_end_io_wq *end_io_wq;
843 843
844 end_io_wq = kmem_cache_alloc(btrfs_end_io_wq_cache, GFP_NOFS); 844 end_io_wq = kmem_cache_alloc(btrfs_end_io_wq_cache, GFP_NOFS);
845 if (!end_io_wq) 845 if (!end_io_wq)
846 return -ENOMEM; 846 return BLK_STS_RESOURCE;
847 847
848 end_io_wq->private = bio->bi_private; 848 end_io_wq->private = bio->bi_private;
849 end_io_wq->end_io = bio->bi_end_io; 849 end_io_wq->end_io = bio->bi_end_io;
850 end_io_wq->info = info; 850 end_io_wq->info = info;
851 end_io_wq->error = 0; 851 end_io_wq->status = 0;
852 end_io_wq->bio = bio; 852 end_io_wq->bio = bio;
853 end_io_wq->metadata = metadata; 853 end_io_wq->metadata = metadata;
854 854
@@ -868,14 +868,14 @@ unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
868static void run_one_async_start(struct btrfs_work *work) 868static void run_one_async_start(struct btrfs_work *work)
869{ 869{
870 struct async_submit_bio *async; 870 struct async_submit_bio *async;
871 int ret; 871 blk_status_t ret;
872 872
873 async = container_of(work, struct async_submit_bio, work); 873 async = container_of(work, struct async_submit_bio, work);
874 ret = async->submit_bio_start(async->inode, async->bio, 874 ret = async->submit_bio_start(async->inode, async->bio,
875 async->mirror_num, async->bio_flags, 875 async->mirror_num, async->bio_flags,
876 async->bio_offset); 876 async->bio_offset);
877 if (ret) 877 if (ret)
878 async->error = ret; 878 async->status = ret;
879} 879}
880 880
881static void run_one_async_done(struct btrfs_work *work) 881static void run_one_async_done(struct btrfs_work *work)
@@ -898,8 +898,8 @@ static void run_one_async_done(struct btrfs_work *work)
898 wake_up(&fs_info->async_submit_wait); 898 wake_up(&fs_info->async_submit_wait);
899 899
900 /* If an error occurred we just want to clean up the bio and move on */ 900 /* If an error occurred we just want to clean up the bio and move on */
901 if (async->error) { 901 if (async->status) {
902 async->bio->bi_error = async->error; 902 async->bio->bi_status = async->status;
903 bio_endio(async->bio); 903 bio_endio(async->bio);
904 return; 904 return;
905 } 905 }
@@ -916,18 +916,17 @@ static void run_one_async_free(struct btrfs_work *work)
916 kfree(async); 916 kfree(async);
917} 917}
918 918
919int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode, 919blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info,
920 struct bio *bio, int mirror_num, 920 struct inode *inode, struct bio *bio, int mirror_num,
921 unsigned long bio_flags, 921 unsigned long bio_flags, u64 bio_offset,
922 u64 bio_offset, 922 extent_submit_bio_hook_t *submit_bio_start,
923 extent_submit_bio_hook_t *submit_bio_start, 923 extent_submit_bio_hook_t *submit_bio_done)
924 extent_submit_bio_hook_t *submit_bio_done)
925{ 924{
926 struct async_submit_bio *async; 925 struct async_submit_bio *async;
927 926
928 async = kmalloc(sizeof(*async), GFP_NOFS); 927 async = kmalloc(sizeof(*async), GFP_NOFS);
929 if (!async) 928 if (!async)
930 return -ENOMEM; 929 return BLK_STS_RESOURCE;
931 930
932 async->inode = inode; 931 async->inode = inode;
933 async->bio = bio; 932 async->bio = bio;
@@ -941,7 +940,7 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
941 async->bio_flags = bio_flags; 940 async->bio_flags = bio_flags;
942 async->bio_offset = bio_offset; 941 async->bio_offset = bio_offset;
943 942
944 async->error = 0; 943 async->status = 0;
945 944
946 atomic_inc(&fs_info->nr_async_submits); 945 atomic_inc(&fs_info->nr_async_submits);
947 946
@@ -959,7 +958,7 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
959 return 0; 958 return 0;
960} 959}
961 960
962static int btree_csum_one_bio(struct bio *bio) 961static blk_status_t btree_csum_one_bio(struct bio *bio)
963{ 962{
964 struct bio_vec *bvec; 963 struct bio_vec *bvec;
965 struct btrfs_root *root; 964 struct btrfs_root *root;
@@ -972,12 +971,12 @@ static int btree_csum_one_bio(struct bio *bio)
972 break; 971 break;
973 } 972 }
974 973
975 return ret; 974 return errno_to_blk_status(ret);
976} 975}
977 976
978static int __btree_submit_bio_start(struct inode *inode, struct bio *bio, 977static blk_status_t __btree_submit_bio_start(struct inode *inode,
979 int mirror_num, unsigned long bio_flags, 978 struct bio *bio, int mirror_num, unsigned long bio_flags,
980 u64 bio_offset) 979 u64 bio_offset)
981{ 980{
982 /* 981 /*
983 * when we're called for a write, we're already in the async 982 * when we're called for a write, we're already in the async
@@ -986,11 +985,11 @@ static int __btree_submit_bio_start(struct inode *inode, struct bio *bio,
986 return btree_csum_one_bio(bio); 985 return btree_csum_one_bio(bio);
987} 986}
988 987
989static int __btree_submit_bio_done(struct inode *inode, struct bio *bio, 988static blk_status_t __btree_submit_bio_done(struct inode *inode,
990 int mirror_num, unsigned long bio_flags, 989 struct bio *bio, int mirror_num, unsigned long bio_flags,
991 u64 bio_offset) 990 u64 bio_offset)
992{ 991{
993 int ret; 992 blk_status_t ret;
994 993
995 /* 994 /*
996 * when we're called for a write, we're already in the async 995 * when we're called for a write, we're already in the async
@@ -998,7 +997,7 @@ static int __btree_submit_bio_done(struct inode *inode, struct bio *bio,
998 */ 997 */
999 ret = btrfs_map_bio(btrfs_sb(inode->i_sb), bio, mirror_num, 1); 998 ret = btrfs_map_bio(btrfs_sb(inode->i_sb), bio, mirror_num, 1);
1000 if (ret) { 999 if (ret) {
1001 bio->bi_error = ret; 1000 bio->bi_status = ret;
1002 bio_endio(bio); 1001 bio_endio(bio);
1003 } 1002 }
1004 return ret; 1003 return ret;
@@ -1015,13 +1014,13 @@ static int check_async_write(unsigned long bio_flags)
1015 return 1; 1014 return 1;
1016} 1015}
1017 1016
1018static int btree_submit_bio_hook(struct inode *inode, struct bio *bio, 1017static blk_status_t btree_submit_bio_hook(struct inode *inode, struct bio *bio,
1019 int mirror_num, unsigned long bio_flags, 1018 int mirror_num, unsigned long bio_flags,
1020 u64 bio_offset) 1019 u64 bio_offset)
1021{ 1020{
1022 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 1021 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
1023 int async = check_async_write(bio_flags); 1022 int async = check_async_write(bio_flags);
1024 int ret; 1023 blk_status_t ret;
1025 1024
1026 if (bio_op(bio) != REQ_OP_WRITE) { 1025 if (bio_op(bio) != REQ_OP_WRITE) {
1027 /* 1026 /*
@@ -1054,7 +1053,7 @@ static int btree_submit_bio_hook(struct inode *inode, struct bio *bio,
1054 return 0; 1053 return 0;
1055 1054
1056out_w_error: 1055out_w_error:
1057 bio->bi_error = ret; 1056 bio->bi_status = ret;
1058 bio_endio(bio); 1057 bio_endio(bio);
1059 return ret; 1058 return ret;
1060} 1059}
@@ -1820,7 +1819,7 @@ static void end_workqueue_fn(struct btrfs_work *work)
1820 end_io_wq = container_of(work, struct btrfs_end_io_wq, work); 1819 end_io_wq = container_of(work, struct btrfs_end_io_wq, work);
1821 bio = end_io_wq->bio; 1820 bio = end_io_wq->bio;
1822 1821
1823 bio->bi_error = end_io_wq->error; 1822 bio->bi_status = end_io_wq->status;
1824 bio->bi_private = end_io_wq->private; 1823 bio->bi_private = end_io_wq->private;
1825 bio->bi_end_io = end_io_wq->end_io; 1824 bio->bi_end_io = end_io_wq->end_io;
1826 kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq); 1825 kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
@@ -3495,11 +3494,11 @@ static void btrfs_end_empty_barrier(struct bio *bio)
3495 * any device where the flush fails with eopnotsupp are flagged as not-barrier 3494 * any device where the flush fails with eopnotsupp are flagged as not-barrier
3496 * capable 3495 * capable
3497 */ 3496 */
3498static int write_dev_flush(struct btrfs_device *device, int wait) 3497static blk_status_t write_dev_flush(struct btrfs_device *device, int wait)
3499{ 3498{
3500 struct request_queue *q = bdev_get_queue(device->bdev); 3499 struct request_queue *q = bdev_get_queue(device->bdev);
3501 struct bio *bio; 3500 struct bio *bio;
3502 int ret = 0; 3501 blk_status_t ret = 0;
3503 3502
3504 if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) 3503 if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags))
3505 return 0; 3504 return 0;
@@ -3511,8 +3510,8 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
3511 3510
3512 wait_for_completion(&device->flush_wait); 3511 wait_for_completion(&device->flush_wait);
3513 3512
3514 if (bio->bi_error) { 3513 if (bio->bi_status) {
3515 ret = bio->bi_error; 3514 ret = bio->bi_status;
3516 btrfs_dev_stat_inc_and_print(device, 3515 btrfs_dev_stat_inc_and_print(device,
3517 BTRFS_DEV_STAT_FLUSH_ERRS); 3516 BTRFS_DEV_STAT_FLUSH_ERRS);
3518 } 3517 }
@@ -3531,7 +3530,7 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
3531 device->flush_bio = NULL; 3530 device->flush_bio = NULL;
3532 bio = btrfs_io_bio_alloc(GFP_NOFS, 0); 3531 bio = btrfs_io_bio_alloc(GFP_NOFS, 0);
3533 if (!bio) 3532 if (!bio)
3534 return -ENOMEM; 3533 return BLK_STS_RESOURCE;
3535 3534
3536 bio->bi_end_io = btrfs_end_empty_barrier; 3535 bio->bi_end_io = btrfs_end_empty_barrier;
3537 bio->bi_bdev = device->bdev; 3536 bio->bi_bdev = device->bdev;
@@ -3556,7 +3555,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
3556 struct btrfs_device *dev; 3555 struct btrfs_device *dev;
3557 int errors_send = 0; 3556 int errors_send = 0;
3558 int errors_wait = 0; 3557 int errors_wait = 0;
3559 int ret; 3558 blk_status_t ret;
3560 3559
3561 /* send down all the barriers */ 3560 /* send down all the barriers */
3562 head = &info->fs_devices->devices; 3561 head = &info->fs_devices->devices;
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 21f1ceb85b76..c581927555f3 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -118,13 +118,13 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
118int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid); 118int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid);
119u32 btrfs_csum_data(const char *data, u32 seed, size_t len); 119u32 btrfs_csum_data(const char *data, u32 seed, size_t len);
120void btrfs_csum_final(u32 crc, u8 *result); 120void btrfs_csum_final(u32 crc, u8 *result);
121int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, 121blk_status_t btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
122 enum btrfs_wq_endio_type metadata); 122 enum btrfs_wq_endio_type metadata);
123int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode, 123blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info,
124 struct bio *bio, int mirror_num, 124 struct inode *inode, struct bio *bio, int mirror_num,
125 unsigned long bio_flags, u64 bio_offset, 125 unsigned long bio_flags, u64 bio_offset,
126 extent_submit_bio_hook_t *submit_bio_start, 126 extent_submit_bio_hook_t *submit_bio_start,
127 extent_submit_bio_hook_t *submit_bio_done); 127 extent_submit_bio_hook_t *submit_bio_done);
128unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info); 128unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info);
129int btrfs_write_tree_block(struct extent_buffer *buf); 129int btrfs_write_tree_block(struct extent_buffer *buf);
130int btrfs_wait_tree_block_writeback(struct extent_buffer *buf); 130int btrfs_wait_tree_block_writeback(struct extent_buffer *buf);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d8da3edf2ac3..35cbb6ceb70d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2399,6 +2399,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
2399 struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; 2399 struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
2400 struct bio *bio; 2400 struct bio *bio;
2401 int read_mode = 0; 2401 int read_mode = 0;
2402 blk_status_t status;
2402 int ret; 2403 int ret;
2403 2404
2404 BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); 2405 BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE);
@@ -2431,11 +2432,12 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
2431 "Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d", 2432 "Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d",
2432 read_mode, failrec->this_mirror, failrec->in_validation); 2433 read_mode, failrec->this_mirror, failrec->in_validation);
2433 2434
2434 ret = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror, 2435 status = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror,
2435 failrec->bio_flags, 0); 2436 failrec->bio_flags, 0);
2436 if (ret) { 2437 if (status) {
2437 free_io_failure(BTRFS_I(inode), failrec); 2438 free_io_failure(BTRFS_I(inode), failrec);
2438 bio_put(bio); 2439 bio_put(bio);
2440 ret = blk_status_to_errno(status);
2439 } 2441 }
2440 2442
2441 return ret; 2443 return ret;
@@ -2474,6 +2476,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
2474 */ 2476 */
2475static void end_bio_extent_writepage(struct bio *bio) 2477static void end_bio_extent_writepage(struct bio *bio)
2476{ 2478{
2479 int error = blk_status_to_errno(bio->bi_status);
2477 struct bio_vec *bvec; 2480 struct bio_vec *bvec;
2478 u64 start; 2481 u64 start;
2479 u64 end; 2482 u64 end;
@@ -2503,7 +2506,7 @@ static void end_bio_extent_writepage(struct bio *bio)
2503 start = page_offset(page); 2506 start = page_offset(page);
2504 end = start + bvec->bv_offset + bvec->bv_len - 1; 2507 end = start + bvec->bv_offset + bvec->bv_len - 1;
2505 2508
2506 end_extent_writepage(page, bio->bi_error, start, end); 2509 end_extent_writepage(page, error, start, end);
2507 end_page_writeback(page); 2510 end_page_writeback(page);
2508 } 2511 }
2509 2512
@@ -2536,7 +2539,7 @@ endio_readpage_release_extent(struct extent_io_tree *tree, u64 start, u64 len,
2536static void end_bio_extent_readpage(struct bio *bio) 2539static void end_bio_extent_readpage(struct bio *bio)
2537{ 2540{
2538 struct bio_vec *bvec; 2541 struct bio_vec *bvec;
2539 int uptodate = !bio->bi_error; 2542 int uptodate = !bio->bi_status;
2540 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); 2543 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
2541 struct extent_io_tree *tree; 2544 struct extent_io_tree *tree;
2542 u64 offset = 0; 2545 u64 offset = 0;
@@ -2556,7 +2559,7 @@ static void end_bio_extent_readpage(struct bio *bio)
2556 2559
2557 btrfs_debug(fs_info, 2560 btrfs_debug(fs_info,
2558 "end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u", 2561 "end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u",
2559 (u64)bio->bi_iter.bi_sector, bio->bi_error, 2562 (u64)bio->bi_iter.bi_sector, bio->bi_status,
2560 io_bio->mirror_num); 2563 io_bio->mirror_num);
2561 tree = &BTRFS_I(inode)->io_tree; 2564 tree = &BTRFS_I(inode)->io_tree;
2562 2565
@@ -2615,7 +2618,7 @@ static void end_bio_extent_readpage(struct bio *bio)
2615 ret = bio_readpage_error(bio, offset, page, 2618 ret = bio_readpage_error(bio, offset, page,
2616 start, end, mirror); 2619 start, end, mirror);
2617 if (ret == 0) { 2620 if (ret == 0) {
2618 uptodate = !bio->bi_error; 2621 uptodate = !bio->bi_status;
2619 offset += len; 2622 offset += len;
2620 continue; 2623 continue;
2621 } 2624 }
@@ -2673,7 +2676,7 @@ readpage_ok:
2673 endio_readpage_release_extent(tree, extent_start, extent_len, 2676 endio_readpage_release_extent(tree, extent_start, extent_len,
2674 uptodate); 2677 uptodate);
2675 if (io_bio->end_io) 2678 if (io_bio->end_io)
2676 io_bio->end_io(io_bio, bio->bi_error); 2679 io_bio->end_io(io_bio, blk_status_to_errno(bio->bi_status));
2677 bio_put(bio); 2680 bio_put(bio);
2678} 2681}
2679 2682
@@ -2743,7 +2746,7 @@ struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
2743static int __must_check submit_one_bio(struct bio *bio, int mirror_num, 2746static int __must_check submit_one_bio(struct bio *bio, int mirror_num,
2744 unsigned long bio_flags) 2747 unsigned long bio_flags)
2745{ 2748{
2746 int ret = 0; 2749 blk_status_t ret = 0;
2747 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 2750 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
2748 struct page *page = bvec->bv_page; 2751 struct page *page = bvec->bv_page;
2749 struct extent_io_tree *tree = bio->bi_private; 2752 struct extent_io_tree *tree = bio->bi_private;
@@ -2761,7 +2764,7 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num,
2761 btrfsic_submit_bio(bio); 2764 btrfsic_submit_bio(bio);
2762 2765
2763 bio_put(bio); 2766 bio_put(bio);
2764 return ret; 2767 return blk_status_to_errno(ret);
2765} 2768}
2766 2769
2767static int merge_bio(struct extent_io_tree *tree, struct page *page, 2770static int merge_bio(struct extent_io_tree *tree, struct page *page,
@@ -3707,7 +3710,7 @@ static void end_bio_extent_buffer_writepage(struct bio *bio)
3707 BUG_ON(!eb); 3710 BUG_ON(!eb);
3708 done = atomic_dec_and_test(&eb->io_pages); 3711 done = atomic_dec_and_test(&eb->io_pages);
3709 3712
3710 if (bio->bi_error || 3713 if (bio->bi_status ||
3711 test_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) { 3714 test_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) {
3712 ClearPageUptodate(page); 3715 ClearPageUptodate(page);
3713 set_btree_ioerr(page); 3716 set_btree_ioerr(page);
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 1eafa2f0ede3..487ca0207cb6 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -92,9 +92,9 @@ struct btrfs_inode;
92struct btrfs_io_bio; 92struct btrfs_io_bio;
93struct io_failure_record; 93struct io_failure_record;
94 94
95typedef int (extent_submit_bio_hook_t)(struct inode *inode, struct bio *bio, 95typedef blk_status_t (extent_submit_bio_hook_t)(struct inode *inode,
96 int mirror_num, unsigned long bio_flags, 96 struct bio *bio, int mirror_num, unsigned long bio_flags,
97 u64 bio_offset); 97 u64 bio_offset);
98struct extent_io_ops { 98struct extent_io_ops {
99 /* 99 /*
100 * The following callbacks must be allways defined, the function 100 * The following callbacks must be allways defined, the function
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 64fcb31d7163..5b1c7090e546 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -160,7 +160,7 @@ static void btrfs_io_bio_endio_readpage(struct btrfs_io_bio *bio, int err)
160 kfree(bio->csum_allocated); 160 kfree(bio->csum_allocated);
161} 161}
162 162
163static int __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, 163static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
164 u64 logical_offset, u32 *dst, int dio) 164 u64 logical_offset, u32 *dst, int dio)
165{ 165{
166 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 166 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -182,7 +182,7 @@ static int __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
182 182
183 path = btrfs_alloc_path(); 183 path = btrfs_alloc_path();
184 if (!path) 184 if (!path)
185 return -ENOMEM; 185 return BLK_STS_RESOURCE;
186 186
187 nblocks = bio->bi_iter.bi_size >> inode->i_sb->s_blocksize_bits; 187 nblocks = bio->bi_iter.bi_size >> inode->i_sb->s_blocksize_bits;
188 if (!dst) { 188 if (!dst) {
@@ -191,7 +191,7 @@ static int __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
191 csum_size, GFP_NOFS); 191 csum_size, GFP_NOFS);
192 if (!btrfs_bio->csum_allocated) { 192 if (!btrfs_bio->csum_allocated) {
193 btrfs_free_path(path); 193 btrfs_free_path(path);
194 return -ENOMEM; 194 return BLK_STS_RESOURCE;
195 } 195 }
196 btrfs_bio->csum = btrfs_bio->csum_allocated; 196 btrfs_bio->csum = btrfs_bio->csum_allocated;
197 btrfs_bio->end_io = btrfs_io_bio_endio_readpage; 197 btrfs_bio->end_io = btrfs_io_bio_endio_readpage;
@@ -303,12 +303,12 @@ next:
303 return 0; 303 return 0;
304} 304}
305 305
306int btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, u32 *dst) 306blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, u32 *dst)
307{ 307{
308 return __btrfs_lookup_bio_sums(inode, bio, 0, dst, 0); 308 return __btrfs_lookup_bio_sums(inode, bio, 0, dst, 0);
309} 309}
310 310
311int btrfs_lookup_bio_sums_dio(struct inode *inode, struct bio *bio, u64 offset) 311blk_status_t btrfs_lookup_bio_sums_dio(struct inode *inode, struct bio *bio, u64 offset)
312{ 312{
313 return __btrfs_lookup_bio_sums(inode, bio, offset, NULL, 1); 313 return __btrfs_lookup_bio_sums(inode, bio, offset, NULL, 1);
314} 314}
@@ -433,7 +433,7 @@ fail:
433 return ret; 433 return ret;
434} 434}
435 435
436int btrfs_csum_one_bio(struct inode *inode, struct bio *bio, 436blk_status_t btrfs_csum_one_bio(struct inode *inode, struct bio *bio,
437 u64 file_start, int contig) 437 u64 file_start, int contig)
438{ 438{
439 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 439 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -452,7 +452,7 @@ int btrfs_csum_one_bio(struct inode *inode, struct bio *bio,
452 sums = kzalloc(btrfs_ordered_sum_size(fs_info, bio->bi_iter.bi_size), 452 sums = kzalloc(btrfs_ordered_sum_size(fs_info, bio->bi_iter.bi_size),
453 GFP_NOFS); 453 GFP_NOFS);
454 if (!sums) 454 if (!sums)
455 return -ENOMEM; 455 return BLK_STS_RESOURCE;
456 456
457 sums->len = bio->bi_iter.bi_size; 457 sums->len = bio->bi_iter.bi_size;
458 INIT_LIST_HEAD(&sums->list); 458 INIT_LIST_HEAD(&sums->list);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 758b2666885e..ea7cae1003eb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -842,13 +842,12 @@ retry:
842 NULL, EXTENT_LOCKED | EXTENT_DELALLOC, 842 NULL, EXTENT_LOCKED | EXTENT_DELALLOC,
843 PAGE_UNLOCK | PAGE_CLEAR_DIRTY | 843 PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
844 PAGE_SET_WRITEBACK); 844 PAGE_SET_WRITEBACK);
845 ret = btrfs_submit_compressed_write(inode, 845 if (btrfs_submit_compressed_write(inode,
846 async_extent->start, 846 async_extent->start,
847 async_extent->ram_size, 847 async_extent->ram_size,
848 ins.objectid, 848 ins.objectid,
849 ins.offset, async_extent->pages, 849 ins.offset, async_extent->pages,
850 async_extent->nr_pages); 850 async_extent->nr_pages)) {
851 if (ret) {
852 struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; 851 struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
853 struct page *p = async_extent->pages[0]; 852 struct page *p = async_extent->pages[0];
854 const u64 start = async_extent->start; 853 const u64 start = async_extent->start;
@@ -1901,11 +1900,11 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
1901 * At IO completion time the cums attached on the ordered extent record 1900 * At IO completion time the cums attached on the ordered extent record
1902 * are inserted into the btree 1901 * are inserted into the btree
1903 */ 1902 */
1904static int __btrfs_submit_bio_start(struct inode *inode, struct bio *bio, 1903static blk_status_t __btrfs_submit_bio_start(struct inode *inode,
1905 int mirror_num, unsigned long bio_flags, 1904 struct bio *bio, int mirror_num, unsigned long bio_flags,
1906 u64 bio_offset) 1905 u64 bio_offset)
1907{ 1906{
1908 int ret = 0; 1907 blk_status_t ret = 0;
1909 1908
1910 ret = btrfs_csum_one_bio(inode, bio, 0, 0); 1909 ret = btrfs_csum_one_bio(inode, bio, 0, 0);
1911 BUG_ON(ret); /* -ENOMEM */ 1910 BUG_ON(ret); /* -ENOMEM */
@@ -1920,16 +1919,16 @@ static int __btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
1920 * At IO completion time the cums attached on the ordered extent record 1919 * At IO completion time the cums attached on the ordered extent record
1921 * are inserted into the btree 1920 * are inserted into the btree
1922 */ 1921 */
1923static int __btrfs_submit_bio_done(struct inode *inode, struct bio *bio, 1922static blk_status_t __btrfs_submit_bio_done(struct inode *inode,
1924 int mirror_num, unsigned long bio_flags, 1923 struct bio *bio, int mirror_num, unsigned long bio_flags,
1925 u64 bio_offset) 1924 u64 bio_offset)
1926{ 1925{
1927 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 1926 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
1928 int ret; 1927 blk_status_t ret;
1929 1928
1930 ret = btrfs_map_bio(fs_info, bio, mirror_num, 1); 1929 ret = btrfs_map_bio(fs_info, bio, mirror_num, 1);
1931 if (ret) { 1930 if (ret) {
1932 bio->bi_error = ret; 1931 bio->bi_status = ret;
1933 bio_endio(bio); 1932 bio_endio(bio);
1934 } 1933 }
1935 return ret; 1934 return ret;
@@ -1939,14 +1938,14 @@ static int __btrfs_submit_bio_done(struct inode *inode, struct bio *bio,
1939 * extent_io.c submission hook. This does the right thing for csum calculation 1938 * extent_io.c submission hook. This does the right thing for csum calculation
1940 * on write, or reading the csums from the tree before a read 1939 * on write, or reading the csums from the tree before a read
1941 */ 1940 */
1942static int btrfs_submit_bio_hook(struct inode *inode, struct bio *bio, 1941static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio,
1943 int mirror_num, unsigned long bio_flags, 1942 int mirror_num, unsigned long bio_flags,
1944 u64 bio_offset) 1943 u64 bio_offset)
1945{ 1944{
1946 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 1945 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
1947 struct btrfs_root *root = BTRFS_I(inode)->root; 1946 struct btrfs_root *root = BTRFS_I(inode)->root;
1948 enum btrfs_wq_endio_type metadata = BTRFS_WQ_ENDIO_DATA; 1947 enum btrfs_wq_endio_type metadata = BTRFS_WQ_ENDIO_DATA;
1949 int ret = 0; 1948 blk_status_t ret = 0;
1950 int skip_sum; 1949 int skip_sum;
1951 int async = !atomic_read(&BTRFS_I(inode)->sync_writers); 1950 int async = !atomic_read(&BTRFS_I(inode)->sync_writers);
1952 1951
@@ -1991,8 +1990,8 @@ mapit:
1991 ret = btrfs_map_bio(fs_info, bio, mirror_num, 0); 1990 ret = btrfs_map_bio(fs_info, bio, mirror_num, 0);
1992 1991
1993out: 1992out:
1994 if (ret < 0) { 1993 if (ret) {
1995 bio->bi_error = ret; 1994 bio->bi_status = ret;
1996 bio_endio(bio); 1995 bio_endio(bio);
1997 } 1996 }
1998 return ret; 1997 return ret;
@@ -8037,7 +8036,7 @@ static void btrfs_retry_endio_nocsum(struct bio *bio)
8037 struct bio_vec *bvec; 8036 struct bio_vec *bvec;
8038 int i; 8037 int i;
8039 8038
8040 if (bio->bi_error) 8039 if (bio->bi_status)
8041 goto end; 8040 goto end;
8042 8041
8043 ASSERT(bio->bi_vcnt == 1); 8042 ASSERT(bio->bi_vcnt == 1);
@@ -8116,7 +8115,7 @@ static void btrfs_retry_endio(struct bio *bio)
8116 int ret; 8115 int ret;
8117 int i; 8116 int i;
8118 8117
8119 if (bio->bi_error) 8118 if (bio->bi_status)
8120 goto end; 8119 goto end;
8121 8120
8122 uptodate = 1; 8121 uptodate = 1;
@@ -8141,8 +8140,8 @@ end:
8141 bio_put(bio); 8140 bio_put(bio);
8142} 8141}
8143 8142
8144static int __btrfs_subio_endio_read(struct inode *inode, 8143static blk_status_t __btrfs_subio_endio_read(struct inode *inode,
8145 struct btrfs_io_bio *io_bio, int err) 8144 struct btrfs_io_bio *io_bio, blk_status_t err)
8146{ 8145{
8147 struct btrfs_fs_info *fs_info; 8146 struct btrfs_fs_info *fs_info;
8148 struct bio_vec *bvec; 8147 struct bio_vec *bvec;
@@ -8184,7 +8183,7 @@ try_again:
8184 io_bio->mirror_num, 8183 io_bio->mirror_num,
8185 btrfs_retry_endio, &done); 8184 btrfs_retry_endio, &done);
8186 if (ret) { 8185 if (ret) {
8187 err = ret; 8186 err = errno_to_blk_status(ret);
8188 goto next; 8187 goto next;
8189 } 8188 }
8190 8189
@@ -8211,8 +8210,8 @@ next:
8211 return err; 8210 return err;
8212} 8211}
8213 8212
8214static int btrfs_subio_endio_read(struct inode *inode, 8213static blk_status_t btrfs_subio_endio_read(struct inode *inode,
8215 struct btrfs_io_bio *io_bio, int err) 8214 struct btrfs_io_bio *io_bio, blk_status_t err)
8216{ 8215{
8217 bool skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; 8216 bool skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
8218 8217
@@ -8232,7 +8231,7 @@ static void btrfs_endio_direct_read(struct bio *bio)
8232 struct inode *inode = dip->inode; 8231 struct inode *inode = dip->inode;
8233 struct bio *dio_bio; 8232 struct bio *dio_bio;
8234 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); 8233 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
8235 int err = bio->bi_error; 8234 blk_status_t err = bio->bi_status;
8236 8235
8237 if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) 8236 if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED)
8238 err = btrfs_subio_endio_read(inode, io_bio, err); 8237 err = btrfs_subio_endio_read(inode, io_bio, err);
@@ -8243,11 +8242,11 @@ static void btrfs_endio_direct_read(struct bio *bio)
8243 8242
8244 kfree(dip); 8243 kfree(dip);
8245 8244
8246 dio_bio->bi_error = bio->bi_error; 8245 dio_bio->bi_status = bio->bi_status;
8247 dio_end_io(dio_bio); 8246 dio_end_io(dio_bio);
8248 8247
8249 if (io_bio->end_io) 8248 if (io_bio->end_io)
8250 io_bio->end_io(io_bio, err); 8249 io_bio->end_io(io_bio, blk_status_to_errno(err));
8251 bio_put(bio); 8250 bio_put(bio);
8252} 8251}
8253 8252
@@ -8299,20 +8298,20 @@ static void btrfs_endio_direct_write(struct bio *bio)
8299 struct bio *dio_bio = dip->dio_bio; 8298 struct bio *dio_bio = dip->dio_bio;
8300 8299
8301 __endio_write_update_ordered(dip->inode, dip->logical_offset, 8300 __endio_write_update_ordered(dip->inode, dip->logical_offset,
8302 dip->bytes, !bio->bi_error); 8301 dip->bytes, !bio->bi_status);
8303 8302
8304 kfree(dip); 8303 kfree(dip);
8305 8304
8306 dio_bio->bi_error = bio->bi_error; 8305 dio_bio->bi_status = bio->bi_status;
8307 dio_end_io(dio_bio); 8306 dio_end_io(dio_bio);
8308 bio_put(bio); 8307 bio_put(bio);
8309} 8308}
8310 8309
8311static int __btrfs_submit_bio_start_direct_io(struct inode *inode, 8310static blk_status_t __btrfs_submit_bio_start_direct_io(struct inode *inode,
8312 struct bio *bio, int mirror_num, 8311 struct bio *bio, int mirror_num,
8313 unsigned long bio_flags, u64 offset) 8312 unsigned long bio_flags, u64 offset)
8314{ 8313{
8315 int ret; 8314 blk_status_t ret;
8316 ret = btrfs_csum_one_bio(inode, bio, offset, 1); 8315 ret = btrfs_csum_one_bio(inode, bio, offset, 1);
8317 BUG_ON(ret); /* -ENOMEM */ 8316 BUG_ON(ret); /* -ENOMEM */
8318 return 0; 8317 return 0;
@@ -8321,7 +8320,7 @@ static int __btrfs_submit_bio_start_direct_io(struct inode *inode,
8321static void btrfs_end_dio_bio(struct bio *bio) 8320static void btrfs_end_dio_bio(struct bio *bio)
8322{ 8321{
8323 struct btrfs_dio_private *dip = bio->bi_private; 8322 struct btrfs_dio_private *dip = bio->bi_private;
8324 int err = bio->bi_error; 8323 blk_status_t err = bio->bi_status;
8325 8324
8326 if (err) 8325 if (err)
8327 btrfs_warn(BTRFS_I(dip->inode)->root->fs_info, 8326 btrfs_warn(BTRFS_I(dip->inode)->root->fs_info,
@@ -8351,7 +8350,7 @@ static void btrfs_end_dio_bio(struct bio *bio)
8351 if (dip->errors) { 8350 if (dip->errors) {
8352 bio_io_error(dip->orig_bio); 8351 bio_io_error(dip->orig_bio);
8353 } else { 8352 } else {
8354 dip->dio_bio->bi_error = 0; 8353 dip->dio_bio->bi_status = 0;
8355 bio_endio(dip->orig_bio); 8354 bio_endio(dip->orig_bio);
8356 } 8355 }
8357out: 8356out:
@@ -8368,14 +8367,14 @@ static struct bio *btrfs_dio_bio_alloc(struct block_device *bdev,
8368 return bio; 8367 return bio;
8369} 8368}
8370 8369
8371static inline int btrfs_lookup_and_bind_dio_csum(struct inode *inode, 8370static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode,
8372 struct btrfs_dio_private *dip, 8371 struct btrfs_dio_private *dip,
8373 struct bio *bio, 8372 struct bio *bio,
8374 u64 file_offset) 8373 u64 file_offset)
8375{ 8374{
8376 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); 8375 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
8377 struct btrfs_io_bio *orig_io_bio = btrfs_io_bio(dip->orig_bio); 8376 struct btrfs_io_bio *orig_io_bio = btrfs_io_bio(dip->orig_bio);
8378 int ret; 8377 blk_status_t ret;
8379 8378
8380 /* 8379 /*
8381 * We load all the csum data we need when we submit 8380 * We load all the csum data we need when we submit
@@ -8406,7 +8405,7 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
8406 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 8405 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
8407 struct btrfs_dio_private *dip = bio->bi_private; 8406 struct btrfs_dio_private *dip = bio->bi_private;
8408 bool write = bio_op(bio) == REQ_OP_WRITE; 8407 bool write = bio_op(bio) == REQ_OP_WRITE;
8409 int ret; 8408 blk_status_t ret;
8410 8409
8411 if (async_submit) 8410 if (async_submit)
8412 async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers); 8411 async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers);
@@ -8649,7 +8648,7 @@ free_ordered:
8649 * callbacks - they require an allocated dip and a clone of dio_bio. 8648 * callbacks - they require an allocated dip and a clone of dio_bio.
8650 */ 8649 */
8651 if (io_bio && dip) { 8650 if (io_bio && dip) {
8652 io_bio->bi_error = -EIO; 8651 io_bio->bi_status = BLK_STS_IOERR;
8653 bio_endio(io_bio); 8652 bio_endio(io_bio);
8654 /* 8653 /*
8655 * The end io callbacks free our dip, do the final put on io_bio 8654 * The end io callbacks free our dip, do the final put on io_bio
@@ -8668,7 +8667,7 @@ free_ordered:
8668 unlock_extent(&BTRFS_I(inode)->io_tree, file_offset, 8667 unlock_extent(&BTRFS_I(inode)->io_tree, file_offset,
8669 file_offset + dio_bio->bi_iter.bi_size - 1); 8668 file_offset + dio_bio->bi_iter.bi_size - 1);
8670 8669
8671 dio_bio->bi_error = -EIO; 8670 dio_bio->bi_status = BLK_STS_IOERR;
8672 /* 8671 /*
8673 * Releases and cleans up our dio_bio, no need to bio_put() 8672 * Releases and cleans up our dio_bio, no need to bio_put()
8674 * nor bio_endio()/bio_io_error() against dio_bio. 8673 * nor bio_endio()/bio_io_error() against dio_bio.
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index d8ea0eb76325..f3d30d9ea8f9 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -871,7 +871,7 @@ static void free_raid_bio(struct btrfs_raid_bio *rbio)
871 * this frees the rbio and runs through all the bios in the 871 * this frees the rbio and runs through all the bios in the
872 * bio_list and calls end_io on them 872 * bio_list and calls end_io on them
873 */ 873 */
874static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, int err) 874static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, blk_status_t err)
875{ 875{
876 struct bio *cur = bio_list_get(&rbio->bio_list); 876 struct bio *cur = bio_list_get(&rbio->bio_list);
877 struct bio *next; 877 struct bio *next;
@@ -884,7 +884,7 @@ static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, int err)
884 while (cur) { 884 while (cur) {
885 next = cur->bi_next; 885 next = cur->bi_next;
886 cur->bi_next = NULL; 886 cur->bi_next = NULL;
887 cur->bi_error = err; 887 cur->bi_status = err;
888 bio_endio(cur); 888 bio_endio(cur);
889 cur = next; 889 cur = next;
890 } 890 }
@@ -897,7 +897,7 @@ static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, int err)
897static void raid_write_end_io(struct bio *bio) 897static void raid_write_end_io(struct bio *bio)
898{ 898{
899 struct btrfs_raid_bio *rbio = bio->bi_private; 899 struct btrfs_raid_bio *rbio = bio->bi_private;
900 int err = bio->bi_error; 900 blk_status_t err = bio->bi_status;
901 int max_errors; 901 int max_errors;
902 902
903 if (err) 903 if (err)
@@ -914,7 +914,7 @@ static void raid_write_end_io(struct bio *bio)
914 max_errors = (rbio->operation == BTRFS_RBIO_PARITY_SCRUB) ? 914 max_errors = (rbio->operation == BTRFS_RBIO_PARITY_SCRUB) ?
915 0 : rbio->bbio->max_errors; 915 0 : rbio->bbio->max_errors;
916 if (atomic_read(&rbio->error) > max_errors) 916 if (atomic_read(&rbio->error) > max_errors)
917 err = -EIO; 917 err = BLK_STS_IOERR;
918 918
919 rbio_orig_end_io(rbio, err); 919 rbio_orig_end_io(rbio, err);
920} 920}
@@ -1092,7 +1092,7 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,
1092 * devices or if they are not contiguous 1092 * devices or if they are not contiguous
1093 */ 1093 */
1094 if (last_end == disk_start && stripe->dev->bdev && 1094 if (last_end == disk_start && stripe->dev->bdev &&
1095 !last->bi_error && 1095 !last->bi_status &&
1096 last->bi_bdev == stripe->dev->bdev) { 1096 last->bi_bdev == stripe->dev->bdev) {
1097 ret = bio_add_page(last, page, PAGE_SIZE, 0); 1097 ret = bio_add_page(last, page, PAGE_SIZE, 0);
1098 if (ret == PAGE_SIZE) 1098 if (ret == PAGE_SIZE)
@@ -1448,7 +1448,7 @@ static void raid_rmw_end_io(struct bio *bio)
1448{ 1448{
1449 struct btrfs_raid_bio *rbio = bio->bi_private; 1449 struct btrfs_raid_bio *rbio = bio->bi_private;
1450 1450
1451 if (bio->bi_error) 1451 if (bio->bi_status)
1452 fail_bio_stripe(rbio, bio); 1452 fail_bio_stripe(rbio, bio);
1453 else 1453 else
1454 set_bio_pages_uptodate(bio); 1454 set_bio_pages_uptodate(bio);
@@ -1991,7 +1991,7 @@ static void raid_recover_end_io(struct bio *bio)
1991 * we only read stripe pages off the disk, set them 1991 * we only read stripe pages off the disk, set them
1992 * up to date if there were no errors 1992 * up to date if there were no errors
1993 */ 1993 */
1994 if (bio->bi_error) 1994 if (bio->bi_status)
1995 fail_bio_stripe(rbio, bio); 1995 fail_bio_stripe(rbio, bio);
1996 else 1996 else
1997 set_bio_pages_uptodate(bio); 1997 set_bio_pages_uptodate(bio);
@@ -2530,7 +2530,7 @@ static void raid56_parity_scrub_end_io(struct bio *bio)
2530{ 2530{
2531 struct btrfs_raid_bio *rbio = bio->bi_private; 2531 struct btrfs_raid_bio *rbio = bio->bi_private;
2532 2532
2533 if (bio->bi_error) 2533 if (bio->bi_status)
2534 fail_bio_stripe(rbio, bio); 2534 fail_bio_stripe(rbio, bio);
2535 else 2535 else
2536 set_bio_pages_uptodate(bio); 2536 set_bio_pages_uptodate(bio);
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index c7b45eb2403d..ba5595d19de1 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -95,7 +95,7 @@ struct scrub_bio {
95 struct scrub_ctx *sctx; 95 struct scrub_ctx *sctx;
96 struct btrfs_device *dev; 96 struct btrfs_device *dev;
97 struct bio *bio; 97 struct bio *bio;
98 int err; 98 blk_status_t status;
99 u64 logical; 99 u64 logical;
100 u64 physical; 100 u64 physical;
101#if SCRUB_PAGES_PER_WR_BIO >= SCRUB_PAGES_PER_RD_BIO 101#if SCRUB_PAGES_PER_WR_BIO >= SCRUB_PAGES_PER_RD_BIO
@@ -1668,14 +1668,14 @@ leave_nomem:
1668 1668
1669struct scrub_bio_ret { 1669struct scrub_bio_ret {
1670 struct completion event; 1670 struct completion event;
1671 int error; 1671 blk_status_t status;
1672}; 1672};
1673 1673
1674static void scrub_bio_wait_endio(struct bio *bio) 1674static void scrub_bio_wait_endio(struct bio *bio)
1675{ 1675{
1676 struct scrub_bio_ret *ret = bio->bi_private; 1676 struct scrub_bio_ret *ret = bio->bi_private;
1677 1677
1678 ret->error = bio->bi_error; 1678 ret->status = bio->bi_status;
1679 complete(&ret->event); 1679 complete(&ret->event);
1680} 1680}
1681 1681
@@ -1693,7 +1693,7 @@ static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info,
1693 int ret; 1693 int ret;
1694 1694
1695 init_completion(&done.event); 1695 init_completion(&done.event);
1696 done.error = 0; 1696 done.status = 0;
1697 bio->bi_iter.bi_sector = page->logical >> 9; 1697 bio->bi_iter.bi_sector = page->logical >> 9;
1698 bio->bi_private = &done; 1698 bio->bi_private = &done;
1699 bio->bi_end_io = scrub_bio_wait_endio; 1699 bio->bi_end_io = scrub_bio_wait_endio;
@@ -1705,7 +1705,7 @@ static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info,
1705 return ret; 1705 return ret;
1706 1706
1707 wait_for_completion(&done.event); 1707 wait_for_completion(&done.event);
1708 if (done.error) 1708 if (done.status)
1709 return -EIO; 1709 return -EIO;
1710 1710
1711 return 0; 1711 return 0;
@@ -1937,7 +1937,7 @@ again:
1937 bio->bi_bdev = sbio->dev->bdev; 1937 bio->bi_bdev = sbio->dev->bdev;
1938 bio->bi_iter.bi_sector = sbio->physical >> 9; 1938 bio->bi_iter.bi_sector = sbio->physical >> 9;
1939 bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 1939 bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
1940 sbio->err = 0; 1940 sbio->status = 0;
1941 } else if (sbio->physical + sbio->page_count * PAGE_SIZE != 1941 } else if (sbio->physical + sbio->page_count * PAGE_SIZE !=
1942 spage->physical_for_dev_replace || 1942 spage->physical_for_dev_replace ||
1943 sbio->logical + sbio->page_count * PAGE_SIZE != 1943 sbio->logical + sbio->page_count * PAGE_SIZE !=
@@ -1992,7 +1992,7 @@ static void scrub_wr_bio_end_io(struct bio *bio)
1992 struct scrub_bio *sbio = bio->bi_private; 1992 struct scrub_bio *sbio = bio->bi_private;
1993 struct btrfs_fs_info *fs_info = sbio->dev->fs_info; 1993 struct btrfs_fs_info *fs_info = sbio->dev->fs_info;
1994 1994
1995 sbio->err = bio->bi_error; 1995 sbio->status = bio->bi_status;
1996 sbio->bio = bio; 1996 sbio->bio = bio;
1997 1997
1998 btrfs_init_work(&sbio->work, btrfs_scrubwrc_helper, 1998 btrfs_init_work(&sbio->work, btrfs_scrubwrc_helper,
@@ -2007,7 +2007,7 @@ static void scrub_wr_bio_end_io_worker(struct btrfs_work *work)
2007 int i; 2007 int i;
2008 2008
2009 WARN_ON(sbio->page_count > SCRUB_PAGES_PER_WR_BIO); 2009 WARN_ON(sbio->page_count > SCRUB_PAGES_PER_WR_BIO);
2010 if (sbio->err) { 2010 if (sbio->status) {
2011 struct btrfs_dev_replace *dev_replace = 2011 struct btrfs_dev_replace *dev_replace =
2012 &sbio->sctx->fs_info->dev_replace; 2012 &sbio->sctx->fs_info->dev_replace;
2013 2013
@@ -2341,7 +2341,7 @@ again:
2341 bio->bi_bdev = sbio->dev->bdev; 2341 bio->bi_bdev = sbio->dev->bdev;
2342 bio->bi_iter.bi_sector = sbio->physical >> 9; 2342 bio->bi_iter.bi_sector = sbio->physical >> 9;
2343 bio_set_op_attrs(bio, REQ_OP_READ, 0); 2343 bio_set_op_attrs(bio, REQ_OP_READ, 0);
2344 sbio->err = 0; 2344 sbio->status = 0;
2345 } else if (sbio->physical + sbio->page_count * PAGE_SIZE != 2345 } else if (sbio->physical + sbio->page_count * PAGE_SIZE !=
2346 spage->physical || 2346 spage->physical ||
2347 sbio->logical + sbio->page_count * PAGE_SIZE != 2347 sbio->logical + sbio->page_count * PAGE_SIZE !=
@@ -2377,7 +2377,7 @@ static void scrub_missing_raid56_end_io(struct bio *bio)
2377 struct scrub_block *sblock = bio->bi_private; 2377 struct scrub_block *sblock = bio->bi_private;
2378 struct btrfs_fs_info *fs_info = sblock->sctx->fs_info; 2378 struct btrfs_fs_info *fs_info = sblock->sctx->fs_info;
2379 2379
2380 if (bio->bi_error) 2380 if (bio->bi_status)
2381 sblock->no_io_error_seen = 0; 2381 sblock->no_io_error_seen = 0;
2382 2382
2383 bio_put(bio); 2383 bio_put(bio);
@@ -2588,7 +2588,7 @@ static void scrub_bio_end_io(struct bio *bio)
2588 struct scrub_bio *sbio = bio->bi_private; 2588 struct scrub_bio *sbio = bio->bi_private;
2589 struct btrfs_fs_info *fs_info = sbio->dev->fs_info; 2589 struct btrfs_fs_info *fs_info = sbio->dev->fs_info;
2590 2590
2591 sbio->err = bio->bi_error; 2591 sbio->status = bio->bi_status;
2592 sbio->bio = bio; 2592 sbio->bio = bio;
2593 2593
2594 btrfs_queue_work(fs_info->scrub_workers, &sbio->work); 2594 btrfs_queue_work(fs_info->scrub_workers, &sbio->work);
@@ -2601,7 +2601,7 @@ static void scrub_bio_end_io_worker(struct btrfs_work *work)
2601 int i; 2601 int i;
2602 2602
2603 BUG_ON(sbio->page_count > SCRUB_PAGES_PER_RD_BIO); 2603 BUG_ON(sbio->page_count > SCRUB_PAGES_PER_RD_BIO);
2604 if (sbio->err) { 2604 if (sbio->status) {
2605 for (i = 0; i < sbio->page_count; i++) { 2605 for (i = 0; i < sbio->page_count; i++) {
2606 struct scrub_page *spage = sbio->pagev[i]; 2606 struct scrub_page *spage = sbio->pagev[i];
2607 2607
@@ -3004,7 +3004,7 @@ static void scrub_parity_bio_endio(struct bio *bio)
3004 struct scrub_parity *sparity = (struct scrub_parity *)bio->bi_private; 3004 struct scrub_parity *sparity = (struct scrub_parity *)bio->bi_private;
3005 struct btrfs_fs_info *fs_info = sparity->sctx->fs_info; 3005 struct btrfs_fs_info *fs_info = sparity->sctx->fs_info;
3006 3006
3007 if (bio->bi_error) 3007 if (bio->bi_status)
3008 bitmap_or(sparity->ebitmap, sparity->ebitmap, sparity->dbitmap, 3008 bitmap_or(sparity->ebitmap, sparity->ebitmap, sparity->dbitmap,
3009 sparity->nsectors); 3009 sparity->nsectors);
3010 3010
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 017b67daa3bb..84a495967e0a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6042,9 +6042,10 @@ static void btrfs_end_bio(struct bio *bio)
6042 struct btrfs_bio *bbio = bio->bi_private; 6042 struct btrfs_bio *bbio = bio->bi_private;
6043 int is_orig_bio = 0; 6043 int is_orig_bio = 0;
6044 6044
6045 if (bio->bi_error) { 6045 if (bio->bi_status) {
6046 atomic_inc(&bbio->error); 6046 atomic_inc(&bbio->error);
6047 if (bio->bi_error == -EIO || bio->bi_error == -EREMOTEIO) { 6047 if (bio->bi_status == BLK_STS_IOERR ||
6048 bio->bi_status == BLK_STS_TARGET) {
6048 unsigned int stripe_index = 6049 unsigned int stripe_index =
6049 btrfs_io_bio(bio)->stripe_index; 6050 btrfs_io_bio(bio)->stripe_index;
6050 struct btrfs_device *dev; 6051 struct btrfs_device *dev;
@@ -6082,13 +6083,13 @@ static void btrfs_end_bio(struct bio *bio)
6082 * beyond the tolerance of the btrfs bio 6083 * beyond the tolerance of the btrfs bio
6083 */ 6084 */
6084 if (atomic_read(&bbio->error) > bbio->max_errors) { 6085 if (atomic_read(&bbio->error) > bbio->max_errors) {
6085 bio->bi_error = -EIO; 6086 bio->bi_status = BLK_STS_IOERR;
6086 } else { 6087 } else {
6087 /* 6088 /*
6088 * this bio is actually up to date, we didn't 6089 * this bio is actually up to date, we didn't
6089 * go over the max number of errors 6090 * go over the max number of errors
6090 */ 6091 */
6091 bio->bi_error = 0; 6092 bio->bi_status = 0;
6092 } 6093 }
6093 6094
6094 btrfs_end_bbio(bbio, bio); 6095 btrfs_end_bbio(bbio, bio);
@@ -6199,7 +6200,7 @@ static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical)
6199 6200
6200 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; 6201 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num;
6201 bio->bi_iter.bi_sector = logical >> 9; 6202 bio->bi_iter.bi_sector = logical >> 9;
6202 bio->bi_error = -EIO; 6203 bio->bi_status = BLK_STS_IOERR;
6203 btrfs_end_bbio(bbio, bio); 6204 btrfs_end_bbio(bbio, bio);
6204 } 6205 }
6205} 6206}
diff --git a/fs/buffer.c b/fs/buffer.c
index 161be58c5cb0..306b720f7383 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3038,7 +3038,7 @@ static void end_bio_bh_io_sync(struct bio *bio)
3038 if (unlikely(bio_flagged(bio, BIO_QUIET))) 3038 if (unlikely(bio_flagged(bio, BIO_QUIET)))
3039 set_bit(BH_Quiet, &bh->b_state); 3039 set_bit(BH_Quiet, &bh->b_state);
3040 3040
3041 bh->b_end_io(bh, !bio->bi_error); 3041 bh->b_end_io(bh, !bio->bi_status);
3042 bio_put(bio); 3042 bio_put(bio);
3043} 3043}
3044 3044
diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c
index a409a84f1bca..6181e9526860 100644
--- a/fs/crypto/bio.c
+++ b/fs/crypto/bio.c
@@ -129,7 +129,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
129 goto errout; 129 goto errout;
130 } 130 }
131 err = submit_bio_wait(bio); 131 err = submit_bio_wait(bio);
132 if ((err == 0) && bio->bi_error) 132 if (err == 0 && bio->bi_status)
133 err = -EIO; 133 err = -EIO;
134 bio_put(bio); 134 bio_put(bio);
135 if (err) 135 if (err)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index bb711e4b86c2..e8baaabebf13 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -294,7 +294,7 @@ static void dio_aio_complete_work(struct work_struct *work)
294 dio_complete(dio, 0, true); 294 dio_complete(dio, 0, true);
295} 295}
296 296
297static int dio_bio_complete(struct dio *dio, struct bio *bio); 297static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio);
298 298
299/* 299/*
300 * Asynchronous IO callback. 300 * Asynchronous IO callback.
@@ -473,11 +473,11 @@ static struct bio *dio_await_one(struct dio *dio)
473/* 473/*
474 * Process one completed BIO. No locks are held. 474 * Process one completed BIO. No locks are held.
475 */ 475 */
476static int dio_bio_complete(struct dio *dio, struct bio *bio) 476static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
477{ 477{
478 struct bio_vec *bvec; 478 struct bio_vec *bvec;
479 unsigned i; 479 unsigned i;
480 int err = bio->bi_error; 480 blk_status_t err = bio->bi_status;
481 481
482 if (err) 482 if (err)
483 dio->io_error = -EIO; 483 dio->io_error = -EIO;
@@ -536,7 +536,7 @@ static inline int dio_bio_reap(struct dio *dio, struct dio_submit *sdio)
536 bio = dio->bio_list; 536 bio = dio->bio_list;
537 dio->bio_list = bio->bi_private; 537 dio->bio_list = bio->bi_private;
538 spin_unlock_irqrestore(&dio->bio_lock, flags); 538 spin_unlock_irqrestore(&dio->bio_lock, flags);
539 ret2 = dio_bio_complete(dio, bio); 539 ret2 = blk_status_to_errno(dio_bio_complete(dio, bio));
540 if (ret == 0) 540 if (ret == 0)
541 ret = ret2; 541 ret = ret2;
542 } 542 }
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 1a82138ba739..930ca0fc9a0f 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -85,7 +85,7 @@ static void ext4_finish_bio(struct bio *bio)
85 } 85 }
86#endif 86#endif
87 87
88 if (bio->bi_error) { 88 if (bio->bi_status) {
89 SetPageError(page); 89 SetPageError(page);
90 mapping_set_error(page->mapping, -EIO); 90 mapping_set_error(page->mapping, -EIO);
91 } 91 }
@@ -104,7 +104,7 @@ static void ext4_finish_bio(struct bio *bio)
104 continue; 104 continue;
105 } 105 }
106 clear_buffer_async_write(bh); 106 clear_buffer_async_write(bh);
107 if (bio->bi_error) 107 if (bio->bi_status)
108 buffer_io_error(bh); 108 buffer_io_error(bh);
109 } while ((bh = bh->b_this_page) != head); 109 } while ((bh = bh->b_this_page) != head);
110 bit_spin_unlock(BH_Uptodate_Lock, &head->b_state); 110 bit_spin_unlock(BH_Uptodate_Lock, &head->b_state);
@@ -303,24 +303,25 @@ static void ext4_end_bio(struct bio *bio)
303 bdevname(bio->bi_bdev, b), 303 bdevname(bio->bi_bdev, b),
304 (long long) bio->bi_iter.bi_sector, 304 (long long) bio->bi_iter.bi_sector,
305 (unsigned) bio_sectors(bio), 305 (unsigned) bio_sectors(bio),
306 bio->bi_error)) { 306 bio->bi_status)) {
307 ext4_finish_bio(bio); 307 ext4_finish_bio(bio);
308 bio_put(bio); 308 bio_put(bio);
309 return; 309 return;
310 } 310 }
311 bio->bi_end_io = NULL; 311 bio->bi_end_io = NULL;
312 312
313 if (bio->bi_error) { 313 if (bio->bi_status) {
314 struct inode *inode = io_end->inode; 314 struct inode *inode = io_end->inode;
315 315
316 ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu " 316 ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu "
317 "(offset %llu size %ld starting block %llu)", 317 "(offset %llu size %ld starting block %llu)",
318 bio->bi_error, inode->i_ino, 318 bio->bi_status, inode->i_ino,
319 (unsigned long long) io_end->offset, 319 (unsigned long long) io_end->offset,
320 (long) io_end->size, 320 (long) io_end->size,
321 (unsigned long long) 321 (unsigned long long)
322 bi_sector >> (inode->i_blkbits - 9)); 322 bi_sector >> (inode->i_blkbits - 9));
323 mapping_set_error(inode->i_mapping, bio->bi_error); 323 mapping_set_error(inode->i_mapping,
324 blk_status_to_errno(bio->bi_status));
324 } 325 }
325 326
326 if (io_end->flag & EXT4_IO_END_UNWRITTEN) { 327 if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index a81b829d56de..40a5497b0f60 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -73,7 +73,7 @@ static void mpage_end_io(struct bio *bio)
73 int i; 73 int i;
74 74
75 if (ext4_bio_encrypted(bio)) { 75 if (ext4_bio_encrypted(bio)) {
76 if (bio->bi_error) { 76 if (bio->bi_status) {
77 fscrypt_release_ctx(bio->bi_private); 77 fscrypt_release_ctx(bio->bi_private);
78 } else { 78 } else {
79 fscrypt_decrypt_bio_pages(bio->bi_private, bio); 79 fscrypt_decrypt_bio_pages(bio->bi_private, bio);
@@ -83,7 +83,7 @@ static void mpage_end_io(struct bio *bio)
83 bio_for_each_segment_all(bv, bio, i) { 83 bio_for_each_segment_all(bv, bio, i) {
84 struct page *page = bv->bv_page; 84 struct page *page = bv->bv_page;
85 85
86 if (!bio->bi_error) { 86 if (!bio->bi_status) {
87 SetPageUptodate(page); 87 SetPageUptodate(page);
88 } else { 88 } else {
89 ClearPageUptodate(page); 89 ClearPageUptodate(page);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7c0f6bdf817d..36fe82012a33 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -58,12 +58,12 @@ static void f2fs_read_end_io(struct bio *bio)
58#ifdef CONFIG_F2FS_FAULT_INJECTION 58#ifdef CONFIG_F2FS_FAULT_INJECTION
59 if (time_to_inject(F2FS_P_SB(bio->bi_io_vec->bv_page), FAULT_IO)) { 59 if (time_to_inject(F2FS_P_SB(bio->bi_io_vec->bv_page), FAULT_IO)) {
60 f2fs_show_injection_info(FAULT_IO); 60 f2fs_show_injection_info(FAULT_IO);
61 bio->bi_error = -EIO; 61 bio->bi_status = BLK_STS_IOERR;
62 } 62 }
63#endif 63#endif
64 64
65 if (f2fs_bio_encrypted(bio)) { 65 if (f2fs_bio_encrypted(bio)) {
66 if (bio->bi_error) { 66 if (bio->bi_status) {
67 fscrypt_release_ctx(bio->bi_private); 67 fscrypt_release_ctx(bio->bi_private);
68 } else { 68 } else {
69 fscrypt_decrypt_bio_pages(bio->bi_private, bio); 69 fscrypt_decrypt_bio_pages(bio->bi_private, bio);
@@ -74,7 +74,7 @@ static void f2fs_read_end_io(struct bio *bio)
74 bio_for_each_segment_all(bvec, bio, i) { 74 bio_for_each_segment_all(bvec, bio, i) {
75 struct page *page = bvec->bv_page; 75 struct page *page = bvec->bv_page;
76 76
77 if (!bio->bi_error) { 77 if (!bio->bi_status) {
78 if (!PageUptodate(page)) 78 if (!PageUptodate(page))
79 SetPageUptodate(page); 79 SetPageUptodate(page);
80 } else { 80 } else {
@@ -102,14 +102,14 @@ static void f2fs_write_end_io(struct bio *bio)
102 unlock_page(page); 102 unlock_page(page);
103 mempool_free(page, sbi->write_io_dummy); 103 mempool_free(page, sbi->write_io_dummy);
104 104
105 if (unlikely(bio->bi_error)) 105 if (unlikely(bio->bi_status))
106 f2fs_stop_checkpoint(sbi, true); 106 f2fs_stop_checkpoint(sbi, true);
107 continue; 107 continue;
108 } 108 }
109 109
110 fscrypt_pullback_bio_page(&page, true); 110 fscrypt_pullback_bio_page(&page, true);
111 111
112 if (unlikely(bio->bi_error)) { 112 if (unlikely(bio->bi_status)) {
113 mapping_set_error(page->mapping, -EIO); 113 mapping_set_error(page->mapping, -EIO);
114 f2fs_stop_checkpoint(sbi, true); 114 f2fs_stop_checkpoint(sbi, true);
115 } 115 }
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 96845854e7ee..ea9f455d94ba 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -749,7 +749,7 @@ static void f2fs_submit_discard_endio(struct bio *bio)
749{ 749{
750 struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private; 750 struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
751 751
752 dc->error = bio->bi_error; 752 dc->error = blk_status_to_errno(bio->bi_status);
753 dc->state = D_DONE; 753 dc->state = D_DONE;
754 complete(&dc->wait); 754 complete(&dc->wait);
755 bio_put(bio); 755 bio_put(bio);
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 13ebf15a4db0..885d36e7a29f 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -170,7 +170,7 @@ static u64 gfs2_log_bmap(struct gfs2_sbd *sdp)
170 */ 170 */
171 171
172static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, struct bio_vec *bvec, 172static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, struct bio_vec *bvec,
173 int error) 173 blk_status_t error)
174{ 174{
175 struct buffer_head *bh, *next; 175 struct buffer_head *bh, *next;
176 struct page *page = bvec->bv_page; 176 struct page *page = bvec->bv_page;
@@ -209,13 +209,13 @@ static void gfs2_end_log_write(struct bio *bio)
209 struct page *page; 209 struct page *page;
210 int i; 210 int i;
211 211
212 if (bio->bi_error) 212 if (bio->bi_status)
213 fs_err(sdp, "Error %d writing to log\n", bio->bi_error); 213 fs_err(sdp, "Error %d writing to log\n", bio->bi_status);
214 214
215 bio_for_each_segment_all(bvec, bio, i) { 215 bio_for_each_segment_all(bvec, bio, i) {
216 page = bvec->bv_page; 216 page = bvec->bv_page;
217 if (page_has_buffers(page)) 217 if (page_has_buffers(page))
218 gfs2_end_log_write_bh(sdp, bvec, bio->bi_error); 218 gfs2_end_log_write_bh(sdp, bvec, bio->bi_status);
219 else 219 else
220 mempool_free(page, gfs2_page_pool); 220 mempool_free(page, gfs2_page_pool);
221 } 221 }
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 663ffc135ef3..fabe1614f879 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -201,7 +201,7 @@ static void gfs2_meta_read_endio(struct bio *bio)
201 do { 201 do {
202 struct buffer_head *next = bh->b_this_page; 202 struct buffer_head *next = bh->b_this_page;
203 len -= bh->b_size; 203 len -= bh->b_size;
204 bh->b_end_io(bh, !bio->bi_error); 204 bh->b_end_io(bh, !bio->bi_status);
205 bh = next; 205 bh = next;
206 } while (bh && len); 206 } while (bh && len);
207 } 207 }
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index ed67548b286c..83953cdbbc6c 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -176,10 +176,10 @@ static void end_bio_io_page(struct bio *bio)
176{ 176{
177 struct page *page = bio->bi_private; 177 struct page *page = bio->bi_private;
178 178
179 if (!bio->bi_error) 179 if (!bio->bi_status)
180 SetPageUptodate(page); 180 SetPageUptodate(page);
181 else 181 else
182 pr_warn("error %d reading superblock\n", bio->bi_error); 182 pr_warn("error %d reading superblock\n", bio->bi_status);
183 unlock_page(page); 183 unlock_page(page);
184} 184}
185 185
diff --git a/fs/iomap.c b/fs/iomap.c
index 4b10892967a5..18f2f2b8ba2c 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -672,8 +672,8 @@ static void iomap_dio_bio_end_io(struct bio *bio)
672 struct iomap_dio *dio = bio->bi_private; 672 struct iomap_dio *dio = bio->bi_private;
673 bool should_dirty = (dio->flags & IOMAP_DIO_DIRTY); 673 bool should_dirty = (dio->flags & IOMAP_DIO_DIRTY);
674 674
675 if (bio->bi_error) 675 if (bio->bi_status)
676 iomap_dio_set_error(dio, bio->bi_error); 676 iomap_dio_set_error(dio, blk_status_to_errno(bio->bi_status));
677 677
678 if (atomic_dec_and_test(&dio->ref)) { 678 if (atomic_dec_and_test(&dio->ref)) {
679 if (is_sync_kiocb(dio->iocb)) { 679 if (is_sync_kiocb(dio->iocb)) {
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index bb1da1feafeb..a21f0e9eecd4 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -2205,7 +2205,7 @@ static void lbmIODone(struct bio *bio)
2205 2205
2206 bp->l_flag |= lbmDONE; 2206 bp->l_flag |= lbmDONE;
2207 2207
2208 if (bio->bi_error) { 2208 if (bio->bi_status) {
2209 bp->l_flag |= lbmERROR; 2209 bp->l_flag |= lbmERROR;
2210 2210
2211 jfs_err("lbmIODone: I/O error in JFS log"); 2211 jfs_err("lbmIODone: I/O error in JFS log");
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 489aaa1403e5..ce93db3aef3c 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -280,7 +280,7 @@ static void metapage_read_end_io(struct bio *bio)
280{ 280{
281 struct page *page = bio->bi_private; 281 struct page *page = bio->bi_private;
282 282
283 if (bio->bi_error) { 283 if (bio->bi_status) {
284 printk(KERN_ERR "metapage_read_end_io: I/O error\n"); 284 printk(KERN_ERR "metapage_read_end_io: I/O error\n");
285 SetPageError(page); 285 SetPageError(page);
286 } 286 }
@@ -337,7 +337,7 @@ static void metapage_write_end_io(struct bio *bio)
337 337
338 BUG_ON(!PagePrivate(page)); 338 BUG_ON(!PagePrivate(page));
339 339
340 if (bio->bi_error) { 340 if (bio->bi_status) {
341 printk(KERN_ERR "metapage_write_end_io: I/O error\n"); 341 printk(KERN_ERR "metapage_write_end_io: I/O error\n");
342 SetPageError(page); 342 SetPageError(page);
343 } 343 }
diff --git a/fs/mpage.c b/fs/mpage.c
index baff8f820c29..9524fdde00c2 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -50,7 +50,8 @@ static void mpage_end_io(struct bio *bio)
50 50
51 bio_for_each_segment_all(bv, bio, i) { 51 bio_for_each_segment_all(bv, bio, i) {
52 struct page *page = bv->bv_page; 52 struct page *page = bv->bv_page;
53 page_endio(page, op_is_write(bio_op(bio)), bio->bi_error); 53 page_endio(page, op_is_write(bio_op(bio)),
54 blk_status_to_errno(bio->bi_status));
54 } 55 }
55 56
56 bio_put(bio); 57 bio_put(bio);
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 0ca370d23ddb..d8863a804b15 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -188,7 +188,7 @@ static void bl_end_io_read(struct bio *bio)
188{ 188{
189 struct parallel_io *par = bio->bi_private; 189 struct parallel_io *par = bio->bi_private;
190 190
191 if (bio->bi_error) { 191 if (bio->bi_status) {
192 struct nfs_pgio_header *header = par->data; 192 struct nfs_pgio_header *header = par->data;
193 193
194 if (!header->pnfs_error) 194 if (!header->pnfs_error)
@@ -319,7 +319,7 @@ static void bl_end_io_write(struct bio *bio)
319 struct parallel_io *par = bio->bi_private; 319 struct parallel_io *par = bio->bi_private;
320 struct nfs_pgio_header *header = par->data; 320 struct nfs_pgio_header *header = par->data;
321 321
322 if (bio->bi_error) { 322 if (bio->bi_status) {
323 if (!header->pnfs_error) 323 if (!header->pnfs_error)
324 header->pnfs_error = -EIO; 324 header->pnfs_error = -EIO;
325 pnfs_set_lo_fail(header->lseg); 325 pnfs_set_lo_fail(header->lseg);
diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index 6f87b2ac1aeb..e73c86d9855c 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -338,7 +338,7 @@ static void nilfs_end_bio_write(struct bio *bio)
338{ 338{
339 struct nilfs_segment_buffer *segbuf = bio->bi_private; 339 struct nilfs_segment_buffer *segbuf = bio->bi_private;
340 340
341 if (bio->bi_error) 341 if (bio->bi_status)
342 atomic_inc(&segbuf->sb_err); 342 atomic_inc(&segbuf->sb_err);
343 343
344 bio_put(bio); 344 bio_put(bio);
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 0da0332725aa..ffe003982d95 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -516,9 +516,9 @@ static void o2hb_bio_end_io(struct bio *bio)
516{ 516{
517 struct o2hb_bio_wait_ctxt *wc = bio->bi_private; 517 struct o2hb_bio_wait_ctxt *wc = bio->bi_private;
518 518
519 if (bio->bi_error) { 519 if (bio->bi_status) {
520 mlog(ML_ERROR, "IO Error %d\n", bio->bi_error); 520 mlog(ML_ERROR, "IO Error %d\n", bio->bi_status);
521 wc->wc_error = bio->bi_error; 521 wc->wc_error = blk_status_to_errno(bio->bi_status);
522 } 522 }
523 523
524 o2hb_bio_wait_dec(wc, 1); 524 o2hb_bio_wait_dec(wc, 1);
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 09af0f7cd55e..76b6f988e2fa 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -276,7 +276,7 @@ xfs_end_io(
276 struct xfs_inode *ip = XFS_I(ioend->io_inode); 276 struct xfs_inode *ip = XFS_I(ioend->io_inode);
277 xfs_off_t offset = ioend->io_offset; 277 xfs_off_t offset = ioend->io_offset;
278 size_t size = ioend->io_size; 278 size_t size = ioend->io_size;
279 int error = ioend->io_bio->bi_error; 279 int error;
280 280
281 /* 281 /*
282 * Just clean up the in-memory strutures if the fs has been shut down. 282 * Just clean up the in-memory strutures if the fs has been shut down.
@@ -289,6 +289,7 @@ xfs_end_io(
289 /* 289 /*
290 * Clean up any COW blocks on an I/O error. 290 * Clean up any COW blocks on an I/O error.
291 */ 291 */
292 error = blk_status_to_errno(ioend->io_bio->bi_status);
292 if (unlikely(error)) { 293 if (unlikely(error)) {
293 switch (ioend->io_type) { 294 switch (ioend->io_type) {
294 case XFS_IO_COW: 295 case XFS_IO_COW:
@@ -332,7 +333,7 @@ xfs_end_bio(
332 else if (ioend->io_append_trans) 333 else if (ioend->io_append_trans)
333 queue_work(mp->m_data_workqueue, &ioend->io_work); 334 queue_work(mp->m_data_workqueue, &ioend->io_work);
334 else 335 else
335 xfs_destroy_ioend(ioend, bio->bi_error); 336 xfs_destroy_ioend(ioend, blk_status_to_errno(bio->bi_status));
336} 337}
337 338
338STATIC int 339STATIC int
@@ -500,7 +501,7 @@ xfs_submit_ioend(
500 * time. 501 * time.
501 */ 502 */
502 if (status) { 503 if (status) {
503 ioend->io_bio->bi_error = status; 504 ioend->io_bio->bi_status = errno_to_blk_status(status);
504 bio_endio(ioend->io_bio); 505 bio_endio(ioend->io_bio);
505 return status; 506 return status;
506 } 507 }
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 62fa39276a24..15c7a484a5d2 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1213,8 +1213,11 @@ xfs_buf_bio_end_io(
1213 * don't overwrite existing errors - otherwise we can lose errors on 1213 * don't overwrite existing errors - otherwise we can lose errors on
1214 * buffers that require multiple bios to complete. 1214 * buffers that require multiple bios to complete.
1215 */ 1215 */
1216 if (bio->bi_error) 1216 if (bio->bi_status) {
1217 cmpxchg(&bp->b_io_error, 0, bio->bi_error); 1217 int error = blk_status_to_errno(bio->bi_status);
1218
1219 cmpxchg(&bp->b_io_error, 0, error);
1220 }
1218 1221
1219 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) 1222 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ))
1220 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); 1223 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp));