Skip to content

Commit 8487f08

Browse files
Christoph Hellwigaxboe
authored andcommitted
io_uring: return REQ_F_ flags from io_file_get_flags
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>
1 parent 3beed23 commit 8487f08

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

io_uring/filetable.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ static inline struct file *io_file_from_index(struct io_file_table *table,
5454
static inline void io_fixed_file_set(struct io_fixed_file *file_slot,
5555
struct file *file)
5656
{
57-
unsigned long file_ptr = (unsigned long) file;
58-
59-
file_ptr |= io_file_get_flags(file);
60-
file_slot->file_ptr = file_ptr;
57+
file_slot->file_ptr = (unsigned long)file |
58+
(io_file_get_flags(file) >> REQ_F_SUPPORT_NOWAIT_BIT);
6159
}
6260

6361
static inline void io_reset_alloc_hint(struct io_ring_ctx *ctx)

io_uring/io_uring.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static void io_prep_async_work(struct io_kiocb *req)
425425
req->work.flags |= IO_WQ_WORK_CONCURRENT;
426426

427427
if (req->file && !(req->flags & REQ_F_FIXED_FILE))
428-
req->flags |= io_file_get_flags(req->file) << REQ_F_SUPPORT_NOWAIT_BIT;
428+
req->flags |= io_file_get_flags(req->file);
429429

430430
if (req->file && (req->flags & REQ_F_ISREG)) {
431431
bool should_hash = def->hash_reg_file;
@@ -1771,9 +1771,9 @@ unsigned int io_file_get_flags(struct file *file)
17711771
unsigned int res = 0;
17721772

17731773
if (S_ISREG(file_inode(file)->i_mode))
1774-
res |= FFS_ISREG;
1774+
res |= REQ_F_ISREG;
17751775
if ((file->f_flags & O_NONBLOCK) || (file->f_mode & FMODE_NOWAIT))
1776-
res |= FFS_NOWAIT;
1776+
res |= REQ_F_SUPPORT_NOWAIT;
17771777
return res;
17781778
}
17791779

io_uring/rw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
667667
return -EBADF;
668668

669669
if (!(req->flags & REQ_F_FIXED_FILE))
670-
req->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT;
670+
req->flags |= io_file_get_flags(file);
671671

672672
kiocb->ki_flags = file->f_iocb_flags;
673673
ret = kiocb_set_rw_flags(kiocb, rw->flags);

0 commit comments

Comments
 (0)