mirror of
https://github.com/torvalds/linux
synced 2024-10-04 18:33:42 +00:00
io_uring: fix issue with io_write() not always undoing sb_start_write()
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>
This commit is contained in:
parent
4e17aaab54
commit
e053aaf4da
|
@ -945,6 +945,8 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
if (rw)
|
if (rw)
|
||||||
rw->bytes_done += ret2;
|
rw->bytes_done += ret2;
|
||||||
|
|
||||||
|
if (kiocb->ki_flags & IOCB_WRITE)
|
||||||
|
kiocb_end_write(req);
|
||||||
return ret ? ret : -EAGAIN;
|
return ret ? ret : -EAGAIN;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
@ -953,7 +955,12 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
copy_iov:
|
copy_iov:
|
||||||
iov_iter_restore(&s->iter, &s->iter_state);
|
iov_iter_restore(&s->iter, &s->iter_state);
|
||||||
ret = io_setup_async_rw(req, iovec, s, false);
|
ret = io_setup_async_rw(req, iovec, s, false);
|
||||||
return ret ?: -EAGAIN;
|
if (!ret) {
|
||||||
|
if (kiocb->ki_flags & IOCB_WRITE)
|
||||||
|
kiocb_end_write(req);
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
/* it's reportedly faster than delegating the null check to kfree() */
|
/* it's reportedly faster than delegating the null check to kfree() */
|
||||||
if (iovec)
|
if (iovec)
|
||||||
|
|
Loading…
Reference in a new issue