#include "../lib/types.h"
#include "../os/linux/io_uring.h"
-#define barrier() __asm__ __volatile__("": : :"memory")
-
#define min(a, b) ((a < b) ? (a) : (b))
struct io_sq_ring {
static int io_uring_register_buffers(struct submitter *s)
{
- struct io_uring_register_buffers reg = {
- .iovecs = s->iovecs,
- .nr_iovecs = DEPTH
- };
-
if (do_nop)
return 0;
return syscall(__NR_sys_io_uring_register, s->ring_fd,
- IORING_REGISTER_BUFFERS, ®);
+ IORING_REGISTER_BUFFERS, s->iovecs, DEPTH);
}
static int io_uring_register_files(struct submitter *s)
{
- struct io_uring_register_files reg;
int i;
if (do_nop)
s->fds[i] = s->files[i].real_fd;
s->files[i].fixed_fd = i;
}
- reg.fds = s->fds;
- reg.nr_fds = s->nr_files;
return syscall(__NR_sys_io_uring_register, s->ring_fd,
- IORING_REGISTER_FILES, ®);
+ IORING_REGISTER_FILES, s->fds, s->nr_files);
}
static int io_uring_setup(unsigned entries, struct io_uring_params *p)
unsigned int min_complete, unsigned int flags)
{
return syscall(__NR_sys_io_uring_enter, s->ring_fd, to_submit,
- min_complete, flags);
+ min_complete, flags, NULL, 0);
}
static int gettid(void)
}
if (fixedbufs) {
sqe->opcode = IORING_OP_READ_FIXED;
- sqe->addr = s->iovecs[index].iov_base;
+ sqe->addr = (unsigned long) s->iovecs[index].iov_base;
sqe->len = BS;
sqe->buf_index = index;
} else {
sqe->opcode = IORING_OP_READV;
- sqe->addr = &s->iovecs[index];
+ sqe->addr = (unsigned long) &s->iovecs[index];
sqe->len = 1;
sqe->buf_index = 0;
}
next_tail = tail = *ring->tail;
do {
next_tail++;
- barrier();
+ read_barrier();
if (next_tail == *ring->head)
break;
if (*ring->tail != tail) {
/* order tail store with writes to sqes above */
- barrier();
+ write_barrier();
*ring->tail = tail;
- barrier();
+ write_barrier();
}
return prepped;
}
do {
struct file *f;
- barrier();
+ read_barrier();
if (head == *ring->tail)
break;
cqe = &ring->cqes[head & cq_ring_mask];
f->pending_ios--;
if (cqe->res != BS) {
printf("io: unexpected ret=%d\n", cqe->res);
+ if (polled && cqe->res == -EOPNOTSUPP)
+ printf("Your filesystem doesn't support poll\n");
return -1;
}
}
s->inflight -= reaped;
*ring->head = head;
- barrier();
+ write_barrier();
return reaped;
}
if (to_wait)
flags = IORING_ENTER_GETEVENTS;
+ if ((*ring->flags & IORING_SQ_NEED_WAKEUP))
+ flags |= IORING_ENTER_SQ_WAKEUP;
ret = io_uring_enter(s, to_submit, to_wait, flags);
s->calls++;
}
i = 1;
while (!do_nop && i < argc) {
- struct file *f = &s->files[s->nr_files];
+ struct file *f;
+ if (s->nr_files == MAX_FDS) {
+ printf("Max number of files (%d) reached\n", MAX_FDS);
+ break;
+ }
fd = open(argv[i], flags);
if (fd < 0) {
perror("open");
return 1;
}
+
+ f = &s->files[s->nr_files];
f->real_fd = fd;
if (get_file_size(f)) {
printf("failed getting size of device/file\n");