From 67bf982340d95ca98098ea050b54b4c7adb116c0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 10 Jan 2013 11:23:19 +0100 Subject: [PATCH] Add configure script Get rid of all the fragile guessing and checking of features, and roll a configure script instead. Signed-off-by: Jens Axboe --- HOWTO | 4 +- Makefile | 144 ++++++-- arch/arch-x86.h | 9 - arch/arch-x86_64.h | 9 - arch/arch.h | 8 - backend.c | 2 +- client.c | 10 +- compiler/compiler.h | 8 - configure | 840 +++++++++++++++++++++++++++++++++++++++++++ engines/fusion-aw.c | 18 - engines/guasi.c | 23 -- engines/libaio.c | 24 +- engines/net.c | 18 +- engines/posixaio.c | 25 +- engines/rdma.c | 45 --- engines/solarisaio.c | 23 -- engines/splice.c | 23 -- engines/syslet-rw.c | 327 ----------------- fio.c | 4 + fio.h | 8 +- gettime.c | 84 +++-- helpers.c | 35 +- helpers.h | 13 +- init.c | 15 +- ioengine.h | 17 +- ioengines.c | 2 +- lib/getopt.h | 8 +- lib/inet_aton.c | 6 + lib/inet_aton.h | 8 + lib/strsep.h | 4 +- options.c | 29 +- os/indirect.h | 40 --- os/os-aix.h | 12 - os/os-android.h | 36 -- os/os-freebsd.h | 3 - os/os-hpux.h | 9 - os/os-linux.h | 112 +----- os/os-mac.h | 2 - os/os-netbsd.h | 4 - os/os-solaris.h | 4 - os/os-windows.h | 6 - os/os.h | 18 +- os/syslet.h | 50 --- os/windows/posix.c | 5 - server.c | 8 +- 45 files changed, 1115 insertions(+), 987 deletions(-) create mode 100755 configure delete mode 100644 engines/syslet-rw.c create mode 100644 lib/inet_aton.c create mode 100644 lib/inet_aton.h delete mode 100644 os/indirect.h delete mode 100644 os/syslet.h diff --git a/HOWTO b/HOWTO index 0930f337..014b7f3d 100644 --- a/HOWTO +++ b/HOWTO @@ -844,9 +844,7 @@ cpus_allowed=str Controls the same options as cpumask, but it allows a text numa_cpu_nodes=str Set this job running on spcified NUMA nodes' CPUs. The arguments allow comma delimited list of cpu numbers, A-B ranges, or 'all'. Note, to enable numa options support, - export the following environment variables, - export EXTFLAGS+=" -DFIO_HAVE_LIBNUMA " - export EXTLIBS+=" -lnuma " + fio must be built on a system with libnuma-dev(el) installed. numa_mem_policy=str Set this job's memory policy and corresponding NUMA nodes. Format of the argements: diff --git a/Makefile b/Makefile index ba8b997b..96819c81 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -CC ?= gcc DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ $(DEBUGFLAGS) @@ -9,62 +8,161 @@ PROGS = fio SCRIPTS = fio_generate_plots UNAME := $(shell uname) +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 fio.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 \ rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \ lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.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 \ - json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c + json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \ + helpers.c + +ifdef CONFIG_64BIT + CFLAGS += -DBITS_PER_LONG=64 +endif +ifdef CONFIG_32BIT + CFLAGS += -DBITS_PER_LONG=32 +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 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))) @@ -72,8 +170,6 @@ ifneq (,$(findstring CYGWIN,$(UNAME))) SOURCE += engines/windowsaio.c os/windows/posix.c LIBS += -lpthread -lpsapi -lws2_32 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format - CC = x86_64-w64-mingw32-gcc - #CC = i686-w64-mingw32-gcc endif OBJS = $(SOURCE:.c=.o) @@ -159,7 +255,7 @@ fio: $(OBJS) $(PROGS): .depend clean: FORCE - -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE + -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.ld cscope.out cscope: @cscope -b -R diff --git a/arch/arch-x86.h b/arch/arch-x86.h index 48030060..679ec281 100644 --- a/arch/arch-x86.h +++ b/arch/arch-x86.h @@ -20,17 +20,8 @@ #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") diff --git a/arch/arch-x86_64.h b/arch/arch-x86_64.h index d8b0933b..cea0451d 100644 --- a/arch/arch-x86_64.h +++ b/arch/arch-x86_64.h @@ -20,17 +20,8 @@ #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") diff --git a/arch/arch.h b/arch/arch.h index f6a8e998..4165c9f9 100644 --- a/arch/arch.h +++ b/arch/arch.h @@ -1,14 +1,6 @@ #ifndef ARCH_H #define ARCH_H -#include - -#ifdef __WORDSIZE -#define BITS_PER_LONG __WORDSIZE -#else -#define BITS_PER_LONG 32 -#endif - enum { arch_x86_64 = 1, arch_i386, diff --git a/backend.c b/backend.c index 099bd9bd..8e96fb08 100644 --- a/backend.c +++ b/backend.c @@ -1074,7 +1074,7 @@ static void *thread_main(void *data) 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; diff --git a/client.c b/client.c index fd67079c..83cb57ea 100644 --- a/client.c +++ b/client.c @@ -267,7 +267,7 @@ int fio_client_add(const char *hostname, void **cookie) 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) { @@ -304,7 +304,7 @@ static int fio_client_connect_ip(struct fio_client *client) static int fio_client_connect_sock(struct fio_client *client) { struct sockaddr_un *addr = &client->addr_un; - fio_socklen_t len; + socklen_t len; int fd; memset(addr, 0, sizeof(*addr)); @@ -1037,7 +1037,7 @@ static int fio_client_timed_out(void) struct timeval tv; int ret = 0; - gettimeofday(&tv, NULL); + fio_gettime(&tv, NULL); flist_for_each_safe(entry, tmp, &client_list) { client = flist_entry(entry, struct fio_client, list); @@ -1061,7 +1061,7 @@ int fio_handle_clients(void) 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)); @@ -1095,7 +1095,7 @@ int fio_handle_clients(void) do { struct timeval tv; - gettimeofday(&tv, NULL); + fio_gettime(&tv, NULL); if (mtime_since(&eta_tv, &tv) >= 900) { request_client_etas(); memcpy(&eta_tv, &tv, sizeof(tv)); diff --git a/compiler/compiler.h b/compiler/compiler.h index 8923f9a6..72e84197 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -13,12 +13,4 @@ #define __must_check #endif -#ifndef _weak -#ifndef __CYGWIN__ -#define _weak __attribute__((weak)) -#else -#define _weak -#endif -#endif - #endif diff --git a/configure b/configure new file mode 100755 index 00000000..9cdfc498 --- /dev/null +++ b/configure @@ -0,0 +1,840 @@ +#!/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 < $TMPC < +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 < +#include +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 < +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 < +#include +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 < +#include +#include +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 +#include +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 +#include +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 +#include +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 +#include +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 +#include +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 +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 +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 +#include +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 +#include +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 +#include +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 +#include +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 +#include +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 +#include +#define _GNU_SOURCE +#include +#include +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 +#include +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" +fi +echo "EXT4 move extent $ext4_me" + +########################################## +# splice probe +linux_splice="no" +cat > $TMPC << EOF +#define _GNU_SOURCE +#include +#include +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 +#include +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 +int main(int argc, char **argv) +{ + struct vsl_iovec iov; + return vsl_vectored_write(0, &iov, 0, O_ATOMIC); +} +EOF +if compile_prog "" "" "fusion-aw"; then + fusion_aw="yes" +fi +echo "Fusion-io atomic engine $fusion_aw" + +########################################## +# libnuma probe +libnuma="no" +cat > $TMPC << EOF +#include +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 +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 +#include +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 +#include +#include +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 +#include +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 +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 "$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 diff --git a/engines/fusion-aw.c b/engines/fusion-aw.c index 118c6dd5..42135924 100644 --- a/engines/fusion-aw.c +++ b/engines/fusion-aw.c @@ -22,8 +22,6 @@ #include "../fio.h" -#ifdef FIO_HAVE_FUSION_AW - #include /* Fix sector size to 512 bytes independent of actual sector size, just like @@ -145,22 +143,6 @@ static struct ioengine_ops ioengine = { .flags = FIO_SYNCIO | FIO_RAWIO | FIO_MEMALIGN }; -#else /* !FUSION_HAVE_FUSION_AW */ - -static int fio_fusion_aw_eng_init(struct thread_data fio_unused *td) -{ - log_err("fio: fusion atomic write engine not available\n"); - return 1; -} - -static struct ioengine_ops ioengine = { - .name = "fusion-aw-sync", - .version = FIO_IOOPS_VERSION, - .init = fio_fusion_aw_eng_init, -}; - -#endif /* FUSION_HAVE_FUSION_AW */ - static void fio_init fio_fusion_aw_init(void) { register_ioengine(&ioengine); diff --git a/engines/guasi.c b/engines/guasi.c index 4839019f..6faae8d0 100644 --- a/engines/guasi.c +++ b/engines/guasi.c @@ -21,8 +21,6 @@ #include "../fio.h" -#ifdef FIO_HAVE_GUASI - #define GFIO_MIN_THREADS 32 #ifndef GFIO_MAX_THREADS #define GFIO_MAX_THREADS 2000 @@ -264,27 +262,6 @@ static struct ioengine_ops ioengine = { .get_file_size = generic_get_file_size, }; -#else /* FIO_HAVE_GUASI */ - -/* - * When we have a proper configure system in place, we simply wont build - * and install this io engine. For now install a crippled version that - * just complains and fails to load. - */ -static int fio_guasi_init(struct thread_data fio_unused *td) -{ - log_err("fio: guasi not available\n"); - return 1; -} - -static struct ioengine_ops ioengine = { - .name = "guasi", - .version = FIO_IOOPS_VERSION, - .init = fio_guasi_init, -}; - -#endif - static void fio_init fio_guasi_register(void) { register_ioengine(&ioengine); diff --git a/engines/libaio.c b/engines/libaio.c index f17260d3..4d1f3a31 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -9,11 +9,10 @@ #include #include #include +#include #include "../fio.h" -#ifdef FIO_HAVE_LIBAIO - struct libaio_data { io_context_t aio_ctx; struct io_event *aio_events; @@ -304,27 +303,6 @@ static struct ioengine_ops ioengine = { .option_struct_size = sizeof(struct libaio_options), }; -#else /* FIO_HAVE_LIBAIO */ - -/* - * When we have a proper configure system in place, we simply wont build - * and install this io engine. For now install a crippled version that - * just complains and fails to load. - */ -static int fio_libaio_init(struct thread_data fio_unused *td) -{ - log_err("fio: libaio not available\n"); - return 1; -} - -static struct ioengine_ops ioengine = { - .name = "libaio", - .version = FIO_IOOPS_VERSION, - .init = fio_libaio_init, -}; - -#endif - static void fio_init fio_libaio_register(void) { register_ioengine(&ioengine); diff --git a/engines/net.c b/engines/net.c index edb55776..eb05bccc 100644 --- a/engines/net.c +++ b/engines/net.c @@ -157,7 +157,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u) return 0; } -#ifdef FIO_HAVE_SPLICE +#ifdef CONFIG_LINUX_SPLICE static int splice_io_u(int fdin, int fdout, unsigned int len) { int bytes = 0; @@ -352,7 +352,7 @@ static int fio_netio_recv(struct thread_data *td, struct io_u *io_u) do { if (o->proto == FIO_TYPE_UDP) { - fio_socklen_t len = sizeof(nd->addr); + socklen_t len = sizeof(nd->addr); struct sockaddr *from = (struct sockaddr *) &nd->addr; ret = recvfrom(io_u->file->fd, io_u->xfer_buf, @@ -474,7 +474,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f) if (o->proto == FIO_TYPE_UDP) return 0; else if (o->proto == FIO_TYPE_TCP) { - fio_socklen_t len = sizeof(nd->addr); + socklen_t len = sizeof(nd->addr); if (connect(f->fd, (struct sockaddr *) &nd->addr, len) < 0) { td_verror(td, errno, "connect"); @@ -483,7 +483,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f) } } else { struct sockaddr_un *addr = &nd->addr_un; - fio_socklen_t len; + socklen_t len; len = sizeof(addr->sun_family) + strlen(addr->sun_path) + 1; @@ -501,7 +501,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f) { struct netio_data *nd = td->io_ops->data; struct netio_options *o = td->eo; - fio_socklen_t socklen = sizeof(nd->addr); + socklen_t socklen = sizeof(nd->addr); int state; if (o->proto == FIO_TYPE_UDP) { @@ -566,7 +566,7 @@ static int fio_netio_udp_recv_open(struct thread_data *td, struct fio_file *f) struct netio_data *nd = td->io_ops->data; struct udp_close_msg msg; struct sockaddr *to = (struct sockaddr *) &nd->addr; - fio_socklen_t len = sizeof(nd->addr); + socklen_t len = sizeof(nd->addr); int ret; ret = recvfrom(f->fd, &msg, sizeof(msg), MSG_WAITALL, to, &len); @@ -887,7 +887,7 @@ static void fio_netio_terminate(struct thread_data *td) kill(td->pid, SIGUSR2); } -#ifdef FIO_HAVE_SPLICE +#ifdef CONFIG_LINUX_SPLICE static int fio_netio_setup_splice(struct thread_data *td) { struct netio_data *nd; @@ -954,7 +954,7 @@ static int str_hostname_cb(void *data, const char *input) static void fio_init fio_netio_register(void) { register_ioengine(&ioengine_rw); -#ifdef FIO_HAVE_SPLICE +#ifdef CONFIG_LINUX_SPLICE register_ioengine(&ioengine_splice); #endif } @@ -962,7 +962,7 @@ static void fio_init fio_netio_register(void) static void fio_exit fio_netio_unregister(void) { unregister_ioengine(&ioengine_rw); -#ifdef FIO_HAVE_SPLICE +#ifdef CONFIG_LINUX_SPLICE unregister_ioengine(&ioengine_splice); #endif } diff --git a/engines/posixaio.c b/engines/posixaio.c index 0966e0d5..0872f9ae 100644 --- a/engines/posixaio.c +++ b/engines/posixaio.c @@ -12,8 +12,6 @@ #include "../fio.h" -#ifdef FIO_HAVE_POSIXAIO - struct posixaio_data { struct io_u **aio_events; unsigned int queued; @@ -173,7 +171,7 @@ static int fio_posixaio_queue(struct thread_data *td, do_io_u_trim(td, io_u); return FIO_Q_COMPLETED; } else { -#ifdef FIO_HAVE_POSIXAIO_FSYNC +#ifdef CONFIG_POSIXAIO_FSYNC ret = aio_fsync(O_SYNC, aiocb); #else if (pd->queued) @@ -240,27 +238,6 @@ static struct ioengine_ops ioengine = { .get_file_size = generic_get_file_size, }; -#else /* FIO_HAVE_POSIXAIO */ - -/* - * When we have a proper configure system in place, we simply wont build - * and install this io engine. For now install a crippled version that - * just complains and fails to load. - */ -static int fio_posixaio_init(struct thread_data fio_unused *td) -{ - log_err("fio: posixaio not available\n"); - return 1; -} - -static struct ioengine_ops ioengine = { - .name = "posixaio", - .version = FIO_IOOPS_VERSION, - .init = fio_posixaio_init, -}; - -#endif - static void fio_init fio_posixaio_register(void) { register_ioengine(&ioengine); diff --git a/engines/rdma.c b/engines/rdma.c index 9b183015..a847b541 100644 --- a/engines/rdma.c +++ b/engines/rdma.c @@ -48,8 +48,6 @@ #include "../fio.h" #include "../hash.h" -#ifdef FIO_HAVE_RDMA - #include #include @@ -1224,49 +1222,6 @@ static struct ioengine_ops ioengine_rw = { .flags = FIO_DISKLESSIO | FIO_UNIDIR | FIO_PIPEIO, }; -#else /* FIO_HAVE_RDMA */ - -static int fio_rdmaio_open_file(struct thread_data *td, struct fio_file *f) -{ - return 0; -} - -static int fio_rdmaio_close_file(struct thread_data *td, struct fio_file *f) -{ - return 0; -} - -static int fio_rdmaio_queue(struct thread_data *td, struct io_u *io_u) -{ - return FIO_Q_COMPLETED; -} - -static int fio_rdmaio_init(struct thread_data fio_unused * td) -{ - log_err("fio: rdma(librdmacm libibverbs) not available\n"); - log_err(" You haven't compiled rdma ioengine into fio.\n"); - log_err(" If you want to try rdma ioengine,\n"); - log_err(" make sure OFED is installed,\n"); - log_err(" $ ofed_info\n"); - log_err(" then try to make fio as follows:\n"); - log_err(" $ export EXTFLAGS+=\" -DFIO_HAVE_RDMA \"\n"); - log_err(" $ export EXTLIBS+=\" -libverbs -lrdmacm \"\n"); - log_err(" $ make clean && make\n"); - return 1; -} - -static struct ioengine_ops ioengine_rw = { - .name = "rdma", - .version = FIO_IOOPS_VERSION, - .init = fio_rdmaio_init, - .queue = fio_rdmaio_queue, - .open_file = fio_rdmaio_open_file, - .close_file = fio_rdmaio_close_file, - .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR | FIO_PIPEIO, -}; - -#endif - static void fio_init fio_rdmaio_register(void) { register_ioengine(&ioengine_rw); diff --git a/engines/solarisaio.c b/engines/solarisaio.c index 906a154a..137dc225 100644 --- a/engines/solarisaio.c +++ b/engines/solarisaio.c @@ -10,8 +10,6 @@ #include "../fio.h" -#ifdef FIO_HAVE_SOLARISAIO - #include struct solarisaio_data { @@ -225,27 +223,6 @@ static struct ioengine_ops ioengine = { .get_file_size = generic_get_file_size, }; -#else /* FIO_HAVE_SOLARISAIO */ - -/* - * When we have a proper configure system in place, we simply wont build - * and install this io engine. For now install a crippled version that - * just complains and fails to load. - */ -static int fio_solarisaio_init(struct thread_data fio_unused *td) -{ - log_err("fio: solarisaio not available\n"); - return 1; -} - -static struct ioengine_ops ioengine = { - .name = "solarisaio", - .version = FIO_IOOPS_VERSION, - .init = fio_solarisaio_init, -}; - -#endif - static void fio_init fio_solarisaio_register(void) { register_ioengine(&ioengine); diff --git a/engines/splice.c b/engines/splice.c index ca7997b7..f35ae17b 100644 --- a/engines/splice.c +++ b/engines/splice.c @@ -15,8 +15,6 @@ #include "../fio.h" -#ifdef FIO_HAVE_SPLICE - struct spliceio_data { int pipe[2]; int vmsplice_to_user; @@ -302,27 +300,6 @@ static struct ioengine_ops ioengine = { .flags = FIO_SYNCIO | FIO_PIPEIO, }; -#else /* FIO_HAVE_SPLICE */ - -/* - * When we have a proper configure system in place, we simply wont build - * and install this io engine. For now install a crippled version that - * just complains and fails to load. - */ -static int fio_spliceio_init(struct thread_data fio_unused *td) -{ - log_err("fio: splice not available\n"); - return 1; -} - -static struct ioengine_ops ioengine = { - .name = "splice", - .version = FIO_IOOPS_VERSION, - .init = fio_spliceio_init, -}; - -#endif - static void fio_init fio_spliceio_register(void) { register_ioengine(&ioengine); diff --git a/engines/syslet-rw.c b/engines/syslet-rw.c deleted file mode 100644 index 15e4c257..00000000 --- a/engines/syslet-rw.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * syslet engine - * - * IO engine that does regular pread(2)/pwrite(2) to transfer data, but - * with syslets to make the execution async. - * - */ -#include -#include -#include -#include -#include -#include -#include - -#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); -} diff --git a/fio.c b/fio.c index f44273f4..24af397a 100644 --- a/fio.c +++ b/fio.c @@ -79,6 +79,10 @@ int main(int argc, char *argv[], char *envp[]) return 1; } +#if !defined(CONFIG_GETTIMEOFDAY) && !defined(CONFIG_CLOCK_GETTIME) +#error "No available clock source!" +#endif + arch_init(envp); sinit(); diff --git a/fio.h b/fio.h index de4ca4da..a528f6a0 100644 --- a/fio.h +++ b/fio.h @@ -40,15 +40,11 @@ struct thread_data; #include "stat.h" #include "flow.h" -#ifdef FIO_HAVE_GUASI -#include -#endif - #ifdef FIO_HAVE_SOLARISAIO #include #endif -#ifdef FIO_HAVE_LIBNUMA +#ifdef CONFIG_LIBNUMA #include #include @@ -213,7 +209,7 @@ struct thread_options { unsigned int cpumask_set; os_cpu_mask_t verify_cpumask; unsigned int verify_cpumask_set; -#ifdef FIO_HAVE_LIBNUMA +#ifdef CONFIG_LIBNUMA struct bitmask *numa_cpunodesmask; unsigned int numa_cpumask_set; unsigned short numa_mem_mode; diff --git a/gettime.c b/gettime.c index 1648b17b..e60d3e20 100644 --- a/gettime.c +++ b/gettime.c @@ -24,7 +24,11 @@ struct tv_valid { int last_tv_valid; unsigned long last_cycles; }; +#ifdef CONFIG_TLS_THREAD +static struct tv_valid __thread static_tv_valid; +#else static pthread_key_t tv_tls_key; +#endif enum fio_cs fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE; int fio_clock_source_set = 0; @@ -121,40 +125,34 @@ static void fio_init gtod_init(void) #endif /* FIO_DEBUG_TIME */ +#ifdef CONFIG_CLOCK_GETTIME static int fill_clock_gettime(struct timespec *ts) { -#ifdef FIO_HAVE_CLOCK_MONOTONIC +#ifdef CONFIG_CLOCK_MONOTONIC return clock_gettime(CLOCK_MONOTONIC, ts); #else return clock_gettime(CLOCK_REALTIME, ts); #endif } - -#ifdef FIO_DEBUG_TIME -void fio_gettime(struct timeval *tp, void *caller) -#else -void fio_gettime(struct timeval *tp, void fio_unused *caller) #endif + +static void *__fio_gettime(struct timeval *tp) { struct tv_valid *tv; -#ifdef FIO_DEBUG_TIME - if (!caller) - caller = __builtin_return_address(0); - - gtod_log_caller(caller); -#endif - if (fio_tv) { - memcpy(tp, fio_tv, sizeof(*tp)); - return; - } - +#ifdef CONFIG_TLS_THREAD + tv = &static_tv_valid; +#else tv = pthread_getspecific(tv_tls_key); +#endif switch (fio_clock_source) { +#ifdef CONFIG_GETTIMEOFDAY case CS_GTOD: gettimeofday(tp, NULL); break; +#endif +#ifdef CONFIG_CLOCK_GETTIME case CS_CGETTIME: { struct timespec ts; @@ -167,6 +165,7 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller) tp->tv_usec = ts.tv_nsec / 1000; break; } +#endif #ifdef ARCH_HAVE_CPU_CLOCK case CS_CPUCLOCK: { unsigned long long usecs, t; @@ -189,6 +188,30 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller) break; } + return tv; +} + +#ifdef FIO_DEBUG_TIME +void fio_gettime(struct timeval *tp, void *caller) +#else +void fio_gettime(struct timeval *tp, void fio_unused *caller) +#endif +{ + struct tv_valid *tv; + +#ifdef FIO_DEBUG_TIME + if (!caller) + caller = __builtin_return_address(0); + + gtod_log_caller(caller); +#endif + if (fio_tv) { + memcpy(tp, fio_tv, sizeof(*tp)); + return; + } + + tv = __fio_gettime(tp); + /* * If Linux is using the tsc clock on non-synced processors, * sometimes time can appear to drift backwards. Fix that up. @@ -209,21 +232,22 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller) #ifdef ARCH_HAVE_CPU_CLOCK static unsigned long get_cycles_per_usec(void) { - struct timespec ts; struct timeval s, e; unsigned long long c_s, c_e; + 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; - fill_clock_gettime(&ts); - e.tv_sec = ts.tv_sec; - e.tv_usec = ts.tv_nsec / 1000; + __fio_gettime(&e); elapsed = utime_since(&s, &e); if (elapsed >= 1280) { @@ -232,6 +256,7 @@ static unsigned long get_cycles_per_usec(void) } } while (1); + fio_clock_source = old_cs; return (c_e - c_s + 127) >> 7; } @@ -287,6 +312,7 @@ static void calibrate_cpu_clock(void) } #endif +#ifndef CONFIG_TLS_THREAD void fio_local_clock_init(int is_thread) { struct tv_valid *t; @@ -300,14 +326,21 @@ static void kill_tv_tls_key(void *data) { free(data); } +#else +void fio_local_clock_init(int is_thread) +{ +} +#endif void fio_clock_init(void) { if (fio_clock_source == fio_clock_source_inited) return; +#ifndef CONFIG_TLS_THREAD if (pthread_key_create(&tv_tls_key, kill_tv_tls_key)) log_err("fio: can't create TLS key\n"); +#endif fio_clock_source_inited = fio_clock_source; calibrate_cpu_clock(); @@ -390,7 +423,8 @@ uint64_t time_since_now(struct timeval *s) return mtime_since_now(s) / 1000; } -#if defined(FIO_HAVE_CPU_AFFINITY) && defined(ARCH_HAVE_CPU_CLOCK) +#if defined(FIO_HAVE_CPU_AFFINITY) && defined(ARCH_HAVE_CPU_CLOCK) && \ + defined(CONFIG_SFAA) #define CLOCK_ENTRIES 100000 diff --git a/helpers.c b/helpers.c index 1b4e1d0a..dce967d3 100644 --- a/helpers.c +++ b/helpers.c @@ -9,50 +9,31 @@ #include "arch/arch.h" #include "os/os.h" -#ifndef FIO_HAVE_LINUX_FALLOCATE -int _weak fallocate(int fd, int mode, off_t offset, off_t len) +#ifndef CONFIG_LINUX_FALLOCATE +int fallocate(int fd, int mode, off_t offset, off_t len) { errno = ENOSYS; return -1; } #endif -#ifndef __NR_fallocate -int _weak posix_fallocate(int fd, off_t offset, off_t len) +#ifndef CONFIG_POSIX_FALLOCATE +int posix_fallocate(int fd, off_t offset, off_t len) { return 0; } #endif -int _weak inet_aton(const char *cp, struct in_addr *inp) -{ - return 0; -} - -int _weak clock_gettime(clockid_t clk_id, struct timespec *ts) -{ - struct timeval tv; - int ret; - - ret = gettimeofday(&tv, NULL); - - ts->tv_sec = tv.tv_sec; - ts->tv_nsec = tv.tv_usec * 1000; - - return ret; -} - -#ifndef __NR_sync_file_range -int _weak sync_file_range(int fd, off64_t offset, off64_t nbytes, - unsigned int flags) +#ifndef CONFIG_SYNC_FILE_RANGE +int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags) { errno = ENOSYS; return -1; } #endif -#ifndef FIO_HAVE_FADVISE -int _weak posix_fadvise(int fd, off_t offset, off_t len, int advice) +#ifndef CONFIG_FADVISE +int posix_fadvise(int fd, off_t offset, off_t len, int advice) { return 0; } diff --git a/helpers.h b/helpers.h index 191096bd..5f1865bb 100644 --- a/helpers.h +++ b/helpers.h @@ -6,15 +6,10 @@ #include #include -struct in_addr; - -extern int _weak fallocate(int fd, int mode, off_t offset, off_t len); -extern int _weak posix_memalign(void **ptr, size_t align, size_t size); -extern int _weak posix_fallocate(int fd, off_t offset, off_t len); -extern int _weak inet_aton(const char *cp, struct in_addr *inp); -extern int _weak clock_gettime(clockid_t clk_id, struct timespec *ts); -extern int _weak sync_file_range(int fd, off64_t offset, off64_t nbytes, +extern int fallocate(int fd, int mode, off_t offset, off_t len); +extern int posix_fallocate(int fd, off_t offset, off_t len); +extern int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags); -extern int _weak posix_fadvise(int fd, off_t offset, off_t len, int advice); +extern int posix_fadvise(int fd, off_t offset, off_t len, int advice); #endif /* FIO_HELPERS_H_ */ diff --git a/init.c b/init.c index e7b3303e..15b54116 100644 --- a/init.c +++ b/init.c @@ -496,17 +496,8 @@ static int fixup_options(struct thread_data *td) /* * The low water mark cannot be bigger than the iodepth */ - if (o->iodepth_low > o->iodepth || !o->iodepth_low) { - /* - * syslet work around - if the workload is sequential, - * we want to let the queue drain all the way down to - * avoid seeking between async threads - */ - if (!strcmp(td->io_ops->name, "syslet-rw") && !td_random(td)) - o->iodepth_low = 1; - else - o->iodepth_low = o->iodepth; - } + if (o->iodepth_low > o->iodepth || !o->iodepth_low) + o->iodepth_low = o->iodepth; /* * If batch number isn't set, default to the same as iodepth @@ -569,7 +560,7 @@ static int fixup_options(struct thread_data *td) } } -#ifndef FIO_HAVE_FDATASYNC +#ifndef CONFIG_FDATASYNC if (o->fdatasync_blocks) { log_info("fio: this platform does not support fdatasync()" " falling back to using fsync(). Use the 'fsync'" diff --git a/ioengine.h b/ioengine.h index 0285b08c..6809501f 100644 --- a/ioengine.h +++ b/ioengine.h @@ -1,6 +1,13 @@ #ifndef FIO_IOENGINE_H #define FIO_IOENGINE_H +#ifdef CONFIG_LIBAIO +#include +#endif +#ifdef CONFIG_GUASI +#include +#endif + #define FIO_IOOPS_VERSION 14 enum { @@ -19,25 +26,25 @@ enum { */ 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; diff --git a/ioengines.c b/ioengines.c index c2a64cb0..a87175a2 100644 --- a/ioengines.c +++ b/ioengines.c @@ -503,7 +503,7 @@ int do_io_u_sync(struct thread_data *td, struct io_u *io_u) if (io_u->ddir == DDIR_SYNC) { ret = fsync(io_u->file->fd); } else if (io_u->ddir == DDIR_DATASYNC) { -#ifdef FIO_HAVE_FDATASYNC +#ifdef CONFIG_FDATASYNC ret = fdatasync(io_u->file->fd); #else ret = io_u->xfer_buflen; diff --git a/lib/getopt.h b/lib/getopt.h index 237cbae5..84272c0c 100644 --- a/lib/getopt.h +++ b/lib/getopt.h @@ -1,8 +1,8 @@ -#if !(defined(_AIX) || defined(__hpux)) +#ifndef CONFIG_GETOPT_LONG_ONLY #include -#else /* _AIX || __hpux */ +#else #ifndef _GETOPT_H #define _GETOPT_H @@ -22,5 +22,5 @@ enum { int getopt_long_only(int, char *const *, const char *, const struct option *, int *); -#endif /* _GETOPT_H */ -#endif /* _AIX || __hpux */ +#endif +#endif diff --git a/lib/inet_aton.c b/lib/inet_aton.c new file mode 100644 index 00000000..7ae7db74 --- /dev/null +++ b/lib/inet_aton.c @@ -0,0 +1,6 @@ +#include "inet_aton.h" + +int inet_aton(const char *cp, struct in_addr *inp) +{ + return inet_pton(AF_INET, cp, inp); +} diff --git a/lib/inet_aton.h b/lib/inet_aton.h new file mode 100644 index 00000000..c93c87f8 --- /dev/null +++ b/lib/inet_aton.h @@ -0,0 +1,8 @@ +#ifndef FIO_INET_ATON_LIB_H +#define FIO_INET_ATON_LIB_H + +#include + +int inet_aton(const char *cp, struct in_addr *inp); + +#endif diff --git a/lib/strsep.h b/lib/strsep.h index 782a3600..5fea5d19 100644 --- a/lib/strsep.h +++ b/lib/strsep.h @@ -1,5 +1,5 @@ -#ifndef FIO_LIB_H -#define FIO_LIB_H +#ifndef FIO_STRSEP_LIB_H +#define FIO_STRSEP_LIB_H char *strsep(char **, const char *); diff --git a/options.c b/options.c index ae290edb..3a406faf 100644 --- a/options.c +++ b/options.c @@ -565,7 +565,7 @@ static int str_verify_cpus_allowed_cb(void *data, const char *input) } #endif -#ifdef FIO_HAVE_LIBNUMA +#ifdef CONFIG_LIBNUMA static int str_numa_cpunodes_cb(void *data, char *input) { struct thread_data *td = data; @@ -713,7 +713,7 @@ static int str_fst_cb(void *data, const char *str) return 0; } -#ifdef FIO_HAVE_SYNC_FILE_RANGE +#ifdef CONFIG_SYNC_FILE_RANGE static int str_sfr_cb(void *data, const char *str) { struct thread_data *td = data; @@ -1272,12 +1272,12 @@ static struct fio_option options[FIO_MAX_OPTS] = { { .ival = "vsync", .help = "Use readv/writev", }, -#ifdef FIO_HAVE_LIBAIO +#ifdef CONFIG_LIBAIO { .ival = "libaio", .help = "Linux native asynchronous IO", }, #endif -#ifdef FIO_HAVE_POSIXAIO +#ifdef CONFIG_POSIXAIO { .ival = "posixaio", .help = "POSIX asynchronous IO", }, @@ -1295,7 +1295,7 @@ static struct fio_option options[FIO_MAX_OPTS] = { { .ival = "mmap", .help = "Memory mapped IO" }, -#ifdef FIO_HAVE_SPLICE +#ifdef CONFIG_LINUX_SPLICE { .ival = "splice", .help = "splice/vmsplice based IO", }, @@ -1314,15 +1314,10 @@ static struct fio_option options[FIO_MAX_OPTS] = { { .ival = "net", .help = "Network IO", }, -#ifdef FIO_HAVE_SYSLET - { .ival = "syslet-rw", - .help = "syslet enabled async pread/pwrite IO", - }, -#endif { .ival = "cpuio", .help = "CPU cycle burner engine", }, -#ifdef FIO_HAVE_GUASI +#ifdef CONFIG_GUASI { .ival = "guasi", .help = "GUASI IO engine", }, @@ -1332,12 +1327,12 @@ static struct fio_option options[FIO_MAX_OPTS] = { .help = "binject direct inject block engine", }, #endif -#ifdef FIO_HAVE_RDMA +#ifdef CONFIG_RDMA { .ival = "rdma", .help = "RDMA IO engine", }, #endif -#ifdef FIO_HAVE_FUSION_AW +#ifdef CONFIG_FUSION_AW { .ival = "fusion-aw-sync", .help = "Fusion-io atomic write engine", }, @@ -1650,7 +1645,7 @@ static struct fio_option options[FIO_MAX_OPTS] = { .help = "Make every Nth write a barrier write", .def = "0", }, -#ifdef FIO_HAVE_SYNC_FILE_RANGE +#ifdef CONFIG_SYNC_FILE_RANGE { .name = "sync_file_range", .posval = { @@ -1747,14 +1742,18 @@ static struct fio_option options[FIO_MAX_OPTS] = { .off1 = td_var_offset(clocksource), .help = "What type of timing source to use", .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, @@ -2278,7 +2277,7 @@ static struct fio_option options[FIO_MAX_OPTS] = { .help = "Set CPUs allowed", }, #endif -#ifdef FIO_HAVE_LIBNUMA +#ifdef CONFIG_LIBNUMA { .name = "numa_cpu_nodes", .type = FIO_OPT_STR, diff --git a/os/indirect.h b/os/indirect.h deleted file mode 100644 index fba6b6be..00000000 --- a/os/indirect.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _INDIRECT_H_ -#define _INDIRECT_H_ - -#include "syslet.h" - -union indirect_params { - struct { - u32 flags; - } file_flags; - struct syslet_args syslet; -}; - -#ifdef __x86_64__ -# define __NR_indirect 286 -struct indirect_registers { - u64 rax; - u64 rdi; - u64 rsi; - u64 rdx; - u64 r10; - u64 r8; - u64 r9; -}; -#elif defined __i386__ -# define __NR_indirect 325 -struct indirect_registers { - u32 eax; - u32 ebx; - u32 ecx; - u32 edx; - u32 esi; - u32 edi; - u32 ebp; -}; -#endif - -#define FILL_IN(var, values...) \ - (var) = (struct indirect_registers) { values, } - -#endif diff --git a/os/os-aix.h b/os/os-aix.h index 1870e6e4..01b2bdbb 100644 --- a/os/os-aix.h +++ b/os/os-aix.h @@ -10,18 +10,9 @@ #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 @@ -36,9 +27,6 @@ #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; diff --git a/os/os-android.h b/os/os-android.h index 3da39531..e78a95bf 100644 --- a/os/os-android.h +++ b/os/os-android.h @@ -15,24 +15,18 @@ #include #include -#include "indirect.h" #include "binject.h" #include "../file.h" #define FIO_HAVE_DISK_UTIL -#define FIO_HAVE_SPLICE #define FIO_HAVE_IOSCHED_SWITCH #define FIO_HAVE_ODIRECT #define FIO_HAVE_HUGETLB #define FIO_HAVE_BLKTRACE -#define FIO_HAVE_STRSEP -#define FIO_HAVE_POSIXAIO_FSYNC #define FIO_HAVE_PSHARED_MUTEX #define FIO_HAVE_CL_SIZE -#define FIO_HAVE_FDATASYNC #define FIO_HAVE_FS_STAT #define FIO_HAVE_TRIM -#define FIO_HAVE_CLOCK_MONOTONIC #define FIO_HAVE_GETTID #define FIO_USE_GENERIC_INIT_RANDOM_STATE #define FIO_HAVE_E4_ENG @@ -78,36 +72,6 @@ static inline int shmdt (const void *__shmaddr) } -/* - * Just check for SPLICE_F_MOVE, if that isn't there, assume the others - * aren't either. - */ -#ifndef SPLICE_F_MOVE -#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */ -#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */ - /* we may still block on the fd we splice */ - /* from/to, of course */ -#define SPLICE_F_MORE (0x04) /* expect more data */ -#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ - -static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out, - size_t len, unsigned int flags) -{ - return syscall(__NR_sys_splice, fdin, off_in, fdout, off_out, len, flags); -} - -static inline int tee(int fdin, int fdout, size_t len, unsigned int flags) -{ - return syscall(__NR_sys_tee, fdin, fdout, len, flags); -} - -static inline int vmsplice(int fd, const struct iovec *iov, - unsigned long nr_segs, unsigned int flags) -{ - return syscall(__NR_sys_vmsplice, fd, iov, nr_segs, flags); -} -#endif - #define SPLICE_DEF_SIZE (64*1024) #ifndef BLKGETSIZE64 diff --git a/os/os-freebsd.h b/os/os-freebsd.h index 2a7b7b32..50126009 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -12,14 +12,11 @@ #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 diff --git a/os/os-hpux.h b/os/os-hpux.h index 821c9169..b4d677a4 100644 --- a/os/os-hpux.h +++ b/os/os-hpux.h @@ -19,17 +19,11 @@ #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 @@ -58,9 +52,6 @@ #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; diff --git a/os/os-linux.h b/os/os-linux.h index e9d7cf3e..d7eec0f2 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -17,88 +17,43 @@ #include #include -#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) \ @@ -131,71 +86,8 @@ static inline int gettid(void) return syscall(__NR_gettid); } -/* - * Just check for SPLICE_F_MOVE, if that isn't there, assume the others - * aren't either. - */ -#ifndef SPLICE_F_MOVE -#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */ -#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */ - /* we may still block on the fd we splice */ - /* from/to, of course */ -#define SPLICE_F_MORE (0x04) /* expect more data */ -#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ - -static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out, - size_t len, unsigned int flags) -{ - return syscall(__NR_sys_splice, fdin, off_in, fdout, off_out, len, flags); -} - -static inline int tee(int fdin, int fdout, size_t len, unsigned int flags) -{ - return syscall(__NR_sys_tee, fdin, fdout, len, flags); -} - -static inline int vmsplice(int fd, const struct iovec *iov, - unsigned long nr_segs, unsigned int flags) -{ - return syscall(__NR_sys_vmsplice, fd, iov, nr_segs, flags); -} -#endif - #define SPLICE_DEF_SIZE (64*1024) -#ifdef FIO_HAVE_SYSLET - -struct syslet_uatom; -struct async_head_user; - -/* - * syslet stuff - */ -static inline struct syslet_uatom * -async_exec(struct syslet_uatom *atom, struct async_head_user *ahu) -{ - return (struct syslet_uatom *) syscall(__NR_async_exec, atom, ahu); -} - -static inline long -async_wait(unsigned long min_wait_events, unsigned long user_ring_idx, - struct async_head_user *ahu) -{ - return syscall(__NR_async_wait, min_wait_events, - user_ring_idx, ahu); -} - -static inline long async_thread(void *event, struct async_head_user *ahu) -{ - return syscall(__NR_async_thread, event, ahu); -} - -static inline long umem_add(unsigned long *uptr, unsigned long inc) -{ - return syscall(__NR_umem_add, uptr, inc); -} -#endif /* FIO_HAVE_SYSLET */ - enum { IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, diff --git a/os/os-mac.h b/os/os-mac.h index 553f8200..0f351a78 100644 --- a/os/os-mac.h +++ b/os/os-mac.h @@ -24,8 +24,6 @@ #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 diff --git a/os/os-netbsd.h b/os/os-netbsd.h index de687ba3..1753226e 100644 --- a/os/os-netbsd.h +++ b/os/os-netbsd.h @@ -16,11 +16,7 @@ #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 diff --git a/os/os-solaris.h b/os/os-solaris.h index 5efd7ac1..7dd62a71 100644 --- a/os/os-solaris.h +++ b/os/os-solaris.h @@ -14,17 +14,13 @@ #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 diff --git a/os/os-windows.h b/os/os-windows.h index ba931953..0b199c52 100644 --- a/os/os-windows.h +++ b/os/os-windows.h @@ -22,8 +22,6 @@ #define FIO_HAVE_WINDOWSAIO #define FIO_HAVE_FALLOCATE #define FIO_HAVE_GETTID -#define FIO_HAVE_CLOCK_MONOTONIC -#define FIO_HAVE_FADVISE #define FIO_USE_GENERIC_RAND #define FIO_PREFERRED_ENGINE "windowsaio" @@ -32,9 +30,6 @@ #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 @@ -97,7 +92,6 @@ struct sigaction void* (*sa_sigaction)(int, siginfo_t *, void*); }; -char *strsep(char **stringp, const char *delim); long sysconf(int name); int kill(pid_t pid, int sig); diff --git a/os/os.h b/os/os.h index 2e4764e1..a14d7f0c 100644 --- a/os/os.h +++ b/os/os.h @@ -44,11 +44,7 @@ enum { #error "unsupported os" #endif -#ifdef FIO_HAVE_LIBAIO -#include -#endif - -#ifdef FIO_HAVE_POSIXAIO +#ifdef CONFIG_POSIXAIO #include #ifndef FIO_OS_HAVE_AIOCB_TYPEDEF typedef struct aiocb os_aiocb_t; @@ -60,7 +56,7 @@ typedef struct aiocb os_aiocb_t; #include #endif -#ifndef FIO_HAVE_STRSEP +#ifdef CONFIG_STRSEP #include "../lib/strsep.h" #endif @@ -116,12 +112,6 @@ typedef unsigned long os_cpu_mask_t; #define OS_RAND_MAX RAND_MAX #endif -#ifdef FIO_HAVE_CLOCK_MONOTONIC -#define FIO_TIMER_CLOCK CLOCK_MONOTONIC -#else -#define FIO_TIMER_CLOCK CLOCK_REALTIME -#endif - #ifndef FIO_HAVE_RAWBIND #define fio_lookup_raw(dev, majdev, mindev) 1 #endif @@ -142,8 +132,8 @@ typedef unsigned long os_cpu_mask_t; #define FIO_MAX_JOBS 2048 #endif -#ifndef FIO_OS_HAVE_SOCKLEN_T -typedef socklen_t fio_socklen_t; +#ifndef CONFIG_SOCKLEN_T +typedef unsigned int socklen_t; #endif #ifndef FIO_OS_HAS_CTIME_R diff --git a/os/syslet.h b/os/syslet.h deleted file mode 100644 index 095cc134..00000000 --- a/os/syslet.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _SYSLET_H_ -#define _SYSLET_H_ - -#include "kcompat.h" - -struct syslet_frame { - u64 ip; - u64 sp; -}; - -struct syslet_args { - u64 ring_ptr; - u64 caller_data; - struct syslet_frame frame; -}; - -struct syslet_completion { - u64 status; - u64 caller_data; -}; - -struct syslet_ring { - u32 kernel_head; - u32 user_tail; - u32 elements; - u32 wait_group; - struct syslet_completion comp[0]; -}; - -#ifdef __x86_64__ -#define __NR_syslet_ring_wait 287 -#elif defined __i386__ -#define __NR_syslet_ring_wait 326 -#endif - -#define ESYSLETPENDING 132 - -typedef void (*syslet_return_func_t)(void); - -static inline void fill_syslet_args(struct syslet_args *args, - struct syslet_ring *ring, uint64_t caller_data, - syslet_return_func_t func, void *stack) -{ - args->ring_ptr = (u64)(unsigned long)ring; - args->caller_data = caller_data; - args->frame.ip = (u64)(unsigned long)func; - args->frame.sp = (u64)(unsigned long)stack; -} - -#endif diff --git a/os/windows/posix.c b/os/windows/posix.c index f616e876..8b451478 100755 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -823,11 +823,6 @@ const char* inet_ntop(int af, const void *restrict src, return ret; } -int inet_aton(const char *cp, struct in_addr *inp) -{ - return inet_pton(AF_INET, cp, inp); -} - int inet_pton(int af, const char *restrict src, void *restrict dst) { INT status = SOCKET_ERROR; diff --git a/server.c b/server.c index f8c36357..ffa6ed4b 100644 --- a/server.c +++ b/server.c @@ -310,7 +310,7 @@ int fio_net_send_simple_cmd(int sk, uint16_t opcode, uint64_t tag, fio_net_cmd_crc(&cmd->cmd); INIT_FLIST_HEAD(&cmd->list); - gettimeofday(&cmd->tv, NULL); + fio_gettime(&cmd->tv, NULL); cmd->saved_tag = tag; ret = fio_send_data(sk, &cmd->cmd, sizeof(cmd->cmd)); @@ -561,7 +561,7 @@ void fio_server_idle_loop(void) 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, sk, flags, exitval = 0; @@ -815,7 +815,7 @@ int fio_server_log(const char *format, ...) static int fio_init_server_ip(void) { struct sockaddr *addr; - fio_socklen_t socklen; + socklen_t socklen; int sk, opt; if (use_ipv6) @@ -864,7 +864,7 @@ static int fio_init_server_ip(void) static int fio_init_server_sock(void) { struct sockaddr_un addr; - fio_socklen_t len; + socklen_t len; mode_t mode; int sk; -- 2.25.1