diff options
author | Kiyoshi Ueda <k-ueda@ct.jp.nec.com> | 2007-12-11 17:41:17 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-01-28 10:35:56 +0100 |
commit | 3b11313a6c2a42425bf06e92528bda6affd58dec (patch) | |
tree | c2d550b2954c106387f1ebe6badb387603002202 /block | |
parent | 336cdb4003200a90f4fc52a4e9ccc2baa570fffb (diff) | |
download | kernel_samsung_smdk4412-3b11313a6c2a42425bf06e92528bda6affd58dec.zip kernel_samsung_smdk4412-3b11313a6c2a42425bf06e92528bda6affd58dec.tar.gz kernel_samsung_smdk4412-3b11313a6c2a42425bf06e92528bda6affd58dec.tar.bz2 |
blk_end_request: add/export functions to get request size (take 4)
This patch adds/exports functions to get the size of request in bytes.
They are useful because blk_end_request interfaces take bytes
as a completed I/O size instead of sectors.
Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/ll_rw_blk.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 5c01911..8b2b250 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, } } -static unsigned int rq_byte_size(struct request *rq) +/** + * blk_rq_bytes - Returns bytes left to complete in the entire request + **/ +unsigned int blk_rq_bytes(struct request *rq) { if (blk_fs_request(rq)) return rq->hard_nr_sectors << 9; return rq->data_len; } +EXPORT_SYMBOL_GPL(blk_rq_bytes); + +/** + * blk_rq_cur_bytes - Returns bytes left to complete in the current segment + **/ +unsigned int blk_rq_cur_bytes(struct request *rq) +{ + if (blk_fs_request(rq)) + return rq->current_nr_sectors << 9; + + if (rq->bio) + return rq->bio->bi_size; + + return rq->data_len; +} +EXPORT_SYMBOL_GPL(blk_rq_cur_bytes); /** * end_queued_request - end all I/O on a queued request @@ -3744,7 +3763,7 @@ static unsigned int rq_byte_size(struct request *rq) **/ void end_queued_request(struct request *rq, int uptodate) { - __end_request(rq, uptodate, rq_byte_size(rq), 1); + __end_request(rq, uptodate, blk_rq_bytes(rq), 1); } EXPORT_SYMBOL(end_queued_request); @@ -3761,7 +3780,7 @@ EXPORT_SYMBOL(end_queued_request); **/ void end_dequeued_request(struct request *rq, int uptodate) { - __end_request(rq, uptodate, rq_byte_size(rq), 0); + __end_request(rq, uptodate, blk_rq_bytes(rq), 0); } EXPORT_SYMBOL(end_dequeued_request); |