diff mbox series

[liburing,v2,2/5] alloc range helpers

Message ID fc7d5dec683c2f989f2bf33906b22d820b4d175e.1656597976.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series ranged file slot alloc | expand

Commit Message

Pavel Begunkov June 30, 2022, 2:10 p.m. UTC
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 src/include/liburing.h |  3 +++
 src/liburing.map       |  1 +
 src/register.c         | 14 ++++++++++++++
 3 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/src/include/liburing.h b/src/include/liburing.h
index bb2fb87..45b4da0 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -186,6 +186,9 @@  int io_uring_unregister_buf_ring(struct io_uring *ring, int bgid);
 int io_uring_register_sync_cancel(struct io_uring *ring,
 				 struct io_uring_sync_cancel_reg *reg);
 
+int io_uring_register_file_alloc_range(struct io_uring *ring,
+					unsigned off, unsigned len);
+
 /*
  * Helper for the peek/wait single cqe functions. Exported because of that,
  * but probably shouldn't be used directly in an application.
diff --git a/src/liburing.map b/src/liburing.map
index a487865..318d3d7 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -59,4 +59,5 @@  LIBURING_2.2 {
 LIBURING_2.3 {
 	global:
 		io_uring_register_sync_cancel;
+		io_uring_register_file_alloc_range;
 } LIBURING_2.2;
diff --git a/src/register.c b/src/register.c
index f2b1026..ee370d6 100644
--- a/src/register.c
+++ b/src/register.c
@@ -352,3 +352,17 @@  int io_uring_register_sync_cancel(struct io_uring *ring,
 	return ____sys_io_uring_register(ring->ring_fd,
 					 IORING_REGISTER_SYNC_CANCEL, reg, 1);
 }
+
+int io_uring_register_file_alloc_range(struct io_uring *ring,
+					unsigned off, unsigned len)
+{
+	struct io_uring_file_index_range range;
+
+	memset(&range, 0, sizeof(range));
+	range.off = off;
+	range.len = len;
+
+	return ____sys_io_uring_register(ring->ring_fd,
+					 IORING_REGISTER_FILE_ALLOC_RANGE,
+					 &range, 0);
+}