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
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:
-CC ?= gcc
DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
$(DEBUGFLAGS)
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 \
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)))
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)
$(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
#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")
#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")
#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,
}
static int check_min_rate(struct thread_data *td, struct timeval *now,
- unsigned long *bytes_done)
+ uint64_t *bytes_done)
{
int ret = 0;
* 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;
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)
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;
}
* 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;
}
/*
* 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;
(!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;
*/
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)
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;
}
}
- 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;
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));
prune_io_piece_log(td);
- do_io(td);
+ verify_bytes = do_io(td);
clear_state = 1;
fio_gettime(&td->start, NULL);
- do_verify(td);
+ do_verify(td, verify_bytes);
td->ts.runtime[DDIR_READ] += utime_since_now(&td->start);
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);
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);
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) {
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));
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);
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));
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));
#define __must_check
#endif
-#ifndef _weak
-#ifndef __CYGWIN__
-#define _weak __attribute__((weak))
-#else
-#define _weak
-#endif
-#endif
-
#endif
--- /dev/null
+#!/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
#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];
};
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");
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) {
rc = -ENOMEM;
goto error;
}
- f->file_data = d;
+ f->engine_data = (uintptr_t) d;
rc = generic_open_file(td, f);
error:
f->fd = -1;
- f->file_data = NULL;
+ f->engine_data = 0;
if (d)
free(d);
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);
.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);
#include "../fio.h"
-#ifdef FIO_HAVE_GUASI
-
#define GFIO_MIN_THREADS 32
#ifndef GFIO_MAX_THREADS
#define GFIO_MAX_THREADS 2000
.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);
#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;
.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);
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;
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,
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");
}
} 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;
{
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) {
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");
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;
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");
}
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;
}
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;
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
}
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
}
#include "../fio.h"
-#ifdef FIO_HAVE_POSIXAIO
-
struct posixaio_data {
struct io_u **aio_events;
unsigned int queued;
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)
if (t && !fill_timespec(&start))
have_timeout = 1;
+ else
+ memset(&start, 0, sizeof(start));
r = 0;
memset(suspend_list, 0, sizeof(*suspend_list));
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)
.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);
#include "../fio.h"
#include "../hash.h"
-#ifdef FIO_HAVE_RDMA
-
#include <rdma/rdma_cma.h>
#include <infiniband/arch.h>
.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);
#include "../fio.h"
-#ifdef FIO_HAVE_SOLARISAIO
-
#include <sys/asynch.h>
struct solarisaio_data {
.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);
#include "../fio.h"
-#ifdef FIO_HAVE_SPLICE
-
struct spliceio_data {
int pipe[2];
int vmsplice_to_user;
.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);
+++ /dev/null
-/*
- * 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(¶ms, 0, sizeof(params));
- fill_syslet_args(¶ms.syslet, sd->ring, (long)io_u, ret_func, sd->stack);
-
- fio_syslet_prep(io_u, ®s);
-
- ret = syscall(__NR_indirect, ®s, ¶ms, 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(¶ms, 0, sizeof(params));
- fill_syslet_args(¶ms.syslet, sd->ring, 0, ret_func, sd->stack);
-
- FILL_IN(regs, __NR_getpid);
-
- pid = syscall(__NR_indirect, ®s, ¶ms, 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);
-}
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;
}
/*
- * 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;
}
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
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;
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;
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);
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]);
+}
.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'.
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
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;
#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>
RW_SEQ_IDENT,
};
-
enum {
TD_F_VER_BACKLOG = 1,
TD_F_TRIM_BACKLOG = 2,
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
*/
}
static inline int should_check_rate(struct thread_data *td,
- unsigned long *bytes_done)
+ uint64_t *bytes_done)
{
int ret = 0;
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
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;
#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;
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) {
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.
#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) {
}
} while (1);
+ fio_clock_source = old_cs;
return (c_e - c_s + 127) >> 7;
}
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();
}
#endif
+#ifndef CONFIG_TLS_THREAD
void fio_local_clock_init(int is_thread)
{
struct tv_valid *t;
{
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();
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 {
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);
#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;
}
#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_ */
/*
* 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
}
}
-#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'"
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.
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
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;
}
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;
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 */
};
* 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);
}
{
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))
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));
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;
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;
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;
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);
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;
}
}
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));
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;
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));
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 &&
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)
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;
}
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++;
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;
* 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);
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;
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;
* 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;
* 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;
#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,
*/
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;
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
*/
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);
#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
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;
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);
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);
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;
#include "lib/rbtree.h"
#include "lib/ieee754.h"
+#include "flist.h"
#include "ioengine.h"
/*
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)
memset(al->map, 0, al->map_size * sizeof(unsigned long));
}
+
+ axmap->first_free = 0;
}
void axmap_free(struct axmap *axmap)
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];
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);
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;
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;
}
* 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)
#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;
--- /dev/null
+#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);
+}
-#if !(defined(_AIX) || defined(__hpux))
+#ifndef CONFIG_GETOPT_LONG_ONLY
#include <getopt.h>
-#else /* _AIX || __hpux */
+#else
#ifndef _GETOPT_H
#define _GETOPT_H
int getopt_long_only(int, char *const *, const char *, const struct option *, int *);
-#endif /* _GETOPT_H */
-#endif /* _AIX || __hpux */
+#endif
+#endif
--- /dev/null
+#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
+}
--- /dev/null
+#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
--- /dev/null
+#include "inet_aton.h"
+
+int inet_aton(const char *cp, struct in_addr *inp)
+{
+ return inet_pton(AF_INET, cp, inp);
+}
--- /dev/null
+#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
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);
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;
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;
}
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
-#ifndef FIO_LIB_H
-#define FIO_LIB_H
+#ifndef FIO_STRSEP_LIB_H
+#define FIO_STRSEP_LIB_H
char *strsep(char **, const char *);
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;
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;
}
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
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;
}
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);
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;
}
}
#endif
-#ifdef FIO_HAVE_LIBNUMA
+#ifdef CONFIG_LIBNUMA
static int str_numa_cpunodes_cb(void *data, char *input)
{
struct thread_data *td = data;
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;
{ .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",
},
{ .ival = "mmap",
.help = "Memory mapped IO"
},
-#ifdef FIO_HAVE_SPLICE
+#ifdef CONFIG_LINUX_SPLICE
{ .ival = "splice",
.help = "splice/vmsplice based IO",
},
{ .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",
},
.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",
},
.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",
.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,
.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",
.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",
.group = FIO_OPT_G_CRED,
},
#endif
-#ifdef FIO_HAVE_LIBNUMA
+#ifdef CONFIG_LIBNUMA
{
.name = "numa_cpu_nodes",
.type = FIO_OPT_STR,
+++ /dev/null
-#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
#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;
#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
}
-/*
- * 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
#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)
#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)
#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;
#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) \
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
#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)
#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)
{
return mach_thread_self();
}
+
+/*
+ * For some reason, there's no header definition for fdatasync(), even
+ * if it exists.
+ */
+extern int fdatasync(int fd);
+
#endif
#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)
#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)
#include "../file.h"
#include "../log.h"
+#include "windows/posix.h"
+
#define FIO_HAVE_ODIRECT
#define FIO_HAVE_CPU_AFFINITY
#define FIO_HAVE_CHARDEV_SIZE
#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
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);
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;
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)
#include <unistd.h>
#include <stdlib.h>
+#include "../arch/arch.h"
+
enum {
os_linux = 1,
os_aix,
#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;
#include <scsi/sg.h>
#endif
-#ifndef FIO_HAVE_STRSEP
+#ifdef CONFIG_STRSEP
#include "../lib/strsep.h"
#endif
#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
#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
#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)
+++ /dev/null
-#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
#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 *);
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:
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;
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;
--- /dev/null
+#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
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));
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;
static int fio_init_server_ip(void)
{
struct sockaddr *addr;
- fio_socklen_t socklen;
+ socklen_t socklen;
int sk, opt;
if (use_ipv6)
}
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;
static int fio_init_server_sock(void)
{
struct sockaddr_un addr;
- fio_socklen_t len;
+ socklen_t len;
mode_t mode;
int sk;
#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)
{
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) {
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;
}
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];
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;
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;
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];
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;
#include "smalloc.h"
#include "trim.h"
#include "lib/rand.h"
+#include "lib/hweight.h"
#include "crc/md5.h"
#include "crc/crc64.h"
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;