diff mbox series

[05/20] block: ensure that async polled IO is marked REQ_NOWAIT

Message ID 20181126164544.5699-6-axboe@kernel.dk (mailing list archive)
State New, archived
Headers show
Series Support for polled aio | expand

Commit Message

Jens Axboe Nov. 26, 2018, 4:45 p.m. UTC
We can't wait for polled events to complete, as they may require active
polling from whoever submitted it. If that is the same task that is
submitting new IO, we could deadlock waiting for IO to complete that
this task is supposed to be completing itself.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/block_dev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9acb26f7c9ec..9580ffe0cf24 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -400,8 +400,16 @@  __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 
 		nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES);
 		if (!nr_pages) {
-			if (iocb->ki_flags & IOCB_HIPRI)
+			if (iocb->ki_flags & IOCB_HIPRI) {
 				bio->bi_opf |= REQ_HIPRI;
+				/*
+				 * For async polled IO, we can't wait for
+				 * requests to complete, as they may also be
+				 * polled and require active reaping.
+				 */
+				if (!is_sync)
+					bio->bi_opf |= REQ_NOWAIT;
+			}
 
 			qc = submit_bio(bio);
 			WRITE_ONCE(iocb->ki_cookie, qc);