aioring: update to newer API
authorJens Axboe <axboe@kernel.dk>
Sat, 5 Jan 2019 05:22:54 +0000 (22:22 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 5 Jan 2019 05:22:54 +0000 (22:22 -0700)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/aioring.c
t/aio-ring.c

index 4b410cf..ca60b28 100644 (file)
@@ -62,13 +62,22 @@ typedef uint16_t u16;
 
 #define IOEV_RES2_CACHEHIT     (1 << 0)
 
-struct aio_uring_offsets {
+struct aio_sqring_offsets {
        u32 head;
        u32 tail;
        u32 ring_mask;
        u32 ring_entries;
        u32 flags;
-       u32 elems;
+       u32 array;
+};
+
+struct aio_cqring_offsets {
+       u32 head;
+       u32 tail;
+       u32 ring_mask;
+       u32 ring_entries;
+       u32 overflow;
+       u32 events;
 };
 
 struct aio_uring_params {
@@ -77,8 +86,8 @@ struct aio_uring_params {
        u32 flags;
        u16 sq_thread_cpu;
        u16 resv[9];
-       struct aio_uring_offsets sq_off;
-       struct aio_uring_offsets cq_off;
+       struct aio_sqring_offsets sq_off;
+       struct aio_cqring_offsets cq_off;
 };
 
 struct aio_sq_ring {
@@ -463,7 +472,7 @@ static int fio_aioring_mmap(struct aioring_data *ld, struct aio_uring_params *p)
        struct aio_cq_ring *cring = &ld->cq_ring;
        void *ptr;
 
-       ld->mmap[0].len = p->sq_off.elems + p->sq_entries * sizeof(u32);
+       ld->mmap[0].len = p->sq_off.array + p->sq_entries * sizeof(u32);
        ptr = mmap(0, ld->mmap[0].len, PROT_READ | PROT_WRITE,
                        MAP_SHARED | MAP_POPULATE, ld->ring_fd,
                        IORING_OFF_SQ_RING);
@@ -473,7 +482,7 @@ static int fio_aioring_mmap(struct aioring_data *ld, struct aio_uring_params *p)
        sring->ring_mask = ptr + p->sq_off.ring_mask;
        sring->ring_entries = ptr + p->sq_off.ring_entries;
        sring->flags = ptr + p->sq_off.flags;
-       sring->array = ptr + p->sq_off.elems;
+       sring->array = ptr + p->sq_off.array;
        ld->sq_ring_mask = *sring->ring_mask;
 
        ld->mmap[1].len = p->sq_entries * sizeof(struct iocb);
@@ -482,7 +491,7 @@ static int fio_aioring_mmap(struct aioring_data *ld, struct aio_uring_params *p)
                                IORING_OFF_IOCB);
        ld->mmap[1].ptr = ld->iocbs;
 
-       ld->mmap[2].len = p->cq_off.elems +
+       ld->mmap[2].len = p->cq_off.events +
                                p->cq_entries * sizeof(struct io_event);
        ptr = mmap(0, ld->mmap[2].len, PROT_READ | PROT_WRITE,
                        MAP_SHARED | MAP_POPULATE, ld->ring_fd,
@@ -492,7 +501,7 @@ static int fio_aioring_mmap(struct aioring_data *ld, struct aio_uring_params *p)
        cring->tail = ptr + p->cq_off.tail;
        cring->ring_mask = ptr + p->cq_off.ring_mask;
        cring->ring_entries = ptr + p->cq_off.ring_entries;
-       cring->events = ptr + p->cq_off.elems;
+       cring->events = ptr + p->cq_off.events;
        ld->cq_ring_mask = *cring->ring_mask;
        return 0;
 }
index 7131eb3..71978c6 100644 (file)
@@ -46,13 +46,22 @@ typedef uint16_t u16;
 #define IORING_OFF_CQ_RING     0x8000000ULL
 #define IORING_OFF_IOCB                0x10000000ULL
 
-struct aio_uring_offsets {
+struct aio_sqring_offsets {
        u32 head;
        u32 tail;
        u32 ring_mask;
        u32 ring_entries;
        u32 flags;
-       u32 elems;
+       u32 array;
+};
+
+struct aio_cqring_offsets {
+       u32 head;
+       u32 tail;
+       u32 ring_mask;
+       u32 ring_entries;
+       u32 overflow;
+       u32 events;
 };
 
 struct aio_uring_params {
@@ -61,8 +70,8 @@ struct aio_uring_params {
        u32 flags;
        u16 sq_thread_cpu;
        u16 resv[9];
-       struct aio_uring_offsets sq_off;
-       struct aio_uring_offsets cq_off;
+       struct aio_sqring_offsets sq_off;
+       struct aio_cqring_offsets cq_off;
 };
 
 struct aio_sq_ring {
@@ -305,7 +314,7 @@ submit:
                        prepped = 0;
                        continue;
                } else if (ret < 0) {
-                       if ((ret == -1 && errno == EAGAIN) || ret == -EAGAIN) {
+                       if (errno == EAGAIN) {
                                if (s->finish)
                                        break;
                                if (this_reap)
@@ -313,10 +322,7 @@ submit:
                                to_submit = 0;
                                goto submit;
                        }
-                       if (ret == -1)
-                               printf("io_submit: %s\n", strerror(errno));
-                       else
-                               printf("io_submit: %s\n", strerror(-ret));
+                       printf("io_submit: %s\n", strerror(errno));
                        break;
                }
        } while (!s->finish);
@@ -377,7 +383,7 @@ static int setup_ring(struct submitter *s)
 
        s->fd = fd;
 
-       ptr = mmap(0, p.sq_off.elems + p.sq_entries * sizeof(u32),
+       ptr = mmap(0, p.sq_off.array + p.sq_entries * sizeof(u32),
                        PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE,
                        fd, IORING_OFF_SQ_RING);
        printf("sq_ring ptr = 0x%p\n", ptr);
@@ -385,14 +391,14 @@ static int setup_ring(struct submitter *s)
        sring->tail = ptr + p.sq_off.tail;
        sring->ring_mask = ptr + p.sq_off.ring_mask;
        sring->ring_entries = ptr + p.sq_off.ring_entries;
-       sring->array = ptr + p.sq_off.elems;
+       sring->array = ptr + p.sq_off.array;
        sq_ring_mask = *sring->ring_mask;
 
        s->iocbs = mmap(0, p.sq_entries * sizeof(struct iocb), PROT_READ | PROT_WRITE,
                        MAP_SHARED | MAP_POPULATE, fd, IORING_OFF_IOCB);
        printf("iocbs ptr   = 0x%p\n", s->iocbs);
 
-       ptr = mmap(0, p.cq_off.elems + p.cq_entries * sizeof(struct io_event),
+       ptr = mmap(0, p.cq_off.events + p.cq_entries * sizeof(struct io_event),
                        PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE,
                        fd, IORING_OFF_CQ_RING);
        printf("cq_ring ptr = 0x%p\n", ptr);
@@ -400,7 +406,7 @@ static int setup_ring(struct submitter *s)
        cring->tail = ptr + p.cq_off.tail;
        cring->ring_mask = ptr + p.cq_off.ring_mask;
        cring->ring_entries = ptr + p.cq_off.ring_entries;
-       cring->events = ptr + p.cq_off.elems;
+       cring->events = ptr + p.cq_off.events;
        cq_ring_mask = *cring->ring_mask;
        return 0;
 }