public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5.10] block: fix inflight statistics of part0
@ 2022-10-13 21:56 Khazhismel Kumykov
  2022-10-16 10:53 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Khazhismel Kumykov @ 2022-10-13 21:56 UTC (permalink / raw)
  To: stable; +Cc: Jeffle Xu, Christoph Hellwig, Jens Axboe, Khazhismel Kumykov

From: Jeffle Xu <jefflexu@linux.alibaba.com>

[ Upstream commit b0d97557ebfc9d5ba5f2939339a9fdd267abafeb ]

The inflight of partition 0 doesn't include inflight IOs to all
sub-partitions, since currently mq calculates inflight of specific
partition by simply camparing the value of the partition pointer.

Thus the following case is possible:

$ cat /sys/block/vda/inflight
       0        0
$ cat /sys/block/vda/vda1/inflight
       0      128

While single queue device (on a previous version, e.g. v3.10) has no
this issue:

$cat /sys/block/sda/sda3/inflight
       0       33
$cat /sys/block/sda/inflight
       0       33

Partition 0 should be specially handled since it represents the whole
disk. This issue is introduced since commit bf0ddaba65dd ("blk-mq: fix
sysfs inflight counter").

Besides, this patch can also fix the inflight statistics of part 0 in
/proc/diskstats. Before this patch, the inflight statistics of part 0
doesn't include that of sub partitions. (I have marked the 'inflight'
field with asterisk.)

$cat /proc/diskstats
 259       0 nvme0n1 45974469 0 367814768 6445794 1 0 1 0 *0* 111062 6445794 0 0 0 0 0 0
 259       2 nvme0n1p1 45974058 0 367797952 6445727 0 0 0 0 *33* 111001 6445727 0 0 0 0 0 0

This is introduced since commit f299b7c7a9de ("blk-mq: provide internal
in-flight variant").

Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[axboe: adapt for 5.11 partition change]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[khazhy: adapt for 5.10 partition]
Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
---
 block/blk-mq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index cfc039fabf8c..e37ba792902a 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -105,7 +105,8 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx,
 {
 	struct mq_inflight *mi = priv;
 
-	if (rq->part == mi->part && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
+	if ((!mi->part->partno || rq->part == mi->part) &&
+	    blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
 		mi->inflight[rq_data_dir(rq)]++;
 
 	return true;
-- 
2.38.0.rc1.362.ged0d419d3c-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v5.10] block: fix inflight statistics of part0
  2022-10-13 21:56 [PATCH v5.10] block: fix inflight statistics of part0 Khazhismel Kumykov
@ 2022-10-16 10:53 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-10-16 10:53 UTC (permalink / raw)
  To: Khazhismel Kumykov
  Cc: stable, Jeffle Xu, Christoph Hellwig, Jens Axboe,
	Khazhismel Kumykov

On Thu, Oct 13, 2022 at 02:56:03PM -0700, Khazhismel Kumykov wrote:
> From: Jeffle Xu <jefflexu@linux.alibaba.com>
> 
> [ Upstream commit b0d97557ebfc9d5ba5f2939339a9fdd267abafeb ]
> 
> The inflight of partition 0 doesn't include inflight IOs to all
> sub-partitions, since currently mq calculates inflight of specific
> partition by simply camparing the value of the partition pointer.
> 
> Thus the following case is possible:
> 
> $ cat /sys/block/vda/inflight
>        0        0
> $ cat /sys/block/vda/vda1/inflight
>        0      128
> 
> While single queue device (on a previous version, e.g. v3.10) has no
> this issue:
> 
> $cat /sys/block/sda/sda3/inflight
>        0       33
> $cat /sys/block/sda/inflight
>        0       33
> 
> Partition 0 should be specially handled since it represents the whole
> disk. This issue is introduced since commit bf0ddaba65dd ("blk-mq: fix
> sysfs inflight counter").
> 
> Besides, this patch can also fix the inflight statistics of part 0 in
> /proc/diskstats. Before this patch, the inflight statistics of part 0
> doesn't include that of sub partitions. (I have marked the 'inflight'
> field with asterisk.)
> 
> $cat /proc/diskstats
>  259       0 nvme0n1 45974469 0 367814768 6445794 1 0 1 0 *0* 111062 6445794 0 0 0 0 0 0
>  259       2 nvme0n1p1 45974058 0 367797952 6445727 0 0 0 0 *33* 111001 6445727 0 0 0 0 0 0
> 
> This is introduced since commit f299b7c7a9de ("blk-mq: provide internal
> in-flight variant").
> 
> Fixes: bf0ddaba65dd ("blk-mq: fix sysfs inflight counter")
> Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant")
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> [axboe: adapt for 5.11 partition change]
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> [khazhy: adapt for 5.10 partition]
> Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
> ---
>  block/blk-mq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-16 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-13 21:56 [PATCH v5.10] block: fix inflight statistics of part0 Khazhismel Kumykov
2022-10-16 10:53 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox