]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: fix FORCE_ASYNC req preparation
authorPavel Begunkov <asml.silence@gmail.com>
Sun, 17 May 2020 11:02:12 +0000 (14:02 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Jun 2020 11:16:46 +0000 (13:16 +0200)
[ 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 <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/io_uring.c

index aa800f70c55ed4658582f9c32ad98ae94559a5b1..504484dc33e405f51121d3a5e37b117196e9802f 100644 (file)
@@ -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.