public inbox for [email protected]
 help / color / mirror / Atom feed
From: Hao Xu <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, Pavel Begunkov <[email protected]>
Subject: [PATCH 3/6] liburing.h: add api to support multishot accept direct
Date: Sat, 14 May 2022 22:35:31 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

From: Hao Xu <[email protected]>

This is to support the multishot accept directly to the fixed table, the
file_Index should be set to IORING_FILE_INDEX_ALLOC in this case.

Signed-off-by: Hao Xu <[email protected]>
---
 src/include/liburing.h          | 11 +++++++++++
 src/include/liburing/io_uring.h |  9 +++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index cf50383c8e63..9065555d39f4 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -512,6 +512,17 @@ static inline void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe,
 	sqe->ioprio |= IORING_ACCEPT_MULTISHOT;
 }
 
+/* multishot accept directly into the fixed file table */
+static inline void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *sqe,
+							 int fd,
+							 struct sockaddr *addr,
+							 socklen_t *addrlen,
+							 int flags)
+{
+	io_uring_prep_multishot_accept(sqe, fd, addr, addrlen, flags);
+	__io_uring_set_target_fixed_file(sqe, IORING_FILE_INDEX_ALLOC - 1);
+}
+
 static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe,
 					__u64 user_data, int flags)
 {
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index 46765d2697ba..6260e0d1f4ef 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -67,6 +67,15 @@ struct io_uring_sqe {
 	__u64	__pad2[2];
 };
 
+/*
+ * If sqe->file_index is set to this for opcodes that instantiate a new
+ * direct descriptor (like openat/openat2/accept), then io_uring will allocate
+ * an available direct descriptor instead of having the application pass one
+ * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE
+ * if the space is full.
+ */
+#define IORING_FILE_INDEX_ALLOC         (~0U)
+
 enum {
 	IOSQE_FIXED_FILE_BIT,
 	IOSQE_IO_DRAIN_BIT,
-- 
2.36.0


  parent reply	other threads:[~2022-05-14 14:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-14 14:35 [PATCH liburing 0/6] liburing changes for multishot accept Hao Xu
2022-05-14 14:35 ` [PATCH 1/6] test/accept.c: close the listen fd at the end of the test Hao Xu
2022-05-14 14:35 ` [PATCH 2/6] liburing.h: support multishot accept Hao Xu
2022-05-14 14:35 ` Hao Xu [this message]
2022-05-14 14:35 ` [PATCH 4/6] test/accept.c: add test for multishot mode accept Hao Xu
2022-05-14 14:35 ` [PATCH 5/6] test/accept.c: test for multishot direct accept with wrong arg Hao Xu
2022-05-14 14:35 ` [PATCH 6/6] man/io_uring_prep_accept.3: add man info for multishot accept Hao Xu
2022-05-14 15:32 ` [PATCH liburing 0/6] liburing changes " Jens Axboe

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 \
    [email protected] \
    [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