aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-log-writes.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-07-20 09:29:37 -0400
committerJens Axboe <axboe@fb.com>2015-07-29 10:55:15 -0400
commit4246a0b63bd8f56a1469b12eafeb875b1041a451 (patch)
tree3281bb158d658ef7f208ad380c0ecee600a5ab5e /drivers/md/dm-log-writes.c
parent0034af036554c39eefd14d835a8ec3496ac46712 (diff)
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. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/md/dm-log-writes.c')
-rw-r--r--drivers/md/dm-log-writes.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
index ad1b049ae2ab..e9d17488d5e3 100644
--- a/drivers/md/dm-log-writes.c
+++ b/drivers/md/dm-log-writes.c
@@ -146,16 +146,16 @@ static void put_io_block(struct log_writes_c *lc)
146 } 146 }
147} 147}
148 148
149static void log_end_io(struct bio *bio, int err) 149static void log_end_io(struct bio *bio)
150{ 150{
151 struct log_writes_c *lc = bio->bi_private; 151 struct log_writes_c *lc = bio->bi_private;
152 struct bio_vec *bvec; 152 struct bio_vec *bvec;
153 int i; 153 int i;
154 154
155 if (err) { 155 if (bio->bi_error) {
156 unsigned long flags; 156 unsigned long flags;
157 157
158 DMERR("Error writing log block, error=%d", err); 158 DMERR("Error writing log block, error=%d", bio->bi_error);
159 spin_lock_irqsave(&lc->blocks_lock, flags); 159 spin_lock_irqsave(&lc->blocks_lock, flags);
160 lc->logging_enabled = false; 160 lc->logging_enabled = false;
161 spin_unlock_irqrestore(&lc->blocks_lock, flags); 161 spin_unlock_irqrestore(&lc->blocks_lock, flags);
@@ -205,7 +205,6 @@ static int write_metadata(struct log_writes_c *lc, void *entry,
205 bio->bi_bdev = lc->logdev->bdev; 205 bio->bi_bdev = lc->logdev->bdev;
206 bio->bi_end_io = log_end_io; 206 bio->bi_end_io = log_end_io;
207 bio->bi_private = lc; 207 bio->bi_private = lc;
208 set_bit(BIO_UPTODATE, &bio->bi_flags);
209 208
210 page = alloc_page(GFP_KERNEL); 209 page = alloc_page(GFP_KERNEL);
211 if (!page) { 210 if (!page) {
@@ -270,7 +269,6 @@ static int log_one_block(struct log_writes_c *lc,
270 bio->bi_bdev = lc->logdev->bdev; 269 bio->bi_bdev = lc->logdev->bdev;
271 bio->bi_end_io = log_end_io; 270 bio->bi_end_io = log_end_io;
272 bio->bi_private = lc; 271 bio->bi_private = lc;
273 set_bit(BIO_UPTODATE, &bio->bi_flags);
274 272
275 for (i = 0; i < block->vec_cnt; i++) { 273 for (i = 0; i < block->vec_cnt; i++) {
276 /* 274 /*
@@ -292,7 +290,6 @@ static int log_one_block(struct log_writes_c *lc,
292 bio->bi_bdev = lc->logdev->bdev; 290 bio->bi_bdev = lc->logdev->bdev;
293 bio->bi_end_io = log_end_io; 291 bio->bi_end_io = log_end_io;
294 bio->bi_private = lc; 292 bio->bi_private = lc;
295 set_bit(BIO_UPTODATE, &bio->bi_flags);
296 293
297 ret = bio_add_page(bio, block->vecs[i].bv_page, 294 ret = bio_add_page(bio, block->vecs[i].bv_page,
298 block->vecs[i].bv_len, 0); 295 block->vecs[i].bv_len, 0);
@@ -606,7 +603,7 @@ static int log_writes_map(struct dm_target *ti, struct bio *bio)
606 WARN_ON(flush_bio || fua_bio); 603 WARN_ON(flush_bio || fua_bio);
607 if (lc->device_supports_discard) 604 if (lc->device_supports_discard)
608 goto map_bio; 605 goto map_bio;
609 bio_endio(bio, 0); 606 bio_endio(bio);
610 return DM_MAPIO_SUBMITTED; 607 return DM_MAPIO_SUBMITTED;
611 } 608 }
612 609