* [PATCH for-5.7 0/2] fortify async punt preparation
@ 2020-05-17 11:02 Pavel Begunkov
2020-05-17 11:02 ` [PATCH 1/2] io_uring: don't prepare DRAIN reqs twice Pavel Begunkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-05-17 11:02 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel
[2] fixes FORCE_ASYNC. I don't want to go through every bit, so
not sure whether this is an actual issue with [1], but it's just
safer this way. Please, consider it for-5.7
IMHO, all preparation thing became a bit messy, definitely could use
some rethinking in the future.
Pavel Begunkov (2):
io_uring: don't prepare DRAIN reqs twice
io_uring: fix FORCE_ASYNC req preparation
fs/io_uring.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
--
2.24.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] io_uring: don't prepare DRAIN reqs twice
2020-05-17 11:02 [PATCH for-5.7 0/2] fortify async punt preparation Pavel Begunkov
@ 2020-05-17 11:02 ` Pavel Begunkov
2020-05-17 11:02 ` [PATCH 2/2] io_uring: fix FORCE_ASYNC req preparation Pavel Begunkov
2020-05-17 15:23 ` [PATCH for-5.7 0/2] fortify async punt preparation Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-05-17 11:02 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel
If req->io is not NULL, it's already prepared. Don't do it again,
it's dangerous.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5a19120345e4..9e81781d7632 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5098,12 +5098,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)) {
--
2.24.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] io_uring: fix FORCE_ASYNC req preparation
2020-05-17 11:02 [PATCH for-5.7 0/2] fortify async punt preparation Pavel Begunkov
2020-05-17 11:02 ` [PATCH 1/2] io_uring: don't prepare DRAIN reqs twice Pavel Begunkov
@ 2020-05-17 11:02 ` Pavel Begunkov
2020-05-17 15:23 ` [PATCH for-5.7 0/2] fortify async punt preparation Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-05-17 11:02 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel
As for other not inlined requests, alloc req->io for FORCE_ASYNC reqs,
so they can be prepared properly.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9e81781d7632..3d0a08560689 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5692,9 +5692,15 @@ static void io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe)
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.
--
2.24.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH for-5.7 0/2] fortify async punt preparation
2020-05-17 11:02 [PATCH for-5.7 0/2] fortify async punt preparation Pavel Begunkov
2020-05-17 11:02 ` [PATCH 1/2] io_uring: don't prepare DRAIN reqs twice Pavel Begunkov
2020-05-17 11:02 ` [PATCH 2/2] io_uring: fix FORCE_ASYNC req preparation Pavel Begunkov
@ 2020-05-17 15:23 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2020-05-17 15:23 UTC (permalink / raw)
To: Pavel Begunkov, io-uring, linux-kernel
On 5/17/20 5:02 AM, Pavel Begunkov wrote:
> [2] fixes FORCE_ASYNC. I don't want to go through every bit, so
> not sure whether this is an actual issue with [1], but it's just
> safer this way. Please, consider it for-5.7
LGTM, applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-17 15:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-17 11:02 [PATCH for-5.7 0/2] fortify async punt preparation Pavel Begunkov
2020-05-17 11:02 ` [PATCH 1/2] io_uring: don't prepare DRAIN reqs twice Pavel Begunkov
2020-05-17 11:02 ` [PATCH 2/2] io_uring: fix FORCE_ASYNC req preparation Pavel Begunkov
2020-05-17 15:23 ` [PATCH for-5.7 0/2] fortify async punt preparation Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox