Merge branch 'master' into gfio
authorJens Axboe <axboe@kernel.dk>
Thu, 24 Jan 2013 16:08:45 +0000 (09:08 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 24 Jan 2013 16:08:45 +0000 (09:08 -0700)
Conflicts:
Makefile
backend.c
client.c
fio.c
fio.h
ioengine.h
options.c
os/os-linux.h
server.c

Signed-off-by: Jens Axboe <axboe@kernel.dk>
67 files changed:
HOWTO
Makefile
arch/arch-x86.h
arch/arch-x86_64.h
arch/arch.h
backend.c
cconv.c
client.c
compiler/compiler.h
configure [new file with mode: 0755]
engines/fusion-aw.c
engines/guasi.c
engines/libaio.c
engines/net.c
engines/posixaio.c
engines/rdma.c
engines/solarisaio.c
engines/splice.c
engines/syslet-rw.c [deleted file]
engines/windowsaio.c
eta.c
file.h
filesetup.c
fio.1
fio.c
fio.h
flist.h
gettime.c
helpers.c
helpers.h
init.c
io_u.c
ioengine.h
ioengines.c
iolog.h
lib/axmap.c
lib/bswap.h
lib/flist_sort.c [new file with mode: 0644]
lib/getopt.h
lib/hweight.c [new file with mode: 0644]
lib/hweight.h [new file with mode: 0644]
lib/inet_aton.c [new file with mode: 0644]
lib/inet_aton.h [new file with mode: 0644]
lib/lfsr.c
lib/lfsr.h
lib/strsep.h
libfio.c
memory.c
options.c
os/indirect.h [deleted file]
os/os-aix.h
os/os-android.h
os/os-freebsd.h
os/os-hpux.h
os/os-linux.h
os/os-mac.h
os/os-netbsd.h
os/os-solaris.h
os/os-windows.h
os/os.h
os/syslet.h [deleted file]
os/windows/posix.c
os/windows/posix.h [new file with mode: 0644]
server.c
t/axmap.c
thread_options.h
verify.c

diff --git a/HOWTO b/HOWTO
index a1e659008b38b82e98ba86d0d5d07b4b35b35897..c9c1d8c6d657dbb81dec21c88be5622aeac9b4e9 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -704,7 +704,7 @@ overwrite=bool      If true, writes to a file will always overwrite existing
                and is large enough for the specified write phase, nothing
                will be done.
 
-end_fsync=bool If true, fsync file contents when the job exits.
+end_fsync=bool If true, fsync file contents when a write stage has completed.
 
 fsync_on_close=bool    If true, fio will fsync() a dirty file on close.
                This differs from end_fsync in that it will happen on every
@@ -844,9 +844,7 @@ cpus_allowed=str Controls the same options as cpumask, but it allows a text
 numa_cpu_nodes=str Set this job running on spcified NUMA nodes' CPUs. The
                arguments allow comma delimited list of cpu numbers,
                A-B ranges, or 'all'. Note, to enable numa options support,
-               export the following environment variables,
-                       export EXTFLAGS+=" -DFIO_HAVE_LIBNUMA "
-                       export EXTLIBS+=" -lnuma "
+               fio must be built on a system with libnuma-dev(el) installed.
 
 numa_mem_policy=str Set this job's memory policy and corresponding NUMA
                nodes. Format of the argements:
index e6e9e8c96cc8108c71b9a137aa6283c5730f7e4a..dbf3049497ac5a4d52fbffb6ce0b212cf84007cb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,3 @@
-CC ?= gcc
 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
 CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
        $(DEBUGFLAGS)
@@ -12,6 +11,20 @@ UNAME  := $(shell uname)
 GTK_CFLAGS = `pkg-config --cflags gtk+-2.0 gthread-2.0`
 GTK_LDFLAGS = `pkg-config --libs gtk+-2.0 gthread-2.0`
 
+ifneq ($(wildcard config-host.mak),)
+all:
+include config-host.mak
+config-host-mak: configure
+       @echo $@ is out-of-date, running configure
+       @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
+else
+config-host.mak:
+       @echo "Running configure for you..."
+       @./configure
+all:
+include config-host.mak
+endif
+
 SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
                eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
                lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
@@ -19,56 +32,155 @@ SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
                engines/mmap.c engines/sync.c engines/null.c engines/net.c \
                memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
                cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
-               lib/lfsr.c gettime-thread.c
+               lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \
+               lib/hweight.c
+
+ifdef CONFIG_64BIT_LLP64
+  CFLAGS += -DBITS_PER_LONG=32
+endif
+ifdef CONFIG_64BIT
+  CFLAGS += -DBITS_PER_LONG=64
+endif
+ifdef CONFIG_32BIT
+  CFLAGS += -DBITS_PER_LONG=32
+endif
+ifdef CONFIG_BIG_ENDIAN
+  CFLAGS += -DCONFIG_BIG_ENDIAN
+endif
+ifdef CONFIG_LITTLE_ENDIAN
+  CFLAGS += -DCONFIG_LITTLE_ENDIAN
+endif
+ifdef CONFIG_LIBAIO
+  CFLAGS += -DCONFIG_LIBAIO
+  SOURCE += engines/libaio.c
+endif
+ifdef CONFIG_RDMA
+  CFLAGS += -DCONFIG_RDMA
+  SOURCE += engines/rdma.c
+endif
+ifdef CONFIG_POSIXAIO
+  CFLAGS += -DCONFIG_POSIXAIO
+  SOURCE += engines/posixaio.c
+endif
+ifdef CONFIG_LINUX_FALLOCATE
+  SOURCE += engines/falloc.c
+endif
+ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
+  SOURCE += engines/e4defrag.c
+endif
+ifdef CONFIG_LINUX_SPLICE
+  CFLAGS += -DCONFIG_LINUX_SPLICE
+  SOURCE += engines/splice.c
+endif
+ifdef CONFIG_GUASI
+  CFLAGS += -DCONFIG_GUASI
+  SOURCE += engines/guasi.c
+endif
+ifdef CONFIG_FUSION_AW
+  CFLAGS += -DCONFIG_FUSION_AW
+  SOURCE += engines/fusion-aw.c
+endif
+ifdef CONFIG_SOLARISAIO
+  CFLAGS += -DCONFIG_SOLARISAIO
+  SOURCE += engines/solarisaio.c
+endif
+
+ifndef CONFIG_STRSEP
+  CFLAGS += -DCONFIG_STRSEP
+  SOURCE += lib/strsep.c
+endif
+ifndef CONFIG_GETOPT_LONG_ONLY
+  CFLAGS += -DCONFIG_GETOPT_LONG_ONLY
+  SOURCE += lib/getopt_long.c
+endif
+
+ifndef CONFIG_INET_ATON
+  CFLAGS += -DCONFIG_INET_ATON
+  SOURCE += lib/inet_aton.c
+endif
+ifdef CONFIG_CLOCK_GETTIME
+  CFLAGS += -DCONFIG_CLOCK_GETTIME
+endif
+ifdef CONFIG_POSIXAIO_FSYNC
+  CFLAGS += -DCONFIG_POSIXAIO_FSYNC
+endif
+ifdef CONFIG_FADVISE
+  CFLAGS += -DCONFIG_FADVISE
+endif
+ifdef CONFIG_CLOCK_MONOTONIC
+  CFLAGS += -DCONFIG_CLOCK_MONOTONIC
+endif
+ifdef CONFIG_CLOCK_MONOTONIC_PRECISE
+  CFLAGS += -DCONFIG_CLOCK_MONOTONIC_PRECISE
+endif
+ifdef CONFIG_GETTIMEOFDAY
+  CFLAGS += -DCONFIG_GETTIMEOFDAY
+endif
+ifdef CONFIG_SOCKLEN_T
+  CFLAGS += -DCONFIG_SOCKLEN_T
+endif
+ifdef CONFIG_SFAA
+  CFLAGS += -DCONFIG_SFAA
+endif
+ifdef CONFIG_FDATASYNC
+  CFLAGS += -DCONFIG_FDATASYNC
+endif
+ifdef CONFIG_3ARG_AFFINITY
+  CFLAGS += -DCONFIG_3ARG_AFFINITY
+endif
+ifdef CONFIG_2ARG_AFFINITY
+  CFLAGS += -DCONFIG_2ARG_AFFINITY
+endif
+ifdef CONFIG_SYNC_FILE_RANGE
+  CFLAGS += -DCONFIG_SYNC_FILE_RANGE
+endif
+ifdef CONFIG_LIBNUMA
+  CFLAGS += -DCONFIG_LIBNUMA
+endif
+ifdef CONFIG_TLS_THREAD
+  CFLAGS += -DCONFIG_TLS_THREAD
+endif
+ifdef CONFIG_POSIX_FALLOCATE
+  CFLAGS += -DCONFIG_POSIX_FALLOCATE
+endif
+ifdef CONFIG_LINUX_FALLOCATE
+  CFLAGS += -DCONFIG_LINUX_FALLOCATE
+endif
 
 ifeq ($(UNAME), Linux)
-  SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
-               engines/libaio.c engines/posixaio.c engines/sg.c \
-               engines/splice.c engines/syslet-rw.c engines/guasi.c \
-               engines/binject.c engines/rdma.c profiles/tiobench.c \
-               engines/fusion-aw.c engines/falloc.c engines/e4defrag.c
-  LIBS += -lpthread -ldl -lrt -laio
+  SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
+               engines/binject.c profiles/tiobench.c
+  LIBS += -lpthread -ldl
   LDFLAGS += -rdynamic
 endif
 ifeq ($(UNAME), Android)
-  SOURCE += diskutil.c fifo.c blktrace.c helpers.c trim.c \
-               engines/splice.c profiles/tiobench.c engines/falloc.c \
-               engines/e4defrag.c
+  SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
   LIBS += -ldl
   LDFLAGS += -rdynamic
   CPPFLAGS += -DFIO_NO_HAVE_SHM_H
 endif
 ifeq ($(UNAME), SunOS)
-  CC      = gcc
-  SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
-               engines/solarisaio.c
   LIBS  += -lpthread -ldl -laio -lrt -lnsl -lsocket
   CPPFLAGS += -D__EXTENSIONS__
 endif
 ifeq ($(UNAME), FreeBSD)
-  SOURCE += helpers.c engines/posixaio.c
   LIBS  += -lpthread -lrt
   LDFLAGS += -rdynamic
 endif
 ifeq ($(UNAME), NetBSD)
-  SOURCE += helpers.c engines/posixaio.c
   LIBS  += -lpthread -lrt
   LDFLAGS += -rdynamic
 endif
 ifeq ($(UNAME), AIX)
-  SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
   LIBS  += -lpthread -ldl -lrt
   CPPFLAGS += -D_LARGE_FILES -D__ppc__
   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
 endif
 ifeq ($(UNAME), HP-UX)
-  CC      = gcc
-  SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c engines/posixaio.c
   LIBS   += -lpthread -ldl -lrt
-  CFLAGS += -D_LARGEFILE64_SOURCE
+  CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
 endif
 ifeq ($(UNAME), Darwin)
-  SOURCE += helpers.c engines/posixaio.c
   LIBS  += -lpthread -ldl
 endif
 ifneq (,$(findstring CYGWIN,$(UNAME)))
@@ -76,8 +188,6 @@ ifneq (,$(findstring CYGWIN,$(UNAME)))
   SOURCE += engines/windowsaio.c os/windows/posix.c
   LIBS  += -lpthread -lpsapi -lws2_32
   CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
-  CC     = x86_64-w64-mingw32-gcc
-  #CC    = i686-w64-mingw32-gcc
 endif
 
 OBJS = $(SOURCE:.c=.o)
@@ -196,7 +306,7 @@ t/axmap: $(T_AXMAP_OBJS)
 $(PROGS): .depend
 
 clean: FORCE
-       -rm -f .depend $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE
+       -rm -f .depend $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE config-host.mak config-host.ld cscope.out
 
 cscope:
        @cscope -b -R
index 48030060041bfc48391ec90f998bbace4556741e..679ec2816992a3c7fa82a00b520cd24a82a936ca 100644 (file)
 #define __NR_sys_vmsplice      316
 #endif
 
-#ifndef __NR_async_exec
-#define __NR_async_exec                325
-#define __NR_async_wait                326
-#define __NR_umem_add          327
-#define __NR_async_thread      328
-#endif
-
 #define        FIO_HUGE_PAGE           4194304
 
-#define FIO_HAVE_SYSLET
-
 #define nop            __asm__ __volatile__("rep;nop": : :"memory")
 #define read_barrier() __asm__ __volatile__("": : :"memory")
 #define write_barrier()        __asm__ __volatile__("": : :"memory")
index d8b0933bdadda5e3c7c076b176d9655022bf93ec..cea0451d8ba6f3788e7658508a27863f494ac590 100644 (file)
 #define __NR_sys_vmsplice      278
 #endif
 
-#ifndef __NR_async_exec
-#define __NR_async_exec                286
-#define __NR_async_wait                287
-#define __NR_umem_add          288
-#define __NR_async_thread      289
-#endif
-
 #define        FIO_HUGE_PAGE           2097152
 
-#define FIO_HAVE_SYSLET
-
 #define nop            __asm__ __volatile__("rep;nop": : :"memory")
 #define read_barrier() __asm__ __volatile__("lfence":::"memory")
 #define write_barrier()        __asm__ __volatile__("sfence":::"memory")
index f6a8e998672c4e4425103e576238946be9cabb61..4165c9f95dba610951dd72c7e81f3af4ec8021c5 100644 (file)
@@ -1,14 +1,6 @@
 #ifndef ARCH_H
 #define ARCH_H
 
-#include <stdint.h>
-
-#ifdef __WORDSIZE
-#define BITS_PER_LONG  __WORDSIZE
-#else
-#define BITS_PER_LONG  32
-#endif
-
 enum {
        arch_x86_64 = 1,
        arch_i386,
index 8f16a165c77edfc76de4bf3056402c0167c4f3fa..48b00b685ae7bb0310b3df48d2044b08e80b1081 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -216,7 +216,7 @@ static int __check_min_rate(struct thread_data *td, struct timeval *now,
 }
 
 static int check_min_rate(struct thread_data *td, struct timeval *now,
-                         unsigned long *bytes_done)
+                         uint64_t *bytes_done)
 {
        int ret = 0;
 
@@ -393,8 +393,9 @@ static int break_on_this_error(struct thread_data *td, enum fio_ddir ddir,
  * The main verify engine. Runs over the writes we previously submitted,
  * reads the blocks back in, and checks the crc/md5 of the data.
  */
-static void do_verify(struct thread_data *td)
+static void do_verify(struct thread_data *td, uint64_t verify_bytes)
 {
+       uint64_t bytes_done[DDIR_RWDIR_CNT] = { 0, 0, 0 };
        struct fio_file *f;
        struct io_u *io_u;
        int ret, min_events;
@@ -438,18 +439,53 @@ static void do_verify(struct thread_data *td)
                if (flow_threshold_exceeded(td))
                        continue;
 
-               io_u = __get_io_u(td);
-               if (!io_u)
-                       break;
+               if (!td->o.experimental_verify) {
+                       io_u = __get_io_u(td);
+                       if (!io_u)
+                               break;
 
-               if (get_next_verify(td, io_u)) {
-                       put_io_u(td, io_u);
-                       break;
-               }
+                       if (get_next_verify(td, io_u)) {
+                               put_io_u(td, io_u);
+                               break;
+                       }
 
-               if (td_io_prep(td, io_u)) {
-                       put_io_u(td, io_u);
-                       break;
+                       if (td_io_prep(td, io_u)) {
+                               put_io_u(td, io_u);
+                               break;
+                       }
+               } else {
+                       if (ddir_rw_sum(bytes_done) + td->o.rw_min_bs > verify_bytes)
+                               break;
+
+                       while ((io_u = get_io_u(td)) != NULL) {
+                               /*
+                                * We are only interested in the places where
+                                * we wrote or trimmed IOs. Turn those into
+                                * reads for verification purposes.
+                                */
+                               if (io_u->ddir == DDIR_READ) {
+                                       /*
+                                        * Pretend we issued it for rwmix
+                                        * accounting
+                                        */
+                                       td->io_issues[DDIR_READ]++;
+                                       put_io_u(td, io_u);
+                                       continue;
+                               } else if (io_u->ddir == DDIR_TRIM) {
+                                       io_u->ddir = DDIR_READ;
+                                       io_u->flags |= IO_U_F_TRIMMED;
+                                       break;
+                               } else if (io_u->ddir == DDIR_WRITE) {
+                                       io_u->ddir = DDIR_READ;
+                                       break;
+                               } else {
+                                       put_io_u(td, io_u);
+                                       continue;
+                               }
+                       }
+
+                       if (!io_u)
+                               break;
                }
 
                if (td->o.verify_async)
@@ -491,7 +527,7 @@ static void do_verify(struct thread_data *td)
                                requeue_io_u(td, &io_u);
                        } else {
 sync_done:
-                               ret = io_u_sync_complete(td, io_u, NULL);
+                               ret = io_u_sync_complete(td, io_u, bytes_done);
                                if (ret < 0)
                                        break;
                        }
@@ -534,7 +570,7 @@ sync_done:
                                 * and do the verification on them through
                                 * the callback handler
                                 */
-                               if (io_u_queued_complete(td, min_events, NULL) < 0) {
+                               if (io_u_queued_complete(td, min_events, bytes_done) < 0) {
                                        ret = -1;
                                        break;
                                }
@@ -576,9 +612,12 @@ static int io_bytes_exceeded(struct thread_data *td)
 /*
  * Main IO worker function. It retrieves io_u's to process and queues
  * and reaps them, checking for rate and errors along the way.
+ *
+ * Returns number of bytes written and trimmed.
  */
-static void do_io(struct thread_data *td)
+static uint64_t do_io(struct thread_data *td)
 {
+       uint64_t bytes_done[DDIR_RWDIR_CNT] = { 0, 0, 0 };
        unsigned int i;
        int ret = 0;
 
@@ -591,7 +630,6 @@ static void do_io(struct thread_data *td)
                (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td) ||
                td->o.time_based) {
                struct timeval comp_time;
-               unsigned long bytes_done[DDIR_RWDIR_CNT] = { 0, 0, 0 };
                int min_evts = 0;
                struct io_u *io_u;
                int ret2, full;
@@ -795,6 +833,8 @@ sync_done:
         */
        if (!ddir_rw_sum(td->this_io_bytes))
                td->done = 1;
+
+       return bytes_done[DDIR_WRITE] + bytes_done[DDIR_TRIM];
 }
 
 static void cleanup_io_u(struct thread_data *td)
@@ -1030,6 +1070,7 @@ static void *thread_main(void *data)
        INIT_FLIST_HEAD(&td->io_hist_list);
        INIT_FLIST_HEAD(&td->verify_list);
        INIT_FLIST_HEAD(&td->trim_list);
+       INIT_FLIST_HEAD(&td->next_rand_list);
        pthread_mutex_init(&td->io_u_lock, NULL);
        td->io_hist_tree = RB_ROOT;
 
@@ -1083,10 +1124,7 @@ static void *thread_main(void *data)
                }
        }
 
-       if (fio_pin_memory(td))
-               goto err;
-
-#ifdef FIO_HAVE_LIBNUMA
+#ifdef CONFIG_LIBNUMA
        /* numa node setup */
        if (td->o.numa_cpumask_set || td->o.numa_memmask_set) {
                int ret;
@@ -1186,6 +1224,8 @@ static void *thread_main(void *data)
 
        clear_state = 0;
        while (keep_running(td)) {
+               uint64_t verify_bytes;
+
                fio_gettime(&td->start, NULL);
                memcpy(&td->bw_sample_time, &td->start, sizeof(td->start));
                memcpy(&td->iops_sample_time, &td->start, sizeof(td->start));
@@ -1206,7 +1246,7 @@ static void *thread_main(void *data)
 
                prune_io_piece_log(td);
 
-               do_io(td);
+               verify_bytes = do_io(td);
 
                clear_state = 1;
 
@@ -1235,7 +1275,7 @@ static void *thread_main(void *data)
 
                fio_gettime(&td->start, NULL);
 
-               do_verify(td);
+               do_verify(td, verify_bytes);
 
                td->ts.runtime[DDIR_READ] += utime_since_now(&td->start);
 
diff --git a/cconv.c b/cconv.c
index 173312311b336b32e8522db2582aef31460d6e10..e7339d04f8a74bef6554fe71c49937c2676b6c4a 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -97,6 +97,8 @@ void convert_thread_options_to_cpu(struct thread_options *o,
        o->verify = le32_to_cpu(top->verify);
        o->do_verify = le32_to_cpu(top->do_verify);
        o->verifysort = le32_to_cpu(top->verifysort);
+       o->verifysort_nr = le32_to_cpu(top->verifysort_nr);
+       o->experimental_verify = le32_to_cpu(top->experimental_verify);
        o->verify_interval = le32_to_cpu(top->verify_interval);
        o->verify_offset = le32_to_cpu(top->verify_offset);
 
@@ -254,6 +256,8 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
        top->verify = cpu_to_le32(o->verify);
        top->do_verify = cpu_to_le32(o->do_verify);
        top->verifysort = cpu_to_le32(o->verifysort);
+       top->verifysort_nr = cpu_to_le32(o->verifysort_nr);
+       top->experimental_verify = cpu_to_le32(o->experimental_verify);
        top->verify_interval = cpu_to_le32(o->verify_interval);
        top->verify_offset = cpu_to_le32(o->verify_offset);
        top->verify_pattern_bytes = cpu_to_le32(o->verify_pattern_bytes);
index 9cbbcf66734877dd79d32fa284e2d7d3f4bb7a3d..c280762265e29061fb15e4e94a8ac7fadf6005c3 100644 (file)
--- a/client.c
+++ b/client.c
@@ -304,7 +304,7 @@ static void probe_client(struct fio_client *client)
 static int fio_client_connect_ip(struct fio_client *client)
 {
        struct sockaddr *addr;
-       fio_socklen_t socklen;
+       socklen_t socklen;
        int fd, domain;
 
        if (client->ipv6) {
@@ -345,7 +345,7 @@ static int fio_client_connect_ip(struct fio_client *client)
 static int fio_client_connect_sock(struct fio_client *client)
 {
        struct sockaddr_un *addr = &client->addr_un;
-       fio_socklen_t len;
+       socklen_t len;
        int fd;
 
        memset(addr, 0, sizeof(*addr));
@@ -1322,7 +1322,7 @@ static int fio_check_clients_timed_out(void)
        struct timeval tv;
        int ret = 0;
 
-       gettimeofday(&tv, NULL);
+       fio_gettime(&tv, NULL);
 
        flist_for_each_safe(entry, tmp, &client_list) {
                client = flist_entry(entry, struct fio_client, list);
@@ -1350,7 +1350,7 @@ int fio_handle_clients(struct client_ops *ops)
        struct pollfd *pfds;
        int i, ret = 0, retval = 0;
 
-       gettimeofday(&eta_tv, NULL);
+       fio_gettime(&eta_tv, NULL);
 
        pfds = malloc(nr_clients * sizeof(struct pollfd));
 
@@ -1384,8 +1384,8 @@ int fio_handle_clients(struct client_ops *ops)
                do {
                        struct timeval tv;
 
-                       gettimeofday(&tv, NULL);
-                       if (mtime_since(&eta_tv, &tv) >= ops->eta_msec) {
+                       fio_gettime(&tv, NULL);
+                       if (mtime_since(&eta_tv, &tv) >= 900) {
                                request_client_etas(ops);
                                memcpy(&eta_tv, &tv, sizeof(tv));
 
index 8923f9a6235190d0837505c1852363fdf3fd6162..72e84197584e1aa8872e2905bc70710989443416 100644 (file)
 #define __must_check
 #endif
 
-#ifndef _weak
-#ifndef __CYGWIN__
-#define _weak  __attribute__((weak))
-#else
-#define _weak
-#endif
-#endif
-
 #endif
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..f730dfd
--- /dev/null
+++ b/configure
@@ -0,0 +1,894 @@
+#!/bin/sh
+#
+# Fio configure script. Heavily influenced by the manual qemu configure
+# script. Sad this this is easier than autoconf and enemies.
+#
+
+# set temporary file name
+if test ! -z "$TMPDIR" ; then
+    TMPDIR1="${TMPDIR}"
+elif test ! -z "$TEMPDIR" ; then
+    TMPDIR1="${TEMPDIR}"
+else
+    TMPDIR1="/tmp"
+fi
+
+TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
+TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
+TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
+
+# NB: do not call "exit" in the trap handler; this is buggy with some shells;
+# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
+trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
+
+rm -rf config.log
+
+config_host_mak="config-host.mak"
+config_host_ld="config-host.ld"
+
+# Print a helpful header at the top of config.log
+echo "# FIO configure log $(date)" >> config.log
+printf "# Configured with:" >> config.log
+printf " '%s'" "$0" "$@" >> config.log
+echo >> config.log
+echo "#" >> config.log
+
+do_cc() {
+    # Run the compiler, capturing its output to the log.
+    echo $cc "$@" >> config.log
+    $cc "$@" >> config.log 2>&1 || return $?
+    # Test passed. If this is an --enable-werror build, rerun
+    # the test with -Werror and bail out if it fails. This
+    # makes warning-generating-errors in configure test code
+    # obvious to developers.
+    if test "$werror" != "yes"; then
+        return 0
+    fi
+    # Don't bother rerunning the compile if we were already using -Werror
+    case "$*" in
+        *-Werror*)
+           return 0
+        ;;
+    esac
+    echo $cc -Werror "$@" >> config.log
+    $cc -Werror "$@" >> config.log 2>&1 && return $?
+    echo "ERROR: configure test passed without -Werror but failed with -Werror."
+    echo "This is probably a bug in the configure script. The failing command"
+    echo "will be at the bottom of config.log."
+    echo "You can run configure with --disable-werror to bypass this check."
+    exit 1
+}
+
+compile_object() {
+  do_cc $CFLAGS -c -o $TMPO $TMPC
+}
+
+compile_prog() {
+  local_cflags="$1"
+  local_ldflags="$2"
+  echo "Compiling test case $3" >> config.log
+  do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
+}
+
+feature_not_found() {
+  feature=$1
+
+  echo "ERROR"
+  echo "ERROR: User requested feature $feature"
+  echo "ERROR: configure was not able to find it"
+  echo "ERROR"
+  exit 1;
+}
+
+has() {
+  type "$1" >/dev/null 2>&1
+}
+
+check_define() {
+  cat > $TMPC <<EOF
+#if !defined($1)
+#error $1 not defined
+#endif
+int main(void)
+{
+  return 0;
+}
+EOF
+  compile_object
+}
+
+targetos=""
+cpu=""
+
+cc="${CC-${cross_prefix}gcc}"
+
+# parse options
+for opt do
+  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
+  case "$opt" in
+  --cc=*) CC="$optarg"
+  ;;
+  *)
+  echo "Bad option $opt"
+  exit 1
+  esac
+done
+
+if check_define __linux__ ; then
+  targetos="Linux"
+elif check_define __OpenBSD__ ; then
+  targetos='OpenBSD'
+elif check_define __sun__ ; then
+  targetos='SunOS'
+else
+  targetos=`uname -s`
+fi
+
+# Some host OSes need non-standard checks for which CPU to use.
+# Note that these checks are broken for cross-compilation: if you're
+# cross-compiling to one of these OSes then you'll need to specify
+# the correct CPU with the --cpu option.
+case $targetos in
+Darwin)
+  # on Leopard most of the system is 32-bit, so we have to ask the kernel if
+  # we can run 64-bit userspace code.
+  # If the user didn't specify a CPU explicitly and the kernel says this is
+  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
+  # detection code.
+  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
+    cpu="x86_64"
+  fi
+  ;;
+SunOS)
+  # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
+  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
+    cpu="x86_64"
+  fi
+  ;;
+CYGWIN*)
+  echo "Forcing known good options on Windows"
+  if test -z "$CC" ; then
+    CC="x86_64-w64-mingw32-gcc"
+  fi
+  echo "CC=$CC"                    >  $config_host_mak
+  echo "CONFIG_LITTLE_ENDIAN=y"    >> $config_host_mak
+  echo "CONFIG_64BIT_LLP64=y"      >> $config_host_mak
+  echo "CONFIG_CLOCK_GETTIME=y"    >> $config_host_mak
+  echo "CONFIG_CLOCK_MONOTONIC=y"  >> $config_host_mak
+  echo "CONFIG_GETTIMEOFDAY=y"     >> $config_host_mak
+  echo "CONFIG_FADVISE=y"          >> $config_host_mak
+  echo "CONFIG_SOCKLEN_T=y"        >> $config_host_mak
+  echo "CONFIG_POSIX_FALLOCATE=y"  >> $config_host_mak
+  echo "CONFIG_FADVISE=y"          >> $config_host_mak
+  echo "CONFIG_SFAA=y"             >> $config_host_mak
+  exit 0
+esac
+
+if test ! -z "$cpu" ; then
+  # command line argument
+  :
+elif check_define __i386__ ; then
+  cpu="i386"
+elif check_define __x86_64__ ; then
+  cpu="x86_64"
+elif check_define __sparc__ ; then
+  if check_define __arch64__ ; then
+    cpu="sparc64"
+  else
+    cpu="sparc"
+  fi
+elif check_define _ARCH_PPC ; then
+  if check_define _ARCH_PPC64 ; then
+    cpu="ppc64"
+  else
+    cpu="ppc"
+  fi
+elif check_define __mips__ ; then
+  cpu="mips"
+elif check_define __ia64__ ; then
+  cpu="ia64"
+elif check_define __s390__ ; then
+  if check_define __s390x__ ; then
+    cpu="s390x"
+  else
+    cpu="s390"
+  fi
+elif check_define __arm__ ; then
+  cpu="arm"
+elif check_define __hppa__ ; then
+  cpu="hppa"
+else
+  cpu=`uname -m`
+fi
+
+# Normalise host CPU name and set ARCH.
+case "$cpu" in
+  ia64|ppc|ppc64|s390|s390x|sparc64)
+    cpu="$cpu"
+  ;;
+  i386|i486|i586|i686|i86pc|BePC)
+    cpu="i386"
+  ;;
+  x86_64|amd64)
+    cpu="x86_64"
+  ;;
+  armv*b|armv*l|arm)
+    cpu="arm"
+  ;;
+  hppa|parisc|parisc64)
+    cpu="hppa"
+  ;;
+  mips*)
+    cpu="mips"
+  ;;
+  sparc|sun4[cdmuv])
+    cpu="sparc"
+  ;;
+  *)
+    echo "Unknown CPU"
+    exit 1;
+  ;;
+esac
+
+if test -z $CC; then
+  if test "$targetos" = "FreeBSD"; then
+    if has clang; then
+      CC=clang
+    else
+      CC=gcc
+    fi
+  fi
+fi
+
+cc="${CC-${cross_prefix}gcc}"
+
+##########################################
+# check endianness
+bigendian="no"
+cat > $TMPC <<EOF
+#include <inttypes.h>
+int main(void)
+{
+  volatile uint32_t i=0x01234567;
+  return (*((uint8_t*)(&i))) == 0x67;
+}
+EOF
+if compile_prog "" "" "endian"; then
+  $TMPE && bigendian="yes"
+fi
+
+
+echo "Operating system              $targetos"
+echo "CPU                           $cpu"
+echo "Big endian                    $bigendian"
+echo "Compiler                      $cc"
+echo
+
+##########################################
+# check for wordsize
+wordsize="0"
+cat > $TMPC <<EOF
+#include <stdio.h>
+int main(void)
+{
+  unsigned int wsize = sizeof(long) * 8;
+  printf("%d\n", wsize);
+  return 0;
+}
+EOF
+if compile_prog "" "" "wordsize"; then
+  wordsize=$($TMPE)
+fi
+echo "Wordsize                      $wordsize"
+
+##########################################
+# linux-aio probe
+libaio="no"
+cat > $TMPC <<EOF
+#include <libaio.h>
+#include <stddef.h>
+int main(void)
+{
+  io_setup(0, NULL);
+  return 0;
+}
+EOF
+if compile_prog "" "-laio" "libaio" ; then
+  libaio=yes
+  LIBS="-laio $LIBS"
+else
+  if test "$libaio" = "yes" ; then
+    feature_not_found "linux AIO"
+  fi
+  libaio=no
+fi
+echo "Linux AIO support             $libaio"
+
+##########################################
+# posix aio probe
+posix_aio="no"
+posix_aio_lrt="no"
+cat > $TMPC <<EOF
+#include <aio.h>
+int main(void)
+{
+  struct aiocb cb;
+  aio_read(&cb);
+  return 0;
+}
+EOF
+if compile_prog "" "" "posixaio" ; then
+  posix_aio="yes"
+elif compile_prog "" "-lrt" "posixaio"; then
+  posix_aio="yes"
+  posix_aio_lrt="yes"
+  LIBS="-lrt $LIBS"
+fi
+echo "POSIX AIO support             $posix_aio"
+echo "POSIX AIO support needs -lrt  $posix_aio_lrt"
+
+##########################################
+# posix aio fsync probe
+posix_aio_fsync="no"
+if test "$posix_aio" = "yes" ; then
+  cat > $TMPC <<EOF
+#include <fcntl.h>
+#include <aio.h>
+int main(void)
+{
+  struct aiocb cb;
+  return aio_fsync(O_SYNC, &cb);
+  return 0;
+}
+EOF
+  if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
+    posix_aio_fsync=yes
+  fi
+fi
+echo "POSIX AIO fsync               $posix_aio_fsync"
+
+##########################################
+# solaris aio probe
+solaris_aio="no"
+cat > $TMPC <<EOF
+#include <sys/types.h>
+#include <sys/asynch.h>
+#include <unistd.h>
+int main(void)
+{
+  aio_result_t res;
+  return aioread(0, NULL, 0, 0, SEEK_SET, &res);
+  return 0;
+}
+EOF
+if compile_prog "" "-laio" "solarisaio" ; then
+  solaris_aio=yes
+  LIBS="-laio $LIBS"
+fi
+echo "Solaris AIO support           $solaris_aio"
+
+##########################################
+# __sync_fetch_and_and test
+sfaa="no"
+cat > $TMPC << EOF
+static int sfaa(int *ptr)
+{
+  return __sync_fetch_and_and(ptr, 0);
+}
+
+int main(int argc, char **argv)
+{
+  int val = 42;
+  sfaa(&val);
+  return val;
+}
+EOF
+if compile_prog "" "" "__sync_fetch_and_add()" ; then
+    sfaa="yes"
+fi
+echo "__sync_fetch_and add          $sfaa"
+
+##########################################
+# libverbs probe
+libverbs="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <infiniband/arch.h>
+int main(int argc, char **argv)
+{
+  struct ibv_pd *pd = ibv_alloc_pd(NULL);
+  return 0;
+}
+EOF
+if compile_prog "" "-libverbs" "libverbs" ; then
+    libverbs="yes"
+    LIBS="-libverbs $LIBS"
+fi
+echo "libverbs                      $libverbs"
+
+##########################################
+# rdmacm probe
+rdmacm="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <rdma/rdma_cma.h>
+int main(int argc, char **argv)
+{
+  rdma_destroy_qp(NULL);
+  return 0;
+}
+EOF
+if compile_prog "" "-lrdmacm" "rdma"; then
+    rdmacm="yes"
+    LIBS="-lrdmacm $LIBS"
+fi
+echo "rdmacm                        $rdmacm"
+
+##########################################
+# Linux fallocate probe
+linux_fallocate="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <linux/falloc.h>
+int main(int argc, char **argv)
+{
+  int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
+  return r;
+}
+EOF
+if compile_prog "" "" "linux_fallocate"; then
+    linux_fallocate="yes"
+fi
+echo "Linux fallocate               $linux_fallocate"
+
+##########################################
+# POSIX fadvise probe
+posix_fadvise="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <fcntl.h>
+int main(int argc, char **argv)
+{
+  int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
+  return r;
+}
+EOF
+if compile_prog "" "" "posix_fadvise"; then
+    posix_fadvise="yes"
+fi
+echo "POSIX fadvise                 $posix_fadvise"
+
+##########################################
+# POSIX fallocate probe
+posix_fallocate="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <fcntl.h>
+int main(int argc, char **argv)
+{
+  int r = posix_fallocate(0, 0, 1024);
+  return r;
+}
+EOF
+if compile_prog "" "" "posix_fallocate"; then
+    posix_fallocate="yes"
+fi
+echo "POSIX fallocate               $posix_fallocate"
+
+##########################################
+# sched_set/getaffinity 2 or 3 argument test
+linux_2arg_affinity="no"
+linux_3arg_affinity="no"
+cat > $TMPC << EOF
+#define _GNU_SOURCE
+#include <sched.h>
+int main(int argc, char **argv)
+{
+  cpu_set_t mask;
+  return sched_setaffinity(0, sizeof(mask), &mask);
+}
+EOF
+if compile_prog "" "" "sched_setaffinity(,,)"; then
+  linux_3arg_affinity="yes"
+else
+  cat > $TMPC << EOF
+#define _GNU_SOURCE
+#include <sched.h>
+int main(int argc, char **argv)
+{
+  cpu_set_t mask;
+  return sched_setaffinity(0, &mask);
+}
+EOF
+  if compile_prog "" "" "sched_setaffinity(,)"; then
+    linux_2arg_affinity="yes"
+  fi
+fi
+echo "sched_setaffinity(3 arg)      $linux_3arg_affinity"
+echo "sched_setaffinity(2 arg)      $linux_2arg_affinity"
+
+##########################################
+# clock_gettime probe
+clock_gettime="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <time.h>
+int main(int argc, char **argv)
+{
+  return clock_gettime(0, NULL);
+}
+EOF
+if compile_prog "" "" "clock_gettime"; then
+    clock_gettime="yes"
+elif compile_prog "" "-lrt" "clock_gettime"; then
+    clock_gettime="yes"
+    LIBS="-lrt $LIBS"
+fi
+echo "clock_gettime                 $clock_gettime"
+
+##########################################
+# CLOCK_MONOTONIC probe
+clock_monotonic="no"
+if test "$clock_gettime" = "yes" ; then
+  cat > $TMPC << EOF
+#include <stdio.h>
+#include <time.h>
+int main(int argc, char **argv)
+{
+  return clock_gettime(CLOCK_MONOTONIC, NULL);
+}
+EOF
+  if compile_prog "" "$LIBS" "clock monotonic"; then
+      clock_monotonic="yes"
+  fi
+fi
+echo "CLOCK_MONOTONIC               $clock_monotonic"
+
+##########################################
+# CLOCK_MONOTONIC_PRECISE probe
+clock_monotonic_precise="no"
+if test "$clock_gettime" = "yes" ; then
+  cat > $TMPC << EOF
+#include <stdio.h>
+#include <time.h>
+int main(int argc, char **argv)
+{
+  return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
+}
+EOF
+  if compile_prog "" "$LIBS" "clock monotonic precise"; then
+      clock_monotonic_precise="yes"
+  fi
+fi
+echo "CLOCK_MONOTONIC_PRECISE       $clock_monotonic_precise"
+
+##########################################
+# gettimeofday() probe
+gettimeofday="no"
+cat > $TMPC << EOF
+#include <sys/time.h>
+#include <stdio.h>
+int main(int argc, char **argv)
+{
+  struct timeval tv;
+  return gettimeofday(&tv, NULL);
+}
+EOF
+if compile_prog "" "" "gettimeofday"; then
+    gettimeofday="yes"
+fi
+echo "gettimeofday                  $gettimeofday"
+
+##########################################
+# fdatasync() probe
+fdatasync="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <unistd.h>
+int main(int argc, char **argv)
+{
+  return fdatasync(0);
+}
+EOF
+if compile_prog "" "" "fdatasync"; then
+  fdatasync="yes"
+fi
+echo "fdatasync                     $fdatasync"
+
+##########################################
+# sync_file_range() probe
+sync_file_range="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <unistd.h>
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <linux/fs.h>
+int main(int argc, char **argv)
+{
+  unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
+                       SYNC_FILE_RANGE_WAIT_AFTER;
+  return sync_file_range(0, 0, 0, flags);
+}
+EOF
+if compile_prog "" "" "sync_file_range"; then
+  sync_file_range="yes"
+fi
+echo "sync_file_range               $sync_file_range"
+
+##########################################
+# ext4 move extent probe
+ext4_me="no"
+cat > $TMPC << EOF
+#include <fcntl.h>
+#include <sys/ioctl.h>
+int main(int argc, char **argv)
+{
+  struct move_extent me;
+  return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
+}
+EOF
+if compile_prog "" "" "ext4 move extent" ; then
+  ext4_me="yes"
+elif test $targetos = "Linux" ; then
+  # On Linux, just default to it on and let it error at runtime if we really
+  # don't have it. None of my updated systems have it defined, but it does
+  # work. Takes a while to bubble back.
+  ext4_me="yes"
+fi
+echo "EXT4 move extent              $ext4_me"
+
+##########################################
+# splice probe
+linux_splice="no"
+cat > $TMPC << EOF
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <fcntl.h>
+int main(int argc, char **argv)
+{
+  return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
+}
+EOF
+if compile_prog "" "" "linux splice"; then
+  linux_splice="yes"
+fi
+echo "Linux splice(2)               $linux_splice"
+
+##########################################
+# GUASI probe
+guasi="no"
+cat > $TMPC << EOF
+#include <guasi.h>
+#include <guasi_syscalls.h>
+int main(int argc, char **argv)
+{
+  guasi_t ctx = guasi_create(0, 0, 0);
+  return 0;
+}
+EOF
+if compile_prog "" "" "guasi"; then
+  guasi="yes"
+fi
+echo "GUASI                         $guasi"
+
+##########################################
+# fusion-aw probe
+fusion_aw="no"
+cat > $TMPC << EOF
+#include <nvm/vectored_write.h>
+int main(int argc, char **argv)
+{
+  struct vsl_iovec iov;
+  return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
+}
+EOF
+if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
+  LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
+  fusion_aw="yes"
+fi
+echo "Fusion-io atomic engine       $fusion_aw"
+
+##########################################
+# libnuma probe
+libnuma="no"
+cat > $TMPC << EOF
+#include <numa.h>
+int main(int argc, char **argv)
+{
+  return numa_available();
+}
+EOF
+if compile_prog "" "-lnuma" "libnuma"; then
+  libnuma="yes"
+  LIBS="-lnuma $LIBS"
+fi
+echo "libnuma                       $libnuma"
+
+##########################################
+# strsep() probe
+strsep="no"
+cat > $TMPC << EOF
+#include <string.h>
+int main(int argc, char **argv)
+{
+  strsep(NULL, NULL);
+  return 0;
+}
+EOF
+if compile_prog "" "" "strsep"; then
+  strsep="yes"
+fi
+echo "strsep                        $strsep"
+
+##########################################
+# getopt_long_only() probe
+getopt_long_only="no"
+cat > $TMPC << EOF
+#include <unistd.h>
+#include <stdio.h>
+int main(int argc, char **argv)
+{
+  int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
+  return c;
+}
+EOF
+if compile_prog "" "" "getopt_long_only"; then
+  getopt_long_only="yes"
+fi
+echo "getopt_long_only()            $getopt_long_only"
+
+##########################################
+# inet_aton() probe
+inet_aton="no"
+cat > $TMPC << EOF
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+int main(int argc, char **argv)
+{
+  struct in_addr in;
+  return inet_aton(NULL, &in);
+}
+EOF
+if compile_prog "" "" "inet_aton"; then
+  inet_aton="yes"
+fi
+echo "inet_aton                     $inet_aton"
+
+##########################################
+# socklen_t probe
+socklen_t="no"
+cat > $TMPC << EOF
+#include <string.h>
+#include <netinet/in.h>
+int main(int argc, char **argv)
+{
+  socklen_t len = 0;
+  return len;
+}
+EOF
+if compile_prog "" "" "socklen_t"; then
+  socklen_t="yes"
+fi
+echo "socklen_t                     $socklen_t"
+
+##########################################
+# Whether or not __thread is supported for TLS
+tls_thread="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+static int __thread ret;
+int main(int argc, char **argv)
+{
+  return ret;
+}
+EOF
+if compile_prog "" "" "__thread"; then
+  tls_thread="yes"
+fi
+echo "__thread                      $tls_thread"
+
+#############################################################################
+
+echo "# Automatically generated by configure - do not modify" > $config_host_mak
+printf "# Configured with:" >> $config_host_mak
+printf " '%s'" "$0" "$@" >> $config_host_mak
+echo >> $config_host_mak
+
+if test "$wordsize" = "64" ; then
+  echo "CONFIG_64BIT=y" >> $config_host_mak
+elif test "$wordsize" = "32" ; then
+  echo "CONFIG_32BIT=y" >> $config_host_mak
+else
+  echo "Unknown wordsize!"
+  exit 1
+fi
+if test "$bigendian" = "yes" ; then
+  echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
+else
+  echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
+fi
+if test "$libaio" = "yes" ; then
+  echo "CONFIG_LIBAIO=y" >> $config_host_mak
+fi
+if test "$posix_aio" = "yes" ; then
+  echo "CONFIG_POSIXAIO=y" >> $config_host_mak
+fi
+if test "$posix_aio_fsync" = "yes" ; then
+  echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
+fi
+if test "$linux_fallocate" = "yes" ; then
+  echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
+fi
+if test "$posix_fallocate" = "yes" ; then
+  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
+fi
+if test "$fdatasync" = "yes" ; then
+  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
+fi
+if test "$sync_file_range" = "yes" ; then
+  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
+fi
+if test "$sfaa" = "yes" ; then
+  echo "CONFIG_SFAA=y" >> $config_host_mak
+fi
+if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
+  echo "CONFIG_RDMA=y" >> $config_host_mak
+fi
+if test "$clock_gettime" = "yes" ; then
+  echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
+fi
+if test "$clock_monotonic" = "yes" ; then
+  echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
+fi
+if test "$clock_monotonic_precise" = "yes" ; then
+  echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
+fi
+if test "$gettimeofday" = "yes" ; then
+  echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
+fi
+if test "$posix_fadvise" = "yes" ; then
+  echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
+fi
+if test "$linux_3arg_affinity" = "yes" ; then
+  echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
+elif test "$linux_2arg_affinity" = "yes" ; then
+  echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
+fi
+if test "$strsep" = "yes" ; then
+  echo "CONFIG_STRSEP=y" >> $config_host_mak
+fi
+if test "$getopt_long_only" = "yes" ; then
+  echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
+fi
+if test "$inet_aton" = "yes" ; then
+  echo "CONFIG_INET_ATON=y" >> $config_host_mak
+fi
+if test "$socklen_t" = "yes" ; then
+  echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
+fi
+if test "$ext4_me" = "yes" ; then
+  echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
+fi
+if test "$linux_splice" = "yes" ; then
+  echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
+fi
+if test "$guasi" = "yes" ; then
+  echo "CONFIG_GUASI=y" >> $config_host_mak
+fi
+if test "$fusion_aw" = "yes" ; then
+  echo "CONFIG_FUSION_AW=y" >> $config_host_mak
+fi
+if test "$libnuma" = "yes" ; then
+  echo "CONFIG_LIBNUMA=y" >> $config_host_mak
+fi
+if test "$solaris_aio" = "yes" ; then
+  echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
+fi
+if test "$tls_thread" = "yes" ; then
+  echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
+fi
+
+echo "LIBS+=$LIBS" >> $config_host_mak
+echo "CC=$cc" >> $config_host_mak
index 118c6dd5a0cc599ca2d36572eb86bcf92fec0e24..0bc5c0b32ddf00d2dec489e1fe9a5861335a3854 100644 (file)
 
 #include "../fio.h"
 
