aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2007-09-27 06:46:13 -0400
committerJens Axboe <axboe@carl.home.kernel.dk>2007-10-10 03:25:57 -0400
commit5bb23a688b2de23d7765a1dd439d89c038378978 (patch)
tree15e5e07c28b5aacd19d76ccdd4f7b2b75804d347
parent9cc54d40b8ca01fcefc9151044b6996565061d90 (diff)
Don't decrement bi_size in bio_endio
The only caller of bio_endio that does not pass the full bi_size is end_that_request_first. Also, no ->bi_end_io method is really interested in bi_size being decremented. So move the decrement and related code into ll_rw_blk and merge it with order_bio_endio to form req_bio_endio which does endio functionality specific to request completion. As some ->bi_end_io methods do check bi_size of 0, we set it thus for now, but that will go in the next patch. Signed-off-by: Neil Brown <neilb@suse.de> ### Diffstat output ./block/ll_rw_blk.c | 42 +++++++++++++++++++++++++++--------------- ./fs/bio.c | 23 +++++++++++------------ 2 files changed, 38 insertions(+), 27 deletions(-) diff .prev/block/ll_rw_blk.c ./block/ll_rw_blk.c Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--block/ll_rw_blk.c42
-rw-r--r--fs/bio.c23
2 files changed, 38 insertions, 27 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index dfe0948ec8b2..b55ed0df33f0 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -527,22 +527,36 @@ int blk_do_ordered(struct request_queue *q, struct request **rqp)
527 return 1; 527 return 1;
528} 528}
529 529
530static int ordered_bio_endio(struct request *rq, struct bio *bio, 530static void req_bio_endio(struct request *rq, struct bio *bio,
531 unsigned int nbytes, int error) 531 unsigned int nbytes, int error)
532{ 532{
533 struct request_queue *q = rq->q; 533 struct request_queue *q = rq->q;
534 534
535 if (&q->bar_rq != rq) 535 if (&q->bar_rq != rq) {
536 return 0; 536 if (error)
537 clear_bit(BIO_UPTODATE, &bio->bi_flags);
538 else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
539 error = -EIO;
537 540
538 /* 541 if (unlikely(nbytes > bio->bi_size)) {
539 * Okay, this is the barrier request in progress, just 542 printk("%s: want %u bytes done, only %u left\n",
540 * record the error; 543 __FUNCTION__, nbytes, bio->bi_size);
541 */ 544 nbytes = bio->bi_size;
542 if (error && !q->orderr) 545 }
543 q->orderr = error;
544 546
545 return 1; 547 bio->bi_size -= nbytes;
548 bio->bi_sector += (nbytes >> 9);
549 if (bio->bi_size == 0)
550 bio_endio(bio, bio->bi_size, error);
551 } else {
552
553 /*
554 * Okay, this is the barrier request in progress, just
555 * record the error;
556 */
557 if (error && !q->orderr)
558 q->orderr = error;
559 }
546} 560}
547 561
548/** 562/**
@@ -3388,8 +3402,7 @@ static int __end_that_request_first(struct request *req, int uptodate,
3388 if (nr_bytes >= bio->bi_size) { 3402 if (nr_bytes >= bio->bi_size) {
3389 req->bio = bio->bi_next; 3403 req->bio = bio->bi_next;
3390 nbytes = bio->bi_size; 3404 nbytes = bio->bi_size;
3391 if (!ordered_bio_endio(req, bio, nbytes, error)) 3405 req_bio_endio(req, bio, nbytes, error);
3392 bio_endio(bio, nbytes, error);
3393 next_idx = 0; 3406 next_idx = 0;
3394 bio_nbytes = 0; 3407 bio_nbytes = 0;
3395 } else { 3408 } else {
@@ -3444,8 +3457,7 @@ static int __end_that_request_first(struct request *req, int uptodate,
3444 * if the request wasn't completed, update state 3457 * if the request wasn't completed, update state
3445 */ 3458 */
3446 if (bio_nbytes) { 3459 if (bio_nbytes) {
3447 if (!ordered_bio_endio(req, bio, bio_nbytes, error)) 3460 req_bio_endio(req, bio, bio_nbytes, error);
3448 bio_endio(bio, bio_nbytes, error);
3449 bio->bi_idx += next_idx; 3461 bio->bi_idx += next_idx;
3450 bio_iovec(bio)->bv_offset += nr_bytes; 3462 bio_iovec(bio)->bv_offset += nr_bytes;
3451 bio_iovec(bio)->bv_len -= nr_bytes; 3463 bio_iovec(bio)->bv_len -= nr_bytes;
diff --git a/fs/bio.c b/fs/bio.c
index 5720b940bb5f..3adecd64ff6e 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1006,13 +1006,14 @@ void bio_check_pages_dirty(struct bio *bio)
1006 * @error: error, if any 1006 * @error: error, if any
1007 * 1007 *
1008 * Description: 1008 * Description:
1009 * bio_endio() will end I/O on @bytes_done number of bytes. This may be 1009 * bio_endio() will end I/O on @bytes_done number of bytes. This
1010 * just a partial part of the bio, or it may be the whole bio. bio_endio() 1010 * must always be the whole (remaining) bio. bio_endio() is the
1011 * is the preferred way to end I/O on a bio, it takes care of decrementing 1011 * preferred way to end I/O on a bio, it takes care of clearing
1012 * bi_size and clearing BIO_UPTODATE on error. @error is 0 on success, and 1012 * BIO_UPTODATE on error. @error is 0 on success, and and one of the
1013 * and one of the established -Exxxx (-EIO, for instance) error values in 1013 * established -Exxxx (-EIO, for instance) error values in case
1014 * case something went wrong. Noone should call bi_end_io() directly on 1014 * something went wrong. Noone should call bi_end_io() directly on a
1015 * a bio unless they own it and thus know that it has an end_io function. 1015 * bio unless they own it and thus know that it has an end_io
1016 * function.
1016 **/ 1017 **/
1017void bio_endio(struct bio *bio, unsigned int bytes_done, int error) 1018void bio_endio(struct bio *bio, unsigned int bytes_done, int error)
1018{ 1019{
@@ -1021,16 +1022,14 @@ void bio_endio(struct bio *bio, unsigned int bytes_done, int error)
1021 else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) 1022 else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
1022 error = -EIO; 1023 error = -EIO;
1023 1024
1024 if (unlikely(bytes_done > bio->bi_size)) { 1025 if (unlikely(bytes_done != bio->bi_size)) {
1025 printk("%s: want %u bytes done, only %u left\n", __FUNCTION__, 1026 printk("%s: want %u bytes done, only %u left\n", __FUNCTION__,
1026 bytes_done, bio->bi_size); 1027 bytes_done, bio->bi_size);
1027 bytes_done = bio->bi_size; 1028 bytes_done = bio->bi_size;
1028 } 1029 }
1029 1030
1030 bio->bi_size -= bytes_done; 1031 bio->bi_size = 0; /* expected by some callees - will be removed */
1031 bio->bi_sector += (bytes_done >> 9); 1032 if (bio->bi_end_io)
1032
1033 if (bio->bi_size && bio->bi_end_io)
1034 bio->bi_end_io(bio, bytes_done, error); 1033 bio->bi_end_io(bio, bytes_done, error);
1035} 1034}
1036 1035