add a bi_error field
Subsystems (34)
Bio error reporting has been a mess for a while, and the increasing use of chained bios makes it worse.
This series attempts to add a proper error field to struct bio to sort this out. It's working fine for me, but MD and btrfs were doing pretty nasty things with the BIO_UPTODATE flag, so I would appreciate some detailed review there.
PATCH 1/1 block: add a bi_error field to struct bio
Currently we have two different ways to signal an I/O error on a BIO:
(1) by clearing the BIO_UPTODATE flag
(2) by returning a Linux errno value to the bi_end_io callback
The first one has the drawback of only communicating a single possible error (-EIO), and the second one has the drawback of not beeing persistent when bios are queued up, and are not passed along from child to parent bio in the ever more popular chaining scenario. Having both mechanisms available has the additional drawback of utterly confusing driver authors and introducing bugs where various I/O submitters only deal with one of them, and the others have to add boilerplate code to deal with both kinds of error returns.
So add a new bi_error field to store an errno value directly in struct bio and remove the existing mechanisms to clean all this up.
--- Documentation/block/biodoc.txt | 2 +- arch/m68k/emu/nfblock.c | 2 +- arch/powerpc/sysdev/axonram.c | 2 +- arch/xtensa/platforms/iss/simdisk.c | 12 ++----- block/bio-integrity.c | 11 +++---- block/bio.c | 43 +++++++++++-------------- block/blk-core.c | 15 ++++----- block/blk-lib.c | 30 ++++++++---------- block/blk-map.c | 2 +- block/blk-mq.c | 6 ++-- block/bounce.c | 27 ++++++++-------- drivers/block/aoe/aoecmd.c | 10 +++--- drivers/block/aoe/aoedev.c | 2 +- drivers/block/brd.c | 13 +++++--- drivers/block/drbd/drbd_actlog.c | 4 +-- drivers/block/drbd/drbd_bitmap.c | 19 +++--------- drivers/block/drbd/drbd_int.h | 11 ++++--- drivers/block/drbd/drbd_req.c | 10 +++--- drivers/block/drbd/drbd_worker.c | 44 +++++++------------------- drivers/block/floppy.c | 7 +++-- drivers/block/null_blk.c | 2 +- drivers/block/pktcdvd.c | 32 +++++++++---------- drivers/block/pmem.c | 8 ++--- drivers/block/ps3vram.c | 3 +- drivers/block/rsxx/dev.c | 9 ++++-- drivers/block/umem.c | 4 +-- drivers/block/xen-blkback/blkback.c | 4 +-- drivers/block/xen-blkfront.c | 9 ++---- drivers/block/zram/zram_drv.c | 5 ++- drivers/md/bcache/btree.c | 8 ++--- drivers/md/bcache/io.c | 8 ++--- drivers/md/bcache/journal.c | 8 ++--- drivers/md/bcache/movinggc.c | 8 ++--- drivers/md/bcache/request.c | 11 ++++--- drivers/md/bcache/super.c | 14 ++++----- drivers/md/bcache/writeback.c | 10 +++--- drivers/md/dm-bio-prison.c | 6 ++-- drivers/md/dm-bufio.c | 26 ++++++++++------ drivers/md/dm-cache-target.c | 24 +++++++------- drivers/md/dm-crypt.c | 14 ++++----- drivers/md/dm-flakey.c | 2 +- drivers/md/dm-io.c | 6 ++-- drivers/md/dm-log-writes.c | 11 +++---- drivers/md/dm-raid1.c | 23 ++++++++------ drivers/md/dm-snap.c | 6 ++-- drivers/md/dm-stripe.c | 2 +- drivers/md/dm-thin.c | 38 +++++++++++++---------- drivers/md/dm-verity.c | 9 +++--- drivers/md/dm-zero.c | 2 +- drivers/md/dm.c | 18 +++++------ drivers/md/faulty.c | 4 +-- drivers/md/linear.c | 2 +- drivers/md/md.c | 18 +++++------ drivers/md/multipath.c | 12 +++---- drivers/md/raid0.c | 2 +- drivers/md/raid1.c | 56 ++++++++++++++++----------------- drivers/md/raid10.c | 55 +++++++++++++++----------------- drivers/md/raid5.c | 52 +++++++++++++++---------------- drivers/s390/block/dcssblk.c | 2 +- drivers/s390/block/xpram.c | 3 +- drivers/target/target_core_iblock.c | 21 +++++-------- drivers/target/target_core_pscsi.c | 6 ++-- fs/btrfs/check-integrity.c | 10 +++--- fs/btrfs/compression.c | 24 ++++++++------ fs/btrfs/disk-io.c | 35 +++++++++++---------- fs/btrfs/extent_io.c | 30 +++++++----------- fs/btrfs/inode.c | 50 ++++++++++++++++-------------- fs/btrfs/raid56.c | 62 +++++++++++++++++-------------------- fs/btrfs/scrub.c | 22 ++++++------- fs/btrfs/volumes.c | 10 +++--- fs/buffer.c | 4 +-- fs/direct-io.c | 13 ++++---- fs/ext4/page-io.c | 15 ++++----- fs/ext4/readpage.c | 6 ++-- fs/f2fs/data.c | 8 ++--- fs/gfs2/lops.c | 10 +++--- fs/gfs2/ops_fstype.c | 6 ++-- fs/jfs/jfs_logmgr.c | 8 ++--- fs/jfs/jfs_metapage.c | 8 ++--- fs/logfs/dev_bdev.c | 12 +++---- fs/mpage.c | 4 +-- fs/nfs/blocklayout/blocklayout.c | 14 ++++----- fs/nilfs2/segbuf.c | 5 ++- fs/ocfs2/cluster/heartbeat.c | 9 +++--- fs/xfs/xfs_aops.c | 5 ++- fs/xfs/xfs_buf.c | 7 ++--- include/linux/bio.h | 13 +++++--- include/linux/blk_types.h | 4 +-- include/linux/swap.h | 4 +-- kernel/power/swap.c | 12 +++---- kernel/trace/blktrace.c | 10 ++---- mm/page_io.c | 12 +++---- 92 files changed, 603 insertions(+), 664 deletions(-)
Documentation/block/biodoc.txt +1 -1
@@ -1109,7 +1109,7 @@ it will loop and handle as many sectors (on a bio-segment granularity) as specified. Now bh->b_end_io is replaced by bio->bi_end_io, but most of the time the -right thing to use is bio_endio(bio, uptodate) instead. +right thing to use is bio_endio(bio) instead. If the driver is dropping the io_request_lock from its request_fn strategy, then it just needs to replace that with q->queue_lock instead.
arch/m68k/emu/nfblock.c +1 -1
@@ -76,7 +76,7 @@ static void nfhd_make_request(struct request_queue *queue, struct bio *bio) bvec_to_phys(&bvec)); sec += len; } -bio_endio (bio,0 ); +bio_endio (bio); }static int nfhd_getgeo (struct block_device *bdev,struct hd_geometry *geo)
arch/powerpc/sysdev/axonram.c +1 -1
@@ -132,7 +132,7 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio) phys_mem += vec.bv_len; transfered += vec.bv_len; } -bio_endio (bio,0 ); +bio_endio (bio); }/**
arch/xtensa/platforms/iss/simdisk.c +3 -9
@@ -101,8 +101,9 @@ static void simdisk_transfer(struct simdisk *dev, unsigned long sector,spin_unlock (&dev->lock); } -static int simdisk_xfer_bio (struct simdisk *dev,struct bio *bio) +static void simdisk_make_request (struct request_queue *q,struct bio *bio) { +struct simdisk *dev = q->queuedata;struct bio_vec bvec;struct bvec_iter iter;sector_t sector = bio->bi_iter.bi_sector;
@@ -116,17 +117,10 @@ static int simdisk_xfer_bio(struct simdisk *dev, struct bio *bio) sector += len;__bio_kunmap_atomic (buffer); } -return 0 ; -} -static void simdisk_make_request (struct request_queue *q,struct bio *bio) -{ -struct simdisk *dev = q->queuedata; -int status =simdisk_xfer_bio (dev, bio); -bio_endio (bio, status); +bio_endio (bio); } -static int simdisk_open (struct block_device *bdev,fmode_t mode) {struct simdisk *dev = bdev->bd_disk->private_data;
block/bio-integrity.c +5 -6
@@ -355,13 +355,12 @@ static void bio_integrity_verify_fn(struct work_struct *work) container_of(work, struct bio_integrity_payload, bip_work);struct bio *bio = bip->bip_bio;struct blk_integrity *bi =bdev_get_integrity (bio->bi_bdev); -int error; - error =bio_integrity_process (bio, bi->verify_fn); + bio->bi_error =bio_integrity_process (bio, bi->verify_fn);/* Restore original bio completion handler */ bio->bi_end_io = bip->bip_end_io; -bio_endio (bio, error); +bio_endio (bio); }/**
@@ -376,7 +375,7 @@ static void bio_integrity_verify_fn(struct work_struct *work)* in process context. This function postpones completion * accordingly. */ -void bio_integrity_endio (struct bio *bio,int error) +void bio_integrity_endio (struct bio *bio) {struct bio_integrity_payload *bip =bio_integrity (bio);
@@ -386,9 +385,9 @@ void bio_integrity_endio(struct bio *bio, int error)* integrity metadata. Restore original bio end_io handler * and run it. */ -if (error) { +if (bio->bi_error) { bio->bi_end_io = bip->bip_end_io; -bio_endio (bio, error); +bio_endio (bio);return ; }
block/bio.c +18 -25
113 lines not on this page · raw message
block/blk-core.c +8 -7
@@ -143,9 +143,7 @@ static void req_bio_endio(struct request *rq, struct bio *bio, unsigned int nbytes, int error) {if (error && !(rq->cmd_flags &REQ_CLONE )) -clear_bit (BIO_UPTODATE , &bio->bi_flags); -else if (!test_bit (BIO_UPTODATE , &bio->bi_flags)) - error = -EIO ; + bio->bi_error = error;if (unlikely (rq->cmd_flags &REQ_QUIET ))set_bit (BIO_QUIET , &bio->bi_flags);
@@ -155,7 +153,7 @@ static void req_bio_endio(struct request *rq, struct bio *bio,/* don't actually finish bio if it's part of flush sequence */ if (bio->bi_iter.bi_size ==0 && !(rq->cmd_flags & (REQ_FLUSH_SEQ |REQ_CLONE ))) -bio_endio (bio, error); +bio_endio (bio); }void blk_dump_rq_flags (struct request *rq,char *msg)
@@ -1617,7 +1615,8 @@ void blk_queue_bio(struct request_queue *q, struct bio *bio)blk_queue_bounce (q, &bio);if (bio_integrity_enabled (bio) &&bio_integrity_prep (bio)) { -bio_endio (bio, -EIO ); + bio->bi_error = -EIO ; +bio_endio (bio);return ; }
@@ -1670,7 +1669,8 @@ get_rq:*/ req =get_request (q, rw_flags, bio,GFP_NOIO );if (IS_ERR (req)) { -bio_endio (bio,PTR_ERR (req));/* @q is dead */ + bio->bi_error =PTR_ERR (req); +bio_endio (bio); goto out_unlock; }
@@ -1894,7 +1894,8 @@ generic_make_request_checks(struct bio *bio)return true; end_io: -bio_endio (bio, err); + bio->bi_error = err; +bio_endio (bio);return false; }
block/blk-lib.c +13 -17
@@ -11,16 +11,16 @@struct bio_batch {atomic_t done; -unsigned long flags; +int error;struct completion *wait; }; -static void bio_batch_end_io (struct bio *bio,int err) +static void bio_batch_end_io (struct bio *bio) {struct bio_batch *bb = bio->bi_private; -if (err && (err != -EOPNOTSUPP )) -clear_bit (BIO_UPTODATE , &bb->flags); +if (bio->bi_error && bio->bi_error != -EOPNOTSUPP ) + bb->error = bio->bi_error;if (atomic_dec_and_test (&bb->done))complete (bb->wait);bio_put (bio);
@@ -78,7 +78,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, }atomic_set (&bb.done,1 ); - bb.flags =1 <<BIO_UPTODATE ; + bb.error =0 ; bb.wait = &wait;blk_start_plug (&plug);
@@ -134,9 +134,8 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,if (!atomic_dec_and_test (&bb.done))wait_for_completion_io (&wait); -if (!test_bit (BIO_UPTODATE , &bb.flags)) - ret = -EIO ; - +if (bb.error) +return bb.error;return ret; }EXPORT_SYMBOL (blkdev_issue_discard);
@@ -172,7 +171,7 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,return -EOPNOTSUPP ;atomic_set (&bb.done,1 ); - bb.flags =1 <<BIO_UPTODATE ; + bb.error =0 ; bb.wait = &wait;while (nr_sects) {
@@ -208,9 +207,8 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,if (!atomic_dec_and_test (&bb.done))wait_for_completion_io (&wait); -if (!test_bit (BIO_UPTODATE , &bb.flags)) - ret = -ENOTSUPP ; - +if (bb.error) +return bb.error;return ret; }EXPORT_SYMBOL (blkdev_issue_write_same);
@@ -236,7 +234,7 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,DECLARE_COMPLETION_ONSTACK (wait);atomic_set (&bb.done,1 ); - bb.flags =1 <<BIO_UPTODATE ; + bb.error =0 ; bb.wait = &wait; ret =0 ;
@@ -270,10 +268,8 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,if (!atomic_dec_and_test (&bb.done))wait_for_completion_io (&wait); -if (!test_bit (BIO_UPTODATE , &bb.flags)) -/* One of bios in the batch was completed with error.*/ - ret = -EIO ; - +if (bb.error) +return bb.error;return ret; }
block/blk-map.c +1 -1
@@ -103,7 +103,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,* normal IO completion path */ bio_get (bio); -bio_endio (bio,0 ); +bio_endio (bio);__blk_rq_unmap_user (bio);return -EINVAL ; }
block/blk-mq.c +3 -3
@@ -1186,7 +1186,7 @@ static struct request *blk_mq_map_request(struct request_queue *q,struct blk_mq_alloc_data alloc_data;if (unlikely (blk_mq_queue_enter (q,GFP_KERNEL ))) { -bio_endio (bio, -EIO ); +bio_io_error (bio);return NULL ; }
@@ -1270,7 +1270,7 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)blk_queue_bounce (q, &bio);if (bio_integrity_enabled (bio) &&bio_integrity_prep (bio)) { -bio_endio (bio, -EIO ); +bio_io_error (bio);return ; }
@@ -1355,7 +1355,7 @@ static void blk_sq_make_request(struct request_queue *q, struct bio *bio)blk_queue_bounce (q, &bio);if (bio_integrity_enabled (bio) &&bio_integrity_prep (bio)) { -bio_endio (bio, -EIO ); +bio_io_error (bio);return ; }
block/bounce.c +14 -13
@@ -123,7 +123,7 @@ static void copy_to_high_bio_irq(struct bio *to, struct bio *from) } } -static void bounce_end_io (struct bio *bio,mempool_t *pool,int err) +static void bounce_end_io (struct bio *bio,mempool_t *pool) {struct bio *bio_orig = bio->bi_private;struct bio_vec *bvec, *org_vec;
@@ -141,39 +141,40 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool, int err)mempool_free (bvec->bv_page, pool); } -bio_endio (bio_orig, err); + bio_orig->bi_error = bio->bi_error; +bio_endio (bio_orig);bio_put (bio); } -static void bounce_end_io_write (struct bio *bio,int err) +static void bounce_end_io_write (struct bio *bio) { -bounce_end_io (bio, page_pool, err); +bounce_end_io (bio, page_pool); } -static void bounce_end_io_write_isa (struct bio *bio,int err) +static void bounce_end_io_write_isa (struct bio *bio) { -bounce_end_io (bio, isa_page_pool, err); +bounce_end_io (bio, isa_page_pool); } -static void __bounce_end_io_read (struct bio *bio,mempool_t *pool,int err) +static void __bounce_end_io_read (struct bio *bio,mempool_t *pool) {struct bio *bio_orig = bio->bi_private; -if (test_bit (BIO_UPTODATE , &bio->bi_flags)) +if (!bio->bi_error)copy_to_high_bio_irq (bio_orig, bio); -bounce_end_io (bio, pool, err); +bounce_end_io (bio, pool); } -static void bounce_end_io_read (struct bio *bio,int err) +static void bounce_end_io_read (struct bio *bio) { -__bounce_end_io_read (bio, page_pool, err); +__bounce_end_io_read (bio, page_pool); } -static void bounce_end_io_read_isa (struct bio *bio,int err) +static void bounce_end_io_read_isa (struct bio *bio) { -__bounce_end_io_read (bio, isa_page_pool, err); +__bounce_end_io_read (bio, isa_page_pool); }#ifdef CONFIG_NEED_BOUNCE_POOL
drivers/block/aoe/aoecmd.c +5 -5
@@ -1110,7 +1110,7 @@ aoe_end_request(struct aoedev *d, struct request *rq, int fastfail) d->ip.rq =NULL ;do { bio = rq->bio; - bok = !fastfail &&test_bit (BIO_UPTODATE , &bio->bi_flags); + bok = !fastfail && !bio->bi_error; }while (__blk_end_request (rq, bok ?0 : -EIO , bio->bi_iter.bi_size));/* cf. http://lkml.org/lkml/2006/10/31/28 */
@@ -1172,7 +1172,7 @@ ktiocomplete(struct frame *f) ahout->cmdstat, ahin->cmdstat, d->aoemajor, d->aoeminor); noskb:if (buf) -clear_bit (BIO_UPTODATE , &buf->bio->bi_flags); + buf->bio->bi_error = -EIO ; goto out; }
@@ -1185,7 +1185,7 @@ noskb: if (buf)"aoe: runt data size in read from" , (long ) d->aoemajor, d->aoeminor, skb->len, n); -clear_bit (BIO_UPTODATE , &buf->bio->bi_flags); + buf->bio->bi_error = -EIO ;break ; }if (n > f->iter.bi_size) {
@@ -1193,7 +1193,7 @@ noskb: if (buf)"aoe: too-large data size in read from" , (long ) d->aoemajor, d->aoeminor, n, f->iter.bi_size); -clear_bit (BIO_UPTODATE , &buf->bio->bi_flags); + buf->bio->bi_error = -EIO ;break ; }bvcpy (skb, f->buf->bio, f->iter, n);
@@ -1695,7 +1695,7 @@ aoe_failbuf(struct aoedev *d, struct buf *buf)if (buf ==NULL )return ; buf->iter.bi_size =0 ; -clear_bit (BIO_UPTODATE , &buf->bio->bi_flags); + buf->bio->bi_error = -EIO ;if (buf->nframesout ==0 )aoe_end_buf (d, buf); }
drivers/block/aoe/aoedev.c +1 -1
@@ -170,7 +170,7 @@ aoe_failip(struct aoedev *d)if (rq ==NULL )return ;while ((bio = d->ip.nxbio)) { -clear_bit (BIO_UPTODATE , &bio->bi_flags); + bio->bi_error = -EIO ; d->ip.nxbio = bio->bi_next; n = (unsigned long ) rq->special; rq->special = (void *) --n;
drivers/block/brd.c +8 -5
@@ -331,14 +331,12 @@ static void brd_make_request(struct request_queue *q, struct bio *bio)struct bio_vec bvec;sector_t sector;struct bvec_iter iter; -int err = -EIO ; sector = bio->bi_iter.bi_sector;if (bio_end_sector (bio) >get_capacity (bdev->bd_disk)) - goto out; + goto io_error;if (unlikely (bio->bi_rw &REQ_DISCARD )) { - err =0 ;discard_from_brd (brd, sector, bio->bi_iter.bi_size); goto out; }
@@ -349,15 +347,20 @@ static void brd_make_request(struct request_queue *q, struct bio *bio)bio_for_each_segment (bvec, bio, iter) {unsigned int len = bvec.bv_len; +int err; + err =brd_do_bvec (brd, bvec.bv_page, len, bvec.bv_offset, rw, sector);if (err) -break ; + goto io_error; sector += len >>SECTOR_SHIFT ; } out: -bio_endio (bio, err); +bio_endio (bio); +return ; +io_error: +bio_io_error (bio); } static int brd_rw_page(struct block_device *bdev, sector_t sector,
drivers/block/drbd/drbd_actlog.c +2 -2
@@ -175,11 +175,11 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,atomic_inc (&device->md_io.in_use);/* drbd_md_put_buffer() is in the completion handler */ device->md_io.submit_jif = jiffies;if (drbd_insert_fault (device, (rw &WRITE ) ?DRBD_FAULT_MD_WR :DRBD_FAULT_MD_RD )) -bio_endio (bio, -EIO ); +bio_io_error (bio);else submit_bio (rw, bio);wait_until_done_or_force_detached (device, bdev, &device->md_io.done); -if (bio_flagged (bio,BIO_UPTODATE )) +if (!bio->bi_error) err = device->md_io.error; out:
drivers/block/drbd/drbd_bitmap.c +5 -14
@@ -941,36 +941,27 @@ static void drbd_bm_aio_ctx_destroy(struct kref *kref) }/* bv_page may be a copy, or may be the original */ -static void drbd_bm_endio (struct bio *bio,int error) +static void drbd_bm_endio (struct bio *bio) {struct drbd_bm_aio_ctx *ctx = bio->bi_private;struct drbd_device *device = ctx->device;struct drbd_bitmap *b = device->bitmap;unsigned int idx =bm_page_to_idx (bio->bi_io_vec[0 ].bv_page); -int uptodate =bio_flagged (bio,BIO_UPTODATE ); - - -/* strange behavior of some lower level drivers... -* fail the request by clearing the uptodate flag, -* but do not return any error?! -* do we want to WARN() on this? */ -if (!error && !uptodate) - error = -EIO ;if ((ctx->flags &BM_AIO_COPY_PAGES ) ==0 && !bm_test_page_unchanged (b->bm_pages[idx]))drbd_warn (device,"bitmap page idx %u changed during IO!\n" , idx); -if (error) { +if (bio->bi_error) {/* ctx error will hold the completed-last non-zero error code, * in case error codes differ. */ - ctx->error = error; + ctx->error = bio->bi_error;bm_set_page_io_err (b->bm_pages[idx]);/* Not identical to on disk version of it. * Is BM_PAGE_IO_ERROR enough? */ if (__ratelimit (&drbd_ratelimit_state))drbd_err (device,"IO ERROR %d on bitmap page idx %u\n" , - error, idx); + bio->bi_error, idx); }else {bm_clear_page_io_err (b->bm_pages[idx]);dynamic_drbd_dbg (device,"bitmap page idx %u completed\n" , idx);
@@ -1031,7 +1022,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_hoif (drbd_insert_fault (device, (rw &WRITE ) ?DRBD_FAULT_MD_WR :DRBD_FAULT_MD_RD )) { bio->bi_rw |= rw; -bio_endio (bio, -EIO ); +bio_io_error (bio); }else {submit_bio (rw, bio);/* this should not count as user activity and cause the
drivers/block/drbd/drbd_int.h +6 -5
@@ -1481,9 +1481,9 @@ extern int drbd_khelper(struct drbd_device *device, char *cmd);/* drbd_worker.c */ /* bi_end_io handlers */ -extern void drbd_md_endio (struct bio *bio,int error); -extern void drbd_peer_request_endio (struct bio *bio,int error); -extern void drbd_request_endio (struct bio *bio,int error); +extern void drbd_md_endio (struct bio *bio); +extern void drbd_peer_request_endio (struct bio *bio); +extern void drbd_request_endio (struct bio *bio);extern int drbd_worker (struct drbd_thread *thi);enum drbd_ret_code drbd_resync_after_valid (struct drbd_device *device,int o_minor);void drbd_resync_after_changed (struct drbd_device *device);
@@ -1604,12 +1604,13 @@ static inline void drbd_generic_make_request(struct drbd_device *device,__release (local);if (!bio->bi_bdev) {drbd_err (device,"drbd_generic_make_request: bio->bi_bdev == NULL\n" ); -bio_endio (bio, -ENODEV ); + bio->bi_error = -ENODEV ; +bio_endio (bio);return ; }if (drbd_insert_fault (device, fault_type)) -bio_endio (bio, -EIO ); +bio_io_error (bio);else generic_make_request (bio); }
drivers/block/drbd/drbd_req.c +6 -4
@@ -201,7 +201,8 @@ void start_new_tl_epoch(struct drbd_connection *connection)void complete_master_bio (struct drbd_device *device,struct bio_and_error *m) { -bio_endio (m->bio, m->error); + m->bio->bi_error = m->error; +bio_endio (m->bio);dec_ap_bio (device); }
@@ -1153,12 +1154,12 @@ drbd_submit_req_private_bio(struct drbd_request *req) rw == WRITE ? DRBD_FAULT_DT_WR : rw == READ ? DRBD_FAULT_DT_RD : DRBD_FAULT_DT_RA)) -bio_endio (bio, -EIO ); +bio_io_error (bio); elsegeneric_make_request (bio );put_ldev (device); }else -bio_endio (bio, -EIO ); +bio_io_error (bio); }static void drbd_queue_write (struct drbd_device *device,struct drbd_request *req)
@@ -1191,7 +1192,8 @@ drbd_request_prepare(struct drbd_device *device, struct bio *bio, unsigned long/* only pass the error to the upper layers. * if user cannot handle io errors, that's not our business. */ drbd_err (device,"could not kmalloc() req\n" ); -bio_endio (bio, -ENOMEM ); + bio->bi_error = -ENOMEM ; +bio_endio (bio);return ERR_PTR (-ENOMEM ); } req->start_jif = start_jif;
drivers/block/drbd/drbd_worker.c +11 -33
99 lines not on this page · raw message
drivers/block/floppy.c +4 -3
@@ -3771,13 +3771,14 @@ struct rb0_cbdata {struct completion complete; }; -static void floppy_rb0_cb (struct bio *bio,int err) +static void floppy_rb0_cb (struct bio *bio) {struct rb0_cbdata *cbdata = (struct rb0_cbdata *)bio->bi_private;int drive = cbdata->drive; -if (err) { -pr_info ("floppy: error %d while reading block 0\n" , err); +if (bio->bi_error) { +pr_info ("floppy: error %d while reading block 0\n" , + bio->bi_error);set_bit (FD_OPEN_SHOULD_FAIL_BIT , &UDRS ->flags); }complete (&cbdata->complete);
drivers/block/null_blk.c +1 -1
@@ -222,7 +222,7 @@ static void end_cmd(struct nullb_cmd *cmd)blk_end_request_all (cmd->rq,0 );break ;case NULL_Q_BIO : -bio_endio (cmd->bio,0 ); +bio_endio (cmd->bio);break ; }
drivers/block/pktcdvd.c +16 -16
@@ -977,7 +977,7 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct bio_vec *bvec) } } -static void pkt_end_io_read (struct bio *bio,int err) +static void pkt_end_io_read (struct bio *bio) {struct packet_data *pkt = bio->bi_private;struct pktcdvd_device *pd = pkt->pd;
@@ -985,9 +985,9 @@ static void pkt_end_io_read(struct bio *bio, int err)pkt_dbg (2 , pd,"bio=%p sec0=%llx sec=%llx err=%d\n" , bio, (unsigned long long )pkt->sector, - (unsigned long long )bio->bi_iter.bi_sector, err); + (unsigned long long )bio->bi_iter.bi_sector, bio->bi_error); -if (err) +if (bio->bi_error)atomic_inc (&pkt->io_errors);if (atomic_dec_and_test (&pkt->io_wait)) {atomic_inc (&pkt->run_sm);
@@ -996,13 +996,13 @@ static void pkt_end_io_read(struct bio *bio, int err)pkt_bio_finished (pd); } -static void pkt_end_io_packet_write (struct bio *bio,int err) +static void pkt_end_io_packet_write (struct bio *bio) {struct packet_data *pkt = bio->bi_private;struct pktcdvd_device *pd = pkt->pd;BUG_ON (!pd); -pkt_dbg (2 , pd,"id=%d, err=%d\n" , pkt->id, err); +pkt_dbg (2 , pd,"id=%d, err=%d\n" , pkt->id, bio->bi_error); pd->stats.pkt_ended++;
@@ -1340,22 +1340,22 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)pkt_queue_bio (pd, pkt->w_bio); } -static void pkt_finish_packet (struct packet_data *pkt,int uptodate) +static void pkt_finish_packet (struct packet_data *pkt,int error) {struct bio *bio; -if (!uptodate) +if (error) pkt->cache_valid =0 ;/* Finish all bios corresponding to this packet */ -while ((bio =bio_list_pop (&pkt->orig_bios))) -bio_endio (bio, uptodate ?0 : -EIO ); +while ((bio =bio_list_pop (&pkt->orig_bios))) { + bio->bi_error = error; +bio_endio (bio); + } }static void pkt_run_state_machine (struct pktcdvd_device *pd,struct packet_data *pkt) { -int uptodate; -pkt_dbg (2 , pd,"pkt %d\n" , pkt->id);for (;;) {
@@ -1384,7 +1384,7 @@ static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_dataif (atomic_read (&pkt->io_wait) >0 )return ; -if (test_bit (BIO_UPTODATE , &pkt->w_bio->bi_flags)) { +if (!pkt->w_bio->bi_error) {pkt_set_state (pkt,PACKET_FINISHED_STATE ); }else {pkt_set_state (pkt,PACKET_RECOVERY_STATE );
@@ -1401,8 +1401,7 @@ static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_databreak ;case PACKET_FINISHED_STATE : - uptodate =test_bit (BIO_UPTODATE , &pkt->w_bio->bi_flags); -pkt_finish_packet (pkt, uptodate); +pkt_finish_packet (pkt, pkt->w_bio->bi_error);return ;default :
@@ -2332,13 +2331,14 @@ static void pkt_close(struct gendisk *disk, fmode_t mode) } -static void pkt_end_io_read_cloned (struct bio *bio,int err) +static void pkt_end_io_read_cloned (struct bio *bio) {struct packet_stacked_data *psd = bio->bi_private;struct pktcdvd_device *pd = psd->pd; + psd->bio->bi_error = bio->bi_error;bio_put (bio); -bio_endio (psd->bio, err); +bio_endio (psd->bio);mempool_free (psd, psd_pool);pkt_bio_finished (pd); }
drivers/block/pmem.c +3 -5
@@ -65,11 +65,10 @@ static void pmem_make_request(struct request_queue *q, struct bio *bio)struct bio_vec bvec;sector_t sector;struct bvec_iter iter; -int err =0 ;if (bio_end_sector (bio) >get_capacity (bdev->bd_disk)) { - err = -EIO ; - goto out; +bio_io_error (bio); +return ; }BUG_ON (bio->bi_rw &REQ_DISCARD );
@@ -82,8 +81,7 @@ static void pmem_make_request(struct request_queue *q, struct bio *bio) sector += bvec.bv_len >>9 ; } -out: -bio_endio (bio, err); +bio_endio (bio); } static int pmem_rw_page(struct block_device *bdev, sector_t sector,
drivers/block/ps3vram.c +2 -1
@@ -593,7 +593,8 @@ out: next =bio_list_peek (&priv->list);spin_unlock_irq (&priv->lock); -bio_endio (bio, error); + bio->bi_error = error; +bio_endio (bio);return next; }
drivers/block/rsxx/dev.c +7 -2
@@ -137,7 +137,10 @@ static void bio_dma_done_cb(struct rsxx_cardinfo *card,if (!card->eeh_state && card->gendisk)disk_stats_complete (card, meta->bio, meta->start_time); -bio_endio (meta->bio,atomic_read (&meta->error) ? -EIO :0 ); +if (atomic_read (&meta->error)) +bio_io_error (meta->bio); +else +bio_endio (meta->bio);kmem_cache_free (bio_meta_pool, meta); } }
@@ -199,7 +202,9 @@ static void rsxx_make_request(struct request_queue *q, struct bio *bio) queue_err:kmem_cache_free (bio_meta_pool, bio_meta); req_err: -bio_endio (bio, st); +if (st) + bio->bi_error = st; +bio_endio (bio); }/*----------------- Device Setup -------------------*/
drivers/block/umem.c +2 -2
@@ -456,7 +456,7 @@ static void process_page(unsigned long data) PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);if (control &DMASCR_HARD_ERROR ) {/* error */ -clear_bit (BIO_UPTODATE , &bio->bi_flags); + bio->bi_error = -EIO ; dev_printk(KERN_WARNING, &card->dev->dev, "I/O error on sector %d/%d\n", le32_to_cpu(desc->local_addr)>>9,
@@ -505,7 +505,7 @@ static void process_page(unsigned long data) return_bio = bio->bi_next; bio->bi_next =NULL ; -bio_endio (bio,0 ); +bio_endio (bio); } }
drivers/block/xen-blkback/blkback.c +2 -2
@@ -1084,9 +1084,9 @@ static void __end_block_io_op(struct pending_req *pending_req, int error)/* * bio callback. */ -static void end_block_io_op (struct bio *bio,int error) +static void end_block_io_op (struct bio *bio) { -__end_block_io_op (bio->bi_private, error); +__end_block_io_op (bio->bi_private, bio->bi_error);bio_put (bio); }
drivers/block/xen-blkfront.c +3 -6
@@ -82,7 +82,6 @@ struct blk_shadow {struct split_bio {struct bio *bio;atomic_t pending; -int err; };static DEFINE_MUTEX (blkfront_mutex);
@@ -1440,16 +1439,14 @@ static int blkfront_probe(struct xenbus_device *dev,return 0 ; } -static void split_bio_end (struct bio *bio,int error) +static void split_bio_end (struct bio *bio) {struct split_bio *split_bio = bio->bi_private; -if (error) - split_bio->err = error; -if (atomic_dec_and_test (&split_bio->pending)) { split_bio->bio->bi_phys_segments =0 ; -bio_endio (split_bio->bio, split_bio->err); + split_bio->bio->bi_error = bio->bi_error; +bio_endio (split_bio->bio);kfree (split_bio); }bio_put (bio);
drivers/block/zram/zram_drv.c +2 -3
@@ -909,7 +909,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)if (unlikely (bio->bi_rw &REQ_DISCARD )) {zram_bio_discard (zram, index, offset, bio); -bio_endio (bio,0 ); +bio_endio (bio);return ; }
@@ -942,8 +942,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)update_position (&index, &offset, &bvec); } -set_bit (BIO_UPTODATE , &bio->bi_flags); -bio_endio (bio,0 ); +bio_endio (bio);return ; out:
drivers/md/bcache/btree.c +4 -4
@@ -305,7 +305,7 @@ static void bch_btree_node_read(struct btree *b)bch_submit_bbio (bio, b->c, &b->key,0 );closure_sync (&cl); -if (!test_bit (BIO_UPTODATE , &bio->bi_flags)) +if (bio->bi_error)set_btree_node_io_error (b);bch_bbio_free (bio, b->c);
@@ -371,15 +371,15 @@ static void btree_node_write_done(struct closure *cl)__btree_node_write_done (cl); } -static void btree_node_write_endio (struct bio *bio,int error) +static void btree_node_write_endio (struct bio *bio) {struct closure *cl = bio->bi_private; struct btree *b = container_of(cl, struct btree, io); -if (error) +if (bio->bi_error)set_btree_node_io_error (b); -bch_bbio_count_io_errors (b->c, bio, error,"writing btree" ); +bch_bbio_count_io_errors (b->c, bio, bio->bi_error,"writing btree" );closure_put (cl); }
drivers/md/bcache/io.c +4 -4
@@ -55,19 +55,19 @@ static void bch_bio_submit_split_done(struct closure *cl) s->bio->bi_end_io = s->bi_end_io; s->bio->bi_private = s->bi_private; -bio_endio (s->bio,0 ); +bio_endio (s->bio);closure_debug_destroy (&s->cl);mempool_free (s, s->p->bio_split_hook); } -static void bch_bio_submit_split_endio (struct bio *bio,int error) +static void bch_bio_submit_split_endio (struct bio *bio) {struct closure *cl = bio->bi_private; struct bio_split_hook *s = container_of(cl, struct bio_split_hook, cl); -if (error) -clear_bit (BIO_UPTODATE , &s->bio->bi_flags); +if (bio->bi_error) + s->bio->bi_error = bio->bi_error;bio_put (bio);closure_put (cl);
drivers/md/bcache/journal.c +4 -4
@@ -24,7 +24,7 @@* bit. */ -static void journal_read_endio (struct bio *bio,int error) +static void journal_read_endio (struct bio *bio) {struct closure *cl = bio->bi_private;closure_put (cl);
@@ -401,7 +401,7 @@ retry:#define last_seq (j) ((j)->seq - fifo_used(&(j)->pin) + 1) -static void journal_discard_endio (struct bio *bio,int error) +static void journal_discard_endio (struct bio *bio) {struct journal_device *ja = container_of(bio, struct journal_device, discard_bio);
@@ -547,11 +547,11 @@ void bch_journal_next(struct journal *j)pr_debug ("journal_pin full (%zu)" ,fifo_used (&j->pin)); } -static void journal_write_endio (struct bio *bio,int error) +static void journal_write_endio (struct bio *bio) {struct journal_write *w = bio->bi_private; -cache_set_err_on (error, w->c,"journal io error" ); +cache_set_err_on (bio->bi_error, w->c,"journal io error" );closure_put (&w->c->journal.io); }
drivers/md/bcache/movinggc.c +4 -4
@@ -60,20 +60,20 @@ static void write_moving_finish(struct closure *cl)closure_return_with_destructor (cl, moving_io_destructor); } -static void read_moving_endio (struct bio *bio,int error) +static void read_moving_endio (struct bio *bio) { struct bbio *b = container_of(bio, struct bbio, bio);struct moving_io *io =container_of (bio->bi_private, struct moving_io, cl); -if (error) - io->op.error = error; +if (bio->bi_error) + io->op.error = bio->bi_error;else if (!KEY_DIRTY (&b->key) &&ptr_stale (io->op.c, &b->key,0 )) { io->op.error = -EINTR ; } -bch_bbio_endio (io->op.c, bio, error,"reading data to move" ); +bch_bbio_endio (io->op.c, bio, bio->bi_error,"reading data to move" ); }static void moving_init (struct moving_io *io)
drivers/md/bcache/request.c +6 -5
@@ -584,13 +584,13 @@ static void cache_lookup(struct closure *cl)/* Common code for the make_request functions */ -static void request_endio (struct bio *bio,int error) +static void request_endio (struct bio *bio) {struct closure *cl = bio->bi_private; -if (error) { +if (bio->bi_error) { struct search *s = container_of(cl, struct search, cl); - s->iop.error = error; + s->iop.error = bio->bi_error;/* Only cache read errors are recoverable */ s->recoverable = false; }
@@ -606,7 +606,8 @@ static void bio_complete(struct search *s) &s->d->disk->part0, s->start_time);trace_bcache_request_end (s->d, s->orig_bio); -bio_endio (s->orig_bio, s->iop.error); + s->orig_bio->bi_error = s->iop.error; +bio_endio (s->orig_bio); s->orig_bio =NULL ; } }
@@ -985,7 +986,7 @@ static void cached_dev_make_request(struct request_queue *q, struct bio *bio) }else {if ((bio->bi_rw &REQ_DISCARD ) && !blk_queue_discard (bdev_get_queue (dc->bdev))) -bio_endio (bio,0 ); +bio_endio (bio);else bch_generic_make_request (bio, &d->bio_split_hook); }
drivers/md/bcache/super.c +7 -7
@@ -221,7 +221,7 @@ err:return err; } -static void write_bdev_super_endio (struct bio *bio,int error) +static void write_bdev_super_endio (struct bio *bio) {struct cached_dev *dc = bio->bi_private;/* XXX: error checking */
@@ -290,11 +290,11 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent)closure_return_with_destructor (cl, bch_write_bdev_super_unlock); } -static void write_super_endio (struct bio *bio,int error) +static void write_super_endio (struct bio *bio) {struct cache *ca = bio->bi_private; -bch_count_io_errors (ca, error,"writing superblock" ); +bch_count_io_errors (ca, bio->bi_error,"writing superblock" );closure_put (&ca->set->sb_write); }
@@ -339,12 +339,12 @@ void bcache_write_super(struct cache_set *c)/* UUID io */ -static void uuid_endio (struct bio *bio,int error) +static void uuid_endio (struct bio *bio) {struct closure *cl = bio->bi_private; struct cache_set *c = container_of(cl, struct cache_set, uuid_write); -cache_set_err_on (error, c,"accessing uuids" ); +cache_set_err_on (bio->bi_error, c,"accessing uuids" );bch_bbio_free (bio, c);closure_put (cl); }
@@ -512,11 +512,11 @@ static struct uuid_entry *uuid_find_empty(struct cache_set *c)* disk. */ -static void prio_endio (struct bio *bio,int error) +static void prio_endio (struct bio *bio) {struct cache *ca = bio->bi_private; -cache_set_err_on (error, ca->set,"accessing priorities" ); +cache_set_err_on (bio->bi_error, ca->set,"accessing priorities" );bch_bbio_free (bio, ca->set);closure_put (&ca->prio); }
drivers/md/bcache/writeback.c +5 -5
@@ -166,12 +166,12 @@ static void write_dirty_finish(struct closure *cl)closure_return_with_destructor (cl, dirty_io_destructor); } -static void dirty_endio (struct bio *bio,int error) +static void dirty_endio (struct bio *bio) {struct keybuf_key *w = bio->bi_private;struct dirty_io *io = w->private; -if (error) +if (bio->bi_error)SET_KEY_DIRTY (&w->key, false);closure_put (&io->cl);
@@ -193,15 +193,15 @@ static void write_dirty(struct closure *cl)continue_at (cl, write_dirty_finish, system_wq); } -static void read_dirty_endio (struct bio *bio,int error) +static void read_dirty_endio (struct bio *bio) {struct keybuf_key *w = bio->bi_private;struct dirty_io *io = w->private;bch_count_io_errors (PTR_CACHE (io->dc->disk.c, &w->key,0 ), - error,"reading dirty data from cache" ); + bio->bi_error,"reading dirty data from cache" ); -dirty_endio (bio, error); +dirty_endio (bio); }static void read_dirty_submit (struct closure *cl)
drivers/md/dm-bio-prison.c +4 -2
@@ -236,8 +236,10 @@ void dm_cell_error(struct dm_bio_prison *prison,bio_list_init (&bios);dm_cell_release (prison, cell, &bios); -while ((bio =bio_list_pop (&bios))) -bio_endio (bio, error); +while ((bio =bio_list_pop (&bios))) { + bio->bi_error = error; +bio_endio (bio); + } }EXPORT_SYMBOL_GPL (dm_cell_error);
drivers/md/dm-bufio.c +16 -10
@@ -545,7 +545,8 @@ static void dmio_complete(unsigned long error, void *context) {struct dm_buffer *b = context; - b->bio.bi_end_io (&b->bio, error ? -EIO :0 ); + b->bio.bi_error = error; + b->bio.bi_end_io (&b->bio); } static void use_dmio(struct dm_buffer *b, int rw, sector_t block,
@@ -575,13 +576,16 @@ static void use_dmio(struct dm_buffer *b, int rw, sector_t block, b->bio.bi_end_io = end_io; r =dm_io (&io_req,1 , ®ion,NULL ); -if (r) -end_io (&b->bio, r); +if (r) { + b->bio.bi_error = r; +end_io (&b->bio); + } } -static void inline_endio (struct bio *bio,int error) +static void inline_endio (struct bio *bio) {bio_end_io_t *end_fn = bio->bi_private; +int error = bio->bi_error;/* * Reset the bio to free any attached resources
@@ -589,7 +593,8 @@ static void inline_endio(struct bio *bio, int error)*/ bio_reset (bio); -end_fn (bio, error); + bio->bi_error = error; +end_fn (bio); } static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block,
@@ -661,13 +666,14 @@ static void submit_io(struct dm_buffer *b, int rw, sector_t block,* Set the error, clear B_WRITING bit and wake anyone who was waiting on * it. */ -static void write_endio (struct bio *bio,int error) +static void write_endio (struct bio *bio) { struct dm_buffer *b = container_of(bio, struct dm_buffer, bio); - b->write_error = error; -if (unlikely (error)) { + b->write_error = bio->bi_error; +if (unlikely (bio->bi_error)) {struct dm_bufio_client *c = b->c; +int error = bio->bi_error; (void )cmpxchg (&c->async_write_error,0 , error); }
@@ -1026,11 +1032,11 @@ found_buffer:* The endio routine for reading: set the error, clear the bit and wake up * anyone waiting on the buffer. */ -static void read_endio (struct bio *bio,int error) +static void read_endio (struct bio *bio) { struct dm_buffer *b = container_of(bio, struct dm_buffer, bio); - b->read_error = error; + b->read_error = bio->bi_error;BUG_ON (!test_bit (B_READING , &b->state));
drivers/md/dm-cache-target.c +13 -11
@@ -828,14 +828,14 @@ static void defer_writethrough_bio(struct cache *cache, struct bio *bio)wake_worker (cache); } -static void writethrough_endio (struct bio *bio,int err) +static void writethrough_endio (struct bio *bio) {struct per_bio_data *pb =get_per_bio_data (bio,PB_DATA_SIZE_WT );dm_unhook_bio (&pb->hook_info, bio); -if (err) { -bio_endio (bio, err); +if (bio->bi_error) { +bio_endio (bio);return ; }
@@ -1006,7 +1006,7 @@ static void migration_success_post_commit(struct dm_cache_migration *mg)* The block was promoted via an overwrite, so it's dirty. */ set_dirty (cache, mg->new_oblock, mg->cblock); -bio_endio (mg->new_ocell->holder,0 ); +bio_endio (mg->new_ocell->holder);cell_defer (cache, mg->new_ocell, false); }free_io_migration (mg);
@@ -1059,7 +1059,7 @@ static void issue_copy(struct dm_cache_migration *mg) } } -static void overwrite_endio (struct bio *bio,int err) +static void overwrite_endio (struct bio *bio) {struct dm_cache_migration *mg = bio->bi_private;struct cache *cache = mg->cache;
@@ -1069,7 +1069,7 @@ static void overwrite_endio(struct bio *bio, int err)dm_unhook_bio (&pb->hook_info, bio); -if (err) +if (bio->bi_error) mg->err = true; mg->requeue_holder = false;
@@ -1133,7 +1133,7 @@ static void issue_discard(struct dm_cache_migration *mg) b =to_dblock (from_dblock (b) +1 ); } -bio_endio (bio,0 ); +bio_endio (bio);cell_defer (mg->cache, mg->new_ocell, false);free_migration (mg); }
@@ -1406,7 +1406,7 @@ static void process_discard_bio(struct cache *cache, struct prealloc *structs,calc_discard_block_range (cache, bio, &b, &e);if (b == e) { -bio_endio (bio,0 ); +bio_endio (bio);return ; }
@@ -1792,8 +1792,10 @@ static void requeue_deferred_io(struct cache *cache)bio_list_merge (&bios, &cache->deferred_bios);bio_list_init (&cache->deferred_bios); -while ((bio =bio_list_pop (&bios))) -bio_endio (bio,DM_ENDIO_REQUEUE ); +while ((bio =bio_list_pop (&bios))) { + bio->bi_error =DM_ENDIO_REQUEUE ; +bio_endio (bio); + } }static int more_work (struct cache *cache)
@@ -2673,7 +2675,7 @@ static int __cache_map(struct cache *cache, struct bio *bio, struct dm_bio_priso* This is a duplicate writethrough io that is no * longer needed because the block has been demoted. */ -bio_endio (bio,0 ); +bio_endio (bio);cell_defer (cache, *cell, false); r =DM_MAPIO_SUBMITTED ;
drivers/md/dm-crypt.c +6 -8
@@ -1062,7 +1062,8 @@ static void crypt_dec_pending(struct dm_crypt_io *io)if (io->ctx.req)crypt_free_req (cc, io->ctx.req, base_bio); -bio_endio (base_bio, error); + base_bio->bi_error = error; +bio_endio (base_bio); }/*
@@ -1082,15 +1083,12 @@ static void crypt_dec_pending(struct dm_crypt_io *io)* The work is done per CPU global for all dm-crypt instances. * They should not depend on each other and do not block. */ -static void crypt_endio (struct bio *clone,int error) +static void crypt_endio (struct bio *clone) {struct dm_crypt_io *io = clone->bi_private;struct crypt_config *cc = io->cc;unsigned rw =bio_data_dir (clone); -if (unlikely (!bio_flagged (clone,BIO_UPTODATE ) && !error)) - error = -EIO ; -/* * free the processed pages */
@@ -1099,13 +1097,13 @@ static void crypt_endio(struct bio *clone, int error)bio_put (clone); -if (rw ==READ && !error) { +if (rw ==READ && !clone->bi_error) {kcryptd_queue_crypt (io);return ; } -if (unlikely (error)) - io->error = error; +if (unlikely (clone->bi_error)) + io->error = clone->bi_error;crypt_dec_pending (io); }
drivers/md/dm-flakey.c +1 -1
@@ -296,7 +296,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)* Drop writes? */ if (test_bit (DROP_WRITES , &fc->flags)) { -bio_endio (bio,0 ); +bio_endio (bio);return DM_MAPIO_SUBMITTED ; }
drivers/md/dm-io.c +3 -3
@@ -134,12 +134,12 @@ static void dec_count(struct io *io, unsigned int region, int error)complete_io (io); } -static void endio (struct bio *bio,int error) +static void endio (struct bio *bio) {struct io *io;unsigned region; -if (error &&bio_data_dir (bio) ==READ ) +if (bio->bi_error &&bio_data_dir (bio) ==READ )zero_fill_bio (bio);/*
@@ -149,7 +149,7 @@ static void endio(struct bio *bio, int error)bio_put (bio); -dec_count (io, region, error); +dec_count (io, region, bio->bi_error); }/*-----------------------------------------------------------------
drivers/md/dm-log-writes.c +4 -7
@@ -146,16 +146,16 @@ static void put_io_block(struct log_writes_c *lc) } } -static void log_end_io (struct bio *bio,int err) +static void log_end_io (struct bio *bio) {struct log_writes_c *lc = bio->bi_private;struct bio_vec *bvec;int i; -if (err) { +if (bio->bi_error) {unsigned long flags; -DMERR ("Error writing log block, error=%d" , err); +DMERR ("Error writing log block, error=%d" , bio->bi_error);spin_lock_irqsave (&lc->blocks_lock, flags); lc->logging_enabled = false;spin_unlock_irqrestore (&lc->blocks_lock, flags);
@@ -205,7 +205,6 @@ static int write_metadata(struct log_writes_c *lc, void *entry, bio->bi_bdev = lc->logdev->bdev; bio->bi_end_io = log_end_io; bio->bi_private = lc; -set_bit (BIO_UPTODATE , &bio->bi_flags); page =alloc_page (GFP_KERNEL );if (!page) {
@@ -270,7 +269,6 @@ static int log_one_block(struct log_writes_c *lc, bio->bi_bdev = lc->logdev->bdev; bio->bi_end_io = log_end_io; bio->bi_private = lc; -set_bit (BIO_UPTODATE , &bio->bi_flags);for (i =0 ; i < block->vec_cnt; i++) {/*
@@ -292,7 +290,6 @@ static int log_one_block(struct log_writes_c *lc, bio->bi_bdev = lc->logdev->bdev; bio->bi_end_io = log_end_io; bio->bi_private = lc; -set_bit (BIO_UPTODATE , &bio->bi_flags); ret =bio_add_page (bio, block->vecs[i].bv_page, block->vecs[i].bv_len,0 );
@@ -606,7 +603,7 @@ static int log_writes_map(struct dm_target *ti, struct bio *bio)WARN_ON (flush_bio || fua_bio);if (lc->device_supports_discard) goto map_bio; -bio_endio (bio,0 ); +bio_endio (bio);return DM_MAPIO_SUBMITTED ; }
drivers/md/dm-raid1.c +13 -10
@@ -476,9 +476,11 @@ static void hold_bio(struct mirror_set *ms, struct bio *bio)* If device is suspended, complete the bio. */ if (dm_noflush_suspending (ms->ti)) -bio_endio (bio,DM_ENDIO_REQUEUE ); + bio->bi_error =DM_ENDIO_REQUEUE ;else -bio_endio (bio, -EIO ); + bio->bi_error = -EIO ; + +bio_endio (bio);return ; }
@@ -501,7 +503,7 @@ static void read_callback(unsigned long error, void *context)bio_set_m (bio,NULL );if (likely (!error)) { -bio_endio (bio,0 ); +bio_endio (bio);return ; }
@@ -517,7 +519,7 @@ static void read_callback(unsigned long error, void *context)DMERR_LIMIT ("Read failure on mirror device %s. Failing I/O." , m->dev->name); -bio_endio (bio, -EIO ); +bio_io_error (bio); }/* Asynchronous read. */
@@ -566,7 +568,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)if (likely (m))read_async_bio (m, bio);else -bio_endio (bio, -EIO ); +bio_io_error (bio); } }
@@ -584,7 +586,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)static void write_callback (unsigned long error,void *context) { -unsigned i, ret =0 ; +unsigned i;struct bio *bio = (struct bio *) context;struct mirror_set *ms;int should_wake =0 ;
@@ -600,7 +602,7 @@ static void write_callback(unsigned long error, void *context)* regions with the same code. */ if (likely (!error)) { -bio_endio (bio, ret); +bio_endio (bio);return ; }
@@ -609,7 +611,8 @@ static void write_callback(unsigned long error, void *context)* degrade the array. */ if (bio->bi_rw &REQ_DISCARD ) { -bio_endio (bio, -EOPNOTSUPP ); + bio->bi_error = -EOPNOTSUPP ; +bio_endio (bio);return ; }
@@ -810,11 +813,11 @@ static void do_failures(struct mirror_set *ms, struct bio_list *failures)* got replicated back to the good legs.) */ if (!get_valid_mirror (ms)) -bio_endio (bio, -EIO ); +bio_io_error (bio);else if (errors_handled (ms))hold_bio (ms, bio);else -bio_endio (bio,0 ); +bio_endio (bio); } }
drivers/md/dm-snap.c +3 -3
@@ -1490,7 +1490,7 @@ out:error_bios (snapshot_bios); }else {if (full_bio) -bio_endio (full_bio,0 ); +bio_endio (full_bio);flush_bios (snapshot_bios); }
@@ -1580,11 +1580,11 @@ static void start_copy(struct dm_snap_pending_exception *pe)dm_kcopyd_copy (s->kcopyd_client, &src,1 , &dest,0 , copy_callback, pe); } -static void full_bio_end_io (struct bio *bio,int error) +static void full_bio_end_io (struct bio *bio) {void *callback_data = bio->bi_private; -dm_kcopyd_do_callback (callback_data,0 , error ?1 :0 ); +dm_kcopyd_do_callback (callback_data,0 , bio->bi_error ?1 :0 ); } static void start_full_bio(struct dm_snap_pending_exception *pe,
drivers/md/dm-stripe.c +1 -1
@@ -273,7 +273,7 @@ static int stripe_map_range(struct stripe_c *sc, struct bio *bio,return DM_MAPIO_REMAPPED ; }else {/* The range doesn't map to the target stripe */ -bio_endio (bio,0 ); +bio_endio (bio);return DM_MAPIO_SUBMITTED ; } }
drivers/md/dm-thin.c +21 -17
@@ -473,8 +473,10 @@ static void error_bio_list(struct bio_list *bios, int error) {struct bio *bio; -while ((bio =bio_list_pop (bios))) -bio_endio (bio, error); +while ((bio =bio_list_pop (bios))) { + bio->bi_error = error; +bio_endio (bio); + } }static void error_thin_bio_list (struct thin_c *tc,struct bio_list *master,int error)
@@ -700,12 +702,12 @@ static void copy_complete(int read_err, unsigned long write_err, void *context)complete_mapping_preparation (m); } -static void overwrite_endio (struct bio *bio,int err) +static void overwrite_endio (struct bio *bio) {struct dm_thin_endio_hook *h =dm_per_bio_data (bio,sizeof (struct dm_thin_endio_hook ));struct dm_thin_new_mapping *m = h->overwrite_mapping; - m->err = err; + m->err = bio->bi_error;complete_mapping_preparation (m); }
@@ -837,7 +839,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)*/ if (bio) {inc_remap_and_issue_cell (tc, m->cell, m->data_block); -bio_endio (bio,0 ); +bio_endio (bio); }else {inc_all_io_entry (tc->pool, m->cell->holder);remap_and_issue (tc, m->cell->holder, m->data_block);
@@ -873,12 +875,12 @@ static void process_prepared_discard_passdown(struct dm_thin_new_mapping *m)else {bool used = false;if (dm_pool_block_is_used (tc->pool->pmd, m->data_block, &used) || used) -bio_endio (m->bio,0 ); +bio_endio (m->bio);else remap_and_issue (tc, m->bio, m->data_block); } else - bio_endio(m->bio, 0); + bio_endio(m->bio);mempool_free (m, tc->pool->mapping_pool); }
@@ -1266,9 +1268,10 @@ static void handle_unserviceable_bio(struct pool *pool, struct bio *bio) {int error =should_error_unserviceable_bio (pool); -if (error) -bio_endio (bio, error); -else +if (error) { + bio->bi_error = error; +bio_endio (bio); + }else retry_on_resume (bio); }
@@ -1352,7 +1355,7 @@ static void process_discard_cell(struct thin_c *tc, struct dm_bio_prison_cell *cif ((!lookup_result.shared) && pool->pf.discard_passdown)remap_and_issue (tc, bio, lookup_result.block);else -bio_endio (bio,0 ); +bio_endio (bio); }break ;
@@ -1361,7 +1364,7 @@ static void process_discard_cell(struct thin_c *tc, struct dm_bio_prison_cell *c* It isn't provisioned, just forget it. */ cell_defer_no_holder (tc, cell); -bio_endio (bio,0 ); +bio_endio (bio);break ;default :
@@ -1513,7 +1516,7 @@ static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t blockif (bio_data_dir (bio) ==READ ) {zero_fill_bio (bio);cell_defer_no_holder (tc, cell); -bio_endio (bio,0 ); +bio_endio (bio);return ; }
@@ -1578,7 +1581,7 @@ static void process_cell(struct thin_c *tc, struct dm_bio_prison_cell *cell) }else {zero_fill_bio (bio); -bio_endio (bio,0 ); +bio_endio (bio); } }else provision_block (tc, bio, block, cell);
@@ -1649,7 +1652,7 @@ static void __process_bio_read_only(struct thin_c *tc, struct bio *bio, }zero_fill_bio (bio); -bio_endio (bio,0 ); +bio_endio (bio);break ;default :
@@ -1674,7 +1677,7 @@ static void process_cell_read_only(struct thin_c *tc, struct dm_bio_prison_cellstatic void process_bio_success (struct thin_c *tc,struct bio *bio) { -bio_endio (bio,0 ); +bio_endio (bio); }static void process_bio_fail (struct thin_c *tc,struct bio *bio)
@@ -2293,7 +2296,8 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)thin_hook_bio (tc, bio);if (tc->requeue_mode) { -bio_endio (bio,DM_ENDIO_REQUEUE ); + bio->bi_error =DM_ENDIO_REQUEUE ; +bio_endio (bio);return DM_MAPIO_SUBMITTED ; }
drivers/md/dm-verity.c +5 -4
@@ -458,8 +458,9 @@ static void verity_finish_io(struct dm_verity_io *io, int error) bio->bi_end_io = io->orig_bi_end_io; bio->bi_private = io->orig_bi_private; + bio->bi_error = error; -bio_endio (bio, error); +bio_endio (bio); }static void verity_work (struct work_struct *w)
@@ -469,12 +470,12 @@ static void verity_work(struct work_struct *w)verity_finish_io (io,verity_verify_io (io)); } -static void verity_end_io (struct bio *bio,int error) +static void verity_end_io (struct bio *bio) {struct dm_verity_io *io = bio->bi_private; -if (error) { -verity_finish_io (io, error); +if (bio->bi_error) { +verity_finish_io (io, bio->bi_error);return ; }
drivers/md/dm-zero.c +1 -1
@@ -47,7 +47,7 @@ static int zero_map(struct dm_target *ti, struct bio *bio)break ; } -bio_endio (bio,0 ); +bio_endio (bio);/* accepted bio, don't make new request */ return DM_MAPIO_SUBMITTED ;
drivers/md/dm.c +9 -9
@@ -941,7 +941,8 @@ static void dec_pending(struct dm_io *io, int error) }else {/* done with normal IO or empty flush */ trace_block_bio_complete (md->queue, bio, io_error); -bio_endio (bio, io_error); + bio->bi_error = io_error; +bio_endio (bio); } } }
@@ -954,25 +955,22 @@ static void disable_write_same(struct mapped_device *md) limits->max_write_same_sectors =0 ; } -static void clone_endio (struct bio *bio,int error) +static void clone_endio (struct bio *bio) { -int r = error; struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);struct dm_io *io = tio->io;struct mapped_device *md = tio->io->md;dm_endio_fn endio = tio->ti->type->end_io; - -if (!bio_flagged (bio,BIO_UPTODATE ) && !error) - error = -EIO ; +int r;if (endio) { - r =endio (tio->ti, bio, error); + r =endio (tio->ti, bio, bio->bi_error);if (r <0 || r ==DM_ENDIO_REQUEUE )/* * error and requeue request are handled * in dec_pending(). */ - error = r; + ;else if (r ==DM_ENDIO_INCOMPLETE )/* The target will handle the io */ return ;
@@ -980,6 +978,8 @@ static void clone_endio(struct bio *bio, int error)DMWARN ("unimplemented target endio return value: %d" , r);BUG (); } + }else { + r = bio->bi_error; } if (unlikely(r == -EREMOTEIO && (bio->bi_rw & REQ_WRITE_SAME) &&
@@ -987,7 +987,7 @@ static void clone_endio(struct bio *bio, int error)disable_write_same (md);free_tio (md, tio); -dec_pending (io, error); +dec_pending (io, r); }static struct dm_rq_target_io *tio_from_request (struct request *rq)
drivers/md/faulty.c +2 -2
@@ -70,7 +70,7 @@#include <linux/seq_file.h> -static void faulty_fail (struct bio *bio,int error) +static void faulty_fail (struct bio *bio) {struct bio *b = bio->bi_private;
@@ -181,7 +181,7 @@ static void make_request(struct mddev *mddev, struct bio *bio)/* special case - don't decrement, don't generic_make_request, * just fail immediately */ -bio_endio (bio, -EIO ); +bio_io_error (bio);return ; }
drivers/md/linear.c +1 -1
@@ -297,7 +297,7 @@ static void linear_make_request(struct mddev *mddev, struct bio *bio)if (unlikely ((split->bi_rw &REQ_DISCARD ) && !blk_queue_discard (bdev_get_queue (split->bi_bdev)))) {/* Just ignore it */ -bio_endio (split,0 ); +bio_endio (split); }else generic_make_request (split); }while (split != bio);
drivers/md/md.c +9 -9
@@ -263,7 +263,9 @@ static void md_make_request(struct request_queue *q, struct bio *bio)return ; }if (mddev->ro ==1 &&unlikely (rw ==WRITE )) { -bio_endio (bio,bio_sectors (bio) ==0 ?0 : -EROFS ); +if (bio_sectors (bio) !=0 ) + bio->bi_error = -EROFS ; +bio_endio (bio);return ; }smp_rmb ();/* Ensure implications of 'active' are visible */
@@ -377,7 +379,7 @@ static int md_mergeable_bvec(struct request_queue *q,* Generic flush handling for md */ -static void md_end_flush (struct bio *bio,int err) +static void md_end_flush (struct bio *bio) {struct md_rdev *rdev = bio->bi_private;struct mddev *mddev = rdev->mddev;
@@ -433,7 +435,7 @@ static void md_submit_flush_data(struct work_struct *ws)if (bio->bi_iter.bi_size ==0 )/* an empty barrier - all done */ -bio_endio (bio,0 ); +bio_endio (bio);else { bio->bi_rw &= ~REQ_FLUSH ; mddev->pers->make_request (mddev, bio);
@@ -728,15 +730,13 @@ void md_rdev_clear(struct md_rdev *rdev) }EXPORT_SYMBOL_GPL (md_rdev_clear); -static void super_written (struct bio *bio,int error) +static void super_written (struct bio *bio) {struct md_rdev *rdev = bio->bi_private;struct mddev *mddev = rdev->mddev; -if (error || !test_bit (BIO_UPTODATE , &bio->bi_flags)) { -printk ("md: super_written gets error=%d, uptodate=%d\n" , - error,test_bit (BIO_UPTODATE , &bio->bi_flags)); -WARN_ON (test_bit (BIO_UPTODATE , &bio->bi_flags)); +if (bio->bi_error) { +printk ("md: super_written gets error=%d\n" , bio->bi_error);md_error (mddev, rdev); }
@@ -791,7 +791,7 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int size,bio_add_page (bio, page, size,0 );submit_bio_wait (rw, bio); - ret =test_bit (BIO_UPTODATE , &bio->bi_flags); + ret = !bio->bi_error;bio_put (bio);return ret; }
drivers/md/multipath.c +6 -6
@@ -77,18 +77,18 @@ static void multipath_end_bh_io (struct multipath_bh *mp_bh, int err)struct bio *bio = mp_bh->master_bio;struct mpconf *conf = mp_bh->mddev->private; -bio_endio (bio, err); + bio->bi_error = err; +bio_endio (bio);mempool_free (mp_bh, conf->pool); } -static void multipath_end_request (struct bio *bio,int error) +static void multipath_end_request (struct bio *bio) { -int uptodate =test_bit (BIO_UPTODATE , &bio->bi_flags);struct multipath_bh *mp_bh = bio->bi_private;struct mpconf *conf = mp_bh->mddev->private;struct md_rdev *rdev = conf->multipaths[mp_bh->path].rdev; -if (uptodate) +if (!bio->bi_error)multipath_end_bh_io (mp_bh,0 );else if (!(bio->bi_rw &REQ_RAHEAD )) {/*
@@ -101,7 +101,7 @@ static void multipath_end_request(struct bio *bio, int error) (unsigned long long)bio->bi_iter.bi_sector);multipath_reschedule_retry (mp_bh); }else -multipath_end_bh_io (mp_bh, error); +multipath_end_bh_io (mp_bh, bio->bi_error);rdev_dec_pending (rdev, conf->mddev); }
@@ -123,7 +123,7 @@ static void multipath_make_request(struct mddev *mddev, struct bio * bio) mp_bh->path =multipath_map (conf);if (mp_bh->path <0 ) { -bio_endio (bio, -EIO ); +bio_io_error (bio);mempool_free (mp_bh, conf->pool);return ; }
drivers/md/raid0.c +1 -1
@@ -540,7 +540,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio)if (unlikely ((split->bi_rw &REQ_DISCARD ) && !blk_queue_discard (bdev_get_queue (split->bi_bdev)))) {/* Just ignore it */ -bio_endio (split,0 ); +bio_endio (split); }else generic_make_request (split); }while (split != bio);
drivers/md/raid1.c +27 -29
173 lines not on this page · raw message
drivers/md/raid10.c +25 -30
192 lines not on this page · raw message
drivers/md/raid5.c +26 -26
184 lines not on this page · raw message
drivers/s390/block/dcssblk.c +1 -1
@@ -871,7 +871,7 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio) } bytes_done += bvec.bv_len; } -bio_endio (bio,0 ); +bio_endio (bio);return ; fail:bio_io_error (bio);
drivers/s390/block/xpram.c +1 -2
@@ -220,8 +220,7 @@ static void xpram_make_request(struct request_queue *q, struct bio *bio) index++; } } -set_bit (BIO_UPTODATE , &bio->bi_flags); -bio_endio (bio,0 ); +bio_endio (bio);return ; fail:bio_io_error (bio);
drivers/target/target_core_iblock.c +7 -14
@@ -306,20 +306,13 @@ static void iblock_complete_cmd(struct se_cmd *cmd)kfree (ibr); } -static void iblock_bio_done (struct bio *bio,int err) +static void iblock_bio_done (struct bio *bio) {struct se_cmd *cmd = bio->bi_private;struct iblock_req *ibr = cmd->priv; -/* -* Set -EIO if !BIO_UPTODATE and the passed is still err=0 -*/ -if (!test_bit (BIO_UPTODATE , &bio->bi_flags) && !err) - err = -EIO ; - -if (err !=0 ) { -pr_err ("test_bit(BIO_UPTODATE) failed for bio: %p," -" err: %d\n" , bio, err); +if (bio->bi_error) { +pr_err ("bio error: %p, err: %d\n" , bio, bio->bi_error);/* * Bump the ib_bio_err_cnt and release bio. */
@@ -370,15 +363,15 @@ static void iblock_submit_bios(struct bio_list *list, int rw)blk_finish_plug (&plug); } -static void iblock_end_io_flush (struct bio *bio,int err) +static void iblock_end_io_flush (struct bio *bio) {struct se_cmd *cmd = bio->bi_private; -if (err) -pr_err ("IBLOCK: cache flush failed: %d\n" , err); +if (bio->bi_error) +pr_err ("IBLOCK: cache flush failed: %d\n" , bio->bi_error);if (cmd) { -if (err) +if (bio->bi_error)target_complete_cmd (cmd,SAM_STAT_CHECK_CONDITION );else target_complete_cmd (cmd,SAM_STAT_GOOD );
drivers/target/target_core_pscsi.c +3 -3
@@ -844,7 +844,7 @@ static ssize_t pscsi_show_configfs_dev_params(struct se_device *dev, char *b)return bl; } -static void pscsi_bi_endio (struct bio *bio,int error) +static void pscsi_bi_endio (struct bio *bio) {bio_put (bio); }
@@ -965,7 +965,7 @@ fail:while (*hbio) { bio = *hbio; *hbio = (*hbio)->bi_next; -bio_endio (bio,0 );/* XXX: should be error */ +bio_endio (bio); }return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ; }
@@ -1104,7 +1104,7 @@ fail_free_bio:while (hbio) {struct bio *bio = hbio; hbio = hbio->bi_next; -bio_endio (bio,0 );/* XXX: should be error */ +bio_endio (bio); } ret =TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ; fail:
fs/btrfs/check-integrity.c +5 -5
@@ -343,7 +343,7 @@ static int btrfsic_process_written_superblock(struct btrfsic_state *state, struct btrfsic_block *const block, struct btrfs_super_block *const super_hdr); -static void btrfsic_bio_end_io (struct bio *bp,int bio_error_status); +static void btrfsic_bio_end_io (struct bio *bp);static void btrfsic_bh_end_io (struct buffer_head *bh,int uptodate); static int btrfsic_is_block_ref_by_superblock(const struct btrfsic_state *state, const struct btrfsic_block *block,
@@ -2207,7 +2207,7 @@ continue_loop: goto again; } -static void btrfsic_bio_end_io (struct bio *bp,int bio_error_status) +static void btrfsic_bio_end_io (struct bio *bp) {struct btrfsic_block *block = (struct btrfsic_block *)bp->bi_private;int iodone_w_error;
@@ -2215,7 +2215,7 @@ static void btrfsic_bio_end_io(struct bio *bp, int bio_error_status)/* mutex is not held! This is not save if IO is not yet completed * on umount */ iodone_w_error =0 ; -if (bio_error_status) +if (bp->bi_error) iodone_w_error =1 ;BUG_ON (NULL == block);
@@ -2230,7 +2230,7 @@ static void btrfsic_bio_end_io(struct bio *bp, int bio_error_status) BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) printk(KERN_INFO"bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n" , - bio_error_status, + bp->bi_error,btrfsic_get_block_type (dev_state->state, block), block->logical_bytenr, dev_state->name, block->dev_bytenr, block->mirror_num);
@@ -2252,7 +2252,7 @@ static void btrfsic_bio_end_io(struct bio *bp, int bio_error_status) block = next_block; }while (NULL != block); - bp->bi_end_io (bp, bio_error_status); + bp->bi_end_io (bp); }static void btrfsic_bh_end_io (struct buffer_head *bh,int uptodate)
fs/btrfs/compression.c +14 -10
@@ -152,7 +152,7 @@ fail:* The compressed pages are freed here, and it must be run * in process context */ -static void end_compressed_bio_read (struct bio *bio,int err) +static void end_compressed_bio_read (struct bio *bio) {struct compressed_bio *cb = bio->bi_private;struct inode *inode;
@@ -160,7 +160,7 @@ static void end_compressed_bio_read(struct bio *bio, int err)unsigned long index;int ret; -if (err) +if (bio->bi_error) cb->errors =1 ;/* if there are more bios still pending for this compressed
@@ -210,7 +210,7 @@ csum_failed:bio_for_each_segment_all (bvec, cb->orig_bio, i)SetPageChecked (bvec->bv_page); -bio_endio (cb->orig_bio,0 ); +bio_endio (cb->orig_bio); }/* finally free the cb struct */
@@ -266,7 +266,7 @@ static noinline void end_compressed_writeback(struct inode *inode,* This also calls the writeback end hooks for the file pages so that * metadata and checksums can be updated in the file. */ -static void end_compressed_bio_write (struct bio *bio,int err) +static void end_compressed_bio_write (struct bio *bio) {struct extent_io_tree *tree;struct compressed_bio *cb = bio->bi_private;
@@ -274,7 +274,7 @@ static void end_compressed_bio_write(struct bio *bio, int err)struct page *page;unsigned long index; -if (err) +if (bio->bi_error) cb->errors =1 ;/* if there are more bios still pending for this compressed
@@ -293,7 +293,7 @@ static void end_compressed_bio_write(struct bio *bio, int err) cb->start, cb->start + cb->len -1 ,NULL , - err ? 0 : 1); + bio->bi_error ? 0 : 1); cb->compressed_pages[0 ]->mapping =NULL ;end_compressed_writeback (inode, cb);
@@ -697,8 +697,10 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ret =btrfs_map_bio (root,READ , comp_bio, mirror_num,0 ); -if (ret) -bio_endio (comp_bio, ret); +if (ret) { + bio->bi_error = ret; +bio_endio (comp_bio); + }bio_put (comp_bio);
@@ -724,8 +726,10 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, } ret =btrfs_map_bio (root,READ , comp_bio, mirror_num,0 ); -if (ret) -bio_endio (comp_bio, ret); +if (ret) { + bio->bi_error = ret; +bio_endio (comp_bio); + }bio_put (comp_bio);return 0 ;
fs/btrfs/disk-io.c +19 -16
@@ -703,7 +703,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror)return -EIO ;/* we fixed nothing */ } -static void end_workqueue_bio (struct bio *bio,int err) +static void end_workqueue_bio (struct bio *bio) {struct btrfs_end_io_wq *end_io_wq = bio->bi_private;struct btrfs_fs_info *fs_info;
@@ -711,7 +711,7 @@ static void end_workqueue_bio(struct bio *bio, int err)btrfs_work_func_t func; fs_info = end_io_wq->info; - end_io_wq->error = err; + end_io_wq->error = bio->bi_error;if (bio->bi_rw &REQ_WRITE ) {if (end_io_wq->metadata ==BTRFS_WQ_ENDIO_METADATA ) {
@@ -808,7 +808,8 @@ static void run_one_async_done(struct btrfs_work *work)/* If an error occured we just want to clean up the bio and move on */ if (async->error) { -bio_endio (async->bio, async->error); + async->bio->bi_error = async->error; +bio_endio (async->bio);return ; }
@@ -908,8 +909,10 @@ static int __btree_submit_bio_done(struct inode *inode, int rw, struct bio *bio,* submission context. Just jump into btrfs_map_bio */ ret =btrfs_map_bio (BTRFS_I (inode)->root, rw, bio, mirror_num,1 ); -if (ret) -bio_endio (bio, ret); +if (ret) { + bio->bi_error = ret; +bio_endio (bio); + }return ret; }
@@ -960,10 +963,13 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, __btree_submit_bio_done); } -if (ret) { +if (ret) + goto out_w_error; +return 0 ; + out_w_error: -bio_endio (bio, ret); - } + bio->bi_error = ret; +bio_endio (bio);return ret; }
@@ -1736,16 +1742,15 @@ static void end_workqueue_fn(struct btrfs_work *work) {struct bio *bio;struct btrfs_end_io_wq *end_io_wq; -int error; end_io_wq = container_of(work, struct btrfs_end_io_wq, work); bio = end_io_wq->bio; - error = end_io_wq->error; + bio->bi_error = end_io_wq->error; bio->bi_private = end_io_wq->private; bio->bi_end_io = end_io_wq->end_io;kmem_cache_free (btrfs_end_io_wq_cache, end_io_wq); -bio_endio (bio, error); +bio_endio (bio); }static int cleaner_kthread (void *arg)
@@ -3267,10 +3272,8 @@ static int write_dev_supers(struct btrfs_device *device,* endio for the write_dev_flush, this will wake anyone waiting * for the barrier when it is done */ -static void btrfs_end_empty_barrier (struct bio *bio,int err) +static void btrfs_end_empty_barrier (struct bio *bio) { -if (err) -clear_bit (BIO_UPTODATE , &bio->bi_flags);if (bio->bi_private)complete (bio->bi_private);bio_put (bio);
@@ -3298,8 +3301,8 @@ static int write_dev_flush(struct btrfs_device *device, int wait)wait_for_completion (&device->flush_wait); -if (!bio_flagged (bio,BIO_UPTODATE )) { - ret = -EIO ; +if (bio->bi_error) { + ret = bio->bi_error;btrfs_dev_stat_inc_and_print (device,BTRFS_DEV_STAT_FLUSH_ERRS ); }
fs/btrfs/extent_io.c +12 -18
@@ -2481,7 +2481,7 @@ int end_extent_writepage(struct page *page, int err, u64 start, u64 end)* Scheduling is not allowed, so the extent state tree is expected * to have one and only one object corresponding to this IO. */ -static void end_bio_extent_writepage (struct bio *bio,int err) +static void end_bio_extent_writepage (struct bio *bio) {struct bio_vec *bvec;u64 start;
@@ -2511,7 +2511,7 @@ static void end_bio_extent_writepage(struct bio *bio, int err) start =page_offset (page); end = start + bvec->bv_offset + bvec->bv_len -1 ; -if (end_extent_writepage (page, err, start, end)) +if (end_extent_writepage (page, bio->bi_error, start, end))continue ;end_page_writeback (page);
@@ -2543,10 +2543,10 @@ endio_readpage_release_extent(struct extent_io_tree *tree, u64 start, u64 len,* Scheduling is not allowed, so the extent state tree is expected * to have one and only one object corresponding to this IO. */ -static void end_bio_extent_readpage (struct bio *bio,int err) +static void end_bio_extent_readpage (struct bio *bio) {struct bio_vec *bvec; -int uptodate =test_bit (BIO_UPTODATE , &bio->bi_flags); +int uptodate = !bio->bi_error;struct btrfs_io_bio *io_bio =btrfs_io_bio (bio);struct extent_io_tree *tree;u64 offset =0 ;
@@ -2559,16 +2559,13 @@ static void end_bio_extent_readpage(struct bio *bio, int err)int ret;int i; -if (err) - uptodate =0 ; -bio_for_each_segment_all (bvec, bio, i) {struct page *page = bvec->bv_page;struct inode *inode = page->mapping->host;pr_debug ("end_bio_extent_readpage: bi_sector=%llu, err=%d, " -"mirror=%u\n" , (u64 )bio->bi_iter.bi_sector, err, - io_bio->mirror_num); +"mirror=%u\n" , (u64 )bio->bi_iter.bi_sector, + bio->bi_error, io_bio->mirror_num); tree = &BTRFS_I (inode)->io_tree;/* We always issue full-page reads, but if some block
@@ -2609,8 +2606,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)if (tree->ops && tree->ops->readpage_io_failed_hook) { ret = tree->ops->readpage_io_failed_hook (page, mirror); -if (!ret && !err && -test_bit (BIO_UPTODATE , &bio->bi_flags)) +if (!ret && !bio->bi_error) uptodate =1 ; }else {/*
@@ -2626,10 +2622,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err) ret =bio_readpage_error (bio, offset, page, start, end, mirror);if (ret ==0 ) { - uptodate = -test_bit (BIO_UPTODATE , &bio->bi_flags); -if (err) - uptodate =0 ; + uptodate = !bio->bi_error; offset += len;continue ; }
@@ -2679,7 +2672,7 @@ readpage_ok:endio_readpage_release_extent (tree, extent_start, extent_len, uptodate);if (io_bio->end_io) - io_bio->end_io (io_bio, err); + io_bio->end_io (io_bio, bio->bi_error);bio_put (bio); }
@@ -3691,7 +3684,7 @@ static void set_btree_ioerr(struct page *page) } } -static void end_bio_extent_buffer_writepage (struct bio *bio,int err) +static void end_bio_extent_buffer_writepage (struct bio *bio) {struct bio_vec *bvec;struct extent_buffer *eb;
@@ -3704,7 +3697,8 @@ static void end_bio_extent_buffer_writepage(struct bio *bio, int err)BUG_ON (!eb); done =atomic_dec_and_test (&eb->io_pages); -if (err ||test_bit (EXTENT_BUFFER_WRITE_ERR , &eb->bflags)) { +if (bio->bi_error || +test_bit (EXTENT_BUFFER_WRITE_ERR , &eb->bflags)) {ClearPageUptodate (page);set_btree_ioerr (page); }
fs/btrfs/inode.c +26 -24
144 lines not on this page · raw message
fs/btrfs/raid56.c +28 -34
48 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.1
Part of the diff is not shown here. View the raw message.
Re: [dm-devel] [PATCH] block: add a bi_error field to struct bio
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" == Christoph Hellwig <[email protected]> writes:
Christoph> The first one has the drawback of only communicating a single Christoph> possible error (-EIO), and the second one has the drawback of Christoph> not beeing persistent when bios are queued up, and are not Christoph> passed along from child to parent bio in the ever more Christoph> popular chaining scenario.
Christoph> So add a new bi_error field to store an errno value directly Christoph> in struct bio and remove the existing mechanisms to clean all Christoph> this up.
Having the error status separate from the bio has been a major headache. I am entirely in favor of this patch.
It was a big chunk of changes to read through but I did not spot any obvious problems or polarity reversals. It would be nice to get the respective fs/md/target driver folks to check their portions, though.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: block: add a bi_error field to struct bio
In reply to Christoph HellwigQuoted 14 lines · Christoph Hellwig
Currently we have two different ways to signal an I/O error on a BIO:
(1) by clearing the
BIO_UPTODATEflag
(2) by returning a Linux errno value to thebi_end_iocallbackThe first one has the drawback of only communicating a single possible error (
-EIO), and the second one has the drawback of not beeing persistent when bios are queued up, and are not passed along from child to parent bio in the ever more popular chaining scenario. Having both mechanisms available has the additional drawback of utterly confusing driver authors and introducing bugs where various I/O submitters only deal with one of them, and the others have to add boilerplate code to deal with both kinds of error returns.
Quoted 4 lines
So add a new
bi_errorfield to store an errno value directly in struct bio and remove the existing mechanisms to clean all this up.Signed-off-by Christoph Hellwig <[email protected]>
This patch _really_ concerns me because just in DM alone I found you took liberties that you shouldn't have and created a regression. First issue is a real bug (your proposed dm-io.c:dmio_complete change missed that dm-io uses error_bits and not traditional error code like expected) the other issue being you added extra branching that isn't needed and made review more tedious (dm.c:clone_endio).
I'll defer to others to check their respective areas of expertise but my experience with this review should really underscore the need for more eyes on this patch. That said, I do appreciate your effort on cleaning this up!
For DM, please add Signed-off-by: Mike Snitzer <[email protected]> once you've folded in this patch, thanks!
drivers/md/dm-bufio.c +2 -1
@@ -545,7 +545,8 @@ static void dmio_complete(unsigned long error, void *context) {struct dm_buffer *b = context; - b->bio.bi_end_io (&b->bio, error ? -EIO :0 ); + b->bio.bi_error = error ? -EIO :0 ; + b->bio.bi_end_io (&b->bio); } static void use_dmio(struct dm_buffer *b, int rw, sector_t block,
drivers/md/dm.c +5 -8
@@ -954,25 +954,22 @@ static void disable_write_same(struct mapped_device *md) limits->max_write_same_sectors =0 ; } -static void clone_endio (struct bio *bio,int error) +static void clone_endio (struct bio *bio) { -int r = error; +int r = bio->bi_error; struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);struct dm_io *io = tio->io;struct mapped_device *md = tio->io->md;dm_endio_fn endio = tio->ti->type->end_io; -if (!bio_flagged (bio,BIO_UPTODATE ) && !error) - error = -EIO ; -if (endio) { - r =endio (tio->ti, bio, error); + r =endio (tio->ti, bio, bio->bi_error);if (r <0 || r ==DM_ENDIO_REQUEUE )/* * error and requeue request are handled * in dec_pending(). */ - error = r; + ;else if (r ==DM_ENDIO_INCOMPLETE )/* The target will handle the io */ return ;
@@ -987,7 +984,7 @@ static void clone_endio(struct bio *bio, int error)disable_write_same (md);free_tio (md, tio); -dec_pending (io, error); +dec_pending (io, r); }static struct dm_rq_target_io *tio_from_request (struct request *rq)
Re: block: add a bi_error field to struct bio
Quoted 4 lines · Mike Snitzer
This patch _really_ concerns me because just in DM alone I found you took liberties that you shouldn't have and created a regression. First issue is a real bug (your proposed dm-io.c:dmio_complete change missed that dm-io uses
error_bitsand not traditional error code like expected)
Point taken. I already wanted to complain about the mess due to the bio error abuse with it's own values in DM in the first posting, guess I need to add that to the second one. I don't think overloading common interfaces with your private error codes is a good idea, but let's leave that for a separate discussion.
Quoted 2 lines
the other issue being you added extra branching that isn't needed and made review more tedious (dm.c:clone_endio).
I think the code is better than what it was before, but it's still a bit of a mess. What do you think of the patch below which I'd like to add before the big bi_error patch as a preparatory one?
Quoted 2 lines
For DM, please add Signed-off-by: Mike Snitzer <[email protected]> once you've folded in this patch, thanks!
FYI, that wasn't a foldable patch but updated hunks of the old one. Not really a problem, but a little confusing.
From f095cbeba5135afa6cf102718319f0d0c1e7b422 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Wed, 10 Jun 2015 10:04:45 +0200
Subject: dm: use a single error code variable in clone_endio
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
clone_endio currently uses two variables for tracking error state, with values getting bounceѕ forth and back between the two, which makes the code hard to read.
--- drivers/md/dm.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/md/dm.c +10 -12
@@ -956,7 +956,6 @@ static void disable_write_same(struct mapped_device *md)static void clone_endio (struct bio *bio,int error) { -int r = error; struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);struct dm_io *io = tio->io;struct mapped_device *md = tio->io->md;
@@ -966,23 +965,22 @@ static void clone_endio(struct bio *bio, int error) error = -EIO ;if (endio) { - r =endio (tio->ti, bio, error); -if (r <0 || r ==DM_ENDIO_REQUEUE ) -/* -* error and requeue request are handled -* in dec_pending(). -*/ - error = r; -else if (r ==DM_ENDIO_INCOMPLETE ) + error =endio (tio->ti, bio, error); +if (error ==DM_ENDIO_INCOMPLETE ) {/* The target will handle the io */ return ; -else if (r) { -DMWARN ("unimplemented target endio return value: %d" , r); + } + +if (error >0 && error !=DM_ENDIO_REQUEUE ) { +DMWARN ("unimplemented target endio return value: %d" , + error);BUG (); } + +/* Error and requeue request are handled in dec_pending(). */ } -if (unlikely (r == -EREMOTEIO && (bio->bi_rw &REQ_WRITE_SAME ) && +if (unlikely (error == -EREMOTEIO && (bio->bi_rw &REQ_WRITE_SAME ) && !bdev_get_queue (bio->bi_bdev)->limits.max_write_same_sectors))disable_write_same (md);
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: block: add a bi_error field to struct bio
Quoted 11 lines · Christoph Hellwig
Quoted 4 lines · Mike Snitzer
This patch _really_ concerns me because just in DM alone I found you took liberties that you shouldn't have and created a regression. First issue is a real bug (your proposed dm-io.c:dmio_complete change missed that dm-io uses
error_bitsand not traditional error code like expected)Point taken. I already wanted to complain about the mess due to the bio error abuse with it's own values in DM in the first posting, guess I need to add that to the second one. I don't think overloading common interfaces with your private error codes is a good idea, but let's leave that for a separate discussion.
I'll queue a patch to rename 'error' to 'error_bits' where appropriate.
Quoted 6 lines
Quoted 2 lines
the other issue being you added extra branching that isn't needed and made review more tedious (dm.c:clone_endio).
I think the code is better than what it was before, but it's still a bit of a mess. What do you think of the patch below which I'd like to add before the big
bi_errorpatch as a preparatory one?
If you're referring to the mix of error variables I totally agree. Just don't think we need the extra branching.
Quoted 5 lines
Quoted 2 lines
For DM, please add Signed-off-by: Mike Snitzer <[email protected]> once you've folded in this patch, thanks!
FYI, that wasn't a foldable patch but updated hunks of the old one. Not really a problem, but a little confusing.
Yeap, should have been clearer they were meant to replace your hunks.
Quoted 65 lines
Quoted 1 line
From
f095cbeba5135afa6cf102718319f0d0c1e7b422Mon Sep 17 00:00:00 2001From: Christoph Hellwig <[email protected]>
Date: Wed, 10 Jun 2015 10:04:45 +0200
Subject: dm: use a single error code variable inclone_endio
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
clone_endiocurrently uses two variables for tracking error state, with values getting bounceѕ forth and back between the two, which makes the code hard to read.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/md/dm.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)drivers/md/dm.c +10
-12@@ -956,7 +956,6 @@ static void disable_write_same(struct mapped_device *md)static void clone_endio (struct bio *bio,int error) { -int r = error; struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);struct dm_io *io = tio->io;struct mapped_device *md = tio->io->md;@@ -966,23 +965,22 @@ static void clone_endio(struct bio *bio, int error) error = -EIO ;if (endio) { - r =endio (tio->ti, bio, error); -if (r <0 || r ==DM_ENDIO_REQUEUE ) -/* -* error and requeue request are handled -* in dec_pending(). -*/ - error = r; -else if (r ==DM_ENDIO_INCOMPLETE ) + error =endio (tio->ti, bio, error); +if (error ==DM_ENDIO_INCOMPLETE ) {/* The target will handle the io */ return ; -else if (r) { -DMWARN ("unimplemented target endio return value: %d" , r); + } + +if (error >0 && error !=DM_ENDIO_REQUEUE ) { +DMWARN ("unimplemented target endio return value: %d" , + error);BUG (); } + +/* Error and requeue request are handled in dec_pending(). */ } -if (unlikely (r == -EREMOTEIO && (bio->bi_rw &REQ_WRITE_SAME ) && +if (unlikely (error == -EREMOTEIO && (bio->bi_rw &REQ_WRITE_SAME ) && !bdev_get_queue (bio->bi_bdev)->limits.max_write_same_sectors))disable_write_same (md);Signature · 1 line
1.9.1
Unfortunately by dropping the original error (e.g. -EREMOTEIO) on the floor (in the 'if (endio) {' branch) you're breaking the REQ_WRITE_SAME check.
Your new bi_error patch gets away with the redundant error code cleanup because we can directly check the bio's bi_error for -EREMOTEIO. So feel free to fold the simplified 'if (error > 0 && error != DM_ENDIO_REQUEUE) {' in to your new patch -- but not seeing the point of making this prep patch in advance.
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: block: add a bi_error field to struct bio
Quoted 9 lines · Mike Snitzer
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Mike Snitzer
This patch _really_ concerns me because just in DM alone I found you took liberties that you shouldn't have and created a regression. First issue is a real bug (your proposed dm-io.c:dmio_complete change missed that dm-io uses
error_bitsand not traditional error code like expected)
Quoted 7 lines
Quoted 5 lines
Point taken. I already wanted to complain about the mess due to the bio error abuse with it's own values in DM in the first posting, guess I need to add that to the second one. I don't think overloading common interfaces with your private error codes is a good idea, but let's leave that for a separate discussion.
I'll queue a patch to rename 'error' to '
error_bits' where appropriate.
Re: block: add a bi_error field to struct bio
Quoted 3 lines · Mike Snitzer
Quoted 1 line
I'll queue a patch to rename 'error' to '
error_bits' where appropriate.
Can we wait with this until we're done with bi_error?
Re: block: add a bi_error field to struct bio
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Mike Snitzer
Quoted 1 line
I'll queue a patch to rename 'error' to '
error_bits' where appropriate.Can we wait with this until we're done with
bi_error?
Sure, I've moved it out to dm-4.3
Re: block: add a bi_error field to struct bio
So Is it safe to use raid 6 with btrfs for home storage now? I will have backup on ZFS.
Quoted 15 lines · Mike Snitzer
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Mike Snitzer
Quoted 1 line
I'll queue a patch to rename 'error' to '
error_bits' where appropriate.Can we wait with this until we're done with
bi_error?Sure, I've moved it out to dm-4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: block: add a bi_error field to struct bio
In reply to Mike SnitzerQuoted 3 lines · Mike Snitzer
Unfortunately by dropping the original error (e.g.
-EREMOTEIO) on the floor (in the 'if (endio) {' branch) you're breaking theREQ_WRITE_SAMEcheck.
I think this also happens in the old code before my patch, e.g.:
static void clone_endio(struct bio *bio, int error)
{
int r = error;
...
if (endio) {
r = endio(tio->ti, bio, error);
...
}
if (unlikely(r == -EREMOTEIO && (bio->bi_rw & REQ_WRITE_SAME) &&so we already check the return value that comes from the endio handler, not any different from my patch.
In the original code r and error are basically always the same, execept after this:
if (!bio_flagged(bio, BIO_UPTODATE) && !error) error = -EIO;
error might be -EIO and r might be 0. Now if we take the endio branch we replace both error and r with the return value of endio for all branches that don't immediately return or BUG(). For the non endio branch we might check in REQ_WRITE_SAME branch, but r can only be -EREMOTEIO if it got that value from error, so it doesn't matter which one we test there.
Based on that I'm pretty sure my prep patch is transformation that does not change behavior.
Re: block: add a bi_error field to struct bio
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Mike Snitzer
Unfortunately by dropping the original error (e.g.
-EREMOTEIO) on the floor (in the 'if (endio) {' branch) you're breaking theREQ_WRITE_SAMEcheck.I think this also happens in the old code before my patch, e.g.:
Ok, after and audit of the instance I noticed that returning 0 from ->end_io even if an error is passed is a valid calling convention, and with that the below analysis is invalid. I'll take it back and will do the simplest possible conversion for now and return my attention to sorting out this mess later.
Re: [dm-devel] [PATCH] block: add a bi_error field to struct bio
In reply to Christoph HellwigQuoted 14 lines · On Wed, 3 Jun 2015 15:42:39 +0200 Christoph Hellwig <[email protected]> wrote:
Currently we have two different ways to signal an I/O error on a BIO:
(1) by clearing the
BIO_UPTODATEflag
(2) by returning a Linux errno value to thebi_end_iocallbackThe first one has the drawback of only communicating a single possible error (
-EIO), and the second one has the drawback of not beeing persistent when bios are queued up, and are not passed along from child to parent bio in the ever more popular chaining scenario. Having both mechanisms available has the additional drawback of utterly confusing driver authors and introducing bugs where various I/O submitters only deal with one of them, and the others have to add boilerplate code to deal with both kinds of error returns.
Quoted 4 lines
So add a new
bi_errorfield to store an errno value directly in struct bio and remove the existing mechanisms to clean all this up.Signed-off-by Christoph Hellwig <[email protected]>
I really like this clean up.
It is unfortunate that the patch is so big, but I guess it has to be.
It mostly looks good, but review is hard and testing is harder :-(
I found:
Quoted 4 lines
drivers/md/raid1.c +0
-0
....
drivers/md/raid1.c static void end_sync_write(struct bio *bio, int error) · line 1805
Quoted 9 lines
drivers/md/raid1.c +1
-1@@ -1800,7 +1799,7 @@ static void end_sync_write(struct bio *bio, int error)reschedule_retry (r1_bio); else {put_buf (r1_bio); -md_done_sync (mddev, s, uptodate); +md_done_sync (mddev, s, !bio->bi_error); } } }
This introduces a use-after-free. put_buf(r1_bio) can result in bio_put on 'bio'.
It is safe to move the put_buf call after the md_done_sync(), but it is probably best to leave the 'update' variable as it. i.e. Just change:
- int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
+ int uptodate = !bio->bi_error;
I can't see any other problems with the md changes.
Thanks,
NeilBrown
Re: [dm-devel] [PATCH] block: add a bi_error field to struct bio
Quoted 10 lines · Neil Brown
This introduces a use-after-free.
put_buf(r1_bio)can result inbio_puton 'bio'.
It is safe to move theput_bufcall after themd_done_sync(), but it is probably best to leave the 'update' variable as it. i.e. Just change:(quoted diff) +1
-1- int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); + int uptodate = !bio->bi_error;I can't see any other problems with the md changes.
Thanks, I'll keep the local uptodate variable for now.
Liu Bo
Reviewed-byQuoted 7 lines · Christoph Hellwig
Bio error reporting has been a mess for a while, and the increasing use of chained bios makes it worse.
This series attempts to add a proper error field to struct bio to sort this out. It's working fine for me, but MD and btrfs were doing pretty nasty things with the
BIO_UPTODATEflag, so I would appreciate some detailed review there.
Somehow the patch is missing from my mailbox, but this cover letter remains, I have to review it from online archive.
Anyway, I went through btrfs part and it looks good.
Thanks,
-liubo
Quoted 9 lines · Liu Bo
Quoted 7 lines · Christoph Hellwig
Bio error reporting has been a mess for a while, and the increasing use of chained bios makes it worse.
This series attempts to add a proper error field to struct bio to sort this out. It's working fine for me, but MD and btrfs were doing pretty nasty things with the
BIO_UPTODATEflag, so I would appreciate some detailed review there.
Quoted 6 lines
Somehow the patch is missing from my mailbox, but this cover letter remains, I have to review it from online archive.
Anyway, I went through btrfs part and it looks good.
Reviewed-by Liu Bo <[email protected]> (btrfs part)
Also there're some conflicts in btrfs_end_empty_barrier():
...
static void btrfs_end_empty_barrier(struct bio *bio, int err)
{
if (err) {
if (err == -EOPNOTSUPP)
set_bit(BIO_EOPNOTSUPP, &bio->bi_flags);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
clear_bit(BIO_UPTODATE, &bio->bi_flags);
}
if (bio->bi_private)
complete(bio->bi_private);
bio_put(bio);
}Thanks,
-liubo
Quoted 3 lines · Liu Bo
Quoted 1 line
Reviewed-by Liu Bo <[email protected]> (btrfs part)Also there're some conflicts in
btrfs_end_empty_barrier():
Hi Liu,
BIO_EOPNOTSUPP has been removed in the block tree:
http://git.kernel.dk/?p=linux-block.git;a=commitdiff;h=b25de9d6da49b1a8760a89672283128aa8c78345
Quoted 11 lines · Christoph Hellwig
Quoted 3 lines · Liu Bo
Quoted 1 line
Reviewed-by Liu Bo <[email protected]> (btrfs part)Also there're some conflicts in
btrfs_end_empty_barrier():Hi Liu,
BIO_EOPNOTSUPPhas been removed in the block tree:http://git.kernel.dk/?p=linux-block.git;a=commitdiff;h=b25de9d6da49b1a8760a89672283128aa8c78345
OK, we're good now.
Thanks,
-liubo