diff mbox series

[5/5] io_uring: use FMODE_NOWAIT to detect files supporting IOCB_NOWAIT

Message ID 20190511165727.31599-5-source@stbuehler.de (mailing list archive)
State RFC
Headers show
Series [1/5] fs: RWF flags override default IOCB flags from file flags | expand

Commit Message

Stefan Bühler May 11, 2019, 4:57 p.m. UTC
This replaces the magic check looking for S_ISBLK(mode) ||
S_ISCHR(mode); given the io_uring file doesn't support read/write the
check for io_uring_fops is useless anyway.

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

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index e1c6ab63628f..396ce6804977 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -867,23 +867,6 @@  static struct file *io_file_get(struct io_submit_state *state, int fd)
 	return state->file;
 }
 
-/*
- * If we tracked the file through the SCM inflight mechanism, we could support
- * any file. For now, just ensure that anything potentially problematic is done
- * inline.
- */
-static bool io_file_supports_async(struct file *file)
-{
-	umode_t mode = file_inode(file)->i_mode;
-
-	if (S_ISBLK(mode) || S_ISCHR(mode))
-		return true;
-	if (S_ISREG(mode) && file->f_op != &io_uring_fops)
-		return true;
-
-	return false;
-}
-
 static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s,
 		      bool force_nonblock)
 {
@@ -896,7 +879,13 @@  static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s,
 	if (!req->file)
 		return -EBADF;
 
-	if (force_nonblock && !io_file_supports_async(req->file))
+	/*
+	 * don't set IOCB_NOWAIT if not supported (forces async punt)
+	 *
+	 * we don't punt if NOWAIT is not supported but requested as
+	 * kiocb_set_rw_flags will return EOPNOTSUPP
+	 */
+	if (force_nonblock && !(req->file->f_mode & FMODE_NOWAIT))
 		force_nonblock = false;
 
 	kiocb->ki_pos = READ_ONCE(sqe->off);