summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorJeffle Xu <jefflexu@linux.alibaba.com>2021-02-22 09:54:52 +0300
committerJens Axboe <axboe@kernel.dk>2021-02-22 16:40:02 +0300
commit6b09b4d33bd964f49d07d3cabfb4204d58cf9811 (patch)
tree7b69248f21d2b2c7db0e8b6f9e8131d8c45515ed /block
parentb357e4a694ac4b95096715df253548f7e1f2723f (diff)
downloadlinux-6b09b4d33bd964f49d07d3cabfb4204d58cf9811.tar.xz
block: fix potential IO hang when turning off io_poll
QUEUE_FLAG_POLL flag will be cleared when turning off 'io_poll', while at that moment there may be IOs stuck in hw queue uncompleted. The following polling routine won't help reap these IOs, since blk_poll() will return immediately because of cleared QUEUE_FLAG_POLL flag. Thus these IOs will hang until they finnaly time out. The hang out can be observed by 'fio --engine=io_uring iodepth=1', while turning off 'io_poll' at the same time. To fix this, freeze and flush the request queue first when turning off 'io_poll'. Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-sysfs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index ae39c7f3d83d..0f4f0c8a7825 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -434,10 +434,13 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
if (ret < 0)
return ret;
- if (poll_on)
+ if (poll_on) {
blk_queue_flag_set(QUEUE_FLAG_POLL, q);
- else
+ } else {
+ blk_mq_freeze_queue(q);
blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
+ blk_mq_unfreeze_queue(q);
+ }
return ret;
}