summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-05-17 14:02:11 +0300
committerJens Axboe <axboe@kernel.dk>2020-05-17 09:22:09 -0600
commit650b548129b60b0d23508351800108196f4aa89f (patch)
tree97d71e8144c7de809786791483fa03edc73f6919 /fs
parent583863ed918136412ddf14de2e12534f17cfdc6f (diff)
downloadlinux-650b548129b60b0d23508351800108196f4aa89f.tar.bz2
io_uring: don't prepare DRAIN reqs twice
If req->io is not NULL, it's already prepared. Don't do it again, it's dangerous. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs')
-rw-r--r--fs/io_uring.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 79c90eb28c0d..51be07390634 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5014,12 +5014,13 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (!req_need_defer(req) && list_empty_careful(&ctx->defer_list))
return 0;
- if (!req->io && io_alloc_async_ctx(req))
- return -EAGAIN;
-
- ret = io_req_defer_prep(req, sqe);
- if (ret < 0)
- return ret;
+ if (!req->io) {
+ if (io_alloc_async_ctx(req))
+ return -EAGAIN;
+ ret = io_req_defer_prep(req, sqe);
+ if (ret < 0)
+ return ret;
+ }
spin_lock_irq(&ctx->completion_lock);
if (!req_need_defer(req) && list_empty(&ctx->defer_list)) {