Commit 9fb8cb49 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: refactor provide/remove buffer locking

Always complete request holding the mutex instead of doing that strange
dancing with conditional ordering.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent f41db273
...@@ -3966,14 +3966,9 @@ static int io_remove_buffers(struct io_kiocb *req, unsigned int issue_flags) ...@@ -3966,14 +3966,9 @@ static int io_remove_buffers(struct io_kiocb *req, unsigned int issue_flags)
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
/* need to hold the lock to complete IOPOLL requests */ /* complete before unlock, IOPOLL may need the lock */
if (ctx->flags & IORING_SETUP_IOPOLL) { __io_req_complete(req, issue_flags, ret, 0);
__io_req_complete(req, issue_flags, ret, 0); io_ring_submit_unlock(ctx, !force_nonblock);
io_ring_submit_unlock(ctx, !force_nonblock);
} else {
io_ring_submit_unlock(ctx, !force_nonblock);
__io_req_complete(req, issue_flags, ret, 0);
}
return 0; return 0;
} }
...@@ -4055,15 +4050,9 @@ static int io_provide_buffers(struct io_kiocb *req, unsigned int issue_flags) ...@@ -4055,15 +4050,9 @@ static int io_provide_buffers(struct io_kiocb *req, unsigned int issue_flags)
} }
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
/* complete before unlock, IOPOLL may need the lock */
/* need to hold the lock to complete IOPOLL requests */ __io_req_complete(req, issue_flags, ret, 0);
if (ctx->flags & IORING_SETUP_IOPOLL) { io_ring_submit_unlock(ctx, !force_nonblock);
__io_req_complete(req, issue_flags, ret, 0);
io_ring_submit_unlock(ctx, !force_nonblock);
} else {
io_ring_submit_unlock(ctx, !force_nonblock);
__io_req_complete(req, issue_flags, ret, 0);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment