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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 fs/io_uring.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

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);
-- 
2.20.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux