Skip to content

Commit

Permalink
io_uring: fix issue with io_write() not always undoing sb_start_write()
Browse files Browse the repository at this point in the history
commit e053aaf upstream.

This is actually an older issue, but we never used to hit the -EAGAIN
path before having done sb_start_write(). Make sure that we always call
kiocb_end_write() if we need to retry the write, so that we keep the
calls to sb_start_write() etc balanced.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
axboe authored and gregkh committed Aug 31, 2022
1 parent f8aafb2 commit 295219a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/io_uring.c
Expand Up @@ -3720,7 +3720,12 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
copy_iov:
iov_iter_restore(iter, state);
ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
return ret ?: -EAGAIN;
if (!ret) {
if (kiocb->ki_flags & IOCB_WRITE)
kiocb_end_write(req);
return -EAGAIN;
}
return ret;
}
out_free:
/* it's reportedly faster than delegating the null check to kfree() */
Expand Down

0 comments on commit 295219a

Please sign in to comment.