5 Commits

Author SHA1 Message Date
Ian Gulliver
38eabdd644 Match const signatures in io_uring_prep_* to native functions
io_uring_prep_{readv,writev,read_fixed,write_fixed}() take
non-const arguments that are const in the native functions
that they mimic. Make those arguments const.

Signed-off-by: Ian Gulliver <git@flamingcow.io>
2019-05-19 10:21:01 -07:00
Jens Axboe
4e41621717 Merge branch 'missing-header' of https://github.com/flamingcow66/liburing
* 'missing-header' of https://github.com/flamingcow66/liburing:
  Fix liburing.h memset() missing declaration
2019-05-18 16:47:01 -06:00
Ian Gulliver
f218f76b82 Fix liburing.h memset() missing declaration
liburing.h uses memset() but doesn't include string.h.
If nothing else includes it, this causes compile errors.
Add the include.

Signed-off-by: Ian Gulliver <git@flamingcow.io>
2019-05-18 13:53:40 -07:00
Jens Axboe
1a90a51ecd io_uring.h: sync with kernel
Add sync_range_file opcode and related fields, and the
io_uring_register(2) commands for eventfd registration.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-18 12:58:47 -06:00
Ian Gulliver
3200e997d0 Fix manpage mmap() syntax
The examples in the io_uring_setup.2 man patch erroneously ORs
the protection bits and mmap flags, fix it up.

Signed-off-by: Ian Gulliver <git@flamingcow.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-18 12:49:55 -06:00
3 changed files with 17 additions and 11 deletions

View File

@@ -172,7 +172,7 @@ submission queue can be mapped with a call like:
.in +4n
.EX
ptr = mmap(0, sq_off.array + sq_entries * sizeof(__u32),
PROT_READ|PROT_WRITE|MAP_SHARED|MAP_POPULATE,
PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE,
ring_fd, IORING_OFF_SQ_RING);
.EE
.in
@@ -229,7 +229,7 @@ The array of submission queue entries is mapped with:
.in +4n
.EX
sqentries = mmap(0, sq_entries * sizeof(struct io_uring_sqe),
PROT_READ|PROT_WRITE|MAP_SHARED|MAP_POPULATE,
PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE,
ring_fd, IORING_OFF_SQES);
.EE
.in
@@ -260,7 +260,7 @@ from the queue itself, and can be mapped with:
.in +4n
.EX
ptr = mmap(0, cq_off.cqes + cq_entries * sizeof(struct io_uring_cqe),
PROT_READ|PROT_WRITE|MAP_SHARED|MAP_POPULATE, ring_fd,
PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE, ring_fd,
IORING_OFF_CQ_RING);
.EE
.in

View File

@@ -26,6 +26,7 @@ struct io_uring_sqe {
__kernel_rwf_t rw_flags;
__u32 fsync_flags;
__u16 poll_events;
__u32 sync_range_flags;
};
__u64 user_data; /* data to be passed back at completion time */
union {
@@ -38,8 +39,8 @@ struct io_uring_sqe {
* sqe->flags
*/
#define IOSQE_FIXED_FILE (1U << 0) /* use fixed fileset */
#define IOSQE_IO_DRAIN (1U << 1)
#define IOSQE_IO_LINK (1U << 2)
#define IOSQE_IO_DRAIN (1U << 1) /* issue after inflight IO */
#define IOSQE_IO_LINK (1U << 2) /* next IO depends on this one */
/*
* io_uring_setup() flags
@@ -56,6 +57,7 @@ struct io_uring_sqe {
#define IORING_OP_WRITE_FIXED 5
#define IORING_OP_POLL_ADD 6
#define IORING_OP_POLL_REMOVE 7
#define IORING_OP_SYNC_FILE_RANGE 8
/*
* sqe->fsync_flags
@@ -135,5 +137,7 @@ struct io_uring_params {
#define IORING_UNREGISTER_BUFFERS 1
#define IORING_REGISTER_FILES 2
#define IORING_UNREGISTER_FILES 3
#define IORING_REGISTER_EVENTFD 4
#define IORING_UNREGISTER_EVENTFD 5
#endif

View File

@@ -7,6 +7,7 @@ extern "C" {
#include <sys/uio.h>
#include <signal.h>
#include <string.h>
#include <inttypes.h>
#include "compat.h"
#include "io_uring.h"
@@ -105,7 +106,8 @@ static inline void *io_uring_cqe_get_data(struct io_uring_cqe *cqe)
}
static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
void *addr, unsigned len, off_t offset)
const void *addr, unsigned len,
off_t offset)
{
memset(sqe, 0, sizeof(*sqe));
sqe->opcode = op;
@@ -116,8 +118,8 @@ static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
}
static inline void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
struct iovec *iovecs, unsigned nr_vecs,
off_t offset)
const struct iovec *iovecs,
unsigned nr_vecs, off_t offset)
{
io_uring_prep_rw(IORING_OP_READV, sqe, fd, iovecs, nr_vecs, offset);
}
@@ -130,14 +132,14 @@ static inline void io_uring_prep_read_fixed(struct io_uring_sqe *sqe, int fd,
}
static inline void io_uring_prep_writev(struct io_uring_sqe *sqe, int fd,
struct iovec *iovecs, unsigned nr_vecs,
off_t offset)
const struct iovec *iovecs,
unsigned nr_vecs, off_t offset)
{
io_uring_prep_rw(IORING_OP_WRITEV, sqe, fd, iovecs, nr_vecs, offset);
}
static inline void io_uring_prep_write_fixed(struct io_uring_sqe *sqe, int fd,
void *buf, unsigned nbytes,
const void *buf, unsigned nbytes,
off_t offset)
{
io_uring_prep_rw(IORING_OP_WRITE_FIXED, sqe, fd, buf, nbytes, offset);