public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing v2] register: add tagging and buf update helpers
@ 2021-08-27 19:32 Pavel Begunkov
  2021-08-27 19:35 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-08-27 19:32 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Add heplers for rsrc (buffers, files) updates and registration with
tags.

Signed-off-by: Pavel Begunkov <[email protected]>
---

v2: update liburing.map

 src/include/liburing.h | 20 ++++++++++++
 src/liburing.map       |  4 +++
 src/register.c         | 71 ++++++++++++++++++++++++++++++++++++++++++
 test/rsrc_tags.c       |  8 +++++
 4 files changed, 103 insertions(+)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 9b38d23..7b364ce 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -125,9 +125,29 @@ extern struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring);
 extern int io_uring_register_buffers(struct io_uring *ring,
 					const struct iovec *iovecs,
 					unsigned nr_iovecs);
+extern int io_uring_register_buffers_tags(struct io_uring *ring,
+					  const struct iovec *iovecs,
+					  const __u64 *tags,
+					  unsigned nr);
+extern int io_uring_register_buffers_update_tag(struct io_uring *ring,
+						unsigned off,
+						const struct iovec *iovecs,
+						const __u64 *tags,
+						unsigned nr);
 extern int io_uring_unregister_buffers(struct io_uring *ring);
+
 extern int io_uring_register_files(struct io_uring *ring, const int *files,
 					unsigned nr_files);
+extern int io_uring_register_files_tags(struct io_uring *ring,
+					const int *files,
+					const __u64 *tags,
+					unsigned nr);
+extern int io_uring_register_files_update_tag(struct io_uring *ring,
+					      unsigned off,
+					      const int *files,
+					      const __u64 *tags,
+					      unsigned nr_files);
+
 extern int io_uring_unregister_files(struct io_uring *ring);
 extern int io_uring_register_files_update(struct io_uring *ring, unsigned off,
 					int *files, unsigned nr_files);
diff --git a/src/liburing.map b/src/liburing.map
index 012ac4e..b29aa5f 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -36,4 +36,8 @@ LIBURING_2.1 {
 	global:
 		io_uring_mlock_size_params;
 		io_uring_mlock_size;
+		io_uring_register_buffers_tags;
+		io_uring_register_buffers_update_tag;
+		io_uring_register_files_tags;
+		io_uring_register_files_update_tag;
 } LIBURING_2.0;
diff --git a/src/register.c b/src/register.c
index 994aaff..a947aec 100644
--- a/src/register.c
+++ b/src/register.c
@@ -14,6 +14,42 @@
 
 #include "syscall.h"
 
+int io_uring_register_buffers_update_tag(struct io_uring *ring, unsigned off,
+					 const struct iovec *iovecs,
+					 const __u64 *tags,
+					 unsigned nr)
+{
+	struct io_uring_rsrc_update2 up = {
+		.offset	= off,
+		.data = (unsigned long)iovecs,
+		.tags = (unsigned long)tags,
+		.nr = nr,
+	};
+	int ret;
+
+	ret = __sys_io_uring_register(ring->ring_fd,
+				      IORING_REGISTER_BUFFERS_UPDATE,
+				      &up, sizeof(up));
+	return ret < 0 ? -errno : ret;
+}
+
+int io_uring_register_buffers_tags(struct io_uring *ring,
+				   const struct iovec *iovecs,
+				   const __u64 *tags,
+				   unsigned nr)
+{
+	struct io_uring_rsrc_register reg = {
+		.nr = nr,
+		.data = (unsigned long)iovecs,
+		.tags = (unsigned long)tags,
+	};
+	int ret;
+
+	ret = __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_BUFFERS2,
+				      &reg, sizeof(reg));
+	return ret < 0 ? -errno : ret;
+}
+
 int io_uring_register_buffers(struct io_uring *ring, const struct iovec *iovecs,
 			      unsigned nr_iovecs)
 {
@@ -39,6 +75,24 @@ int io_uring_unregister_buffers(struct io_uring *ring)
 	return 0;
 }
 
+int io_uring_register_files_update_tag(struct io_uring *ring, unsigned off,
+					const int *files, const __u64 *tags,
+					unsigned nr_files)
+{
+	struct io_uring_rsrc_update2 up = {
+		.offset	= off,
+		.data = (unsigned long)files,
+		.tags = (unsigned long)tags,
+		.nr = nr_files,
+	};
+	int ret;
+
+	ret = __sys_io_uring_register(ring->ring_fd,
+					IORING_REGISTER_FILES_UPDATE2,
+					&up, sizeof(up));
+	return ret < 0 ? -errno : ret;
+}
+
 /*
  * Register an update for an existing file set. The updates will start at
  * 'off' in the original array, and 'nr_files' is the number of files we'll
@@ -64,6 +118,23 @@ int io_uring_register_files_update(struct io_uring *ring, unsigned off,
 	return ret;
 }
 
+
+int io_uring_register_files_tags(struct io_uring *ring,
+				 const int *files, const __u64 *tags,
+				 unsigned nr)
+{
+	struct io_uring_rsrc_register reg = {
+		.nr = nr,
+		.data = (unsigned long)files,
+		.tags = (unsigned long)tags,
+	};
+	int ret;
+
+	ret = __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_FILES2,
+				      &reg, sizeof(reg));
+	return ret < 0 ? -errno : ret;
+}
+
 int io_uring_register_files(struct io_uring *ring, const int *files,
 			      unsigned nr_files)
 {
diff --git a/test/rsrc_tags.c b/test/rsrc_tags.c
index 337fbb8..57b47f7 100644
--- a/test/rsrc_tags.c
+++ b/test/rsrc_tags.c
@@ -32,6 +32,10 @@ static bool check_cq_empty(struct io_uring *ring)
 	return ret == -EAGAIN;
 }
 
+/*
+ * There are io_uring_register_buffers_tags() and other wrappers,
+ * but they may change, so hand-code to specifically test this ABI.
+ */
 static int register_rsrc(struct io_uring *ring, int type, int nr,
 			  const void *arg, const __u64 *tags)
 {
@@ -52,6 +56,10 @@ static int register_rsrc(struct io_uring *ring, int type, int nr,
 	return ret ? -errno : 0;
 }
 
+/*
+ * There are io_uring_register_buffers_update_tag() and other wrappers,
+ * but they may change, so hand-code to specifically test this ABI.
+ */
 static int update_rsrc(struct io_uring *ring, int type, int nr, int off,
 			const void *arg, const __u64 *tags)
 {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH liburing v2] register: add tagging and buf update helpers
  2021-08-27 19:32 [PATCH liburing v2] register: add tagging and buf update helpers Pavel Begunkov
@ 2021-08-27 19:35 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-08-27 19:35 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 8/27/21 1:32 PM, Pavel Begunkov wrote:
> Add heplers for rsrc (buffers, files) updates and registration with
> tags.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-27 19:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-27 19:32 [PATCH liburing v2] register: add tagging and buf update helpers Pavel Begunkov
2021-08-27 19:35 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox