#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)
}
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];
s->inflight -= reaped;
*ring->head = head;
- barrier();
+ write_barrier();
return reaped;
}