block: don't call blk_throtl_stat_add for non-READ/WRITE commands
authorChristoph Hellwig <hch@lst.de>
Fri, 3 Feb 2023 15:03:42 +0000 (16:03 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Feb 2023 15:20:04 +0000 (08:20 -0700)
blk_throtl_stat_add is called from blk_stat_add explicitly, unlike the
other stats that go through q->stats->callbacks.  To prepare for cgroup
data moving to the gendisk, ensure blk_throtl_stat_add is only called
for the plain READ and WRITE commands that it actually handles internally,
as blk_stat_add can also be called for passthrough commands on queues that
do not have a gendisk associated with them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20230203150400.3199230-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-stat.c

index 2ea01b5..c6ca16a 100644 (file)
@@ -58,7 +58,8 @@ void blk_stat_add(struct request *rq, u64 now)
 
        value = (now >= rq->io_start_time_ns) ? now - rq->io_start_time_ns : 0;
 
-       blk_throtl_stat_add(rq, value);
+       if (req_op(rq) == REQ_OP_READ || req_op(rq) == REQ_OP_WRITE)
+               blk_throtl_stat_add(rq, value);
 
        rcu_read_lock();
        cpu = get_cpu();