io_uring: rely solely on FMODE_NOWAIT fmode_nowait
authorJens Axboe <axboe@kernel.dk>
Tue, 9 May 2023 14:56:01 +0000 (08:56 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 11 May 2023 13:24:07 +0000 (07:24 -0600)
Now that we have both sockets and block devices setting FMODE_NOWAIT
appropriately, we can get rid of all the odd special casing in
__io_file_supports_nowait() and rely soley on FMODE_NOWAIT and
O_NONBLOCK rather than special case sockets and (in particular) bdevs.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index 3bca7a79efda4c40c7eb384a84582ec01bc5c3cb..3ea314a1e7fa7cf6403517c97ea7820a5475e1b9 100644 (file)
@@ -1758,34 +1758,13 @@ static void io_iopoll_req_issued(struct io_kiocb *req, unsigned int issue_flags)
        }
 }
 
-static bool io_bdev_nowait(struct block_device *bdev)
-{
-       return !bdev || bdev_nowait(bdev);
-}
-
 /*
  * 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_nowait(struct file *file, umode_t mode)
+static bool __io_file_supports_nowait(struct file *file)
 {
-       if (S_ISBLK(mode)) {
-               if (IS_ENABLED(CONFIG_BLOCK) &&
-                   io_bdev_nowait(I_BDEV(file->f_mapping->host)))
-                       return true;
-               return false;
-       }
-       if (S_ISSOCK(mode))
-               return true;
-       if (S_ISREG(mode)) {
-               if (IS_ENABLED(CONFIG_BLOCK) &&
-                   io_bdev_nowait(file->f_inode->i_sb->s_bdev) &&
-                   !io_is_uring_fops(file))
-                       return true;
-               return false;
-       }
-
        /* any ->read/write should understand O_NONBLOCK */
        if (file->f_flags & O_NONBLOCK)
                return true;
@@ -1799,12 +1778,11 @@ static bool __io_file_supports_nowait(struct file *file, umode_t mode)
  */
 unsigned int io_file_get_flags(struct file *file)
 {
-       umode_t mode = file_inode(file)->i_mode;
        unsigned int res = 0;
 
-       if (S_ISREG(mode))
+       if (S_ISREG(file_inode(file)->i_mode))
                res |= FFS_ISREG;
-       if (__io_file_supports_nowait(file, mode))
+       if (__io_file_supports_nowait(file))
                res |= FFS_NOWAIT;
        return res;
 }