From: Pavel Begunkov Date: Sun, 17 May 2020 11:02:12 +0000 (+0300) Subject: io_uring: fix FORCE_ASYNC req preparation X-Git-Tag: v5.6.17~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a04fbca67f33e7d76dcb4779e54b8184f7329c9d;p=thirdparty%2Fkernel%2Fstable.git io_uring: fix FORCE_ASYNC req preparation [ Upstream commit bd2ab18a1d6267446eae1b47dd839050452bdf7f ] As for other not inlined requests, alloc req->io for FORCE_ASYNC reqs, so they can be prepared properly. Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- diff --git a/fs/io_uring.c b/fs/io_uring.c index aa800f70c55ed..504484dc33e40 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4823,9 +4823,15 @@ fail_req: io_double_put_req(req); } } else if (req->flags & REQ_F_FORCE_ASYNC) { - ret = io_req_defer_prep(req, sqe); - if (unlikely(ret < 0)) - goto fail_req; + if (!req->io) { + ret = -EAGAIN; + if (io_alloc_async_ctx(req)) + goto fail_req; + ret = io_req_defer_prep(req, sqe); + if (unlikely(ret < 0)) + goto fail_req; + } + /* * Never try inline submit of IOSQE_ASYNC is set, go straight * to async execution.