block: fix potential IO hang when turning off io_poll
Subsystems (2)
PATCH 1/1 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'.
--- block/blk-sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
block/blk-sysfs.c +4 -1
@@ -430,8 +430,11 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,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; }
Signature · 1 line
2.27.0
Quoted 24 lines · Jeffle Xu
QUEUE_FLAG_POLLflag 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, sinceblk_poll()will return immediately because of clearedQUEUE_FLAG_POLLflag. 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]>--- block/blk-sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)block/blk-sysfs.c +0
-0@@ -430,8 +430,11 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,if (poll_on)
block/blk-sysfs.c static ssize_t queue_poll_store(struct request_queue *q, const char *page, · line 440
Quoted 10 lines
block/blk-sysfs.c +4
-1blk_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; }
Better to place brace to 'if' as well.
Thanks,
Joseph
Quoted 34 lines · Joseph Qi
Quoted 31 lines · Jeffle Xu
QUEUE_FLAG_POLLflag 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, sinceblk_poll()will return immediately because of clearedQUEUE_FLAG_POLLflag. 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]>--- block/blk-sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)block/blk-sysfs.c +4
-1@@ -430,8 +430,11 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,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); + }
Quoted 5 lines
block/blk-sysfs.c static ssize_t queue_poll_store(struct request_queue *q, const char *page, · line 440
Quoted 3 lines
block/blk-sysfs.c +0
-0return ret; }Better to place brace to 'if' as well.
Got it, thanks.
Signature · 2 lines
Thanks, Jeffle
Quoted 10 lines · Jeffle Xu
QUEUE_FLAG_POLLflag 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, sinceblk_poll()will return immediately because of clearedQUEUE_FLAG_POLLflag. 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'.
Applied, thanks. Fixed up the braces.
Signature · 1 line
Jens Axboe