io_uring: return REQ_F_ flags from io_file_get_flags
authorChristoph Hellwig <hch@lst.de>
Tue, 20 Jun 2023 11:32:32 +0000 (13:32 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 20 Jun 2023 15:36:22 +0000 (09:36 -0600)
Two of the three callers want them, so return the more usual format,
and shift into the FFS_ form only for the fixed file table.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230620113235.920399-6-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/filetable.h
io_uring/io_uring.c
io_uring/rw.c

index 351111ff888274e8fddcb7c6c963e74059dae7d4..697cb68adc816981b2e16067fa4dad984605cfd6 100644 (file)
@@ -54,10 +54,8 @@ static inline struct file *io_file_from_index(struct io_file_table *table,
 static inline void io_fixed_file_set(struct io_fixed_file *file_slot,
                                     struct file *file)
 {
-       unsigned long file_ptr = (unsigned long) file;
-
-       file_ptr |= io_file_get_flags(file);
-       file_slot->file_ptr = file_ptr;
+       file_slot->file_ptr = (unsigned long)file |
+               (io_file_get_flags(file) >> REQ_F_SUPPORT_NOWAIT_BIT);
 }
 
 static inline void io_reset_alloc_hint(struct io_ring_ctx *ctx)
index 0e0bdb6ac9a202e12d95e0353a35deb33c9a27f9..1f348753694bfe8eb3fccb25da7c3f6645fa243d 100644 (file)
@@ -425,7 +425,7 @@ static void io_prep_async_work(struct io_kiocb *req)
                req->work.flags |= IO_WQ_WORK_CONCURRENT;
 
        if (req->file && !(req->flags & REQ_F_FIXED_FILE))
-               req->flags |= io_file_get_flags(req->file) << REQ_F_SUPPORT_NOWAIT_BIT;
+               req->flags |= io_file_get_flags(req->file);
 
        if (req->file && (req->flags & REQ_F_ISREG)) {
                bool should_hash = def->hash_reg_file;
@@ -1771,9 +1771,9 @@ unsigned int io_file_get_flags(struct file *file)
        unsigned int res = 0;
 
        if (S_ISREG(file_inode(file)->i_mode))
-               res |= FFS_ISREG;
+               res |= REQ_F_ISREG;
        if ((file->f_flags & O_NONBLOCK) || (file->f_mode & FMODE_NOWAIT))
-               res |= FFS_NOWAIT;
+               res |= REQ_F_SUPPORT_NOWAIT;
        return res;
 }
 
index 1cf5742f2ae9cbe8a41ebd7b76944899e749be86..1bce2208b65c4fe1672ab08e7c6873d23e8c246c 100644 (file)
@@ -667,7 +667,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
                return -EBADF;
 
        if (!(req->flags & REQ_F_FIXED_FILE))
-               req->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT;
+               req->flags |= io_file_get_flags(file);
 
        kiocb->ki_flags = file->f_iocb_flags;
        ret = kiocb_set_rw_flags(kiocb, rw->flags);