io_uring: update kiocb->ki_pos at execution time
authorDylan Yudaken <dylany@fb.com>
Tue, 22 Feb 2022 10:55:02 +0000 (02:55 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jan 2023 06:22:44 +0000 (07:22 +0100)
commitff8a070253d906dc325784ac48fe8bf695b91df6
tree419f08e1442a215b8a121f224dea3daaf4995376
parentb7958caf415b8ebbfce2d39b1f43a70ea8842960
io_uring: update kiocb->ki_pos at execution time

commit d34e1e5b396a0dbaa4a29b7138df662cfb9d8e8e upstream.

Update kiocb->ki_pos at execution time rather than in io_prep_rw().
io_prep_rw() happens before the job is enqueued to a worker and so the
offset might be read multiple times before being executed once.

Ensures that the file position in a set of _linked_ SQEs will be only
obtained after earlier SQEs have completed, and so will include their
incremented file position.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
io_uring/io_uring.c