summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/io_uring.c3
-rw-r--r--src/io_uring.h25
-rw-r--r--src/liburing.h6
-rw-r--r--src/syscall.c17
-rw-r--r--test/io_uring-cp.c12
-rw-r--r--test/io_uring-test.c3
6 files changed, 43 insertions, 23 deletions
diff --git a/src/io_uring.c b/src/io_uring.c
index d9c1511..bf79b9f 100644
--- a/src/io_uring.c
+++ b/src/io_uring.c
@@ -189,12 +189,11 @@ err:
* contains the necessary information to read/write to the rings.
*/
int io_uring_queue_init(unsigned entries, struct io_uring_params *p,
- struct iovec *iovecs, unsigned nr_iovecs,
struct io_uring *ring)
{
int fd, ret;
- fd = io_uring_setup(entries, iovecs, nr_iovecs, p);
+ fd = io_uring_setup(entries, p);
if (fd < 0)
return fd;
diff --git a/src/io_uring.h b/src/io_uring.h
index b07bbbb..613930d 100644
--- a/src/io_uring.h
+++ b/src/io_uring.h
@@ -29,25 +29,27 @@ struct io_uring_sqe {
__kernel_rwf_t rw_flags;
__u32 __resv;
};
- __u16 index; /* index into fixed buffers, if used */
+ __u16 buf_index; /* index into fixed buffers, if used */
__u16 __pad2[3];
__u64 data; /* data to be passed back at completion time */
};
/*
+ * sqe->flags
+ */
+#define IOSQE_FIXED_BUFFER (1 << 0) /* use fixed buffer */
+
+/*
* io_uring_setup() flags
*/
#define IORING_SETUP_IOPOLL (1 << 0) /* io_context is polled */
-#define IORING_SETUP_SQTHREAD (1 << 1) /* Use SQ thread */
-#define IORING_SETUP_SQWQ (1 << 2) /* Use SQ workqueue */
-#define IORING_SETUP_SQPOLL (1 << 3) /* SQ thread polls */
+#define IORING_SETUP_SQPOLL (1 << 1) /* SQ poll thread */
+#define IORING_SETUP_SQ_AFF (1 << 2) /* sq_thread_cpu is valid */
#define IORING_OP_READV 1
#define IORING_OP_WRITEV 2
#define IORING_OP_FSYNC 3
#define IORING_OP_FDSYNC 4
-#define IORING_OP_READ_FIXED 5
-#define IORING_OP_WRITE_FIXED 6
/*
* IO completion data structure (Completion Queue Entry)
@@ -114,4 +116,15 @@ struct io_uring_params {
struct io_cqring_offsets cq_off;
};
+/*
+ * io_uring_register(2) opcodes and arguments
+ */
+#define IORING_REGISTER_BUFFERS 0
+#define IORING_UNREGISTER_BUFFERS 1
+
+struct io_uring_register_buffers {
+ struct iovec *iovecs;
+ unsigned nr_iovecs;
+};
+
#endif
diff --git a/src/liburing.h b/src/liburing.h
index ac645f1..4123ba1 100644
--- a/src/liburing.h
+++ b/src/liburing.h
@@ -43,16 +43,16 @@ struct io_uring {
/*
* System calls
*/
-extern int io_uring_setup(unsigned entries, struct iovec *iovecs,
- unsigned nr_iovecs, struct io_uring_params *p);
+extern int io_uring_setup(unsigned entries, struct io_uring_params *p);
extern int io_uring_enter(unsigned fd, unsigned to_submit,
unsigned min_complete, unsigned flags);
+extern int io_uring_register(int fd, unsigned int opcode, void *arg);
/*
* Library interface
*/
extern int io_uring_queue_init(unsigned entries, struct io_uring_params *p,
- struct iovec *iovecs, unsigned nr_iovecs, struct io_uring *ring);
+ struct io_uring *ring);
extern void io_uring_queue_exit(struct io_uring *ring);
extern int io_uring_get_completion(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr);
diff --git a/src/syscall.c b/src/syscall.c
index d06d59c..6347244 100644
--- a/src/syscall.c
+++ b/src/syscall.c
@@ -8,19 +8,26 @@
#if defined(__x86_64)
#ifndef __NR_sys_io_uring_setup
-#define __NR_sys_io_uring_setup 335
+#define __NR_sys_io_uring_setup 335
#endif
#ifndef __NR_sys_io_uring_enter
-#define __NR_sys_io_uring_enter 336
+#define __NR_sys_io_uring_enter 336
+#endif
+#ifndef __NR_sys_io_uring_register
+#define __NR_sys_io_uring_register 337
#endif
#else
#error "Arch not supported yet"
#endif
-int io_uring_setup(unsigned int entries, struct iovec *iovecs,
- unsigned nr_iovecs, struct io_uring_params *p)
+int io_uring_register(int fd, unsigned int opcode, void *arg)
+{
+ return syscall(__NR_sys_io_uring_register, fd, opcode, arg);
+}
+
+int io_uring_setup(unsigned int entries, struct io_uring_params *p)
{
- return syscall(__NR_sys_io_uring_setup, entries, iovecs, nr_iovecs, p);
+ return syscall(__NR_sys_io_uring_setup, entries, p);
}
int io_uring_enter(int fd, unsigned int to_submit, unsigned int min_complete,
diff --git a/test/io_uring-cp.c b/test/io_uring-cp.c
index 9d7c56c..0fbd1d3 100644
--- a/test/io_uring-cp.c
+++ b/test/io_uring-cp.c
@@ -23,16 +23,14 @@ struct io_data {
struct iovec *iov;
};
-static int setup_context(unsigned entries, struct io_uring *ring, int offload)
+static int setup_context(unsigned entries, struct io_uring *ring)
{
struct io_uring_params p;
int ret;
memset(&p, 0, sizeof(p));
- if (offload)
- p.flags = IORING_SETUP_SQWQ;
- ret = io_uring_queue_init(entries, &p, NULL, 0, ring);
+ ret = io_uring_queue_init(entries, &p, ring);
if (ret < 0) {
fprintf(stderr, "queue_init: %s\n", strerror(-ret));
return -1;
@@ -79,6 +77,7 @@ static int queue_read(int fd, off_t size, off_t offset)
sqe->fd = fd;
sqe->off = offset;
sqe->addr = data->iov;
+ sqe->buf_index = 0;
sqe->data = (unsigned long) data;
iovecs[sqe_index(sqe)].iov_len = size;
sqe->len = 1;
@@ -128,6 +127,7 @@ static void queue_write(int fd, struct io_uring_cqe *cqe)
sqe->fd = fd;
sqe->off = data->offset;
sqe->addr = data->iov;
+ sqe->buf_index = 0;
sqe->data = 0;
data->iov->iov_len = cqe->res;
sqe->len = 1;
@@ -166,9 +166,9 @@ int main(int argc, char *argv[])
iovecs[i].iov_len = BS;
}
- if (setup_context(QD, &in_ring, 1))
+ if (setup_context(QD, &in_ring))
return 1;
- if (setup_context(QD, &out_ring, 0))
+ if (setup_context(QD, &out_ring))
return 1;
if (get_file_size(infd, &read_left))
return 1;
diff --git a/test/io_uring-test.c b/test/io_uring-test.c
index caf61ed..4bd0892 100644
--- a/test/io_uring-test.c
+++ b/test/io_uring-test.c
@@ -32,7 +32,7 @@ int main(int argc, char *argv[])
memset(&p, 0, sizeof(p));
p.flags = IORING_SETUP_IOPOLL;
- ret = io_uring_queue_init(QD, &p, NULL, 0, &ring);
+ ret = io_uring_queue_init(QD, &p, &ring);
if (ret < 0) {
fprintf(stderr, "queue_init: %s\n", strerror(-ret));
return 1;
@@ -65,6 +65,7 @@ int main(int argc, char *argv[])
sqe->off = offset;
sqe->addr = &iovecs[i];
sqe->len = 1;
+ sqe->buf_index = 0;
offset += iovecs[i].iov_len;
} while (1);