Skip to content

Commit 9728463

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix rw req completion
WARNING: at fs/io_uring.c:8578 io_ring_exit_work.cold+0x0/0x18 As reissuing is now passed back by REQ_F_REISSUE and kiocb_done() internally uses __io_complete_rw(), it may stop after setting the flag so leaving a dangling request. There are tricky edge cases, e.g. reading beyound file, boundary, so the easiest way is to hand code reissue in kiocb_done() as __io_complete_rw() was doing for us before. Fixes: 230d50d ("io_uring: move reissue into regular IO path") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/f602250d292f8a84cca9a01d747744d1e797be26.1617842918.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6ad7f23 commit 9728463

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fs/io_uring.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,7 @@ static void kiocb_done(struct kiocb *kiocb, ssize_t ret,
27622762
{
27632763
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);
27642764
struct io_async_rw *io = req->async_data;
2765+
bool check_reissue = kiocb->ki_complete == io_complete_rw;
27652766

27662767
/* add previously done IO, if any */
27672768
if (io && io->bytes_done > 0) {
@@ -2777,6 +2778,18 @@ static void kiocb_done(struct kiocb *kiocb, ssize_t ret,
27772778
__io_complete_rw(req, ret, 0, issue_flags);
27782779
else
27792780
io_rw_done(kiocb, ret);
2781+
2782+
if (check_reissue && req->flags & REQ_F_REISSUE) {
2783+
req->flags &= ~REQ_F_REISSUE;
2784+
if (!io_rw_reissue(req)) {
2785+
int cflags = 0;
2786+
2787+
req_set_fail_links(req);
2788+
if (req->flags & REQ_F_BUFFER_SELECTED)
2789+
cflags = io_put_rw_kbuf(req);
2790+
__io_req_complete(req, issue_flags, ret, cflags);
2791+
}
2792+
}
27802793
}
27812794

27822795
static int io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *iter)

0 commit comments

Comments
 (0)