diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-04-01 15:44:01 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-04-11 19:30:35 -0600 |
commit | 9a321c98490c70653a4f0a10b28c45edbcf7a93d (patch) | |
tree | d4480095ea1fb00ae265b5a1a672662cf241df43 /fs/io_uring.c | |
parent | 044118069a23fdfb31677631cfdfc5e33b488752 (diff) | |
download | lwn-9a321c98490c70653a4f0a10b28c45edbcf7a93d.tar.gz lwn-9a321c98490c70653a4f0a10b28c45edbcf7a93d.zip |
io_uring: set proper FFS* flags on reg file update
Set FFS_* flags (e.g. FFS_ASYNC_READ) not only in initial registration
but also on registered files update. Not a bug, but may miss getting
profit out of the feature.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/df29a841a2d3d3695b509cdffce5070777d9d942.1617287883.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 5fb664e8ae49..ede9d01efb3b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6292,6 +6292,19 @@ static inline struct file *io_file_from_index(struct io_ring_ctx *ctx, return (struct file *) ((unsigned long) *file_slot & FFS_MASK); } +static void io_fixed_file_set(struct file **file_slot, struct file *file) +{ + unsigned long file_ptr = (unsigned long) file; + + if (__io_file_supports_async(file, READ)) + file_ptr |= FFS_ASYNC_READ; + if (__io_file_supports_async(file, WRITE)) + file_ptr |= FFS_ASYNC_WRITE; + if (S_ISREG(file_inode(file)->i_mode)) + file_ptr |= FFS_ISREG; + *file_slot = (struct file *)file_ptr; +} + static struct file *io_file_get(struct io_submit_state *state, struct io_kiocb *req, int fd, bool fixed) { @@ -7631,8 +7644,6 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg, goto out_free; for (i = 0; i < nr_args; i++, ctx->nr_user_files++) { - unsigned long file_ptr; - if (copy_from_user(&fd, &fds[i], sizeof(fd))) { ret = -EFAULT; goto out_fput; @@ -7657,14 +7668,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg, fput(file); goto out_fput; } - file_ptr = (unsigned long) file; - if (__io_file_supports_async(file, READ)) - file_ptr |= FFS_ASYNC_READ; - if (__io_file_supports_async(file, WRITE)) - file_ptr |= FFS_ASYNC_WRITE; - if (S_ISREG(file_inode(file)->i_mode)) - file_ptr |= FFS_ISREG; - *io_fixed_file_slot(file_data, i) = (struct file *) file_ptr; + io_fixed_file_set(io_fixed_file_slot(file_data, i), file); } ret = io_sqe_files_scm(ctx); @@ -7806,7 +7810,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, err = -EBADF; break; } - *file_slot = file; + io_fixed_file_set(file_slot, file); err = io_sqe_file_register(ctx, file, i); if (err) { *file_slot = NULL; |