Skip to contentSkip to conversation

Recent changes (master)

PATCH Jens Axboe 1 participant 1 message Jan 9, 2019 Library code

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

The following changes since commit 6e70fd303855575c99c520e8c46b7d85c9f21dc8:

io_uring.h should include <linux/fs.h> (2019-01-08 05:43:38 -0700)

are available in the Git repository at:

git://git.kernel.dk/fio.git master

for you to fetch changes up to b08e7d6b18b4a38f61800e7553cd5e5d282da4a8:

engines/devdax: Make detection of device-dax instances more robust (2019-01-08 12:47:37 -0700)

----------------------------------------------------------------
Dan Williams (1):
engines/devdax: Make detection of device-dax instances more robust

Jens Axboe (4):
io_uring: use kernel header directly
configure: add __kernel_rwf_t check
engines/io_uring: ensure to use the right opcode for fixed buffers t/io_uring: ensure to use the right opcode for fixed buffers

 configure          | 20 ++++++++++++++
 engines/dev-dax.c  |  5 ++--
 engines/io_uring.c | 47 +++++++++++++++++---------------
 lib/types.h        |  4 +++
 os/io_uring.h      | 78 ++++++++++++++++++++++++++++++++----------------------
 t/io_uring.c       | 37 ++++++++++++--------------
 6 files changed, 115 insertions(+), 76 deletions(-)

---

Diff of recent changes:

configure +20 -0
index 1f4e50b1..c4fffd99 100755
@@ -2295,6 +2295,23 @@ if compile_prog "" "-lcunit" "CUnit"; then
 fi
 print_config "CUnit" "$cunit"
 
+##########################################
+# check for __kernel_rwf_t
+__kernel_rwf_t="no"
+cat > $TMPC << EOF
+#include <linux/fs.h>
+int main(int argc, char **argv)
+{
+  __kernel_rwf_t x;
+  x = 0;
+  return x;
+}
+EOF
+if compile_prog "" "" "__kernel_rwf_t"; then
+  __kernel_rwf_t="yes"
+fi
+print_config "__kernel_rwf_t" "$__kernel_rwf_t"
+
 #############################################################################
 
 if test "$wordsize" = "64" ; then
@@ -2563,6 +2580,9 @@ fi
 if test "$cunit" = "yes" ; then
   output_sym "CONFIG_HAVE_CUNIT"
 fi
+if test "$__kernel_rwf_t" = "yes"; then
+  output_sym "CONFIG_HAVE_KERNEL_RWF_T"
+fi
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
engines/dev-dax.c +3 -2
index 0660bba5..422ea634 100644
@@ -259,7 +259,7 @@ fio_devdax_get_file_size(struct thread_data *td, struct fio_file *f)
 {
 	char spath[PATH_MAX];
 	char npath[PATH_MAX];
-	char *rpath;
+	char *rpath, *basename;
 	FILE *sfile;
 	uint64_t size;
 	struct stat st;
@@ -289,7 +289,8 @@ fio_devdax_get_file_size(struct thread_data *td, struct fio_file *f)
 	}
 
 	/* check if DAX device */
-	if (strcmp("/sys/class/dax", rpath)) {
+	basename = strrchr(rpath, '/');
+	if (!basename || strcmp("dax", basename+1)) {
 		log_err("%s: %s not a DAX device!\n",
 			td->o.name, f->file_name);
 	}
engines/io_uring.c +25 -22

83 lines not on this page · raw message

lib/types.h +4 -0
index 236bf8a3..d92b064c 100644
@@ -13,4 +13,8 @@ typedef int bool;
 #include <stdbool.h> /* IWYU pragma: export */
 #endif
 
+#if !defined(CONFIG_HAVE_KERNEL_RWF_T)
+typedef int __kernel_rwf_t;
+#endif
+
 #endif
os/io_uring.h +46 -32

120 lines not on this page · raw message

t/io_uring.c +17 -20
index 83d723f9..fb2654a3 100644
@@ -21,13 +21,7 @@
 #include <sched.h>
 
 #include "../arch/arch.h"
-
-typedef uint64_t u64;
-typedef uint32_t u32;
-typedef int32_t s32;
-typedef uint16_t u16;
-typedef uint8_t u8;
-
+#include "../lib/types.h"
 #include "../os/io_uring.h"
 
 #define barrier()	__asm__ __volatile__("": : :"memory")
@@ -35,18 +29,18 @@ typedef uint8_t u8;
 #define min(a, b)		((a < b) ? (a) : (b))
 
 struct io_sq_ring {
-	u32 *head;
-	u32 *tail;
-	u32 *ring_mask;
-	u32 *ring_entries;
-	u32 *array;
+	unsigned *head;
+	unsigned *tail;
+	unsigned *ring_mask;
+	unsigned *ring_entries;
+	unsigned *array;
 };
 
 struct io_cq_ring {
-	u32 *head;
-	u32 *tail;
-	u32 *ring_mask;
-	u32 *ring_entries;
+	unsigned *head;
+	unsigned *tail;
+	unsigned *ring_mask;
+	unsigned *ring_entries;
 	struct io_uring_event *events;
 };
 
@@ -113,7 +107,10 @@ static void init_io(struct submitter *s, int fd, unsigned index)
 	lrand48_r(&s->rand, &r);
 	offset = (r % (s->max_blocks - 1)) * BS;
 
-	iocb->opcode = IORING_OP_READ;
+	if (fixedbufs)
+		iocb->opcode = IORING_OP_READ_FIXED;
+	else
+		iocb->opcode = IORING_OP_READ;
 	iocb->flags = 0;
 	iocb->ioprio = 0;
 	iocb->fd = fd;
@@ -125,7 +122,7 @@ static void init_io(struct submitter *s, int fd, unsigned index)
 static int prep_more_ios(struct submitter *s, int fd, int max_ios)
 {
 	struct io_sq_ring *ring = &s->sq_ring;
-	u32 index, tail, next_tail, prepped = 0;
+	unsigned index, tail, next_tail, prepped = 0;
 
 	next_tail = tail = *ring->tail;
 	do {
@@ -176,7 +173,7 @@ static int reap_events(struct submitter *s)
 {
 	struct io_cq_ring *ring = &s->cq_ring;
 	struct io_uring_event *ev;
-	u32 head, reaped = 0;
+	unsigned head, reaped = 0;
 
 	head = *ring->head;
 	do {
@@ -345,7 +342,7 @@ static int setup_ring(struct submitter *s)
 	}
 
 	s->ring_fd = fd;
-	ptr = mmap(0, p.sq_off.array + 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);