-#ifdef FIO_HAVE_FUSION_AW
-
-#include <vsl_dp_experimental/vectored_write.h>
+#include <nvm/vectored_write.h>
 
 /* Fix sector size to 512 bytes independent of actual sector size, just like
  * the linux kernel. */
 #define SECTOR_SHIFT    9
 #define SECTOR_SIZE    (1U<<SECTOR_SHIFT)
 
-struct acs_file_data {
+struct acs_engine_data {
        struct vsl_iovec iov[IO_VECTOR_LIMIT];
 };
 
@@ -42,7 +40,8 @@ static int queue(struct thread_data *td, struct io_u *io_u)
        off_t offset;
        char *xfer_buf;
        size_t xfer_buflen;
-       struct acs_file_data *d = io_u->file->file_data;
+       struct acs_engine_data *d =
+               (struct acs_engine_data *) io_u->file->engine_data;
 
        if (io_u->ddir != DDIR_WRITE) {
                td_vmsg(td, -EIO, "only writes supported", "io_u->ddir");
@@ -101,7 +100,7 @@ out:
 static int open_file(struct thread_data *td, struct fio_file *f)
 {
        int rc;
-       struct acs_file_data *d = NULL;
+       struct acs_engine_data *d = NULL;
 
        d = malloc(sizeof(*d));
        if (!d) {
@@ -109,7 +108,7 @@ static int open_file(struct thread_data *td, struct fio_file *f)
                rc = -ENOMEM;
                goto error;
        }
-       f->file_data = d;
+       f->engine_data = (uintptr_t) d;
 
        rc = generic_open_file(td, f);
 
@@ -118,7 +117,7 @@ out:
 
 error:
        f->fd = -1;
-       f->file_data = NULL;
+       f->engine_data = 0;
        if (d)
                free(d);
 
@@ -127,9 +126,9 @@ error:
 
 static int close_file(struct thread_data *td, struct fio_file *f)
 {
-       if (f->file_data) {
-               free(f->file_data);
-               f->file_data = NULL;
+       if (f->engine_data) {
+               free((void *) f->engine_data);
+               f->engine_data = 0;
        }
 
        return generic_close_file(td, f);
@@ -145,22 +144,6 @@ static struct ioengine_ops ioengine = {
        .flags = FIO_SYNCIO | FIO_RAWIO | FIO_MEMALIGN
 };
 
-#else /* !FUSION_HAVE_FUSION_AW */
-
-static int fio_fusion_aw_eng_init(struct thread_data fio_unused *td)
-{
-       log_err("fio: fusion atomic write engine not available\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "fusion-aw-sync",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_fusion_aw_eng_init,
-};
-
-#endif /* FUSION_HAVE_FUSION_AW */
-
 static void fio_init fio_fusion_aw_init(void)
 {
        register_ioengine(&ioengine);
index 4839019fc49c3ec88facc04eda4e5c812b3a68f9..6faae8d0bfc2054ea542f31181b3f888437ea06c 100644 (file)
@@ -21,8 +21,6 @@
 
 #include "../fio.h"
 
-#ifdef FIO_HAVE_GUASI
-
 #define GFIO_MIN_THREADS 32
 #ifndef GFIO_MAX_THREADS
 #define GFIO_MAX_THREADS 2000
@@ -264,27 +262,6 @@ static struct ioengine_ops ioengine = {
        .get_file_size  = generic_get_file_size,
 };
 
-#else /* FIO_HAVE_GUASI */
-
-/*
- * When we have a proper configure system in place, we simply wont build
- * and install this io engine. For now install a crippled version that
- * just complains and fails to load.
- */
-static int fio_guasi_init(struct thread_data fio_unused *td)
-{
-       log_err("fio: guasi not available\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "guasi",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_guasi_init,
-};
-
-#endif
-
 static void fio_init fio_guasi_register(void)
 {
        register_ioengine(&ioengine);
index e9ce0ce7d4ac81c174d4932510b82c6fd732527d..d668325f4af34ff8247e777eaf45e9f5e7804172 100644 (file)
@@ -9,11 +9,10 @@
 #include <unistd.h>
 #include <errno.h>
 #include <assert.h>
+#include <libaio.h>
 
 #include "../fio.h"
 
-#ifdef FIO_HAVE_LIBAIO
-
 struct libaio_data {
        io_context_t aio_ctx;
        struct io_event *aio_events;
@@ -306,27 +305,6 @@ static struct ioengine_ops ioengine = {
        .option_struct_size     = sizeof(struct libaio_options),
 };
 
-#else /* FIO_HAVE_LIBAIO */
-
-/*
- * When we have a proper configure system in place, we simply wont build
- * and install this io engine. For now install a crippled version that
- * just complains and fails to load.
- */
-static int fio_libaio_init(struct thread_data fio_unused *td)
-{
-       log_err("fio: libaio not available\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "libaio",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_libaio_init,
-};
-
-#endif
-
 static void fio_init fio_libaio_register(void)
 {
        register_ioengine(&ioengine);
index bbfce811cc67d3605c7154281c5d1195a717b313..9451186934d8de438dd95b9a172ffb0281a23ac6 100644 (file)
@@ -165,7 +165,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u)
        return 0;
 }
 
-#ifdef FIO_HAVE_SPLICE
+#ifdef CONFIG_LINUX_SPLICE
 static int splice_io_u(int fdin, int fdout, unsigned int len)
 {
        int bytes = 0;
@@ -360,7 +360,7 @@ static int fio_netio_recv(struct thread_data *td, struct io_u *io_u)
 
        do {
                if (o->proto == FIO_TYPE_UDP) {
-                       fio_socklen_t len = sizeof(nd->addr);
+                       socklen_t len = sizeof(nd->addr);
                        struct sockaddr *from = (struct sockaddr *) &nd->addr;
 
                        ret = recvfrom(io_u->file->fd, io_u->xfer_buf,
@@ -482,7 +482,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f)
        if (o->proto == FIO_TYPE_UDP)
                return 0;
        else if (o->proto == FIO_TYPE_TCP) {
-               fio_socklen_t len = sizeof(nd->addr);
+               socklen_t len = sizeof(nd->addr);
 
                if (connect(f->fd, (struct sockaddr *) &nd->addr, len) < 0) {
                        td_verror(td, errno, "connect");
@@ -491,7 +491,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f)
                }
        } else {
                struct sockaddr_un *addr = &nd->addr_un;
-               fio_socklen_t len;
+               socklen_t len;
 
                len = sizeof(addr->sun_family) + strlen(addr->sun_path) + 1;
 
@@ -509,7 +509,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f)
 {
        struct netio_data *nd = td->io_ops->data;
        struct netio_options *o = td->eo;
-       fio_socklen_t socklen = sizeof(nd->addr);
+       socklen_t socklen = sizeof(nd->addr);
        int state;
 
        if (o->proto == FIO_TYPE_UDP) {
@@ -549,7 +549,7 @@ static void fio_netio_udp_close(struct thread_data *td, struct fio_file *f)
        msg.magic = htonl(FIO_LINK_OPEN_CLOSE_MAGIC);
        msg.cmd = htonl(FIO_LINK_CLOSE);
 
-       ret = sendto(f->fd, &msg, sizeof(msg), MSG_WAITALL, to,
+       ret = sendto(f->fd, (void *) &msg, sizeof(msg), MSG_WAITALL, to,
                        sizeof(nd->addr));
        if (ret < 0)
                td_verror(td, errno, "sendto udp link close");
@@ -574,10 +574,10 @@ static int fio_netio_udp_recv_open(struct thread_data *td, struct fio_file *f)
        struct netio_data *nd = td->io_ops->data;
        struct udp_close_msg msg;
        struct sockaddr *to = (struct sockaddr *) &nd->addr;
-       fio_socklen_t len = sizeof(nd->addr);
+       socklen_t len = sizeof(nd->addr);
        int ret;
 
-       ret = recvfrom(f->fd, &msg, sizeof(msg), MSG_WAITALL, to, &len);
+       ret = recvfrom(f->fd, (void *) &msg, sizeof(msg), MSG_WAITALL, to, &len);
        if (ret < 0) {
                td_verror(td, errno, "sendto udp link open");
                return ret;
@@ -603,7 +603,7 @@ static int fio_netio_udp_send_open(struct thread_data *td, struct fio_file *f)
        msg.magic = htonl(FIO_LINK_OPEN_CLOSE_MAGIC);
        msg.cmd = htonl(FIO_LINK_OPEN);
 
-       ret = sendto(f->fd, &msg, sizeof(msg), MSG_WAITALL, to,
+       ret = sendto(f->fd, (void *) &msg, sizeof(msg), MSG_WAITALL, to,
                        sizeof(nd->addr));
        if (ret < 0) {
                td_verror(td, errno, "sendto udp link open");
@@ -751,7 +751,7 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port)
        }
 
        opt = 1;
-       if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
+       if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(opt)) < 0) {
                td_verror(td, errno, "setsockopt");
                return 1;
        }
@@ -895,7 +895,7 @@ static void fio_netio_terminate(struct thread_data *td)
        kill(td->pid, SIGUSR2);
 }
 
-#ifdef FIO_HAVE_SPLICE
+#ifdef CONFIG_LINUX_SPLICE
 static int fio_netio_setup_splice(struct thread_data *td)
 {
        struct netio_data *nd;
@@ -962,7 +962,7 @@ static int str_hostname_cb(void *data, const char *input)
 static void fio_init fio_netio_register(void)
 {
        register_ioengine(&ioengine_rw);
-#ifdef FIO_HAVE_SPLICE
+#ifdef CONFIG_LINUX_SPLICE
        register_ioengine(&ioengine_splice);
 #endif
 }
@@ -970,7 +970,7 @@ static void fio_init fio_netio_register(void)
 static void fio_exit fio_netio_unregister(void)
 {
        unregister_ioengine(&ioengine_rw);
-#ifdef FIO_HAVE_SPLICE
+#ifdef CONFIG_LINUX_SPLICE
        unregister_ioengine(&ioengine_splice);
 #endif
 }
index 0966e0d5e7fa66b261c20bb1948177e108ab4455..a943e5bbf6eaad2c953d21f5c9abd431690fdabf 100644 (file)
@@ -12,8 +12,6 @@
 
 #include "../fio.h"
 
-#ifdef FIO_HAVE_POSIXAIO
-
 struct posixaio_data {
        struct io_u **aio_events;
        unsigned int queued;
@@ -21,13 +19,25 @@ struct posixaio_data {
 
 static int fill_timespec(struct timespec *ts)
 {
-#ifdef _POSIX_TIMERS
-       if (!clock_gettime(CLOCK_MONOTONIC, ts))
+#ifdef CONFIG_CLOCK_GETTIME
+#ifdef CONFIG_CLOCK_MONOTONIC
+       clockid_t clk = CLOCK_MONOTONIC;
+#else
+       clockid_t clk = CLOCK_REALTIME;
+#endif
+       if (!clock_gettime(clk, ts))
                return 0;
 
        perror("clock_gettime");
-#endif
        return 1;
+#else
+       struct timeval tv;
+
+       gettimeofday(&tv, NULL);
+       ts->tv_sec = tv.tv_sec;
+       ts->tv_nsec = tv.tv_usec * 1000;
+       return 0;
+#endif
 }
 
 static unsigned long long ts_utime_since_now(struct timespec *t)
@@ -93,6 +103,8 @@ static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
 
        if (t && !fill_timespec(&start))
                have_timeout = 1;
+       else
+               memset(&start, 0, sizeof(start));
 
        r = 0;
        memset(suspend_list, 0, sizeof(*suspend_list));
@@ -173,7 +185,7 @@ static int fio_posixaio_queue(struct thread_data *td,
                do_io_u_trim(td, io_u);
                return FIO_Q_COMPLETED;
        } else {
-#ifdef FIO_HAVE_POSIXAIO_FSYNC
+#ifdef CONFIG_POSIXAIO_FSYNC
                ret = aio_fsync(O_SYNC, aiocb);
 #else
                if (pd->queued)
@@ -240,27 +252,6 @@ static struct ioengine_ops ioengine = {
        .get_file_size  = generic_get_file_size,
 };
 
-#else /* FIO_HAVE_POSIXAIO */
-
-/*
- * When we have a proper configure system in place, we simply wont build
- * and install this io engine. For now install a crippled version that
- * just complains and fails to load.
- */
-static int fio_posixaio_init(struct thread_data fio_unused *td)
-{
-       log_err("fio: posixaio not available\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "posixaio",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_posixaio_init,
-};
-
-#endif
-
 static void fio_init fio_posixaio_register(void)
 {
        register_ioengine(&ioengine);
index 9b1830158a652f6b48399c323faa11130cd4bc03..a847b541d3a0927dd3b575fa5a38fb3dc5832ff4 100644 (file)
@@ -48,8 +48,6 @@
 #include "../fio.h"
 #include "../hash.h"
 
-#ifdef FIO_HAVE_RDMA
-
 #include <rdma/rdma_cma.h>
 #include <infiniband/arch.h>
 
@@ -1224,49 +1222,6 @@ static struct ioengine_ops ioengine_rw = {
        .flags          = FIO_DISKLESSIO | FIO_UNIDIR | FIO_PIPEIO,
 };
 
-#else /* FIO_HAVE_RDMA */
-
-static int fio_rdmaio_open_file(struct thread_data *td, struct fio_file *f)
-{
-       return 0;
-}
-
-static int fio_rdmaio_close_file(struct thread_data *td, struct fio_file *f)
-{
-       return 0;
-}
-
-static int fio_rdmaio_queue(struct thread_data *td, struct io_u *io_u)
-{
-       return FIO_Q_COMPLETED;
-}
-
-static int fio_rdmaio_init(struct thread_data fio_unused * td)
-{
-       log_err("fio: rdma(librdmacm libibverbs) not available\n");
-       log_err("     You haven't compiled rdma ioengine into fio.\n");
-       log_err("     If you want to try rdma ioengine,\n");
-       log_err("     make sure OFED is installed,\n");
-       log_err("     $ ofed_info\n");
-       log_err("     then try to make fio as follows:\n");
-       log_err("     $ export EXTFLAGS+=\" -DFIO_HAVE_RDMA \"\n");
-       log_err("     $ export EXTLIBS+=\" -libverbs -lrdmacm \"\n");
-       log_err("     $ make clean && make\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine_rw = {
-       .name           = "rdma",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_rdmaio_init,
-       .queue          = fio_rdmaio_queue,
-       .open_file      = fio_rdmaio_open_file,
-       .close_file     = fio_rdmaio_close_file,
-       .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR | FIO_PIPEIO,
-};
-
-#endif
-
 static void fio_init fio_rdmaio_register(void)
 {
        register_ioengine(&ioengine_rw);
index 906a154a2eee3093274f3537cdf4bf40bcf1751c..137dc225d151393959266e0e6e1df51377c67bfc 100644 (file)
@@ -10,8 +10,6 @@
 
 #include "../fio.h"
 
-#ifdef FIO_HAVE_SOLARISAIO
-
 #include <sys/asynch.h>
 
 struct solarisaio_data {
@@ -225,27 +223,6 @@ static struct ioengine_ops ioengine = {
        .get_file_size  = generic_get_file_size,
 };
 
-#else /* FIO_HAVE_SOLARISAIO */
-
-/*
- * When we have a proper configure system in place, we simply wont build
- * and install this io engine. For now install a crippled version that
- * just complains and fails to load.
- */
-static int fio_solarisaio_init(struct thread_data fio_unused *td)
-{
-       log_err("fio: solarisaio not available\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "solarisaio",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_solarisaio_init,
-};
-
-#endif
-
 static void fio_init fio_solarisaio_register(void)
 {
        register_ioengine(&ioengine);
index ca7997b70aeae1142263a580acdfb555c6fd8b2c..f35ae17bc574b7af5928e4c73e6e76f8a744b230 100644 (file)
@@ -15,8 +15,6 @@
 
 #include "../fio.h"
 
-#ifdef FIO_HAVE_SPLICE
-
 struct spliceio_data {
        int pipe[2];
        int vmsplice_to_user;
@@ -302,27 +300,6 @@ static struct ioengine_ops ioengine = {
        .flags          = FIO_SYNCIO | FIO_PIPEIO,
 };
 
-#else /* FIO_HAVE_SPLICE */
-
-/*
- * When we have a proper configure system in place, we simply wont build
- * and install this io engine. For now install a crippled version that
- * just complains and fails to load.
- */
-static int fio_spliceio_init(struct thread_data fio_unused *td)
-{
-       log_err("fio: splice not available\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "splice",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_spliceio_init,
-};
-
-#endif
-
 static void fio_init fio_spliceio_register(void)
 {
        register_ioengine(&ioengine);
diff --git a/engines/syslet-rw.c b/engines/syslet-rw.c
deleted file mode 100644 (file)
index 15e4c25..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * syslet engine
- *
- * IO engine that does regular pread(2)/pwrite(2) to transfer data, but
- * with syslets to make the execution async.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <assert.h>
-#include <malloc.h>
-#include <asm/unistd.h>
-
-#include "../fio.h"
-#include "../lib/fls.h"
-
-#ifdef FIO_HAVE_SYSLET
-
-#ifdef __NR_pread64
-#define __NR_fio_pread __NR_pread64
-#define __NR_fio_pwrite        __NR_pwrite64
-#else
-#define __NR_fio_pread __NR_pread
-#define __NR_fio_pwrite        __NR_pwrite
-#endif
-
-struct syslet_data {
-       struct io_u **events;
-       unsigned int nr_events;
-       
-       struct syslet_ring *ring;
-       unsigned int ring_mask;
-       void *stack;
-};
-
-static void fio_syslet_add_event(struct thread_data *td, struct io_u *io_u)
-{
-       struct syslet_data *sd = td->io_ops->data;
-
-       assert(sd->nr_events < td->o.iodepth);
-       sd->events[sd->nr_events++] = io_u;
-}
-
-static void fio_syslet_add_events(struct thread_data *td, unsigned int nr)
-{
-       struct syslet_data *sd = td->io_ops->data;
-       unsigned int i, uidx;
-
-       uidx = sd->ring->user_tail;
-       read_barrier();
-
-       for (i = 0; i < nr; i++) {
-               unsigned int idx = (i + uidx) & sd->ring_mask;
-               struct syslet_completion *comp = &sd->ring->comp[idx];
-               struct io_u *io_u = (struct io_u *) (long) comp->caller_data;
-               long ret;
-
-               ret = comp->status;
-               if (ret <= 0) {
-                       io_u->resid = io_u->xfer_buflen;
-                       io_u->error = -ret;
-               } else {
-                       io_u->resid = io_u->xfer_buflen - ret;
-                       io_u->error = 0;
-               }
-
-               fio_syslet_add_event(td, io_u);
-       }
-}
-
-static void fio_syslet_wait_for_events(struct thread_data *td)
-{
-       struct syslet_data *sd = td->io_ops->data;
-       struct syslet_ring *ring = sd->ring;
-
-       do {
-               unsigned int kh = ring->kernel_head;
-               int ret;
-
-               /*
-                * first reap events that are already completed
-                */
-               if (ring->user_tail != kh) {
-                       unsigned int nr = kh - ring->user_tail;
-
-                       fio_syslet_add_events(td, nr);
-                       ring->user_tail = kh;
-                       break;
-               }
-
-               /*
-                * block waiting for at least one event
-                */
-               ret = syscall(__NR_syslet_ring_wait, ring, ring->user_tail);
-               assert(!ret);
-       } while (1);
-}
-
-static int fio_syslet_getevents(struct thread_data *td, unsigned int min,
-                               unsigned int fio_unused max,
-                               struct timespec fio_unused *t)
-{
-       struct syslet_data *sd = td->io_ops->data;
-       long ret;
-
-       /*
-        * While we have less events than requested, block waiting for them
-        * (if we have to, there may already be more completed events ready
-        * for us - see fio_syslet_wait_for_events()
-        */
-       while (sd->nr_events < min)
-               fio_syslet_wait_for_events(td);
-
-       ret = sd->nr_events;
-       sd->nr_events = 0;
-       return ret;
-}
-
-static struct io_u *fio_syslet_event(struct thread_data *td, int event)
-{
-       struct syslet_data *sd = td->io_ops->data;
-
-       return sd->events[event];
-}
-
-static void fio_syslet_prep_sync(struct fio_file *f,
-                                struct indirect_registers *regs)
-{
-       FILL_IN(*regs, __NR_fsync, (long) f->fd);
-}
-
-static void fio_syslet_prep_datasync(struct fio_file *f,
-                                    struct indirect_registers *regs)
-{
-       FILL_IN(*regs, __NR_fdatasync, (long) f->fd);
-}
-
-static void fio_syslet_prep_rw(struct io_u *io_u, struct fio_file *f,
-                              struct indirect_registers *regs)
-{
-       long nr;
-
-       /*
-        * prepare rw
-        */
-       if (io_u->ddir == DDIR_READ)
-               nr = __NR_fio_pread;
-       else
-               nr = __NR_fio_pwrite;
-
-       FILL_IN(*regs, nr, (long) f->fd, (long) io_u->xfer_buf,
-               (long) io_u->xfer_buflen, (long) io_u->offset);
-}
-
-static void fio_syslet_prep(struct io_u *io_u, struct indirect_registers *regs)
-{
-       struct fio_file *f = io_u->file;
-
-       if (io_u->ddir == DDIR_SYNC)
-               fio_syslet_prep_sync(f, regs);
-       else if (io_u->ddir == DDIR_DATASYNC)
-               fio_syslet_prep_datasync(f, regs);
-       else
-               fio_syslet_prep_rw(io_u, f, regs);
-}
-
-static void ret_func(void)
-{
-       syscall(__NR_exit);
-}
-
-static int fio_syslet_queue(struct thread_data *td, struct io_u *io_u)
-{
-       struct syslet_data *sd = td->io_ops->data;
-       union indirect_params params;
-       struct indirect_registers regs;
-       int ret;
-
-       fio_ro_check(td, io_u);
-
-       memset(&params, 0, sizeof(params));
-       fill_syslet_args(&params.syslet, sd->ring, (long)io_u, ret_func, sd->stack);
-
-       fio_syslet_prep(io_u, &regs);
-
-       ret = syscall(__NR_indirect, &regs, &params, sizeof(params), 0);
-       if (ret == (int) io_u->xfer_buflen) {
-               /*
-                * completed sync, account. this also catches fsync().
-                */
-               return FIO_Q_COMPLETED;
-       } else if (ret < 0) {
-               /*
-                * queued for async execution
-                */
-               if (errno == ESYSLETPENDING)
-                       return FIO_Q_QUEUED;
-       }
-
-       io_u->error = errno;
-       td_verror(td, io_u->error, "xfer");
-       return FIO_Q_COMPLETED;
-}
-
-static int check_syslet_support(struct syslet_data *sd)
-{
-       union indirect_params params;
-       struct indirect_registers regs;
-       pid_t pid, my_pid = getpid();
-
-       memset(&params, 0, sizeof(params));
-       fill_syslet_args(&params.syslet, sd->ring, 0, ret_func, sd->stack);
-
-       FILL_IN(regs, __NR_getpid);
-
-       pid = syscall(__NR_indirect, &regs, &params, sizeof(params), 0);
-       if (pid == my_pid)
-               return 0;
-
-       return 1;
-}
-
-static void fio_syslet_cleanup(struct thread_data *td)
-{
-       struct syslet_data *sd = td->io_ops->data;
-
-       if (sd) {
-               free(sd->events);
-               free(sd->ring);
-               free(sd);
-       }
-}
-
-static int fio_syslet_init(struct thread_data *td)
-{
-       struct syslet_data *sd;
-       void *ring = NULL, *stack = NULL;
-       unsigned int ring_size, ring_nr;
-
-       sd = malloc(sizeof(*sd));
-       memset(sd, 0, sizeof(*sd));
-
-       sd->events = malloc(sizeof(struct io_u *) * td->o.iodepth);
-       memset(sd->events, 0, sizeof(struct io_u *) * td->o.iodepth);
-
-       /*
-        * The ring needs to be a power-of-2, so round it up if we have to
-        */
-       ring_nr = td->o.iodepth;
-       if (ring_nr & (ring_nr - 1))
-               ring_nr = 1 << __fls(ring_nr);
-
-       ring_size = sizeof(struct syslet_ring) +
-                       ring_nr * sizeof(struct syslet_completion);
-       if (posix_memalign(&ring, sizeof(uint64_t), ring_size))
-               goto err_mem;
-       if (posix_memalign(&stack, page_size, page_size))
-               goto err_mem;
-
-       sd->ring = ring;
-       sd->ring_mask = ring_nr - 1;
-       sd->stack = stack;
-
-       memset(sd->ring, 0, ring_size);
-       sd->ring->elements = ring_nr;
-
-       if (!check_syslet_support(sd)) {
-               td->io_ops->data = sd;
-               return 0;
-       }
-
-       log_err("fio: syslets do not appear to work\n");
-err_mem:
-       free(sd->events);
-       if (ring)
-               free(ring);
-       if (stack)
-               free(stack);
-       free(sd);
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "syslet-rw",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_syslet_init,
-       .queue          = fio_syslet_queue,
-       .getevents      = fio_syslet_getevents,
-       .event          = fio_syslet_event,
-       .cleanup        = fio_syslet_cleanup,
-       .open_file      = generic_open_file,
-       .close_file     = generic_close_file,
-       .get_file_size  = generic_get_file_size,
-};
-
-#else /* FIO_HAVE_SYSLET */
-
-/*
- * When we have a proper configure system in place, we simply wont build
- * and install this io engine. For now install a crippled version that
- * just complains and fails to load.
- */
-static int fio_syslet_init(struct thread_data fio_unused *td)
-{
-       log_err("fio: syslet not available\n");
-       return 1;
-}
-
-static struct ioengine_ops ioengine = {
-       .name           = "syslet-rw",
-       .version        = FIO_IOOPS_VERSION,
-       .init           = fio_syslet_init,
-};
-
-#endif /* FIO_HAVE_SYSLET */
-
-static void fio_init fio_syslet_register(void)
-{
-       register_ioengine(&ioengine);
-}
-
-static void fio_exit fio_syslet_unregister(void)
-{
-       unregister_ioengine(&ioengine);
-}
index f1b0bc51f4e8487c91439d8b14a93b7b6bf977fb..773f027c0e424000cbeaf1137fd44fb04e148798 100644 (file)
@@ -126,13 +126,6 @@ static int win_to_posix_error(DWORD winerr)
        return winerr;
 }
 
-int sync_file_range(int fd, off64_t offset, off64_t nbytes,
-                          unsigned int flags)
-{
-       errno = ENOSYS;
-       return -1;
-}
-
 static int fio_windowsaio_init(struct thread_data *td)
 {
        struct windowsaio_data *wd;
diff --git a/eta.c b/eta.c
index bcf0676a157d2094b2298bf69e8bffd96a322016..066a732f23a211cdc167e0f6419c75d751cc1390 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -140,13 +140,19 @@ static int thread_eta(struct thread_data *td)
        }
 
        /*
-        * if writing, bytes_total will be twice the size. If mixing,
-        * assume a 50/50 split and thus bytes_total will be 50% larger.
+        * if writing and verifying afterwards, bytes_total will be twice the
+        * size. In a mixed workload, verify phase will be the size of the
+        * first stage writes.
         */
        if (td->o.do_verify && td->o.verify && td_write(td)) {
-               if (td_rw(td))
-                       bytes_total = bytes_total * 3 / 2;
-               else
+               if (td_rw(td)) {
+                       unsigned int perc = 50;
+
+                       if (td->o.rwmix[DDIR_WRITE])
+                               perc = td->o.rwmix[DDIR_WRITE];
+
+                       bytes_total += (bytes_total * perc) / 100;
+               } else
                        bytes_total <<= 1;
        }
 
diff --git a/file.h b/file.h
index 5f125c3b5924e8f95b55be9cde1a00c7786fb13c..95ecefe7d4f5ec1abece4a862f8784caad4fe781 100644 (file)
--- a/file.h
+++ b/file.h
@@ -175,13 +175,6 @@ extern int init_random_map(struct thread_data *);
 extern void dup_files(struct thread_data *, struct thread_data *);
 extern int get_fileno(struct thread_data *, const char *);
 extern void free_release_files(struct thread_data *);
-
-static inline void fio_file_reset(struct fio_file *f)
-{
-       f->last_pos = f->file_offset;
-       f->last_start = -1ULL;
-       if (f->io_axmap)
-               axmap_reset(f->io_axmap);
-}
+void fio_file_reset(struct thread_data *, struct fio_file *);
 
 #endif
index 0c104ed748186d5343a210e7a5d9786702943876..c2170aae2ad44401d04231d1fdceefc8b81dabb2 100644 (file)
@@ -956,7 +956,9 @@ int init_random_map(struct thread_data *td)
                return 0;
 
        for_each_file(td, f, i) {
-               blocks = (f->real_file_size + td->o.rw_min_bs - 1) /
+               uint64_t file_size = min(f->real_file_size, f->io_size);
+
+               blocks = (file_size + td->o.rw_min_bs - 1) /
                                (unsigned long long) td->o.rw_min_bs;
                if (td->o.random_generator == FIO_RAND_GEN_LFSR) {
                        unsigned long seed;
@@ -1071,14 +1073,18 @@ int add_file(struct thread_data *td, const char *fname)
 
        f->fd = -1;
        f->shadow_fd = -1;
-       fio_file_reset(f);
+       fio_file_reset(td, f);
 
        if (td->files_size <= td->files_index) {
-               int new_size = td->o.nr_files + 1;
+               unsigned int new_size = td->o.nr_files + 1;
 
                dprint(FD_FILE, "resize file array to %d files\n", new_size);
 
                td->files = realloc(td->files, new_size * sizeof(f));
+               if (td->files == NULL) {
+                       log_err("fio: realloc OOM\n");
+                       assert(0);
+               }
                td->files_size = new_size;
        }
        td->files[cur_files] = f;
@@ -1313,7 +1319,7 @@ void dup_files(struct thread_data *td, struct thread_data *org)
                        assert(0);
                }
                __f->fd = -1;
-               fio_file_reset(__f);
+               fio_file_reset(td, __f);
 
                if (f->file_name) {
                        __f->file_name = smalloc_strdup(f->file_name);
@@ -1353,3 +1359,13 @@ void free_release_files(struct thread_data *td)
        td->files_index = 0;
        td->nr_normal_files = 0;
 }
+
+void fio_file_reset(struct thread_data *td, struct fio_file *f)
+{
+       f->last_pos = f->file_offset;
+       f->last_start = -1ULL;
+       if (f->io_axmap)
+               axmap_reset(f->io_axmap);
+       if (td->o.random_generator == FIO_RAND_GEN_LFSR)
+               lfsr_reset(&f->lfsr, td->rand_seeds[FIO_RAND_BLOCK_OFF]);
+}
diff --git a/fio.1 b/fio.1
index 7a06fbc4fc7b61435f09d2863c5917ac7151d089..d224d5403388212b04d4d4607ee76d81b85bf1c6 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -50,9 +50,6 @@ List all commands defined by \fIioengine\fR, or print help for \fIcommand\fR def
 .BI \-\-showcmd \fR=\fPjobfile
 Convert \fIjobfile\fR to a set of command-line options.
 .TP
-.B \-\-readonly
-Enable read-only safety checks.
-.TP
 .BI \-\-eta \fR=\fPwhen
 Specifies when real-time ETA estimate should be printed.  \fIwhen\fR may
 be one of `always', `never' or `auto'.
@@ -564,7 +561,7 @@ Also see the sync_file_range(2) man page.  This option is Linux specific.
 If writing, setup the file first and do overwrites.  Default: false.
 .TP
 .BI end_fsync \fR=\fPbool
-Sync file contents when job exits.  Default: false.
+Sync file contents when a write stage has completed.  Default: false.
 .TP
 .BI fsync_on_close \fR=\fPbool
 If true, sync file contents on close.  This differs from \fBend_fsync\fR in that
diff --git a/fio.c b/fio.c
index 16e18b211b910f3db2a0b036c7918490745e8919..755a4d523285836b2eab8d9a9f34765569118d62 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -42,6 +42,10 @@ int main(int argc, char *argv[], char *envp[])
        if (initialize_fio(envp))
                return 1;
 
+#if !defined(CONFIG_GETTIMEOFDAY) && !defined(CONFIG_CLOCK_GETTIME)
+#error "No available clock source!"
+#endif
+
        if (parse_options(argc, argv))
                return 1;
 
diff --git a/fio.h b/fio.h
index 82e2b62f62d8f16a48fc242790580de7a1b2dc46..db08aff8bdfcc07cbe51981b0380f67f1e064925 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -42,15 +42,11 @@ struct thread_data;
 #include "stat.h"
 #include "flow.h"
 
-#ifdef FIO_HAVE_GUASI
-#include <guasi.h>
-#endif
-
 #ifdef FIO_HAVE_SOLARISAIO
 #include <sys/asynch.h>
 #endif
 
-#ifdef FIO_HAVE_LIBNUMA
+#ifdef CONFIG_LIBNUMA
 #include <linux/mempolicy.h>
 #include <numa.h>
 
@@ -68,7 +64,6 @@ enum {
        RW_SEQ_IDENT,
 };
 
-
 enum {
        TD_F_VER_BACKLOG        = 1,
        TD_F_TRIM_BACKLOG       = 2,
@@ -278,6 +273,8 @@ struct thread_data {
        struct flist_head trim_list;
        unsigned long trim_entries;
 
+       struct flist_head next_rand_list;
+
        /*
         * for fileservice, how often to switch to a new file
         */
@@ -558,7 +555,7 @@ static inline int __should_check_rate(struct thread_data *td,
 }
 
 static inline int should_check_rate(struct thread_data *td,
-                                   unsigned long *bytes_done)
+                                   uint64_t *bytes_done)
 {
        int ret = 0;
 
diff --git a/flist.h b/flist.h
index 7aca9730b2e9621349cfb27b427c3ff19f91829f..8e1304142cc3d3468b79f75872e534220626ce59 100644 (file)
--- a/flist.h
+++ b/flist.h
@@ -176,4 +176,7 @@ static inline void flist_splice_init(struct flist_head *list,
        for (pos = (head)->next, n = pos->next; pos != (head); \
                pos = n, n = pos->next)
 
+extern void flist_sort(void *priv, struct flist_head *head,
+       int (*cmp)(void *priv, struct flist_head *a, struct flist_head *b));
+
 #endif
index 1648b17b677f3325664282eb66052f40a2b646fd..cc9dcb7bea7ab28215e09304b3c32688be8d8f25 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -21,10 +21,14 @@ int tsc_reliable = 0;
 
 struct tv_valid {
        struct timeval last_tv;
+       uint64_t last_cycles;
        int last_tv_valid;
-       unsigned long last_cycles;
 };
+#ifdef CONFIG_TLS_THREAD
+static struct tv_valid __thread static_tv_valid;
+#else
 static pthread_key_t tv_tls_key;
+#endif
 
 enum fio_cs fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE;
 int fio_clock_source_set = 0;
@@ -121,40 +125,34 @@ static void fio_init gtod_init(void)
 
 #endif /* FIO_DEBUG_TIME */
 
+#ifdef CONFIG_CLOCK_GETTIME
 static int fill_clock_gettime(struct timespec *ts)
 {
-#ifdef FIO_HAVE_CLOCK_MONOTONIC
+#ifdef CONFIG_CLOCK_MONOTONIC
        return clock_gettime(CLOCK_MONOTONIC, ts);
 #else
        return clock_gettime(CLOCK_REALTIME, ts);
 #endif
 }
-
-#ifdef FIO_DEBUG_TIME
-void fio_gettime(struct timeval *tp, void *caller)
-#else
-void fio_gettime(struct timeval *tp, void fio_unused *caller)
 #endif
+
+static void *__fio_gettime(struct timeval *tp)
 {
        struct tv_valid *tv;
 
-#ifdef FIO_DEBUG_TIME
-       if (!caller)
-               caller = __builtin_return_address(0);
-
-       gtod_log_caller(caller);
-#endif
-       if (fio_tv) {
-               memcpy(tp, fio_tv, sizeof(*tp));
-               return;
-       }
-
+#ifdef CONFIG_TLS_THREAD
+       tv = &static_tv_valid;
+#else
        tv = pthread_getspecific(tv_tls_key);
+#endif
 
        switch (fio_clock_source) {
+#ifdef CONFIG_GETTIMEOFDAY
        case CS_GTOD:
                gettimeofday(tp, NULL);
                break;
+#endif
+#ifdef CONFIG_CLOCK_GETTIME
        case CS_CGETTIME: {
                struct timespec ts;
 
@@ -167,9 +165,10 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller)
                tp->tv_usec = ts.tv_nsec / 1000;
                break;
                }
+#endif
 #ifdef ARCH_HAVE_CPU_CLOCK
        case CS_CPUCLOCK: {
-               unsigned long long usecs, t;
+               uint64_t usecs, t;
 
                t = get_cpu_clock();
                if (tv && t < tv->last_cycles) {
@@ -189,6 +188,30 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller)
                break;
        }
 
+       return tv;
+}
+
+#ifdef FIO_DEBUG_TIME
+void fio_gettime(struct timeval *tp, void *caller)
+#else
+void fio_gettime(struct timeval *tp, void fio_unused *caller)
+#endif
+{
+       struct tv_valid *tv;
+
+#ifdef FIO_DEBUG_TIME
+       if (!caller)
+               caller = __builtin_return_address(0);
+
+       gtod_log_caller(caller);
+#endif
+       if (fio_tv) {
+               memcpy(tp, fio_tv, sizeof(*tp));
+               return;
+       }
+
+       tv = __fio_gettime(tp);
+
        /*
         * If Linux is using the tsc clock on non-synced processors,
         * sometimes time can appear to drift backwards. Fix that up.
@@ -209,21 +232,22 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller)
 #ifdef ARCH_HAVE_CPU_CLOCK
 static unsigned long get_cycles_per_usec(void)
 {
-       struct timespec ts;
        struct timeval s, e;
-       unsigned long long c_s, c_e;
+       uint64_t c_s, c_e;
+       enum fio_cs old_cs = fio_clock_source;
 
-       fill_clock_gettime(&ts);
-       s.tv_sec = ts.tv_sec;
-       s.tv_usec = ts.tv_nsec / 1000;
+#ifdef CONFIG_CLOCK_GETTIME
+       fio_clock_source = CS_CGETTIME;
+#else
+       fio_clock_source = CS_GTOD;
+#endif
+       __fio_gettime(&s);
 
        c_s = get_cpu_clock();
        do {
-               unsigned long long elapsed;
+               uint64_t elapsed;
 
-               fill_clock_gettime(&ts);
-               e.tv_sec = ts.tv_sec;
-               e.tv_usec = ts.tv_nsec / 1000;
+               __fio_gettime(&e);
 
                elapsed = utime_since(&s, &e);
                if (elapsed >= 1280) {
@@ -232,6 +256,7 @@ static unsigned long get_cycles_per_usec(void)
                }
        } while (1);
 
+       fio_clock_source = old_cs;
        return (c_e - c_s + 127) >> 7;
 }
 
@@ -240,7 +265,7 @@ static unsigned long get_cycles_per_usec(void)
 static void calibrate_cpu_clock(void)
 {
        double delta, mean, S;
-       unsigned long avg, cycles[NR_TIME_ITERS];
+       uint64_t avg, cycles[NR_TIME_ITERS];
        int i, samples;
 
        cycles[0] = get_cycles_per_usec();
@@ -287,6 +312,7 @@ static void calibrate_cpu_clock(void)
 }
 #endif
 
+#ifndef CONFIG_TLS_THREAD
 void fio_local_clock_init(int is_thread)
 {
        struct tv_valid *t;
@@ -300,14 +326,21 @@ static void kill_tv_tls_key(void *data)
 {
        free(data);
 }
+#else
+void fio_local_clock_init(int is_thread)
+{
+}
+#endif
 
 void fio_clock_init(void)
 {
        if (fio_clock_source == fio_clock_source_inited)
                return;
 
+#ifndef CONFIG_TLS_THREAD
        if (pthread_key_create(&tv_tls_key, kill_tv_tls_key))
                log_err("fio: can't create TLS key\n");
+#endif
 
        fio_clock_source_inited = fio_clock_source;
        calibrate_cpu_clock();
@@ -390,14 +423,15 @@ uint64_t time_since_now(struct timeval *s)
        return mtime_since_now(s) / 1000;
 }
 
-#if defined(FIO_HAVE_CPU_AFFINITY) && defined(ARCH_HAVE_CPU_CLOCK)
+#if defined(FIO_HAVE_CPU_AFFINITY) && defined(ARCH_HAVE_CPU_CLOCK)  && \
+    defined(CONFIG_SFAA)
 
 #define CLOCK_ENTRIES  100000
 
 struct clock_entry {
-       unsigned long seq;
-       unsigned long tsc;
-       unsigned long cpu;
+       uint64_t seq;
+       uint64_t tsc;
+       uint64_t cpu;
 };
 
 struct clock_thread {
@@ -470,6 +504,8 @@ int fio_monotonic_clocktest(void)
        uint64_t seq = 0;
        int i;
 
+       log_info("cs: reliable_tsc: %s\n", tsc_reliable ? "yes" : "no");
+
        fio_debug |= 1U << FD_TIME;
        calibrate_cpu_clock();
        fio_debug &= ~(1U << FD_TIME);
index 1b4e1d0a2c9ccabe9c3e6483223f2abae54b5c7d..dce967d39d6c4bc8f1e2b7cbf8410fdaa1aed093 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -9,50 +9,31 @@
 #include "arch/arch.h"
 #include "os/os.h"
 
-#ifndef FIO_HAVE_LINUX_FALLOCATE 
-int _weak fallocate(int fd, int mode, off_t offset, off_t len)
+#ifndef CONFIG_LINUX_FALLOCATE
+int fallocate(int fd, int mode, off_t offset, off_t len)
 {
        errno = ENOSYS;
        return -1;
 }
 #endif
 
-#ifndef __NR_fallocate
-int _weak posix_fallocate(int fd, off_t offset, off_t len)
+#ifndef CONFIG_POSIX_FALLOCATE
+int posix_fallocate(int fd, off_t offset, off_t len)
 {
        return 0;
 }
 #endif
 
-int _weak inet_aton(const char *cp, struct in_addr *inp)
-{
-       return 0;
-}
-
-int _weak clock_gettime(clockid_t clk_id, struct timespec *ts)
-{
-       struct timeval tv;
-       int ret;
-
-       ret = gettimeofday(&tv, NULL);
-
-       ts->tv_sec = tv.tv_sec;
-       ts->tv_nsec = tv.tv_usec * 1000;
-
-       return ret;
-}
-
-#ifndef __NR_sync_file_range
-int _weak sync_file_range(int fd, off64_t offset, off64_t nbytes,
-                          unsigned int flags)
+#ifndef CONFIG_SYNC_FILE_RANGE
+int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
 {
        errno = ENOSYS;
        return -1;
 }
 #endif
 
-#ifndef FIO_HAVE_FADVISE
-int _weak posix_fadvise(int fd, off_t offset, off_t len, int advice)
+#ifndef CONFIG_FADVISE
+int posix_fadvise(int fd, off_t offset, off_t len, int advice)
 {
        return 0;
 }
index 191096bde600b07c1ed352b69cd4d72cf193a337..5f1865bba8129f272edc4afbce9d2e281bc41949 100644 (file)
--- a/helpers.h
+++ b/helpers.h
@@ -6,15 +6,10 @@
 #include <sys/types.h>
 #include <time.h>
 
-struct in_addr;
-
-extern int _weak fallocate(int fd, int mode, off_t offset, off_t len);
-extern int _weak posix_memalign(void **ptr, size_t align, size_t size);
-extern int _weak posix_fallocate(int fd, off_t offset, off_t len);
-extern int _weak inet_aton(const char *cp, struct in_addr *inp);
-extern int _weak clock_gettime(clockid_t clk_id, struct timespec *ts);
-extern int _weak sync_file_range(int fd, off64_t offset, off64_t nbytes,
+extern int fallocate(int fd, int mode, off_t offset, off_t len);
+extern int posix_fallocate(int fd, off_t offset, off_t len);
+extern int sync_file_range(int fd, off64_t offset, off64_t nbytes,
                                        unsigned int flags);
-extern int _weak posix_fadvise(int fd, off_t offset, off_t len, int advice);
+extern int posix_fadvise(int fd, off_t offset, off_t len, int advice);
 
 #endif /* FIO_HELPERS_H_ */
diff --git a/init.c b/init.c
index dc0440e4b49f67bee8831d030ca4e51136b3b138..688c8efa731cb1974506d138600bb2e2cddf744e 100644 (file)
--- a/init.c
+++ b/init.c
@@ -503,17 +503,8 @@ static int fixup_options(struct thread_data *td)
        /*
         * The low water mark cannot be bigger than the iodepth
         */
-       if (o->iodepth_low > o->iodepth || !o->iodepth_low) {
-               /*
-                * syslet work around - if the workload is sequential,
-                * we want to let the queue drain all the way down to
-                * avoid seeking between async threads
-                */
-               if (!strcmp(td->io_ops->name, "syslet-rw") && !td_random(td))
-                       o->iodepth_low = 1;
-               else
-                       o->iodepth_low = o->iodepth;
-       }
+       if (o->iodepth_low > o->iodepth || !o->iodepth_low)
+               o->iodepth_low = o->iodepth;
 
        /*
         * If batch number isn't set, default to the same as iodepth
@@ -576,7 +567,7 @@ static int fixup_options(struct thread_data *td)
                }
        }
 
-#ifndef FIO_HAVE_FDATASYNC
+#ifndef CONFIG_FDATASYNC
        if (o->fdatasync_blocks) {
                log_info("fio: this platform does not support fdatasync()"
                         " falling back to using fsync().  Use the 'fsync'"
@@ -722,7 +713,6 @@ void td_fill_rand_seeds(struct thread_data *td)
        init_rand_seed(&td->buf_state, td->rand_seeds[FIO_RAND_BUF_OFF]);
 }
 
-
 /*
  * Initializes the ioengine configured for a job, if it has not been done so
  * already.
@@ -797,6 +787,26 @@ static void init_flags(struct thread_data *td)
                td->flags |= TD_F_VER_NONE;
 }
 
+static int setup_random_seeds(struct thread_data *td)
+{
+       unsigned long seed;
+       unsigned int i;
+
+       if (!td->o.rand_repeatable)
+               return init_random_state(td, td->rand_seeds, sizeof(td->rand_seeds));
+
+       for (seed = 0x89, i = 0; i < 4; i++)
+               seed *= 0x9e370001UL;
+
+       for (i = 0; i < FIO_RAND_NR_OFFS; i++) {
+               td->rand_seeds[i] = seed;
+               seed *= 0x9e370001UL;
+       }
+
+       td_fill_rand_seeds(td);
+       return 0;
+}
+
 /*
  * Adds a job to the list of things todo. Sanitizes the various options
  * to make sure we don't have conflicts, and initializes various
@@ -894,7 +904,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
        td->groupid = groupid;
        prev_group_jobs++;
 
-       if (init_random_state(td, td->rand_seeds, sizeof(td->rand_seeds))) {
+       if (setup_random_seeds(td)) {
                td_verror(td, errno, "init_random_state");
                goto err;
        }
@@ -1673,6 +1683,9 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        do_exit++;
                        exit_val = fio_monotonic_clocktest();
                        break;
+               case '?':
+                       log_err("%s: unrecognized option '%s'\n", argv[0],
+                                                       argv[optind - 1]);
                default:
                        do_exit++;
                        exit_val = 1;
diff --git a/io_u.c b/io_u.c
index 6f1db1842c677337faa705008f3eef42e04ee01f..6ae3eae817782bd2d82c408b7b74f6dec6d59cf2 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -16,7 +16,7 @@ struct io_completion_data {
        int nr;                         /* input */
 
        int error;                      /* output */
-       unsigned long bytes_done[DDIR_RWDIR_CNT];       /* output */
+       uint64_t bytes_done[DDIR_RWDIR_CNT];    /* output */
        struct timeval time;            /* output */
 };
 
@@ -24,7 +24,7 @@ struct io_completion_data {
  * The ->io_axmap contains a map of blocks we have or have not done io
  * to yet. Used to make sure we cover the entire range in a fair fashion.
  */
-static int random_map_free(struct fio_file *f, const unsigned long long block)
+static int random_map_free(struct fio_file *f, const uint64_t block)
 {
        return !axmap_isset(f->io_axmap, block);
 }
@@ -36,10 +36,10 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u)
 {
        unsigned int min_bs = td->o.rw_min_bs;
        struct fio_file *f = io_u->file;
-       unsigned long long block;
        unsigned int nr_blocks;
+       uint64_t block;
 
-       block = (io_u->offset - f->file_offset) / (unsigned long long) min_bs;
+       block = (io_u->offset - f->file_offset) / (uint64_t) min_bs;
        nr_blocks = (io_u->buflen + min_bs - 1) / min_bs;
 
        if (!(io_u->flags & IO_U_F_BUSY_OK))
@@ -49,11 +49,11 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u)
                io_u->buflen = nr_blocks * min_bs;
 }
 
-static unsigned long long last_block(struct thread_data *td, struct fio_file *f,
-                                    enum fio_ddir ddir)
+static uint64_t last_block(struct thread_data *td, struct fio_file *f,
+                          enum fio_ddir ddir)
 {
-       unsigned long long max_blocks;
-       unsigned long long max_size;
+       uint64_t max_blocks;
+       uint64_t max_size;
 
        assert(ddir_rw(ddir));
 
@@ -67,24 +67,29 @@ static unsigned long long last_block(struct thread_data *td, struct fio_file *f,
        if (td->o.zone_range)
                max_size = td->o.zone_range;
 
-       max_blocks = max_size / (unsigned long long) td->o.ba[ddir];
+       max_blocks = max_size / (uint64_t) td->o.ba[ddir];
        if (!max_blocks)
                return 0;
 
        return max_blocks;
 }
 
+struct rand_off {
+       struct flist_head list;
+       uint64_t off;
+};
+
 static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
-                                 enum fio_ddir ddir, unsigned long long *b)
+                                 enum fio_ddir ddir, uint64_t *b)
 {
-       unsigned long long r;
+       uint64_t r, lastb;
 
-       if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE) {
-               unsigned long long rmax, lastb;
+       lastb = last_block(td, f, ddir);
+       if (!lastb)
+               return 1;
 
-               lastb = last_block(td, f, ddir);
-               if (!lastb)
-                       return 1;
+       if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE) {
+               uint64_t rmax;
 
                rmax = td->o.use_os_rand ? OS_RAND_MAX : FRAND_MAX;
 
@@ -98,11 +103,11 @@ static int __get_next_rand_offset(struct thread_data *td, struct fio_file *f,
 
                dprint(FD_RANDOM, "off rand %llu\n", r);
 
-               *b = (lastb - 1) * (r / ((unsigned long long) rmax + 1.0));
+               *b = (lastb - 1) * (r / ((uint64_t) rmax + 1.0));
        } else {
                uint64_t off = 0;
 
-               if (lfsr_next(&f->lfsr, &off))
+               if (lfsr_next(&f->lfsr, &off, lastb))
                        return 1;
 
                *b = off;
@@ -131,7 +136,7 @@ ret:
 
 static int __get_next_rand_offset_zipf(struct thread_data *td,
                                       struct fio_file *f, enum fio_ddir ddir,
-                                      unsigned long long *b)
+                                      uint64_t *b)
 {
        *b = zipf_next(&f->zipf);
        return 0;
@@ -139,14 +144,22 @@ static int __get_next_rand_offset_zipf(struct thread_data *td,
 
 static int __get_next_rand_offset_pareto(struct thread_data *td,
                                         struct fio_file *f, enum fio_ddir ddir,
-                                        unsigned long long *b)
+                                        uint64_t *b)
 {
        *b = pareto_next(&f->zipf);
        return 0;
 }
 
-static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
-                               enum fio_ddir ddir, unsigned long long *b)
+static int flist_cmp(void *data, struct flist_head *a, struct flist_head *b)
+{
+       struct rand_off *r1 = flist_entry(a, struct rand_off, list);
+       struct rand_off *r2 = flist_entry(b, struct rand_off, list);
+
+       return r1->off - r2->off;
+}
+
+static int get_off_from_method(struct thread_data *td, struct fio_file *f,
+                              enum fio_ddir ddir, uint64_t *b)
 {
        if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
                return __get_next_rand_offset(td, f, ddir, b);
@@ -159,14 +172,71 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
        return 1;
 }
 
+/*
+ * Sort the reads for a verify phase in batches of verifysort_nr, if
+ * specified.
+ */
+static inline int should_sort_io(struct thread_data *td)
+{
+       if (!td->o.verifysort_nr || !td->o.do_verify)
+               return 0;
+       if (!td_random(td))
+               return 0;
+       if (td->runstate != TD_VERIFYING)
+               return 0;
+       if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE)
+               return 0;
+
+       return 1;
+}
+
+static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
+                               enum fio_ddir ddir, uint64_t *b)
+{
+       struct rand_off *r;
+       int i, ret = 1;
+
+       if (!should_sort_io(td))
+               return get_off_from_method(td, f, ddir, b);
+
+       if (!flist_empty(&td->next_rand_list)) {
+               struct rand_off *r;
+fetch:
+               r = flist_entry(td->next_rand_list.next, struct rand_off, list);
+               flist_del(&r->list);
+               *b = r->off;
+               free(r);
+               return 0;
+       }
+
+       for (i = 0; i < td->o.verifysort_nr; i++) {
+               r = malloc(sizeof(*r));
+
+               ret = get_off_from_method(td, f, ddir, &r->off);
+               if (ret) {
+                       free(r);
+                       break;
+               }
+
+               flist_add(&r->list, &td->next_rand_list);
+       }
+
+       if (ret && !i)
+               return ret;
+
+       assert(!flist_empty(&td->next_rand_list));
+       flist_sort(NULL, &td->next_rand_list, flist_cmp);
+       goto fetch;
+}
+
 static int get_next_rand_block(struct thread_data *td, struct fio_file *f,
-                              enum fio_ddir ddir, unsigned long long *b)
+                              enum fio_ddir ddir, uint64_t *b)
 {
        if (!get_next_rand_offset(td, f, ddir, b))
                return 0;
 
        if (td->o.time_based) {
-               fio_file_reset(f);
+               fio_file_reset(td, f);
                if (!get_next_rand_offset(td, f, ddir, b))
                        return 0;
        }
@@ -177,7 +247,7 @@ static int get_next_rand_block(struct thread_data *td, struct fio_file *f,
 }
 
 static int get_next_seq_offset(struct thread_data *td, struct fio_file *f,
-                              enum fio_ddir ddir, unsigned long long *offset)
+                              enum fio_ddir ddir, uint64_t *offset)
 {
        assert(ddir_rw(ddir));
 
@@ -185,7 +255,7 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f,
                f->last_pos = f->last_pos - f->io_size;
 
        if (f->last_pos < f->real_file_size) {
-               unsigned long long pos;
+               uint64_t pos;
 
                if (f->last_pos == f->file_offset && td->o.ddir_seq_add < 0)
                        f->last_pos = f->real_file_size;
@@ -205,7 +275,7 @@ static int get_next_block(struct thread_data *td, struct io_u *io_u,
                          enum fio_ddir ddir, int rw_seq)
 {
        struct fio_file *f = io_u->file;
-       unsigned long long b, offset;
+       uint64_t b, offset;
        int ret;
 
        assert(ddir_rw(ddir));
@@ -542,7 +612,7 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td)
 
 static void set_rw_ddir(struct thread_data *td, struct io_u *io_u)
 {
-       io_u->ddir = get_rw_ddir(td);
+       io_u->ddir = io_u->acct_ddir = get_rw_ddir(td);
 
        if (io_u->ddir == DDIR_WRITE && (td->io_ops->flags & FIO_BARRIER) &&
            td->o.barrier_blocks &&
@@ -586,14 +656,15 @@ void clear_io_u(struct thread_data *td, struct io_u *io_u)
 void requeue_io_u(struct thread_data *td, struct io_u **io_u)
 {
        struct io_u *__io_u = *io_u;
+       enum fio_ddir ddir = acct_ddir(__io_u);
 
        dprint(FD_IO, "requeue %p\n", __io_u);
 
        td_io_u_lock(td);
 
        __io_u->flags |= IO_U_F_FREE;
-       if ((__io_u->flags & IO_U_F_FLIGHT) && ddir_rw(__io_u->ddir))
-               td->io_issues[__io_u->ddir]--;
+       if ((__io_u->flags & IO_U_F_FLIGHT) && ddir_rw(ddir))
+               td->io_issues[ddir]--;
 
        __io_u->flags &= ~IO_U_F_FLIGHT;
        if (__io_u->flags & IO_U_F_IN_CUR_DEPTH)
@@ -655,13 +726,9 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
        if (td_random(td) && file_randommap(td, io_u->file))
                mark_random_map(td, io_u);
 
-       /*
-        * If using a write iolog, store this entry.
-        */
 out:
        dprint_io_u(io_u, "fill_io_u");
        td->zone_bytes += io_u->buflen;
-       log_io_u(td, io_u);
        return 0;
 }
 
@@ -1027,6 +1094,7 @@ again:
                io_u->flags &= ~IO_U_F_VER_LIST;
 
                io_u->error = 0;
+               io_u->acct_ddir = -1;
                flist_del(&io_u->list);
                flist_add_tail(&io_u->list, &td->io_u_busylist);
                td->cur_depth++;
@@ -1106,7 +1174,7 @@ static int check_get_verify(struct thread_data *td, struct io_u *io_u)
 static void small_content_scramble(struct io_u *io_u)
 {
        unsigned int i, nr_blocks = io_u->buflen / 512;
-       unsigned long long boffset;
+       uint64_t boffset;
        unsigned int offset;
        void *p, *end;
 
@@ -1124,9 +1192,9 @@ static void small_content_scramble(struct io_u *io_u)
                 * and the actual offset.
                 */
                offset = (io_u->start_time.tv_usec ^ boffset) & 511;
-               offset &= ~(sizeof(unsigned long long) - 1);
-               if (offset >= 512 - sizeof(unsigned long long))
-                       offset -= sizeof(unsigned long long);
+               offset &= ~(sizeof(uint64_t) - 1);
+               if (offset >= 512 - sizeof(uint64_t))
+                       offset -= sizeof(uint64_t);
                memcpy(p + offset, &boffset, sizeof(boffset));
 
                end = p + 512 - sizeof(io_u->start_time);
@@ -1285,7 +1353,8 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u,
 
 static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir)
 {
-       unsigned long long secs, remainder, bps, bytes;
+       uint64_t secs, remainder, bps, bytes;
+
        bytes = td->this_io_bytes[ddir];
        bps = td->rate_bps[ddir];
        secs = bytes / bps;
@@ -1360,7 +1429,8 @@ static void io_completed(struct thread_data *td, struct io_u *io_u,
 
                if (td_write(td) && idx == DDIR_WRITE &&
                    td->o.do_verify &&
-                   td->o.verify != VERIFY_NONE)
+                   td->o.verify != VERIFY_NONE &&
+                   !td->o.experimental_verify)
                        log_io_piece(td, io_u);
 
                icd->bytes_done[idx] += bytes;
@@ -1423,7 +1493,7 @@ static void ios_completed(struct thread_data *td,
  * Complete a single io_u for the sync engines.
  */
 int io_u_sync_complete(struct thread_data *td, struct io_u *io_u,
-                      unsigned long *bytes)
+                      uint64_t *bytes)
 {
        struct io_completion_data icd;
 
@@ -1452,7 +1522,7 @@ int io_u_sync_complete(struct thread_data *td, struct io_u *io_u,
  * Called to complete min_events number of io for the async engines.
  */
 int io_u_queued_complete(struct thread_data *td, int min_evts,
-                        unsigned long *bytes)
+                        uint64_t *bytes)
 {
        struct io_completion_data icd;
        struct timespec *tvp = NULL;
index df5f8893dc76ed1174331f9f025bfbe55706c526..55039578d9edad878519cde64b665ea81c5e2b0f 100644 (file)
@@ -2,11 +2,20 @@
 #define FIO_IOENGINE_H
 
 #include "compiler/compiler.h"
+#include "os/os.h"
+#include "log.h"
 #include "io_ddir.h"
 #include "debug.h"
 #include "file.h"
 
-#define FIO_IOOPS_VERSION      14
+#ifdef CONFIG_LIBAIO
+#include <libaio.h>
+#endif
+#ifdef CONFIG_GUASI
+#include <guasi.h>
+#endif
+
+#define FIO_IOOPS_VERSION      15
 
 enum {
        IO_U_F_FREE             = 1 << 0,
@@ -26,25 +35,25 @@ struct thread_data;
  */
 struct io_u {
        union {
-#ifdef FIO_HAVE_LIBAIO
+#ifdef CONFIG_LIBAIO
                struct iocb iocb;
 #endif
-#ifdef FIO_HAVE_POSIXAIO
+#ifdef CONFIG_POSIXAIO
                os_aiocb_t aiocb;
 #endif
 #ifdef FIO_HAVE_SGIO
                struct sg_io_hdr hdr;
 #endif
-#ifdef FIO_HAVE_GUASI
+#ifdef CONFIG_GUASI
                guasi_req_t greq;
 #endif
-#ifdef FIO_HAVE_SOLARISAIO
+#ifdef CONFIG_SOLARISAIO
                aio_result_t resultp;
 #endif
 #ifdef FIO_HAVE_BINJECT
                struct b_user_cmd buc;
 #endif
-#ifdef FIO_HAVE_RDMA
+#ifdef CONFIG_RDMA
                struct ibv_mr *mr;
 #endif
                void *mmap_data;
@@ -56,6 +65,12 @@ struct io_u {
        unsigned int flags;
        enum fio_ddir ddir;
 
+       /*
+        * For replay workloads, we may want to account as a different
+        * IO type than what is being submitted.
+        */
+       enum fio_ddir acct_ddir;
+
        /*
         * Allocated/set buffer and length
         */
@@ -179,8 +194,8 @@ extern struct io_u *get_io_u(struct thread_data *);
 extern void put_io_u(struct thread_data *, struct io_u *);
 extern void clear_io_u(struct thread_data *, struct io_u *);
 extern void requeue_io_u(struct thread_data *, struct io_u **);
-extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *, unsigned long *);
-extern int __must_check io_u_queued_complete(struct thread_data *, int, unsigned long *);
+extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *, uint64_t *);
+extern int __must_check io_u_queued_complete(struct thread_data *, int, uint64_t *);
 extern void io_u_queued(struct thread_data *, struct io_u *);
 extern void io_u_log_error(struct thread_data *, struct io_u *);
 extern void io_u_mark_depth(struct thread_data *, unsigned int);
@@ -210,4 +225,12 @@ static inline void dprint_io_u(struct io_u *io_u, const char *p)
 #define dprint_io_u(io_u, p)
 #endif
 
+static inline enum fio_ddir acct_ddir(struct io_u *io_u)
+{
+       if (io_u->acct_ddir != -1)
+               return io_u->acct_ddir;
+
+       return io_u->ddir;
+}
+
 #endif
index 8b71e13449638dfec259370a57b74d1f7f1258c2..f4eae04db6df5d072103191f05b187fcb6f19e80 100644 (file)
@@ -260,6 +260,11 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
 
        assert(fio_file_open(io_u->file));
 
+       /*
+        * If using a write iolog, store this entry.
+        */
+       log_io_u(td, io_u);
+
        io_u->error = 0;
        io_u->resid = 0;
 
@@ -275,8 +280,8 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
                                        sizeof(struct timeval));
        }
 
-       if (ddir_rw(io_u->ddir))
-               td->io_issues[io_u->ddir]++;
+       if (ddir_rw(acct_ddir(io_u)))
+               td->io_issues[acct_ddir(io_u)]++;
 
        ret = td->io_ops->queue(td, io_u);
 
@@ -397,7 +402,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
-       fio_file_reset(f);
+       fio_file_reset(td, f);
        fio_file_set_open(f);
        fio_file_clear_closing(f);
        disk_util_inc(f->du);
@@ -503,7 +508,7 @@ int do_io_u_sync(struct thread_data *td, struct io_u *io_u)
        if (io_u->ddir == DDIR_SYNC) {
                ret = fsync(io_u->file->fd);
        } else if (io_u->ddir == DDIR_DATASYNC) {
-#ifdef FIO_HAVE_FDATASYNC
+#ifdef CONFIG_FDATASYNC
                ret = fdatasync(io_u->file->fd);
 #else
                ret = io_u->xfer_buflen;
diff --git a/iolog.h b/iolog.h
index 4ad4e79ebf2c66ee79597e42fc1d0411ccaf3332..af84e102e65054db60a26bc4ec6b9df121caf259 100644 (file)
--- a/iolog.h
+++ b/iolog.h
@@ -3,6 +3,7 @@
 
 #include "lib/rbtree.h"
 #include "lib/ieee754.h"
+#include "flist.h"
 #include "ioengine.h"
 
 /*
index a44e0ecb35c347ecc74882a0e45f7d94d28d34a4..533a155c7243ea5195b19baae6d023cbc23335b2 100644 (file)
@@ -48,6 +48,7 @@ struct axmap {
        unsigned int nr_levels;
        struct axmap_level *levels;
        uint64_t first_free;
+       uint64_t nr_bits;
 };
 
 static unsigned long ulog64(unsigned long val, unsigned int log)
@@ -67,6 +68,8 @@ void axmap_reset(struct axmap *axmap)
 
                memset(al->map, 0, al->map_size * sizeof(unsigned long));
        }
+
+       axmap->first_free = 0;
 }
 
 void axmap_free(struct axmap *axmap)
@@ -101,7 +104,7 @@ struct axmap *axmap_new(unsigned long nr_bits)
 
        axmap->nr_levels = levels;
        axmap->levels = smalloc(axmap->nr_levels * sizeof(struct axmap_level));
-       axmap->first_free = 0;
+       axmap->nr_bits = nr_bits;
 
        for (i = 0; i < axmap->nr_levels; i++) {
                struct axmap_level *al = &axmap->levels[i];
@@ -260,6 +263,11 @@ static void __axmap_set(struct axmap *axmap, uint64_t bit_nr,
            axmap->first_free < bit_nr + data->nr_bits)
                axmap->first_free = -1ULL;
 
+       if (bit_nr > axmap->nr_bits)
+               return;
+       else if (bit_nr + nr_bits > axmap->nr_bits)
+               nr_bits = axmap->nr_bits - bit_nr;
+
        set_bits = 0;
        while (nr_bits) {
                axmap_handler(axmap, bit_nr, axmap_set_fn, data);
@@ -301,12 +309,16 @@ static int axmap_isset_fn(struct axmap_level *al, unsigned long offset,
 
 int axmap_isset(struct axmap *axmap, uint64_t bit_nr)
 {
-       return axmap_handler_topdown(axmap, bit_nr, axmap_isset_fn, NULL);
+       if (bit_nr <= axmap->nr_bits)
+               return axmap_handler_topdown(axmap, bit_nr, axmap_isset_fn, NULL);
+
+       return 0;
 }
 
 static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
                                       uint64_t index)
 {
+       uint64_t ret = -1ULL;
        unsigned long j;
        int i;
 
@@ -316,8 +328,11 @@ static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
        for (i = level; i >= 0; i--) {
                struct axmap_level *al = &axmap->levels[i];
 
+               /*
+                * Clear 'ret', this is a bug condition.
+                */
                if (index >= al->map_size) {
-                       index = -1ULL;
+                       ret = -1ULL;
                        break;
                }
 
@@ -329,12 +344,15 @@ static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
                         * First free bit here is our index into the first
                         * free bit at the next higher level
                         */
-                       index = (j << UNIT_SHIFT) + ffz(al->map[j]);
+                       ret = index = (j << UNIT_SHIFT) + ffz(al->map[j]);
                        break;
                }
        }
 
-       return index;
+       if (ret < axmap->nr_bits)
+               return ret;
+
+       return (uint64_t) -1ULL;
 }
 
 uint64_t axmap_first_free(struct axmap *axmap)
index 30fcac54a514e8c8fc00e67da7da646ecdbcdfd5..1fe5194729a6541bb8c8795ad15899bce7052d00 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <inttypes.h>
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef CONFIG_LITTLE_ENDIAN
 static inline uint32_t __be32_to_cpu(uint32_t val)
 {
        uint32_t c1, c2, c3, c4;
diff --git a/lib/flist_sort.c b/lib/flist_sort.c
new file mode 100644 (file)
index 0000000..1c91cc4
--- /dev/null
@@ -0,0 +1,140 @@
+#include <stdio.h>
+#include <string.h>
+#include "../flist.h"
+#include "../log.h"
+
+#define MAX_LIST_LENGTH_BITS 20
+
+/*
+ * Returns a list organized in an intermediate format suited
+ * to chaining of merge() calls: null-terminated, no reserved or
+ * sentinel head node, "prev" links not maintained.
+ */
+static struct flist_head *merge(void *priv,
+                               int (*cmp)(void *priv, struct flist_head *a,
+                                       struct flist_head *b),
+                               struct flist_head *a, struct flist_head *b)
+{
+       struct flist_head head, *tail = &head;
+
+       while (a && b) {
+               /* if equal, take 'a' -- important for sort stability */
+               if ((*cmp)(priv, a, b) <= 0) {
+                       tail->next = a;
+                       a = a->next;
+               } else {
+                       tail->next = b;
+                       b = b->next;
+               }
+               tail = tail->next;
+       }
+       tail->next = a?:b;
+       return head.next;
+}
+
+/*
+ * Combine final list merge with restoration of standard doubly-linked
+ * list structure.  This approach duplicates code from merge(), but
+ * runs faster than the tidier alternatives of either a separate final
+ * prev-link restoration pass, or maintaining the prev links
+ * throughout.
+ */
+static void merge_and_restore_back_links(void *priv,
+                               int (*cmp)(void *priv, struct flist_head *a,
+                                       struct flist_head *b),
+                               struct flist_head *head,
+                               struct flist_head *a, struct flist_head *b)
+{
+       struct flist_head *tail = head;
+
+       while (a && b) {
+               /* if equal, take 'a' -- important for sort stability */
+               if ((*cmp)(priv, a, b) <= 0) {
+                       tail->next = a;
+                       a->prev = tail;
+                       a = a->next;
+               } else {
+                       tail->next = b;
+                       b->prev = tail;
+                       b = b->next;
+               }
+               tail = tail->next;
+       }
+       tail->next = a ? : b;
+
+       do {
+               /*
+                * In worst cases this loop may run many iterations.
+                * Continue callbacks to the client even though no
+                * element comparison is needed, so the client's cmp()
+                * routine can invoke cond_resched() periodically.
+                */
+               (*cmp)(priv, tail->next, tail->next);
+
+               tail->next->prev = tail;
+               tail = tail->next;
+       } while (tail->next);
+
+       tail->next = head;
+       head->prev = tail;
+}
+
+/**
+ * list_sort - sort a list
+ * @priv: private data, opaque to list_sort(), passed to @cmp
+ * @head: the list to sort
+ * @cmp: the elements comparison function
+ *
+ * This function implements "merge sort", which has O(nlog(n))
+ * complexity.
+ *
+ * The comparison function @cmp must return a negative value if @a
+ * should sort before @b, and a positive value if @a should sort after
+ * @b. If @a and @b are equivalent, and their original relative
+ * ordering is to be preserved, @cmp must return 0.
+ */
+void flist_sort(void *priv, struct flist_head *head,
+               int (*cmp)(void *priv, struct flist_head *a,
+                       struct flist_head *b))
+{
+       struct flist_head *part[MAX_LIST_LENGTH_BITS+1]; /* sorted partial lists
+                                               -- last slot is a sentinel */
+       int lev;  /* index into part[] */
+       int max_lev = 0;
+       struct flist_head *list;
+
+       if (flist_empty(head))
+               return;
+
+       memset(part, 0, sizeof(part));
+
+       head->prev->next = NULL;
+       list = head->next;
+
+       while (list) {
+               struct flist_head *cur = list;
+               list = list->next;
+               cur->next = NULL;
+
+               for (lev = 0; part[lev]; lev++) {
+                       cur = merge(priv, cmp, part[lev], cur);
+                       part[lev] = NULL;
+               }
+               if (lev > max_lev) {
+                       if (lev >= MAX_LIST_LENGTH_BITS) {
+                               log_err("fio: list passed to"
+                                       " list_sort() too long for"
+                                       " efficiency\n");
+                               lev--;
+                       }
+                       max_lev = lev;
+               }
+               part[lev] = cur;
+       }
+
+       for (lev = 0; lev < max_lev; lev++)
+               if (part[lev])
+                       list = merge(priv, cmp, part[lev], list);
+
+       merge_and_restore_back_links(priv, cmp, head, part[max_lev], list);
+}
index 237cbae541e716ea046fc55c35b1362014dada87..84272c0c8c288a3d0e5e8a6c2ce493d78c583999 100644 (file)
@@ -1,8 +1,8 @@
-#if !(defined(_AIX) || defined(__hpux))
+#ifndef CONFIG_GETOPT_LONG_ONLY
 
 #include <getopt.h>
 
-#else /* _AIX || __hpux */
+#else
 
 #ifndef _GETOPT_H
 #define _GETOPT_H
@@ -22,5 +22,5 @@ enum {
 
 int getopt_long_only(int, char *const *, const char *, const struct option *, int *);
 
-#endif /* _GETOPT_H */
-#endif /* _AIX || __hpux */
+#endif
+#endif
diff --git a/lib/hweight.c b/lib/hweight.c
new file mode 100644 (file)
index 0000000..2c819d6
--- /dev/null
@@ -0,0 +1,33 @@
+#include "hweight.h"
+
+unsigned int hweight8(uint8_t w)
+{
+       unsigned int res = w - ((w >> 1) & 0x55);
+
+       res = (res & 0x33) + ((res >> 2) & 0x33);
+       return (res + (res >> 4)) & 0x0F;
+}
+
+unsigned int hweight32(uint32_t w)
+{
+       unsigned int res = w - ((w >> 1) & 0x55555555);
+
+       res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+       res = (res + (res >> 4)) & 0x0F0F0F0F;
+       res = res + (res >> 8);
+       return (res + (res >> 16)) & 0x000000FF;
+}
+
+unsigned int hweight64(uint64_t w)
+{
+#if BITS_PER_LONG == 32
+       return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w);
+#else
+       uint64_t res = w - ((w >> 1) & 0x5555555555555555ULL);
+       res = (res & 0x3333333333333333ULL) + ((res >> 2) & 0x3333333333333333ULL);
+       res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
+       res = res + (res >> 8);
+       res = res + (res >> 16);
+       return (res + (res >> 32)) & 0x00000000000000FFULL;
+#endif
+}
diff --git a/lib/hweight.h b/lib/hweight.h
new file mode 100644 (file)
index 0000000..68861dd
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef FIO_HWEIGHT_H
+#define FIO_HWEIGHT_H
+
+#include <inttypes.h>
+
+unsigned int hweight8(uint8_t w);
+unsigned int hweight32(uint32_t w);
+unsigned int hweight64(uint64_t w);
+
+#endif
diff --git a/lib/inet_aton.c b/lib/inet_aton.c
new file mode 100644 (file)
index 0000000..7ae7db7
--- /dev/null
@@ -0,0 +1,6 @@
+#include "inet_aton.h"
+
+int inet_aton(const char *cp, struct in_addr *inp)
+{
+       return inet_pton(AF_INET, cp, inp);
+}
diff --git a/lib/inet_aton.h b/lib/inet_aton.h
new file mode 100644 (file)
index 0000000..c93c87f
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef FIO_INET_ATON_LIB_H
+#define FIO_INET_ATON_LIB_H
+
+#include <arpa/inet.h>
+
+int inet_aton(const char *cp, struct in_addr *inp);
+
+#endif
index 8a70029627a34ccbec53a104f879c94ec6498234..61a3aaf3e6532c32722314da125bcce69cf98416 100644 (file)
@@ -216,14 +216,15 @@ static uint64_t __lfsr_next(uint64_t v, struct lfsr_taps *lt)
        return xor_mask | (v >> 1);
 }
 
-int lfsr_next(struct fio_lfsr *fl, uint64_t *off)
+int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t last)
 {
        if (fl->num_vals > fl->max_val)
                return 1;
 
        do {
                fl->last_val = __lfsr_next(fl->last_val, &fl->taps);
-               if (fl->last_val - 1 <= fl->max_val)
+               if (fl->last_val - 1 <= fl->max_val &&
+                   fl->last_val <= last)
                        break;
        } while (1);
 
@@ -243,6 +244,17 @@ static struct lfsr_taps *find_lfsr(uint64_t size)
        return NULL;
 }
 
+void lfsr_reset(struct fio_lfsr *fl, unsigned long seed)
+{
+       unsigned int i;
+
+       fl->last_val = seed;
+       fl->num_vals = 0;
+
+       for (i = 0; i < FIO_LFSR_CRANKS; i++)
+               fl->last_val = __lfsr_next(fl->last_val, &fl->taps);
+}
+
 int lfsr_init(struct fio_lfsr *fl, uint64_t size, unsigned long seed)
 {
        struct lfsr_taps *tap;
@@ -252,18 +264,15 @@ int lfsr_init(struct fio_lfsr *fl, uint64_t size, unsigned long seed)
        if (!tap)
                return 1;
 
-       fl->last_val = seed;
        fl->max_val = size - 1;
-       fl->num_vals = 0;
        fl->taps.length = tap->length;
+
        for (i = 0; i < FIO_MAX_TAPS; i++) {
                fl->taps.taps[i] = tap->taps[i];
                if (!fl->taps.taps[i])
                        break;
        }
 
-       for (i = 0; i < FIO_LFSR_CRANKS; i++)
-               fl->last_val = __lfsr_next(fl->last_val, &fl->taps);
-
+       lfsr_reset(fl, seed);
        return 0;
 }
index 09f5ac0bd3d73f63541a16ea46778a9d5cecf178..45d7028c49731f4f647d8977c26348a97f812b48 100644 (file)
@@ -18,7 +18,8 @@ struct fio_lfsr {
        struct lfsr_taps taps;
 };
 
-int lfsr_next(struct fio_lfsr *fl, uint64_t *off);
+int lfsr_next(struct fio_lfsr *fl, uint64_t *off, uint64_t);
 int lfsr_init(struct fio_lfsr *fl, uint64_t size, unsigned long seed);
+void lfsr_reset(struct fio_lfsr *fl, unsigned long seed);
 
 #endif
index 782a360097cae1eaeed290af5c5439e2bf248226..5fea5d191f3dc7122bb9446b22851a355c108bca 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef FIO_LIB_H
-#define FIO_LIB_H
+#ifndef FIO_STRSEP_LIB_H
+#define FIO_STRSEP_LIB_H
 
 char *strsep(char **, const char *);
 
index 5395dd2d690f45deda57a0b2124fb61eb1b58ea9..37e5c0db5a6e32fd67b6bd1f24addf4d73066f88 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -75,6 +75,7 @@ static const char *fio_arch_strings[arch_nr] = {
 static void reset_io_counters(struct thread_data *td)
 {
        int ddir;
+
        for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) {
                td->stat_io_bytes[ddir] = 0;
                td->this_io_bytes[ddir] = 0;
@@ -82,15 +83,17 @@ static void reset_io_counters(struct thread_data *td)
                td->this_io_blocks[ddir] = 0;
                td->rate_bytes[ddir] = 0;
                td->rate_blocks[ddir] = 0;
+               td->io_issues[ddir] = 0;
        }
        td->zone_bytes = 0;
 
        td->last_was_sync = 0;
+       td->rwmix_issues = 0;
 
        /*
         * reset file done count if we are to start over
         */
-       if (td->o.time_based || td->o.loops)
+       if (td->o.time_based || td->o.loops || td->o.do_verify)
                td->nr_done_files = 0;
 }
 
@@ -211,10 +214,10 @@ static int endian_check(void)
        else if (u.c[0] == 0x12)
                le = 1;
 
-#if defined(FIO_LITTLE_ENDIAN)
+#if defined(CONFIG_LITTLE_ENDIAN)
        if (be)
                return 1;
-#elif defined(FIO_BIG_ENDIAN)
+#elif defined(CONFIG_BIG_ENDIAN)
        if (le)
                return 1;
 #else
index 5293af96b226240117d312f24875f0406ceff5fd..e969221f36f86a8a1c74b502152a97e75f81c219 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -117,14 +117,16 @@ static void free_mem_shm(struct thread_data *td)
 
 static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
 {
-       int flags = MAP_PRIVATE;
+       int flags = 0;
 
        td->mmapfd = 1;
 
        if (td->o.mem_type == MEM_MMAPHUGE) {
                unsigned long mask = td->o.hugepage_size - 1;
 
-               flags |= MAP_HUGETLB;
+               /* TODO: make sure the file is a real hugetlbfs file */
+               if (!td->o.mmapfile)
+                       flags |= MAP_HUGETLB;
                total_mem = (total_mem + mask) & ~mask;
        }
 
@@ -136,13 +138,18 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
                        td->orig_buffer = NULL;
                        return 1;
                }
-               if (ftruncate(td->mmapfd, total_mem) < 0) {
+               if (td->o.mem_type != MEM_MMAPHUGE &&
+                   ftruncate(td->mmapfd, total_mem) < 0) {
                        td_verror(td, errno, "truncate mmap file");
                        td->orig_buffer = NULL;
                        return 1;
                }
+               if (td->o.mem_type == MEM_MMAPHUGE)
+                       flags |= MAP_SHARED;
+               else
+                       flags |= MAP_PRIVATE;
        } else
-               flags |= OS_MAP_ANON;
+               flags |= OS_MAP_ANON | MAP_PRIVATE;
 
        td->orig_buffer = mmap(NULL, total_mem, PROT_READ | PROT_WRITE, flags,
                                td->mmapfd, 0);
index a7a133f834b169658a50734868e5df3c95ff4149..14616408dcd0da3953f764289b0196309220af70 100644 (file)
--- a/options.c
+++ b/options.c
@@ -341,15 +341,9 @@ static int str_rw_cb(void *data, const char *str)
 static int str_mem_cb(void *data, const char *mem)
 {
        struct thread_data *td = data;
-       struct thread_options *o = &td->o;
 
-       if (o->mem_type == MEM_MMAPHUGE || o->mem_type == MEM_MMAP) {
-               o->mmapfile = get_opt_postfix(mem);
-               if (o->mem_type == MEM_MMAPHUGE && !o->mmapfile) {
-                       log_err("fio: mmaphuge:/path/to/file\n");
-                       return 1;
-               }
-       }
+       if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
+               td->o.mmapfile = get_opt_postfix(mem);
 
        return 0;
 }
@@ -514,7 +508,7 @@ static int str_verify_cpus_allowed_cb(void *data, const char *input)
 }
 #endif
 
-#ifdef FIO_HAVE_LIBNUMA
+#ifdef CONFIG_LIBNUMA
 static int str_numa_cpunodes_cb(void *data, char *input)
 {
        struct thread_data *td = data;
@@ -652,7 +646,7 @@ static int str_fst_cb(void *data, const char *str)
        return 0;
 }
 
-#ifdef FIO_HAVE_SYNC_FILE_RANGE
+#ifdef CONFIG_SYNC_FILE_RANGE
 static int str_sfr_cb(void *data, const char *str)
 {
        struct thread_data *td = data;
@@ -1296,12 +1290,12 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                          { .ival = "vsync",
                            .help = "Use readv/writev",
                          },
-#ifdef FIO_HAVE_LIBAIO
+#ifdef CONFIG_LIBAIO
                          { .ival = "libaio",
                            .help = "Linux native asynchronous IO",
                          },
 #endif
-#ifdef FIO_HAVE_POSIXAIO
+#ifdef CONFIG_POSIXAIO
                          { .ival = "posixaio",
                            .help = "POSIX asynchronous IO",
                          },
@@ -1319,7 +1313,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                          { .ival = "mmap",
                            .help = "Memory mapped IO"
                          },
-#ifdef FIO_HAVE_SPLICE
+#ifdef CONFIG_LINUX_SPLICE
                          { .ival = "splice",
                            .help = "splice/vmsplice based IO",
                          },
@@ -1338,15 +1332,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                          { .ival = "net",
                            .help = "Network IO",
                          },
-#ifdef FIO_HAVE_SYSLET
-                         { .ival = "syslet-rw",
-                           .help = "syslet enabled async pread/pwrite IO",
-                         },
-#endif
                          { .ival = "cpuio",
                            .help = "CPU cycle burner engine",
                          },
-#ifdef FIO_HAVE_GUASI
+#ifdef CONFIG_GUASI
                          { .ival = "guasi",
                            .help = "GUASI IO engine",
                          },
@@ -1356,12 +1345,12 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .help = "binject direct inject block engine",
                          },
 #endif
-#ifdef FIO_HAVE_RDMA
+#ifdef CONFIG_RDMA
                          { .ival = "rdma",
                            .help = "RDMA IO engine",
                          },
 #endif
-#ifdef FIO_HAVE_FUSION_AW
+#ifdef CONFIG_FUSION_AW
                          { .ival = "fusion-aw-sync",
                            .help = "Fusion-io atomic write engine",
                          },
@@ -1786,7 +1775,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_INVALID,
        },
-#ifdef FIO_HAVE_SYNC_FILE_RANGE
+#ifdef CONFIG_SYNC_FILE_RANGE
        {
                .name   = "sync_file_range",
                .lname  = "Sync file range",
@@ -1920,14 +1909,18 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_GENERAL,
                .group  = FIO_OPT_G_CLOCK,
                .posval = {
+#ifdef CONFIG_GETTIMEOFDAY
                          { .ival = "gettimeofday",
                            .oval = CS_GTOD,
                            .help = "Use gettimeofday(2) for timing",
                          },
+#endif
+#ifdef CONFIG_CLOCK_GETTIME
                          { .ival = "clock_gettime",
                            .oval = CS_CGETTIME,
                            .help = "Use clock_gettime(2) for timing",
                          },
+#endif
 #ifdef ARCH_HAVE_CPU_CLOCK
                          { .ival = "cpu",
                            .oval = CS_CPUCLOCK,
@@ -2077,6 +2070,18 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_VERIFY,
        },
+       {
+               .name   = "verifysort_nr",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(verifysort_nr),
+               .help   = "Pre-load and sort verify blocks for a read workload",
+               .minval = 0,
+               .maxval = 131072,
+               .def    = "1024",
+               .parent = "verify",
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_VERIFY,
+       },
        {
                .name   = "verify_interval",
                .lname  = "Verify interval",
@@ -2184,6 +2189,13 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .group  = FIO_OPT_G_VERIFY,
        },
 #endif
+       {
+               .name   = "experimental_verify",
+               .off1   = td_var_offset(experimental_verify),
+               .type   = FIO_OPT_BOOL,
+               .category = FIO_OPT_C_IO,
+               .group  = FIO_OPT_G_VERIFY,
+       },
 #ifdef FIO_HAVE_TRIM
        {
                .name   = "trim_percentage",
@@ -2616,7 +2628,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .group  = FIO_OPT_G_CRED,
        },
 #endif
-#ifdef FIO_HAVE_LIBNUMA
+#ifdef CONFIG_LIBNUMA
        {
                .name   = "numa_cpu_nodes",
                .type   = FIO_OPT_STR,
diff --git a/os/indirect.h b/os/indirect.h
deleted file mode 100644 (file)
index fba6b6b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef _INDIRECT_H_
-#define _INDIRECT_H_
-
-#include "syslet.h"
-
-union indirect_params {
-       struct {
-               u32 flags;
-       } file_flags;
-       struct syslet_args syslet;
-};
-
-#ifdef __x86_64__
-# define __NR_indirect 286
-struct indirect_registers {
-       u64 rax;
-       u64 rdi;
-       u64 rsi;
-       u64 rdx;
-       u64 r10;
-       u64 r8;
-       u64 r9;
-};
-#elif defined __i386__
-# define __NR_indirect 325
-struct indirect_registers {
-       u32 eax;
-       u32 ebx;
-       u32 ecx;
-       u32 edx;
-       u32 esi;
-       u32 edi;
-       u32 ebp;
-};
-#endif
-
-#define FILL_IN(var, values...) \
-         (var) = (struct indirect_registers) { values, }
-
-#endif
index 1870e6e46f9c14676c53394eaadff3383a08d675..3d677650934e8a762d6651f32cfa5ee096b47b69 100644 (file)
 
 #include "../file.h"
 
-#define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_ODIRECT
 #define FIO_USE_GENERIC_RAND
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
-#define FIO_HAVE_CLOCK_MONOTONIC
-
-/*
- * This is broken on AIX if _LARGE_FILES is defined...
- */
-#if 0
-#define FIO_HAVE_FALLOCATE
-#endif
 
 #define FIO_HAVE_PSHARED_MUTEX
 
 #define OS_MAP_ANON            MAP_ANON
 #define OS_MSG_DONTWAIT                0
 
-#if BYTE_ORDER == BIG_ENDIAN
-#define FIO_BIG_ENDIAN
-#else
-#define FIO_LITTLE_ENDIAN
-#endif
-
 #define FIO_USE_GENERIC_SWAP
 
-#define FIO_OS_HAVE_SOCKLEN_T
-#define fio_socklen_t socklen_t
-
 static inline int blockdev_invalidate_cache(struct fio_file *f)
 {
        return EINVAL;
index 3da39531bff53c5f931e9557b240ac8c883824ec..e436f8fbdd050061383dd9a0d592240d289fc8c0 100644 (file)
 #include <sched.h>
 #include <linux/unistd.h>
 #include <linux/major.h>
-#include <endian.h>
 
-#include "indirect.h"
 #include "binject.h"
 #include "../file.h"
 
 #define FIO_HAVE_DISK_UTIL
-#define FIO_HAVE_SPLICE
 #define FIO_HAVE_IOSCHED_SWITCH
 #define FIO_HAVE_ODIRECT
 #define FIO_HAVE_HUGETLB
 #define FIO_HAVE_BLKTRACE
-#define FIO_HAVE_STRSEP
-#define FIO_HAVE_POSIXAIO_FSYNC
 #define FIO_HAVE_PSHARED_MUTEX
 #define FIO_HAVE_CL_SIZE
-#define FIO_HAVE_FDATASYNC
 #define FIO_HAVE_FS_STAT
 #define FIO_HAVE_TRIM
-#define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_HAVE_GETTID
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define FIO_HAVE_E4_ENG
@@ -78,36 +71,6 @@ static inline int shmdt (const void *__shmaddr)
 }
 
 
-/*
- * Just check for SPLICE_F_MOVE, if that isn't there, assume the others
- * aren't either.
- */
-#ifndef SPLICE_F_MOVE
-#define SPLICE_F_MOVE  (0x01)  /* move pages instead of copying */
-#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
-                                /* we may still block on the fd we splice */
-                                /* from/to, of course */
-#define SPLICE_F_MORE  (0x04)  /* expect more data */
-#define SPLICE_F_GIFT   (0x08)  /* pages passed in are a gift */
-
-static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out,
-                        size_t len, unsigned int flags)
-{
-       return syscall(__NR_sys_splice, fdin, off_in, fdout, off_out, len, flags);
-}
-
-static inline int tee(int fdin, int fdout, size_t len, unsigned int flags)
-{
-       return syscall(__NR_sys_tee, fdin, fdout, len, flags);
-}
-
-static inline int vmsplice(int fd, const struct iovec *iov,
-                          unsigned long nr_segs, unsigned int flags)
-{
-       return syscall(__NR_sys_vmsplice, fd, iov, nr_segs, flags);
-}
-#endif
-
 #define SPLICE_DEF_SIZE        (64*1024)
 
 #ifndef BLKGETSIZE64
@@ -170,14 +133,6 @@ static inline long os_random_long(os_random_state_t *rs)
 #define FIO_O_NOATIME  0
 #endif
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define FIO_BIG_ENDIAN
-#else
-#error "Unknown endianness"
-#endif
-
 #define fio_swap16(x)  __bswap_16(x)
 #define fio_swap32(x)  __bswap_32(x)
 #define fio_swap64(x)  __bswap_64(x)
index 2a7b7b327a83f6fb50eb7f1839108ca108b9e1ef..c55a7c315ca2efc2ab609f5d60019da0805f46b3 100644 (file)
@@ -7,28 +7,18 @@
 #include <sys/sysctl.h>
 #include <sys/disk.h>
 #include <sys/thr.h>
-#include <sys/endian.h>
 #include <sys/socket.h>
 
 #include "../file.h"
 
-#define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_ODIRECT
-#define FIO_HAVE_STRSEP
 #define FIO_USE_GENERIC_RAND
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_HAVE_GETTID
-#define FIO_HAVE_CLOCK_MONOTONIC
 
 #define OS_MAP_ANON            MAP_ANON
 
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#else
-#define FIO_BIG_ENDIAN
-#endif
-
 #define fio_swap16(x)  bswap16(x)
 #define fio_swap32(x)  bswap32(x)
 #define fio_swap64(x)  bswap64(x)
index 821c91690b12c8165488c5d2e99170d98a77e1af..82acd1105fc51aa22f3976643a18999b245ebb3e 100644 (file)
 
 #include "../file.h"
 
-#define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_ODIRECT
 #define FIO_USE_GENERIC_RAND
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
-#define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_HAVE_PSHARED_MUTEX
-#define FIO_HAVE_FADVISE
 #define FIO_HAVE_CHARDEV_SIZE
-#define FIO_HAVE_FALLOCATE
-#define FIO_HAVE_POSIXAIO_FSYNC
-#define FIO_HAVE_FDATASYNC
 
 #define OS_MAP_ANON            MAP_ANONYMOUS
 #define OS_MSG_DONTWAIT                0
 #define POSIX_MADV_RANDOM      MADV_RANDOM
 #define posix_madvise(ptr, sz, hint)   madvise((ptr), (sz), (hint))
 
-#ifndef CLOCK_MONOTONIC
-#define CLOCK_MONOTONIC                CLOCK_REALTIME
-#endif
-
 #ifndef MSG_WAITALL
 #define MSG_WAITALL    0x40
 #endif
 
-#ifdef LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#else
-#define FIO_BIG_ENDIAN
-#endif
-
 #define FIO_USE_GENERIC_SWAP
 
 #define FIO_OS_HAVE_AIOCB_TYPEDEF
 typedef struct aiocb64 os_aiocb_t;
 
-#define FIO_OS_HAVE_SOCKLEN_T
-typedef int fio_socklen_t;
-
 static inline int blockdev_invalidate_cache(struct fio_file *f)
 {
        return EINVAL;
index 0d9829885b3be853f99de85e9431622c7c8a809a..75964dca89543d67c6588b8fd635ac1c8dbcfc54 100644 (file)
 #include <linux/unistd.h>
 #include <linux/raw.h>
 #include <linux/major.h>
-#include <endian.h>
 
-#include "indirect.h"
 #include "binject.h"
 #include "../file.h"
 
-#define FIO_HAVE_LIBAIO
-#define FIO_HAVE_POSIXAIO
-#define FIO_HAVE_FADVISE
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_DISK_UTIL
 #define FIO_HAVE_SGIO
 #define FIO_HAVE_IOPRIO
-#define FIO_HAVE_SPLICE
 #define FIO_HAVE_IOSCHED_SWITCH
 #define FIO_HAVE_ODIRECT
 #define FIO_HAVE_HUGETLB
 #define FIO_HAVE_RAWBIND
 #define FIO_HAVE_BLKTRACE
-#define FIO_HAVE_STRSEP
-#define FIO_HAVE_POSIXAIO_FSYNC
 #define FIO_HAVE_PSHARED_MUTEX
 #define FIO_HAVE_CL_SIZE
 #define FIO_HAVE_CGROUPS
-#define FIO_HAVE_FDATASYNC
 #define FIO_HAVE_FS_STAT
 #define FIO_HAVE_TRIM
 #define FIO_HAVE_BINJECT
-#define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_HAVE_GETTID
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
-#define FIO_HAVE_E4_ENG
 
 #ifdef MAP_HUGETLB
 #define FIO_HAVE_MMAP_HUGE
 #endif
 
-/*
- * Can only enable this for newer glibcs, or the header and defines are
- * missing
- */
-#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 6
-#define FIO_HAVE_FALLOCATE
-#endif
-#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 8
-#define FIO_HAVE_LINUX_FALLOCATE
-#endif
-
-#ifdef FIO_HAVE_LINUX_FALLOCATE
-#define FIO_HAVE_FALLOC_ENG
-#endif
-
-#ifdef SYNC_FILE_RANGE_WAIT_BEFORE
-#define FIO_HAVE_SYNC_FILE_RANGE
-#endif
-
 #define OS_MAP_ANON            MAP_ANONYMOUS
 
-#ifndef CLOCK_MONOTONIC
-#define CLOCK_MONOTONIC 1
-#endif
-
 typedef cpu_set_t os_cpu_mask_t;
 
 typedef struct drand48_data os_random_state_t;
 
-/*
- * we want fadvise64 really, but it's so tangled... later
- */
-#ifdef FIO_HAVE_FADVISE
-#define fadvise(fd, off, len, advice)  \
-       posix_fadvise((fd), (off_t)(off), (len), (advice))
-#endif
-
-/*
- * If you are on an ancient glibc (2.3.2), then define GLIBC_2_3_2 if you want
- * the affinity helpers to work.
- */
-#ifndef GLIBC_2_3_2
+#ifdef CONFIG_3ARG_AFFINITY
 #define fio_setaffinity(pid, cpumask)          \
        sched_setaffinity((pid), sizeof(cpumask), &(cpumask))
 #define fio_getaffinity(pid, ptr)      \
        sched_getaffinity((pid), sizeof(cpu_set_t), (ptr))
-#else
+#elif defined(CONFIG_2ARG_AFFINITY)
 #define fio_setaffinity(pid, cpumask)  \
        sched_setaffinity((pid), &(cpumask))
 #define fio_getaffinity(pid, ptr)      \
@@ -154,71 +108,8 @@ static inline int gettid(void)
        return syscall(__NR_gettid);
 }
 
-/*
- * Just check for SPLICE_F_MOVE, if that isn't there, assume the others
- * aren't either.
- */
-#ifndef SPLICE_F_MOVE
-#define SPLICE_F_MOVE  (0x01)  /* move pages instead of copying */
-#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
-                                /* we may still block on the fd we splice */
-                                /* from/to, of course */
-#define SPLICE_F_MORE  (0x04)  /* expect more data */
-#define SPLICE_F_GIFT   (0x08)  /* pages passed in are a gift */
-
-static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out,
-                        size_t len, unsigned int flags)
-{
-       return syscall(__NR_sys_splice, fdin, off_in, fdout, off_out, len, flags);
-}
-
-static inline int tee(int fdin, int fdout, size_t len, unsigned int flags)
-{
-       return syscall(__NR_sys_tee, fdin, fdout, len, flags);
-}
-
-static inline int vmsplice(int fd, const struct iovec *iov,
-                          unsigned long nr_segs, unsigned int flags)
-{
-       return syscall(__NR_sys_vmsplice, fd, iov, nr_segs, flags);
-}
-#endif
-
 #define SPLICE_DEF_SIZE        (64*1024)
 
-#ifdef FIO_HAVE_SYSLET
-
-struct syslet_uatom;
-struct async_head_user;
-
-/*
- * syslet stuff
- */
-static inline struct syslet_uatom *
-async_exec(struct syslet_uatom *atom, struct async_head_user *ahu)
-{
-       return (struct syslet_uatom *) syscall(__NR_async_exec, atom, ahu);
-}
-
-static inline long
-async_wait(unsigned long min_wait_events, unsigned long user_ring_idx,
-          struct async_head_user *ahu)
-{
-       return syscall(__NR_async_wait, min_wait_events,
-                       user_ring_idx, ahu);
-}
-
-static inline long async_thread(void *event, struct async_head_user *ahu)
-{
-       return syscall(__NR_async_thread, event, ahu);
-}
-
-static inline long umem_add(unsigned long *uptr, unsigned long inc)
-{
-       return syscall(__NR_umem_add, uptr, inc);
-}
-#endif /* FIO_HAVE_SYSLET */
-
 #ifndef BLKGETSIZE64
 #define BLKGETSIZE64   _IOR(0x12,114,size_t)
 #endif
@@ -309,14 +200,6 @@ static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
 #define FIO_MADV_FREE  MADV_REMOVE
 #endif
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define FIO_BIG_ENDIAN
-#else
-#error "Unknown endianness"
-#endif
-
 #define fio_swap16(x)  __bswap_16(x)
 #define fio_swap32(x)  __bswap_32(x)
 #define fio_swap64(x)  __bswap_64(x)
index 553f82007fae7c23a83a5b89ac77108907e2cb18..d202e99dd60a93bc3c11dd0088456bbc1a731adf 100644 (file)
 
 #include "../file.h"
 
-#ifndef CLOCK_MONOTONIC
-#define CLOCK_MONOTONIC 1
-#endif
-
-#ifndef CLOCK_REALTIME
-#define CLOCK_REALTIME 1
-#endif
-
-#define FIO_HAVE_POSIXAIO
-#define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_USE_GENERIC_RAND
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define FIO_HAVE_GETTID
 
 #define OS_MAP_ANON            MAP_ANON
 
-#if defined(__LITTLE_ENDIAN__)
-#define FIO_LITTLE_ENDIAN
-#elif defined(__BIG_ENDIAN__)
-#define FIO_BIG_ENDIAN
-#else
-#error "Undefined byte order"
-#endif
-
 #define fio_swap16(x)  OSSwapInt16(x)
 #define fio_swap32(x)  OSSwapInt32(x)
 #define fio_swap64(x)  OSSwapInt64(x)
@@ -179,4 +161,11 @@ static inline int gettid(void)
 {
        return mach_thread_self();
 }
+
+/*
+ * For some reason, there's no header definition for fdatasync(), even
+ * if it exists.
+ */
+extern int fdatasync(int fd);
+
 #endif
index de687ba386103b7e40be350724d4262b2894fa06..4b0269e6cab673311576689d514db5b09d49d822 100644 (file)
@@ -6,7 +6,6 @@
 #include <errno.h>
 #include <lwp.h>
 #include <sys/param.h>
-#include <sys/endian.h>
 /* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
 #define        rb_node _rb_node
 #include <sys/sysctl.h>
 
 #include "../file.h"
 
-#define FIO_HAVE_POSIXAIO
-#define FIO_HAVE_FADVISE
 #define FIO_HAVE_ODIRECT
-#define FIO_HAVE_STRSEP
-#define FIO_HAVE_FDATASYNC
 #define FIO_USE_GENERIC_BDEV_SIZE
 #define FIO_USE_GENERIC_RAND
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define PTHREAD_STACK_MIN 4096
 #endif
 
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#else
-#define FIO_BIG_ENDIAN
-#endif
-
 #define fio_swap16(x)  bswap16(x)
 #define fio_swap32(x)  bswap32(x)
 #define fio_swap64(x)  bswap64(x)
index 5efd7ac1e96481ec4ed0645c2c2bb88a66cbdf6d..de59f774d7fb1a8c51b9da20acf00c61923444da 100644 (file)
 
 #include "../file.h"
 
-#define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_SOLARISAIO
-#define FIO_HAVE_POSIXAIO_FSYNC
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_PSHARED_MUTEX
-#define FIO_HAVE_FDATASYNC
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_USE_GENERIC_BDEV_SIZE
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define FIO_HAVE_GETTID
-#define FIO_HAVE_FADVISE
 
 #define OS_MAP_ANON            MAP_ANON
 #define OS_RAND_MAX            2147483648UL
 
-#if defined(_BIG_ENDIAN)
-#define FIO_BIG_ENDIAN
-#else
-#define FIO_LITTLE_ENDIAN
-#endif
-
 #define fio_swap16(x)  BSWAP_16(x)
 #define fio_swap32(x)  BSWAP_32(x)
 #define fio_swap64(x)  BSWAP_64(x)
index ba9319536a04d9ce75d811c65d34fc0e19b79962..f68f654c8c832ba8be0aea618d3b622c7377cc48 100644 (file)
@@ -15,6 +15,8 @@
 #include "../file.h"
 #include "../log.h"
 
+#include "windows/posix.h"
+
 #define FIO_HAVE_ODIRECT
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_CHARDEV_SIZE
@@ -22,8 +24,6 @@
 #define FIO_HAVE_WINDOWSAIO
 #define FIO_HAVE_FALLOCATE
 #define FIO_HAVE_GETTID
-#define FIO_HAVE_CLOCK_MONOTONIC
-#define FIO_HAVE_FADVISE
 #define FIO_USE_GENERIC_RAND
 
 #define FIO_PREFERRED_ENGINE           "windowsaio"
 
 #define FIO_MAX_CPUS   MAXIMUM_PROCESSORS
 
-#define FIO_OS_HAVE_SOCKLEN_T
-typedef int fio_socklen_t;
-
 #define OS_MAP_ANON            MAP_ANON
 
-#define FIO_LITTLE_ENDIAN
 #define fio_swap16(x)  _byteswap_ushort(x)
 #define fio_swap32(x)  _byteswap_ulong(x)
 #define fio_swap64(x)  _byteswap_uint64(x)
 
-typedef off_t off64_t;
-typedef int clockid_t;
-
 typedef DWORD_PTR os_cpu_mask_t;
 
 #define CLOCK_REALTIME 1
@@ -97,7 +90,6 @@ struct sigaction
        void* (*sa_sigaction)(int, siginfo_t *, void*);
 };
 
-char *strsep(char **stringp, const char *delim);
 long sysconf(int name);
 
 int kill(pid_t pid, int sig);
@@ -188,7 +180,12 @@ static inline int fio_setaffinity(int pid, os_cpu_mask_t cpumask)
        h = OpenThread(THREAD_QUERY_INFORMATION | THREAD_SET_INFORMATION, TRUE, pid);
        if (h != NULL) {
                bSuccess = SetThreadAffinityMask(h, cpumask);
+               if (!bSuccess)
+                       log_err("fio_setaffinity failed: failed to set thread affinity (pid %d, mask %.16llx)\n", pid, cpumask);
+
                CloseHandle(h);
+       } else {
+               log_err("fio_setaffinity failed: failed to get handle for pid %d\n", pid);
        }
 
        return (bSuccess)? 0 : -1;
@@ -215,7 +212,7 @@ static inline void fio_cpu_clear(os_cpu_mask_t *mask, int cpu)
 
 static inline void fio_cpu_set(os_cpu_mask_t *mask, int cpu)
 {
-       *mask |= 1 << (cpu-1);
+       *mask |= 1 << cpu;
 }
 
 static inline int fio_cpuset_init(os_cpu_mask_t *mask)
diff --git a/os/os.h b/os/os.h
index 8ca507a68cbbede9c2f5367e49174f9ec7a2a2b6..28bb6319f216e095c04324163cd3bf90b65a2077 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -8,6 +8,8 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+#include "../arch/arch.h"
+
 enum {
        os_linux = 1,
        os_aix,
@@ -44,11 +46,7 @@ enum {
 #error "unsupported os"
 #endif
 
-#ifdef FIO_HAVE_LIBAIO
-#include <libaio.h>
-#endif
-
-#ifdef FIO_HAVE_POSIXAIO
+#ifdef CONFIG_POSIXAIO
 #include <aio.h>
 #ifndef FIO_OS_HAVE_AIOCB_TYPEDEF
 typedef struct aiocb os_aiocb_t;
@@ -60,7 +58,7 @@ typedef struct aiocb os_aiocb_t;
 #include <scsi/sg.h>
 #endif
 
-#ifndef FIO_HAVE_STRSEP
+#ifdef CONFIG_STRSEP
 #include "../lib/strsep.h"
 #endif
 
@@ -116,12 +114,6 @@ typedef unsigned long os_cpu_mask_t;
 #define OS_RAND_MAX                    RAND_MAX
 #endif
 
-#ifdef FIO_HAVE_CLOCK_MONOTONIC
-#define FIO_TIMER_CLOCK CLOCK_MONOTONIC
-#else
-#define FIO_TIMER_CLOCK CLOCK_REALTIME
-#endif
-
 #ifndef FIO_HAVE_RAWBIND
 #define fio_lookup_raw(dev, majdev, mindev)    1
 #endif
@@ -142,12 +134,12 @@ typedef unsigned long os_cpu_mask_t;
 #define FIO_MAX_JOBS           2048
 #endif
 
-#ifndef FIO_OS_HAVE_SOCKLEN_T
-typedef socklen_t fio_socklen_t;
+#ifndef CONFIG_SOCKLEN_T
+typedef unsigned int socklen_t;
 #endif
 
 #ifndef FIO_OS_HAS_CTIME_R
-#define os_ctime_r(x, y, z)     ctime_r((x), (y))
+#define os_ctime_r(x, y, z)     (void) ctime_r((x), (y))
 #endif
 
 #ifdef FIO_USE_GENERIC_SWAP
@@ -175,7 +167,7 @@ static inline uint64_t fio_swap64(uint64_t val)
 #endif
 
 #ifndef FIO_HAVE_BYTEORDER_FUNCS
-#ifdef FIO_LITTLE_ENDIAN
+#ifdef CONFIG_LITTLE_ENDIAN
 #define __le16_to_cpu(x)               (x)
 #define __le32_to_cpu(x)               (x)
 #define __le64_to_cpu(x)               (x)
diff --git a/os/syslet.h b/os/syslet.h
deleted file mode 100644 (file)
index 095cc13..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef _SYSLET_H_
-#define _SYSLET_H_
-
-#include "kcompat.h"
-
-struct syslet_frame {
-       u64 ip;
-       u64 sp;
-};
-
-struct syslet_args {
-       u64 ring_ptr;
-       u64 caller_data;
-       struct syslet_frame frame;
-};
-
-struct syslet_completion {
-       u64 status;
-       u64 caller_data;
-};
-
-struct syslet_ring {
-       u32 kernel_head;
-       u32 user_tail;
-       u32 elements;
-       u32 wait_group;
-       struct syslet_completion comp[0];
-};
-
-#ifdef __x86_64__
-#define __NR_syslet_ring_wait  287
-#elif defined __i386__
-#define __NR_syslet_ring_wait  326
-#endif
-
-#define ESYSLETPENDING   132
-
-typedef void (*syslet_return_func_t)(void);
-
-static inline void fill_syslet_args(struct syslet_args *args,
-                     struct syslet_ring *ring, uint64_t caller_data,
-                     syslet_return_func_t func, void *stack)
-{
-       args->ring_ptr = (u64)(unsigned long)ring;
-       args->caller_data = caller_data;
-       args->frame.ip = (u64)(unsigned long)func;
-       args->frame.sp = (u64)(unsigned long)stack;
-}
-
-#endif
index f616e876ba79e70c84d862535861d43f848da72d..67e71c8eabe57a0f2041c78a10cab9ac7c133ec0 100755 (executable)
@@ -20,6 +20,7 @@
 #include <sys/poll.h>
 
 #include "../os-windows.h"
+#include "../../lib/hweight.h"
 
 extern unsigned long mtime_since_now(struct timeval *);
 extern void fio_gettime(struct timeval *, void *);
@@ -42,20 +43,52 @@ int vsprintf_s(
   const char *format,
   va_list argptr);
 
+int GetNumLogicalProcessors(void)
+{
+       SYSTEM_LOGICAL_PROCESSOR_INFORMATION *processor_info = NULL;
+       DWORD len = 0;
+       DWORD num_processors = 0;
+       DWORD error = 0;
+       DWORD i;
+
+       while (!GetLogicalProcessorInformation(processor_info, &len)) {
+               error = GetLastError();
+               if (error == ERROR_INSUFFICIENT_BUFFER)
+                       processor_info = malloc(len);
+               else {
+                       log_err("Error: GetLogicalProcessorInformation failed: %d\n", error);
+                       return -1;
+               }
+
+               if (processor_info == NULL) {
+                       log_err("Error: failed to allocate memory for GetLogicalProcessorInformation");
+                       return -1;
+               }
+       }
+
+       for (i = 0; i < len / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); i++)
+       {
+               if (processor_info[i].Relationship == RelationProcessorCore)
+                       num_processors += hweight64(processor_info[i].ProcessorMask);
+       }
+
+       free(processor_info);
+       return num_processors;
+}
+
 long sysconf(int name)
 {
-       long long val = -1;
-       DWORD len;
-       SYSTEM_LOGICAL_PROCESSOR_INFORMATION processorInfo;
+       long val = -1;
        SYSTEM_INFO sysInfo;
        MEMORYSTATUSEX status;
 
        switch (name)
        {
        case _SC_NPROCESSORS_ONLN:
-               len = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
-               GetLogicalProcessorInformation(&processorInfo, &len);
-               val = len / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
+               val = GetNumLogicalProcessors();
+               if (val == -1)
+                       log_err("_SC_NPROCESSORS_ONLN failed\n");
+
                break;
 
        case _SC_PAGESIZE:
@@ -595,39 +628,6 @@ long long strtoll(const char *restrict str, char **restrict endptr,
        return _strtoi64(str, endptr, base);
 }
 
-char *strsep(char **stringp, const char *delim)
-{
-       char *orig = *stringp;
-       BOOL gotMatch = FALSE;
-       int i = 0;
-       int j = 0;
-
-       if (*stringp == NULL)
-               return NULL;
-
-       while ((*stringp)[i] != '\0') {
-               j = 0;
-               while (delim[j] != '\0') {
-                       if ((*stringp)[i] == delim[j]) {
-                               gotMatch = TRUE;
-                               (*stringp)[i] = '\0';
-                               *stringp = *stringp + i + 1;
-                               break;
-                       }
-                       j++;
-               }
-               if (gotMatch)
-                       break;
-
-               i++;
-       }
-
-       if (!gotMatch)
-               *stringp = NULL;
-
-       return orig;
-}
-
 int poll(struct pollfd fds[], nfds_t nfds, int timeout)
 {
        struct timeval tv;
@@ -823,11 +823,6 @@ const char* inet_ntop(int af, const void *restrict src,
        return ret;
 }
 
-int inet_aton(const char *cp, struct in_addr *inp)
-{
-       return inet_pton(AF_INET, cp, inp);
-}
-
 int inet_pton(int af, const char *restrict src, void *restrict dst)
 {
        INT status = SOCKET_ERROR;
diff --git a/os/windows/posix.h b/os/windows/posix.h
new file mode 100644 (file)
index 0000000..cb89cf6
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef FIO_WINDOWS_POSIX_H
+#define FIO_WINDOWS_POSIX_H
+
+typedef off_t off64_t;
+typedef int clockid_t;
+
+extern int clock_gettime(clockid_t clock_id, struct timespec *tp);
+extern int inet_aton(const char *, struct in_addr *);
+
+#endif
index 8d7f9b7be11d47f48c24e53a345df5717e89ebf2..514306dcff5daadb1bb7f45edf5e0d2c78cd2189 100644 (file)
--- a/server.c
+++ b/server.c
@@ -621,7 +621,7 @@ static int handle_probe_cmd(struct fio_net_cmd *cmd)
 
        memset(&probe, 0, sizeof(probe));
        gethostname((char *) probe.hostname, sizeof(probe.hostname));
-#ifdef FIO_BIG_ENDIAN
+#ifdef CONFIG_BIG_ENDIAN
        probe.bigendian = 1;
 #endif
        strncpy((char *) probe.fio_version, fio_version_string, sizeof(probe.fio_version));
@@ -821,7 +821,7 @@ static int handle_connection(int sk)
 static int accept_loop(int listen_sk)
 {
        struct sockaddr_in addr;
-       fio_socklen_t len = sizeof(addr);
+       socklen_t len = sizeof(addr);
        struct pollfd pfd;
        int ret = 0, sk, flags, exitval = 0;
 
@@ -1208,7 +1208,7 @@ void fio_server_send_start(struct thread_data *td)
 static int fio_init_server_ip(void)
 {
        struct sockaddr *addr;
-       fio_socklen_t socklen;
+       socklen_t socklen;
        int sk, opt;
 
        if (use_ipv6)
@@ -1222,7 +1222,7 @@ static int fio_init_server_ip(void)
        }
 
        opt = 1;
-       if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
+       if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt)) < 0) {
                log_err("fio: setsockopt: %s\n", strerror(errno));
                close(sk);
                return -1;
@@ -1257,7 +1257,7 @@ static int fio_init_server_ip(void)
 static int fio_init_server_sock(void)
 {
        struct sockaddr_un addr;
-       fio_socklen_t len;
+       socklen_t len;
        mode_t mode;
        int sk;
 
index 3f6043dbfe0e5af49182691dc747aaa1c7e6ff80..27fdaa73922526b92e9e25fd5ff59cfb63d2f59c 100644 (file)
--- a/t/axmap.c
+++ b/t/axmap.c
@@ -6,10 +6,7 @@
 #include <inttypes.h>
 
 #include "../lib/lfsr.h"
-
-struct axmap;
-void axmap_set(struct axmap *, uint64_t);
-struct axmap *axmap_new(uint64_t size);
+#include "../lib/axmap.h"
 
 void *smalloc(size_t size)
 {
@@ -24,8 +21,9 @@ void sfree(void *ptr)
 int main(int argc, char *argv[])
 {
        struct fio_lfsr lfsr;
-       size_t size = (1UL << 28) - 200;
+       size_t osize, size = (1UL << 28) - 200;
        struct axmap *map;
+       uint64_t ff;
        int seed = 1;
 
        if (argc > 1) {
@@ -38,13 +36,23 @@ int main(int argc, char *argv[])
 
        lfsr_init(&lfsr, size, seed);
        map = axmap_new(size);
+       osize = size;
 
        while (size--) {
                uint64_t val;
 
-               lfsr_next(&lfsr, &val);
+               if (lfsr_next(&lfsr, &val, osize)) {
+                       printf("lfsr: short loop\n");
+                       break;
+               }
                axmap_set(map, val);
        }
 
+       ff = axmap_next_free(map, osize);
+       if (ff != (uint64_t) -1ULL) {
+               printf("axmap_next_free broken: got %llu\n", (unsigned long long) ff);
+               return 1;
+       }
+
        return 0;
 }
index 5354473bce9c9cb2cdabe517f85f1e256429e781..21c1dac5b8bedc243cfa6b770cd7050e8b3f2cc8 100644 (file)
@@ -98,6 +98,7 @@ struct thread_options {
        unsigned int verify;
        unsigned int do_verify;
        unsigned int verifysort;
+       unsigned int verifysort_nr;
        unsigned int verify_interval;
        unsigned int verify_offset;
        char verify_pattern[MAX_PATTERN_SIZE];
@@ -107,6 +108,7 @@ struct thread_options {
        unsigned int verify_async;
        unsigned long long verify_backlog;
        unsigned int verify_batch;
+       unsigned int experimental_verify;
        unsigned int use_thread;
        unsigned int unlink;
        unsigned int do_disk_util;
@@ -156,7 +158,7 @@ struct thread_options {
        unsigned int cpumask_set;
        os_cpu_mask_t verify_cpumask;
        unsigned int verify_cpumask_set;
-#ifdef FIO_HAVE_LIBNUMA
+#ifdef CONFIG_LIBNUMA
        struct bitmask *numa_cpunodesmask;
        unsigned int numa_cpumask_set;
        unsigned short numa_mem_mode;
@@ -303,6 +305,7 @@ struct thread_options_pack {
        uint32_t verify;
        uint32_t do_verify;
        uint32_t verifysort;
+       uint32_t verifysort_nr;
        uint32_t verify_interval;
        uint32_t verify_offset;
        uint8_t verify_pattern[MAX_PATTERN_SIZE];
@@ -312,6 +315,7 @@ struct thread_options_pack {
        uint32_t verify_async;
        uint64_t verify_backlog;
        uint32_t verify_batch;
+       uint32_t experimental_verify;
        uint32_t use_thread;
        uint32_t unlink;
        uint32_t do_disk_util;
index 85fc448f8877f8f4cffe2c158cbeda24418b98ce..fa24702b49dfd3ef2379683022b9b9cd64e332b0 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -13,6 +13,7 @@
 #include "smalloc.h"
 #include "trim.h"
 #include "lib/rand.h"
+#include "lib/hweight.h"
 
 #include "crc/md5.h"
 #include "crc/crc64.h"
@@ -308,14 +309,6 @@ static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc)
        return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(hdr);
 }
 
-static unsigned int hweight8(unsigned int w)
-{
-       unsigned int res = w - ((w >> 1) & 0x55);
-
-       res = (res & 0x33) + ((res >> 2) & 0x33);
-       return (res + (res >> 4)) & 0x0F;
-}
-
 static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
 {
        struct thread_data *td = vc->td;