mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 05:04:09 +08:00
io_uring: ensure REQ_F_ISREG is set async offload
If we're offloading requests directly to io-wq because IOSQE_ASYNC was
set in the sqe, we can miss hashing writes appropriately because we
haven't set REQ_F_ISREG yet. This can cause a performance regression
with buffered writes, as io-wq then no longer correctly serializes writes
to that file.
Ensure that we set the flags in io_prep_async_work(), which will cause
the io-wq work item to be hashed appropriately.
Fixes: 584b0180f0
("io_uring: move read/write file prep state into actual opcode handler")
Link: https://lore.kernel.org/io-uring/20220608080054.GB22428@xsang-OptiPlex-9020/
Reported-by: kernel test robot <oliver.sang@intel.com>
Tested-by: Yin Fengwei <fengwei.yin@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
4f6a94d337
commit
f6b543fd03
@ -406,6 +406,9 @@ static void io_prep_async_work(struct io_kiocb *req)
|
||||
if (req->flags & REQ_F_FORCE_ASYNC)
|
||||
req->work.flags |= IO_WQ_WORK_CONCURRENT;
|
||||
|
||||
if (req->file && !io_req_ffs_set(req))
|
||||
req->flags |= io_file_get_flags(req->file) << REQ_F_SUPPORT_NOWAIT_BIT;
|
||||
|
||||
if (req->flags & REQ_F_ISREG) {
|
||||
if (def->hash_reg_file || (ctx->flags & IORING_SETUP_IOPOLL))
|
||||
io_wq_hash_work(&req->work, file_inode(req->file));
|
||||
|
@ -41,6 +41,11 @@ struct file *io_file_get_normal(struct io_kiocb *req, int fd);
|
||||
struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
|
||||
unsigned issue_flags);
|
||||
|
||||
static inline bool io_req_ffs_set(struct io_kiocb *req)
|
||||
{
|
||||
return req->flags & REQ_F_FIXED_FILE;
|
||||
}
|
||||
|
||||
bool io_is_uring_fops(struct file *file);
|
||||
bool io_alloc_async_data(struct io_kiocb *req);
|
||||
void io_req_task_work_add(struct io_kiocb *req);
|
||||
|
@ -647,11 +647,6 @@ static bool need_read_all(struct io_kiocb *req)
|
||||
S_ISBLK(file_inode(req->file)->i_mode);
|
||||
}
|
||||
|
||||
static inline bool io_req_ffs_set(struct io_kiocb *req)
|
||||
{
|
||||
return req->flags & REQ_F_FIXED_FILE;
|
||||
}
|
||||
|
||||
static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
|
||||
{
|
||||
struct io_rw *rw = io_kiocb_to_cmd(req);
|
||||
|
Loading…
Reference in New Issue
Block a user