Skip to content

Commit 41fa722

Browse files
Christoph Hellwigaxboe
authored andcommitted
blk-mq: do not include passthrough requests in I/O accounting
I/O accounting buckets I/O into the read/write/discard categories into which passthrough I/O does not fit at all. It also accounts to the block_device, which may not even exist for passthrough I/O. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20220308055200.735835-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 4e5cc99 commit 41fa722

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

block/blk-mq.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,10 +884,15 @@ static inline void blk_account_io_done(struct request *req, u64 now)
884884

885885
static void __blk_account_io_start(struct request *rq)
886886
{
887-
/* passthrough requests can hold bios that do not have ->bi_bdev set */
888-
if (rq->bio && rq->bio->bi_bdev)
887+
/*
888+
* All non-passthrough requests are created from a bio with one
889+
* exception: when a flush command that is part of a flush sequence
890+
* generated by the state machine in blk-flush.c is cloned onto the
891+
* lower device by dm-multipath we can get here without a bio.
892+
*/
893+
if (rq->bio)
889894
rq->part = rq->bio->bi_bdev;
890-
else if (rq->q->disk)
895+
else
891896
rq->part = rq->q->disk->part0;
892897

893898
part_stat_lock();

block/blk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ int blk_dev_init(void);
325325
*/
326326
static inline bool blk_do_io_stat(struct request *rq)
327327
{
328-
return (rq->rq_flags & RQF_IO_STAT) && rq->q->disk;
328+
return (rq->rq_flags & RQF_IO_STAT) && !blk_rq_is_passthrough(rq);
329329
}
330330

331331
void update_io_ticks(struct block_device *part, unsigned long now, bool end);

0 commit comments

Comments
 (0)