From: Olivier Langlois <[email protected]>
To: Jens Axboe <[email protected]>,
Pavel Begunkov <[email protected]>,
[email protected]
Subject: [PATCH] liburing: Add io_uring_submit_and_wait_timeout function in API
Date: Mon, 4 Oct 2021 09:31:05 -0400 [thread overview]
Message-ID: <86271fc62d96470896b9edc88036072f051a788f.1633354465.git.olivier@trillion01.com> (raw)
before commit 0ea4ccd1c0e4 ("src/queue: don't flush SQ ring for new wait interface"),
io_uring_wait_cqes() was serving the purpose of submit sqe and wait for cqe up to a certain timeout value.
Since the commit, a new function is needed to fill this gap.
Fixes: https://github.com/axboe/liburing/issues/440
Signed-off-by: Olivier Langlois <[email protected]>
---
src/include/liburing.h | 5 +++++
src/liburing.map | 5 +++++
src/queue.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 0c2c5c2..fe8bfbe 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -122,6 +122,11 @@ int io_uring_wait_cqe_timeout(struct io_uring *ring,
struct __kernel_timespec *ts);
int io_uring_submit(struct io_uring *ring);
int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr);
+int io_uring_submit_and_wait_timout(struct io_uring *ring,
+ struct io_uring_cqe **cqe_ptr,
+ unsigned wait_nr,
+ struct __kernel_timespec *ts,
+ sigset_t *sigmask);
struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring);
int io_uring_register_buffers(struct io_uring *ring, const struct iovec *iovecs,
diff --git a/src/liburing.map b/src/liburing.map
index 6692a3b..09f4275 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -44,3 +44,8 @@ LIBURING_2.1 {
io_uring_unregister_iowq_aff;
io_uring_register_iowq_max_workers;
} LIBURING_2.0;
+
+LIBURING_2.2 {
+ global:
+ io_uring_submit_and_wait_timout;
+} LIBURING_2.1;
diff --git a/src/queue.c b/src/queue.c
index 31aa17c..9ac9fe5 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -305,6 +305,39 @@ int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
return __io_uring_get_cqe(ring, cqe_ptr, to_submit, wait_nr, sigmask);
}
+int io_uring_submit_and_wait_timout(struct io_uring *ring,
+ struct io_uring_cqe **cqe_ptr,
+ unsigned wait_nr,
+ struct __kernel_timespec *ts,
+ sigset_t *sigmask)
+{
+ if (uring_likely(ts)) {
+ if (uring_unlikely(!(ring->features & IORING_FEAT_EXT_ARG)))
+ return io_uring_wait_cqes(ring, cqe_ptr, wait_nr,
+ ts, sigmask);
+ else {
+ struct io_uring_getevents_arg arg = {
+ .sigmask = (unsigned long) sigmask,
+ .sigmask_sz = _NSIG / 8,
+ .ts = (unsigned long) ts
+ };
+ struct get_data data = {
+ .submit = __io_uring_flush_sq(ring),
+ .wait_nr = wait_nr,
+ .get_flags = IORING_ENTER_EXT_ARG,
+ .sz = sizeof(arg),
+ .arg = &arg
+ };
+
+ return _io_uring_get_cqe(ring, cqe_ptr, &data);
+ }
+ }
+ else
+ return __io_uring_get_cqe(ring, cqe_ptr,
+ __io_uring_flush_sq(ring),
+ wait_nr, sigmask);
+}
+
/*
* See io_uring_wait_cqes() - this function is the same, it just always uses
* '1' as the wait_nr.
--
2.33.0
next reply other threads:[~2021-10-04 13:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 13:31 Olivier Langlois [this message]
2021-10-04 14:38 ` [PATCH] liburing: Add io_uring_submit_and_wait_timeout function in API Jens Axboe
2021-10-04 15:07 ` Olivier Langlois
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86271fc62d96470896b9edc88036072f051a788f.1633354465.git.olivier@trillion01.com \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox