diff mbox series

[02/15] block: don't call blk_throtl_stat_add for non-READ/WRITE commands

Message ID 20230117081257.3089859-3-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/15] blk-cgroup: don't defer blkg_free to a workqueue | expand

Commit Message

Christoph Hellwig Jan. 17, 2023, 8:12 a.m. UTC
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 genisk associated with them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-stat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andreas Herrmann Jan. 20, 2023, 8:55 a.m. UTC | #1
On Tue, Jan 17, 2023 at 09:12:44AM +0100, Christoph Hellwig wrote:
> 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 genisk associated with them.
                ^^^^^^
		gendisk
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-stat.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Looks good to me. Feel free to add
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>

> diff --git a/block/blk-stat.c b/block/blk-stat.c
> index 2ea01b5c1aca04..c6ca16abf911e2 100644
> --- a/block/blk-stat.c
> +++ b/block/blk-stat.c
> @@ -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();
> -- 
> 2.39.0
>
Hannes Reinecke Jan. 27, 2023, 7 a.m. UTC | #2
On 1/17/23 09:12, Christoph Hellwig wrote:
> 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 genisk associated with them.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/blk-stat.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/block/blk-stat.c b/block/blk-stat.c
index 2ea01b5c1aca04..c6ca16abf911e2 100644
--- a/block/blk-stat.c
+++ b/block/blk-stat.c
@@ -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();