* any file. For now, just ensure that anything potentially problematic is done
  * inline.
  */
-static bool __io_file_supports_nowait(struct file *file)
+static bool __io_file_supports_nowait(struct file *file, umode_t mode)
 {
-       umode_t mode = file_inode(file)->i_mode;
-
        if (S_ISBLK(mode)) {
                if (IS_ENABLED(CONFIG_BLOCK) &&
                    io_bdev_nowait(I_BDEV(file->f_mapping->host)))
        return file->f_mode & FMODE_NOWAIT;
 }
 
+/*
+ * 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 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))
+               res |= FFS_ISREG;
+       if (__io_file_supports_nowait(file, mode))
+               res |= FFS_NOWAIT;
+       return res;
+}
+
 static inline bool io_file_supports_nowait(struct io_kiocb *req)
 {
-       if (likely(req->flags & REQ_F_SUPPORT_NOWAIT))
-               return true;
-       return __io_file_supports_nowait(req->file);
+       return req->flags & REQ_F_SUPPORT_NOWAIT;
 }
 
 static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
        unsigned ioprio;
        int ret;
 
-       if (!io_req_ffs_set(req) && S_ISREG(file_inode(file)->i_mode))
-               req->flags |= REQ_F_ISREG;
+       if (!io_req_ffs_set(req))
+               req->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT;
 
        kiocb->ki_pos = READ_ONCE(sqe->off);
        if (kiocb->ki_pos == -1 && !(file->f_mode & FMODE_STREAM)) {
 {
        unsigned long file_ptr = (unsigned long) file;
 
-       if (__io_file_supports_nowait(file))
-               file_ptr |= FFS_NOWAIT;
-       if (S_ISREG(file_inode(file)->i_mode))
-               file_ptr |= FFS_ISREG;
+       file_ptr |= io_file_get_flags(file);
        file_slot->file_ptr = file_ptr;
 }