Skip to content

Commit 86d7331

Browse files
Zhang Wenshengaxboe
authored andcommitted
block: update io_ticks when io hang
When the inflight IOs are slow and no new IOs are issued, we expect iostat could manifest the IO hang problem. However after commit 5b18b5a ("block: delete part_round_stats and switch to less precise counting"), io_tick and time_in_queue will not be updated until the end of IO, and the avgqu-sz and %util columns of iostat will be zero. Because it has using stat.nsecs accumulation to express time_in_queue which is not suitable to change, and may %util will express the status better when io hang occur. To fix io_ticks, we use update_io_ticks and inflight to update io_ticks when diskstats_show and part_stat_show been called. Fixes: 5b18b5a ("block: delete part_round_stats and switch to less precise counting") Signed-off-by: Zhang Wensheng <zhangwensheng5@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20220217064247.4041435-1-zhangwensheng5@huawei.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8410f70 commit 86d7331

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

block/genhd.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,17 @@ ssize_t part_stat_show(struct device *dev,
919919
struct disk_stats stat;
920920
unsigned int inflight;
921921

922-
part_stat_read_all(bdev, &stat);
923922
if (queue_is_mq(q))
924923
inflight = blk_mq_in_flight(q, bdev);
925924
else
926925
inflight = part_in_flight(bdev);
927926

927+
if (inflight) {
928+
part_stat_lock();
929+
update_io_ticks(bdev, jiffies, true);
930+
part_stat_unlock();
931+
}
932+
part_stat_read_all(bdev, &stat);
928933
return sprintf(buf,
929934
"%8lu %8lu %8llu %8u "
930935
"%8lu %8lu %8llu %8u "
@@ -1184,12 +1189,17 @@ static int diskstats_show(struct seq_file *seqf, void *v)
11841189
xa_for_each(&gp->part_tbl, idx, hd) {
11851190
if (bdev_is_partition(hd) && !bdev_nr_sectors(hd))
11861191
continue;
1187-
part_stat_read_all(hd, &stat);
11881192
if (queue_is_mq(gp->queue))
11891193
inflight = blk_mq_in_flight(gp->queue, hd);
11901194
else
11911195
inflight = part_in_flight(hd);
11921196

1197+
if (inflight) {
1198+
part_stat_lock();
1199+
update_io_ticks(hd, jiffies, true);
1200+
part_stat_unlock();
1201+
}
1202+
part_stat_read_all(hd, &stat);
11931203
seq_printf(seqf, "%4d %7d %pg "
11941204
"%lu %lu %lu %u "
11951205
"%lu %lu %lu %u "

0 commit comments

Comments
 (0)