All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeffle Xu <jefflexu@linux.alibaba.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, io-uring@vger.kernel.org,
	joseph.qi@linux.alibaba.com
Subject: [PATCH] block: fix potential IO hang when turning off io_poll
Date: Mon, 22 Feb 2021 14:54:52 +0800	[thread overview]
Message-ID: <20210222065452.21897-1-jefflexu@linux.alibaba.com> (raw)

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>
---
 block/blk-sysfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index b513f1683af0..10d74741c002 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -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;
 }
-- 
2.27.0


             reply	other threads:[~2021-02-22  6:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22  6:54 Jeffle Xu [this message]
2021-02-22  7:12 ` [PATCH] block: fix potential IO hang when turning off io_poll Joseph Qi
2021-02-22  7:46   ` JeffleXu
2021-02-22 13:40 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210222065452.21897-1-jefflexu@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.