diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-10-02 13:19:48 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-10-22 08:14:56 -0600 |
commit | 8933805623fafc0e276ddd8110672068c5bd9763 (patch) | |
tree | b3d348a7f7bfb5d79ed31d9a925b97eb730b49a7 /block | |
parent | 42f7652d3eb527d03665b09edac47f85fb600924 (diff) | |
download | lwn-8933805623fafc0e276ddd8110672068c5bd9763.tar.gz lwn-8933805623fafc0e276ddd8110672068c5bd9763.zip |
block: move iostat check into blk_acount_io_start()
Rather than have blk_do_io_stat() check for both RQF_IO_STAT and whether
the request is a passthrough requests every time, move both of those
checks into blk_account_io_start(). Then blk_do_io_stat() can be reduced
to just checking for RQF_IO_STAT.
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-mq.c | 40 | ||||
-rw-r--r-- | block/blk.h | 2 |
2 files changed, 22 insertions, 20 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index cf626e061dd7..6a339942948a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -359,8 +359,6 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, if (data->flags & BLK_MQ_REQ_PM) data->rq_flags |= RQF_PM; - if (blk_queue_io_stat(q)) - data->rq_flags |= RQF_IO_STAT; rq->rq_flags = data->rq_flags; if (data->rq_flags & RQF_SCHED_TAGS) { @@ -1000,24 +998,28 @@ static inline void blk_account_io_start(struct request *req) { trace_block_io_start(req); - if (blk_do_io_stat(req)) { - /* - * All non-passthrough requests are created from a bio with one - * exception: when a flush command that is part of a flush sequence - * generated by the state machine in blk-flush.c is cloned onto the - * lower device by dm-multipath we can get here without a bio. - */ - if (req->bio) - req->part = req->bio->bi_bdev; - else - req->part = req->q->disk->part0; + if (!blk_queue_io_stat(req->q)) + return; + if (blk_rq_is_passthrough(req)) + return; - part_stat_lock(); - update_io_ticks(req->part, jiffies, false); - part_stat_local_inc(req->part, - in_flight[op_is_write(req_op(req))]); - part_stat_unlock(); - } + req->rq_flags |= RQF_IO_STAT; + + /* + * All non-passthrough requests are created from a bio with one + * exception: when a flush command that is part of a flush sequence + * generated by the state machine in blk-flush.c is cloned onto the + * lower device by dm-multipath we can get here without a bio. + */ + if (req->bio) + req->part = req->bio->bi_bdev; + else + req->part = req->q->disk->part0; + + part_stat_lock(); + update_io_ticks(req->part, jiffies, false); + part_stat_local_inc(req->part, in_flight[op_is_write(req_op(req))]); + part_stat_unlock(); } static inline void __blk_mq_end_request_acct(struct request *rq, u64 now) diff --git a/block/blk.h b/block/blk.h index c718e4291db0..84178e535533 100644 --- a/block/blk.h +++ b/block/blk.h @@ -413,7 +413,7 @@ int blk_dev_init(void); */ static inline bool blk_do_io_stat(struct request *rq) { - return (rq->rq_flags & RQF_IO_STAT) && !blk_rq_is_passthrough(rq); + return rq->rq_flags & RQF_IO_STAT; } void update_io_ticks(struct block_device *part, unsigned long now, bool end); |