diff mbox series

[2/2] io_uring: punt to workers if file doesn't support async

Message ID 20190503094715.2381-2-source@stbuehler.de (mailing list archive)
State New, archived
Headers show
Series [1/2] io_uring: restructure io_{read,write} control flow | expand

Commit Message

Stefan Bühler May 3, 2019, 9:47 a.m. UTC
If force_nonblock is set we must not try io operations that don't
support async (i.e. are missing the IOCB_NOWAIT flag).

Signed-off-by: Stefan Bühler <source@stbuehler.de>
---
 fs/io_uring.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 52e435a72b6f..1be7fdb65c3f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1064,6 +1064,11 @@  static int io_read(struct io_kiocb *req, const struct sqe_submit *s,
 		return ret;
 	iov_count = iov_iter_count(&iter);
 
+	/* async punt if file doesn't support non-blocking */
+	ret = -EAGAIN;
+	if (force_nonblock && !(kiocb->ki_flags & IOCB_NOWAIT))
+		goto out_free;
+
 	ret = rw_verify_area(READ, file, &kiocb->ki_pos, iov_count);
 	if (ret)
 		goto out_free;
@@ -1109,6 +1114,11 @@  static int io_write(struct io_kiocb *req, const struct sqe_submit *s,
 		return ret;
 	iov_count = iov_iter_count(&iter);
 
+	/* async punt if file doesn't support non-blocking */
+	ret = -EAGAIN;
+	if (force_nonblock && !(kiocb->ki_flags & IOCB_NOWAIT))
+		goto out_free;
+
 	ret = -EAGAIN;
 	if (force_nonblock && !(kiocb->ki_flags & IOCB_DIRECT))
 		goto out_free;