提交 7ec2ec68 编写于 作者: Z Zhang Wensheng 提交者: Zheng Zengkai

block: update io_ticks when io hang

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4STNX?from=project-issue
CVE: NA

--------------------------------

When the inflight IOs are slow and no new IOs are issued, we expect
iostat could manifest the IO hang problem. However after
commit 5b18b5a7 ("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: 5b18b5a7 ("block: delete part_round_stats and switch to less precise counting")
Signed-off-by: NZhang Wensheng <zhangwensheng5@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 0c093ccd
...@@ -1249,7 +1249,7 @@ unsigned int blk_rq_err_bytes(const struct request *rq) ...@@ -1249,7 +1249,7 @@ unsigned int blk_rq_err_bytes(const struct request *rq)
} }
EXPORT_SYMBOL_GPL(blk_rq_err_bytes); EXPORT_SYMBOL_GPL(blk_rq_err_bytes);
static void update_io_ticks(struct hd_struct *part, unsigned long now, bool end) void update_io_ticks(struct hd_struct *part, unsigned long now, bool end)
{ {
unsigned long stamp; unsigned long stamp;
again: again:
......
...@@ -255,6 +255,8 @@ static inline bool blk_do_io_stat(struct request *rq) ...@@ -255,6 +255,8 @@ static inline bool blk_do_io_stat(struct request *rq)
return rq->rq_disk && (rq->rq_flags & RQF_IO_STAT); return rq->rq_disk && (rq->rq_flags & RQF_IO_STAT);
} }
void update_io_ticks(struct hd_struct *part, unsigned long now, bool end);
static inline void req_set_nomerge(struct request_queue *q, struct request *req) static inline void req_set_nomerge(struct request_queue *q, struct request *req)
{ {
req->cmd_flags |= REQ_NOMERGE; req->cmd_flags |= REQ_NOMERGE;
......
...@@ -1301,12 +1301,17 @@ ssize_t part_stat_show(struct device *dev, ...@@ -1301,12 +1301,17 @@ ssize_t part_stat_show(struct device *dev,
struct disk_stats stat; struct disk_stats stat;
unsigned int inflight; unsigned int inflight;
part_stat_read_all(p, &stat);
if (queue_is_mq(q)) if (queue_is_mq(q))
inflight = blk_mq_in_flight(q, p); inflight = blk_mq_in_flight(q, p);
else else
inflight = part_in_flight(p); inflight = part_in_flight(p);
if (inflight) {
part_stat_lock();
update_io_ticks(p, jiffies, true);
part_stat_unlock();
}
part_stat_read_all(p, &stat);
return sprintf(buf, return sprintf(buf,
"%8lu %8lu %8llu %8u " "%8lu %8lu %8llu %8u "
"%8lu %8lu %8llu %8u " "%8lu %8lu %8llu %8u "
...@@ -1623,12 +1628,17 @@ static int diskstats_show(struct seq_file *seqf, void *v) ...@@ -1623,12 +1628,17 @@ static int diskstats_show(struct seq_file *seqf, void *v)
disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0); disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
while ((hd = disk_part_iter_next(&piter))) { while ((hd = disk_part_iter_next(&piter))) {
part_stat_read_all(hd, &stat);
if (queue_is_mq(gp->queue)) if (queue_is_mq(gp->queue))
inflight = blk_mq_in_flight(gp->queue, hd); inflight = blk_mq_in_flight(gp->queue, hd);
else else
inflight = part_in_flight(hd); inflight = part_in_flight(hd);
if (inflight) {
part_stat_lock();
update_io_ticks(hd, jiffies, true);
part_stat_unlock();
}
part_stat_read_all(hd, &stat);
seq_printf(seqf, "%4d %7d %s " seq_printf(seqf, "%4d %7d %s "
"%lu %lu %lu %u " "%lu %lu %lu %u "
"%lu %lu %lu %u " "%lu %lu %lu %u "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册