* [PATCH v2] io_uring: add flag to not fail link after timeout
@ 2021-10-02 8:44 Pavel Begunkov
2021-10-02 14:58 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2021-10-02 8:44 UTC (permalink / raw)
To: Jens Axboe, io-uring; +Cc: asml.silence
For some reason non-off IORING_OP_TIMEOUT always fails links, it's
pretty inconvenient and unnecessary limits chaining after it to hard
linking, which is far from ideal, e.g. doesn't pair well with timeout
cancellation. Prevent it and treat -ETIME as success.
Signed-off-by: Pavel Begunkov <[email protected]>
---
v2: conditional behaviour with a new timeout flag
fs/io_uring.c | 8 ++++++--
include/uapi/linux/io_uring.h | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index c1ad5817b114..98401ec46c12 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5860,7 +5860,10 @@ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags)
static void io_req_task_timeout(struct io_kiocb *req, bool *locked)
{
- req_set_fail(req);
+ struct io_timeout_data *data = req->async_data;
+
+ if (!(data->flags & IORING_TIMEOUT_DONT_FAIL))
+ req_set_fail(req);
io_req_complete_post(req, -ETIME, 0);
}
@@ -6066,7 +6069,8 @@ static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (off && is_timeout_link)
return -EINVAL;
flags = READ_ONCE(sqe->timeout_flags);
- if (flags & ~(IORING_TIMEOUT_ABS | IORING_TIMEOUT_CLOCK_MASK))
+ if (flags & ~(IORING_TIMEOUT_ABS | IORING_TIMEOUT_CLOCK_MASK |
+ IORING_TIMEOUT_DONT_FAIL))
return -EINVAL;
/* more than one clock specified is invalid, obviously */
if (hweight32(flags & IORING_TIMEOUT_CLOCK_MASK) > 1)
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index b270a07b285e..259453ce5f90 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -158,6 +158,7 @@ enum {
#define IORING_TIMEOUT_BOOTTIME (1U << 2)
#define IORING_TIMEOUT_REALTIME (1U << 3)
#define IORING_LINK_TIMEOUT_UPDATE (1U << 4)
+#define IORING_TIMEOUT_DONT_FAIL (1U << 5)
#define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)
#define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)
/*
--
2.33.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] io_uring: add flag to not fail link after timeout
2021-10-02 8:44 [PATCH v2] io_uring: add flag to not fail link after timeout Pavel Begunkov
@ 2021-10-02 14:58 ` Jens Axboe
2021-10-02 16:18 ` Pavel Begunkov
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2021-10-02 14:58 UTC (permalink / raw)
To: Pavel Begunkov, io-uring
On 10/2/21 2:44 AM, Pavel Begunkov wrote:
> For some reason non-off IORING_OP_TIMEOUT always fails links, it's
> pretty inconvenient and unnecessary limits chaining after it to hard
> linking, which is far from ideal, e.g. doesn't pair well with timeout
> cancellation. Prevent it and treat -ETIME as success.
That seems like a sane addition, but I'm not a huge fan of the
#define IORING_TIMEOUT_DONT_FAIL (1U << 5)
name, as it isn't very descriptive. Don't fail what? Maybe
#define IORING_TIMEOUT_ETIME_SUCCESS
instead? At least that tells the story of -ETIME being considered
success, hence not breaking a link.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] io_uring: add flag to not fail link after timeout
2021-10-02 14:58 ` Jens Axboe
@ 2021-10-02 16:18 ` Pavel Begunkov
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2021-10-02 16:18 UTC (permalink / raw)
To: Jens Axboe, io-uring
On 10/2/21 3:58 PM, Jens Axboe wrote:
> On 10/2/21 2:44 AM, Pavel Begunkov wrote:
>> For some reason non-off IORING_OP_TIMEOUT always fails links, it's
>> pretty inconvenient and unnecessary limits chaining after it to hard
>> linking, which is far from ideal, e.g. doesn't pair well with timeout
>> cancellation. Prevent it and treat -ETIME as success.
>
> That seems like a sane addition, but I'm not a huge fan of the
>
> #define IORING_TIMEOUT_DONT_FAIL (1U << 5)
>
> name, as it isn't very descriptive. Don't fail what? Maybe
>
> #define IORING_TIMEOUT_ETIME_SUCCESS
>
> instead? At least that tells the story of -ETIME being considered
> success, hence not breaking a link.
Agree, sounds better
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-02 16:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-02 8:44 [PATCH v2] io_uring: add flag to not fail link after timeout Pavel Begunkov
2021-10-02 14:58 ` Jens Axboe
2021-10-02 16:18 ` Pavel Begunkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox