Re: [PATCH] block: fix inflight statistics of part0
From: JeffleXu <jefflexu@linux.alibaba.com>
Date: 2020-12-01 01:54:44
The traditional single queue block device has no problem. Following is
the output when I writes to sda3 on version v3.10.
$cat /sys/block/sda/sda3/inflight
0 33
$cat /sys/block/sda/inflight
0 33
On the other hand, we can analyze this from the code. Following code
path for single-queue block device is from v4.19.
1. When reading '/sys/block/sda/inflight', the statistics is actually
fetched from part 0.
part_inflight_show
part_in_flight_rw
inflight[0] = atomic_read(&part->in_flight[0]);
inflight[1] = atomic_read(&part->in_flight[1]);
2. part 0 will always be updated whenever sub partition is updated.
blk_queue_bio
add_acct_request
blk_account_io_start
part_inc_in_flight
atomic_inc(&part->in_flight[rw])
if (part->partno)
atomic_inc(part0.in_flight[rw]);
On 12/1/20 1:05 AM, Christoph Hellwig wrote:On Thu, Nov 26, 2020 at 05:48:33PM +0800, Jeffle Xu wrote:quoted
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 Partition 0 should be specially handled since it represents the whole disk.I'm not sure and can see arguments for either side. In doubt we should stick to historic behavior, can you check what old kernels (especially before blk-mq) did?
-- Thanks, Jeffle