Skip to content

Commit 797f3f5

Browse files
Bijan Mottahedehaxboe
authored andcommitted
io_uring: clear req->result always before issuing a read/write request
req->result is cleared when io_issue_sqe() calls io_read/write_pre() routines. Those routines however are not called when the sqe argument is NULL, which is the case when io_issue_sqe() is called from io_wq_submit_work(). io_issue_sqe() may then examine a stale result if a polled request had previously failed with -EAGAIN: if (ctx->flags & IORING_SETUP_IOPOLL) { if (req->result == -EAGAIN) return -EAGAIN; io_iopoll_req_issued(req); } and in turn cause a subsequently completed request to be re-issued in io_wq_submit_work(). Signed-off-by: Bijan Mottahedeh <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 7891293 commit 797f3f5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/io_uring.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,7 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
18431843
if (!force_nonblock)
18441844
req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;
18451845

1846+
req->result = 0;
18461847
io_size = ret;
18471848
if (req->flags & REQ_F_LINK)
18481849
req->result = io_size;
@@ -1930,6 +1931,7 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,
19301931
if (!force_nonblock)
19311932
req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;
19321933

1934+
req->result = 0;
19331935
io_size = ret;
19341936
if (req->flags & REQ_F_LINK)
19351937
req->result = io_size;

0 commit comments

Comments
 (0)