This is a note to let you know that I've just added the patch titled io_uring: fix issue with io_write() not always undoing sb_start_write() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-fix-issue-with-io_write-not-always-undoing-sb_start_write.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Mon Aug 29 10:00:25 AM CEST 2022 From: Jens Axboe <axboe@xxxxxxxxx> Date: Thu, 25 Aug 2022 10:19:08 -0600 Subject: io_uring: fix issue with io_write() not always undoing sb_start_write() From: Jens Axboe <axboe@xxxxxxxxx> commit e053aaf4da56cbf0afb33a0fda4a62188e2c0637 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@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/io_uring.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3720,7 +3720,12 @@ done: 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() */ Patches currently in stable-queue which might be from axboe@xxxxxxxxx are queue-5.15/block-add-bdev_max_segments-helper.patch queue-5.15/block-add-a-bdev_max_zone_append_sectors-helper.patch queue-5.15/loop-check-for-overflow-while-configuring-loop.patch queue-5.15/io_uring-fix-issue-with-io_write-not-always-undoing-sb_start_write.patch