Skip to content

Commit

Permalink
block: fix potential IO hang when turning off io_poll
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
lostjeffle authored and axboe committed Feb 22, 2021
1 parent b357e4a commit 6b09b4d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions block/blk-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 6b09b4d

Please sign in to comment.