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 <bijan.mottahedeh@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by Bijan Mottahedeh and committed by Jens Axboe 797f3f53 78912934

Changed files
+2
fs
+2
fs/io_uring.c
··· 1843 1843 if (!force_nonblock) 1844 1844 req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT; 1845 1845 1846 + req->result = 0; 1846 1847 io_size = ret; 1847 1848 if (req->flags & REQ_F_LINK) 1848 1849 req->result = io_size; ··· 1931 1930 if (!force_nonblock) 1932 1931 req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT; 1933 1932 1933 + req->result = 0; 1934 1934 io_size = ret; 1935 1935 if (req->flags & REQ_F_LINK) 1936 1936 req->result = io_size;