diff options
author | Christoph Hellwig <hch@lst.de> | 2021-11-17 07:14:01 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-11-29 14:34:51 +0100 |
commit | 450b7879e34517c3ebc3a35a53806fe40e60fac2 (patch) | |
tree | 2437681fff3078cd71bc3f45f854ca785411fe76 /block/blk-mq.c | |
parent | block: move blk_steal_bios to blk-mq.c (diff) | |
download | linux-450b7879e34517c3ebc3a35a53806fe40e60fac2.tar.xz linux-450b7879e34517c3ebc3a35a53806fe40e60fac2.zip |
block: move blk_account_io_{start,done} to blk-mq.c
These are only used for request based I/O, so move them where they are
used.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20211117061404.331732-9-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r-- | block/blk-mq.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index cd5f31c4d2fd..3921c7cfd64c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -809,6 +809,48 @@ bool blk_update_request(struct request *req, blk_status_t error, } EXPORT_SYMBOL_GPL(blk_update_request); +static void __blk_account_io_done(struct request *req, u64 now) +{ + const int sgrp = op_stat_group(req_op(req)); + + part_stat_lock(); + update_io_ticks(req->part, jiffies, true); + part_stat_inc(req->part, ios[sgrp]); + part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns); + part_stat_unlock(); +} + +static inline void blk_account_io_done(struct request *req, u64 now) +{ + /* + * Account IO completion. flush_rq isn't accounted as a + * normal IO on queueing nor completion. Accounting the + * containing request is enough. + */ + if (blk_do_io_stat(req) && req->part && + !(req->rq_flags & RQF_FLUSH_SEQ)) + __blk_account_io_done(req, now); +} + +static void __blk_account_io_start(struct request *rq) +{ + /* passthrough requests can hold bios that do not have ->bi_bdev set */ + if (rq->bio && rq->bio->bi_bdev) + rq->part = rq->bio->bi_bdev; + else + rq->part = rq->rq_disk->part0; + + part_stat_lock(); + update_io_ticks(rq->part, jiffies, false); + part_stat_unlock(); +} + +static inline void blk_account_io_start(struct request *req) +{ + if (blk_do_io_stat(req)) + __blk_account_io_start(req); +} + static inline void __blk_mq_end_request_acct(struct request *rq, u64 now) { if (rq->rq_flags & RQF_STATS) { |