diff options
-rw-r--r-- | block/ll_rw_blk.c | 25 | ||||
-rw-r--r-- | include/linux/blkdev.h | 8 |
2 files changed, 30 insertions, 3 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 5c01911af47c..8b2b2509f60e 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c | |||
@@ -3723,13 +3723,32 @@ static inline void __end_request(struct request *rq, int uptodate, | |||
3723 | } | 3723 | } |
3724 | } | 3724 | } |
3725 | 3725 | ||
3726 | static unsigned int rq_byte_size(struct request *rq) | 3726 | /** |
3727 | * blk_rq_bytes - Returns bytes left to complete in the entire request | ||
3728 | **/ | ||
3729 | unsigned int blk_rq_bytes(struct request *rq) | ||
3727 | { | 3730 | { |
3728 | if (blk_fs_request(rq)) | 3731 | if (blk_fs_request(rq)) |
3729 | return rq->hard_nr_sectors << 9; | 3732 | return rq->hard_nr_sectors << 9; |
3730 | 3733 | ||
3731 | return rq->data_len; | 3734 | return rq->data_len; |
3732 | } | 3735 | } |
3736 | EXPORT_SYMBOL_GPL(blk_rq_bytes); | ||
3737 | |||
3738 | /** | ||
3739 | * blk_rq_cur_bytes - Returns bytes left to complete in the current segment | ||
3740 | **/ | ||
3741 | unsigned int blk_rq_cur_bytes(struct request *rq) | ||
3742 | { | ||
3743 | if (blk_fs_request(rq)) | ||
3744 | return rq->current_nr_sectors << 9; | ||
3745 | |||
3746 | if (rq->bio) | ||
3747 | return rq->bio->bi_size; | ||
3748 | |||
3749 | return rq->data_len; | ||
3750 | } | ||
3751 | EXPORT_SYMBOL_GPL(blk_rq_cur_bytes); | ||
3733 | 3752 | ||
3734 | /** | 3753 | /** |
3735 | * end_queued_request - end all I/O on a queued request | 3754 | * end_queued_request - end all I/O on a queued request |
@@ -3744,7 +3763,7 @@ static unsigned int rq_byte_size(struct request *rq) | |||
3744 | **/ | 3763 | **/ |
3745 | void end_queued_request(struct request *rq, int uptodate) | 3764 | void end_queued_request(struct request *rq, int uptodate) |
3746 | { | 3765 | { |
3747 | __end_request(rq, uptodate, rq_byte_size(rq), 1); | 3766 | __end_request(rq, uptodate, blk_rq_bytes(rq), 1); |
3748 | } | 3767 | } |
3749 | EXPORT_SYMBOL(end_queued_request); | 3768 | EXPORT_SYMBOL(end_queued_request); |
3750 | 3769 | ||
@@ -3761,7 +3780,7 @@ EXPORT_SYMBOL(end_queued_request); | |||
3761 | **/ | 3780 | **/ |
3762 | void end_dequeued_request(struct request *rq, int uptodate) | 3781 | void end_dequeued_request(struct request *rq, int uptodate) |
3763 | { | 3782 | { |
3764 | __end_request(rq, uptodate, rq_byte_size(rq), 0); | 3783 | __end_request(rq, uptodate, blk_rq_bytes(rq), 0); |
3765 | } | 3784 | } |
3766 | EXPORT_SYMBOL(end_dequeued_request); | 3785 | EXPORT_SYMBOL(end_dequeued_request); |
3767 | 3786 | ||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3b212f02db8d..aa2341df7932 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -737,6 +737,14 @@ extern void end_dequeued_request(struct request *, int); | |||
737 | extern void blk_complete_request(struct request *); | 737 | extern void blk_complete_request(struct request *); |
738 | 738 | ||
739 | /* | 739 | /* |
740 | * blk_end_request() takes bytes instead of sectors as a complete size. | ||
741 | * blk_rq_bytes() returns bytes left to complete in the entire request. | ||
742 | * blk_rq_cur_bytes() returns bytes left to complete in the current segment. | ||
743 | */ | ||
744 | extern unsigned int blk_rq_bytes(struct request *rq); | ||
745 | extern unsigned int blk_rq_cur_bytes(struct request *rq); | ||
746 | |||
747 | /* | ||
740 | * end_that_request_first/chunk() takes an uptodate argument. we account | 748 | * end_that_request_first/chunk() takes an uptodate argument. we account |
741 | * any value <= as an io error. 0 means -EIO for compatability reasons, | 749 | * any value <= as an io error. 0 means -EIO for compatability reasons, |
742 | * any other < 0 value is the direct error type. An uptodate value of | 750 | * any other < 0 value is the direct error type. An uptodate value of |