public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: avoid io timeout in case of sync polled dio
@ 2022-04-13  8:48 Ming Lei
  2022-04-13 16:51 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2022-04-13  8:48 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Changhui Zhong

If the bio is marked as POLLED after submission, bio_poll() should be
called for reaping io since there isn't irq for completing the request,
so we can't call into blk_io_schedule() in case that bio_poll() returns
zero.

Also for calling bio_poll(), current->plug has to be flushed out,
otherwise bio may not be issued to driver, and ->bi_cookie won't
be set.

Reported-by: Changhui Zhong <czhong@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/fops.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/fops.c b/block/fops.c
index 9f2ecec406b0..17798aa31bf6 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -101,11 +101,16 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,
 		bio_set_polled(&bio, iocb);
 
 	submit_bio(&bio);
+	/* flush plug list to make sure that bio is issued */
+	if (bio.bi_opf & REQ_POLLED)
+		blk_flush_plug(current->plug, false);
 	for (;;) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (!READ_ONCE(bio.bi_private))
 			break;
-		if (!(iocb->ki_flags & IOCB_HIPRI) || !bio_poll(&bio, NULL, 0))
+		if (bio.bi_opf & REQ_POLLED)
+			bio_poll(&bio, NULL, 0);
+		else
 			blk_io_schedule();
 	}
 	__set_current_state(TASK_RUNNING);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-14  1:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-13  8:48 [PATCH] block: avoid io timeout in case of sync polled dio Ming Lei
2022-04-13 16:51 ` Christoph Hellwig
2022-04-14  1:38   ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox