+++ /dev/null
-#ifndef ARCH_ALPHA_H
-#define ARCH_ALPHA_H
-
-#define ARCH (arch_alpha)
-
-#ifndef __NR_ioprio_set
-#define __NR_ioprio_set 442
-#define __NR_ioprio_get 443
-#endif
-
-#ifndef __NR_fadvise64
-#define __NR_fadvise64 413
-#endif
-
-#define nop do { } while (0)
-#define ffz(v) generic_ffz((v))
-
-#endif
+++ /dev/null
-#ifndef ARCH_IA64_H
-#define ARCH_IA64_H
-
-#define ARCH (arch_ia64)
-
-#ifndef __NR_ioprio_set
-#define __NR_ioprio_set 1274
-#define __NR_ioprio_get 1275
-#endif
-
-#ifndef __NR_fadvise64
-#define __NR_fadvise64 1234
-#endif
-
-#ifndef __NR_sys_splice
-#define __NR_sys_splice 1297
-#define __NR_sys_tee 1301
-#define __NR_sys_vmsplice 1302
-#endif
-
-#define nop asm volatile ("hint @pause" ::: "memory");
-
-#define ia64_popcnt(x) \
-({ \
- unsigned long ia64_intri_res; \
- asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \
- ia64_intri_res; \
-})
-
-static inline unsigned long ffz(unsigned long bitmask)
-{
- return ia64_popcnt(bitmask & (~bitmask - 1));
-}
-
-#endif
+++ /dev/null
-#ifndef ARCH_PPC_H
-#define ARCH_PPH_H
-
-#define ARCH (arch_ppc)
-
-#ifndef __NR_ioprio_set
-#define __NR_ioprio_set 273
-#define __NR_ioprio_get 274
-#endif
-
-#ifndef __NR_fadvise64
-#define __NR_fadvise64 233
-#endif
-
-#ifndef __NR_sys_splice
-#define __NR_sys_splice 283
-#define __NR_sys_tee 284
-#define __NR_sys_vmsplice 285
-#endif
-
-#define nop do { } while (0)
-
-static inline int __ilog2(unsigned long bitmask)
-{
- int lz;
-
- asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask));
- return 31 - lz;
-}
-
-static inline int ffz(unsigned long bitmask)
-{
- if ((bitmask = ~bitmask) == 0)
- return 32;
- return __ilog2(bitmask & -bitmask);
-}
-
-#endif
+++ /dev/null
-#ifndef ARCH_S390_H
-#define ARCH_S390_H
-
-#define ARCH (arch_s390)
-
-#ifndef __NR_ioprio_set
-#define __NR_ioprio_set 282
-#define __NR_ioprio_get 283
-#endif
-
-#ifndef __NR_fadvise64
-#define __NR_fadvise64 253
-#endif
-
-#define nop asm volatile ("diag 0,0,68" : : : "memory")
-#define ffz(v) generic_ffz((v))
-
-#endif
+++ /dev/null
-#ifndef ARCH_X86_H
-#define ARCH_X86_H
-
-#define ARCH (arch_i386)
-
-#ifndef __NR_ioprio_set
-#define __NR_ioprio_set 289
-#define __NR_ioprio_get 290
-#endif
-
-#ifndef __NR_fadvise64
-#define __NR_fadvise64 250
-#endif
-
-#ifndef __NR_sys_splice
-#define __NR_sys_splice 313
-#define __NR_sys_tee 315
-#define __NR_sys_vmsplice 316
-#endif
-
-#ifndef __NR_async_exec
-#define __NR_async_exec 320
-#define __NR_async_wait 321
-#define __NR_umem_add 322
-#define __NR_async_thread 323
-#endif
-
-#define FIO_HUGE_PAGE 4194304
-
-#define FIO_HAVE_SYSLET
-
-#define nop __asm__ __volatile__("rep;nop": : :"memory")
-
-static inline unsigned long ffz(unsigned long bitmask)
-{
- __asm__("bsfl %1,%0" :"=r" (bitmask) :"r" (~bitmask));
- return bitmask;
-}
-
-#endif
+++ /dev/null
-#ifndef ARCH_X86_64_h
-#define ARCH_X86_64_h
-
-#define ARCH (arch_x86_64)
-
-#ifndef __NR_ioprio_set
-#define __NR_ioprio_set 251
-#define __NR_ioprio_get 252
-#endif
-
-#ifndef __NR_fadvise64
-#define __NR_fadvise64 221
-#endif
-
-#ifndef __NR_sys_splice
-#define __NR_sys_splice 275
-#define __NR_sys_tee 276
-#define __NR_sys_vmsplice 278
-#endif
-
-#ifndef __NR_async_exec
-#define __NR_async_exec 280
-#define __NR_async_wait 281
-#define __NR_umem_add 282
-#define __NR_async_thread 283
-#endif
-
-#define FIO_HUGE_PAGE 2097152
-
-#define FIO_HAVE_SYSLET
-
-#define nop __asm__ __volatile__("rep;nop": : :"memory")
-
-static inline unsigned long ffz(unsigned long bitmask)
-{
- __asm__("bsfq %1,%0" :"=r" (bitmask) :"r" (~bitmask));
- return bitmask;
-}
-
-
-#endif
+++ /dev/null
-#ifndef ARCH_H
-#define ARCH_H
-
-enum {
- arch_x86_64,
- arch_i386,
- arch_ppc,
- arch_ia64,
- arch_s390,
- arch_alpha,
-};
-
-static inline unsigned long generic_ffz(unsigned long word)
-{
- unsigned int i;
-
- for (i = 0; i < sizeof(word) * 8; i++)
- if ((word & (1UL << i)) == 0)
- return i;
-
- return -1;
-}
-
-#if defined(__i386__)
-#include "arch-x86.h"
-#elif defined(__x86_64__)
-#include "arch-x86_64.h"
-#elif defined(__powerpc__) || defined(__powerpc64__)
-#include "arch-ppc.h"
-#elif defined(__ia64__)
-#include "arch-ia64.h"
-#elif defined(__alpha__)
-#include "arch-alpha.h"
-#elif defined(__s390x__) || defined(__s390__)
-#include "arch-s390.h"
-#else
-#error "Unsupported arch"
-#endif
-
-#define BITS_PER_LONG (__WORDSIZE)
-
-#endif
--- /dev/null
+#ifndef ARCH_ALPHA_H
+#define ARCH_ALPHA_H
+
+#define ARCH (arch_alpha)
+
+#ifndef __NR_ioprio_set
+#define __NR_ioprio_set 442
+#define __NR_ioprio_get 443
+#endif
+
+#ifndef __NR_fadvise64
+#define __NR_fadvise64 413
+#endif
+
+#define nop do { } while (0)
+#define ffz(v) generic_ffz((v))
+
+#endif
--- /dev/null
+#ifndef ARCH_IA64_H
+#define ARCH_IA64_H
+
+#define ARCH (arch_ia64)
+
+#ifndef __NR_ioprio_set
+#define __NR_ioprio_set 1274
+#define __NR_ioprio_get 1275
+#endif
+
+#ifndef __NR_fadvise64
+#define __NR_fadvise64 1234
+#endif
+
+#ifndef __NR_sys_splice
+#define __NR_sys_splice 1297
+#define __NR_sys_tee 1301
+#define __NR_sys_vmsplice 1302
+#endif
+
+#define nop asm volatile ("hint @pause" ::: "memory");
+
+#define ia64_popcnt(x) \
+({ \
+ unsigned long ia64_intri_res; \
+ asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \
+ ia64_intri_res; \
+})
+
+static inline unsigned long ffz(unsigned long bitmask)
+{
+ return ia64_popcnt(bitmask & (~bitmask - 1));
+}
+
+#endif
--- /dev/null
+#ifndef ARCH_PPC_H
+#define ARCH_PPH_H
+
+#define ARCH (arch_ppc)
+
+#ifndef __NR_ioprio_set
+#define __NR_ioprio_set 273
+#define __NR_ioprio_get 274
+#endif
+
+#ifndef __NR_fadvise64
+#define __NR_fadvise64 233
+#endif
+
+#ifndef __NR_sys_splice
+#define __NR_sys_splice 283
+#define __NR_sys_tee 284
+#define __NR_sys_vmsplice 285
+#endif
+
+#define nop do { } while (0)
+
+static inline int __ilog2(unsigned long bitmask)
+{
+ int lz;
+
+ asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask));
+ return 31 - lz;
+}
+
+static inline int ffz(unsigned long bitmask)
+{
+ if ((bitmask = ~bitmask) == 0)
+ return 32;
+ return __ilog2(bitmask & -bitmask);
+}
+
+#endif
--- /dev/null
+#ifndef ARCH_S390_H
+#define ARCH_S390_H
+
+#define ARCH (arch_s390)
+
+#ifndef __NR_ioprio_set
+#define __NR_ioprio_set 282
+#define __NR_ioprio_get 283
+#endif
+
+#ifndef __NR_fadvise64
+#define __NR_fadvise64 253
+#endif
+
+#define nop asm volatile ("diag 0,0,68" : : : "memory")
+#define ffz(v) generic_ffz((v))
+
+#endif
--- /dev/null
+#ifndef ARCH_X86_H
+#define ARCH_X86_H
+
+#define ARCH (arch_i386)
+
+#ifndef __NR_ioprio_set
+#define __NR_ioprio_set 289
+#define __NR_ioprio_get 290
+#endif
+
+#ifndef __NR_fadvise64
+#define __NR_fadvise64 250
+#endif
+
+#ifndef __NR_sys_splice
+#define __NR_sys_splice 313
+#define __NR_sys_tee 315
+#define __NR_sys_vmsplice 316
+#endif
+
+#ifndef __NR_async_exec
+#define __NR_async_exec 320
+#define __NR_async_wait 321
+#define __NR_umem_add 322
+#define __NR_async_thread 323
+#endif
+
+#define FIO_HUGE_PAGE 4194304
+
+#define FIO_HAVE_SYSLET
+
+#define nop __asm__ __volatile__("rep;nop": : :"memory")
+
+static inline unsigned long ffz(unsigned long bitmask)
+{
+ __asm__("bsfl %1,%0" :"=r" (bitmask) :"r" (~bitmask));
+ return bitmask;
+}
+
+#endif
--- /dev/null
+#ifndef ARCH_X86_64_h
+#define ARCH_X86_64_h
+
+#define ARCH (arch_x86_64)
+
+#ifndef __NR_ioprio_set
+#define __NR_ioprio_set 251
+#define __NR_ioprio_get 252
+#endif
+
+#ifndef __NR_fadvise64
+#define __NR_fadvise64 221
+#endif
+
+#ifndef __NR_sys_splice
+#define __NR_sys_splice 275
+#define __NR_sys_tee 276
+#define __NR_sys_vmsplice 278
+#endif
+
+#ifndef __NR_async_exec
+#define __NR_async_exec 280
+#define __NR_async_wait 281
+#define __NR_umem_add 282
+#define __NR_async_thread 283
+#endif
+
+#define FIO_HUGE_PAGE 2097152
+
+#define FIO_HAVE_SYSLET
+
+#define nop __asm__ __volatile__("rep;nop": : :"memory")
+
+static inline unsigned long ffz(unsigned long bitmask)
+{
+ __asm__("bsfq %1,%0" :"=r" (bitmask) :"r" (~bitmask));
+ return bitmask;
+}
+
+
+#endif
--- /dev/null
+#ifndef ARCH_H
+#define ARCH_H
+
+enum {
+ arch_x86_64,
+ arch_i386,
+ arch_ppc,
+ arch_ia64,
+ arch_s390,
+ arch_alpha,
+};
+
+static inline unsigned long generic_ffz(unsigned long word)
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof(word) * 8; i++)
+ if ((word & (1UL << i)) == 0)
+ return i;
+
+ return -1;
+}
+
+#if defined(__i386__)
+#include "arch-x86.h"
+#elif defined(__x86_64__)
+#include "arch-x86_64.h"
+#elif defined(__powerpc__) || defined(__powerpc64__)
+#include "arch-ppc.h"
+#elif defined(__ia64__)
+#include "arch-ia64.h"
+#elif defined(__alpha__)
+#include "arch-alpha.h"
+#elif defined(__s390x__) || defined(__s390__)
+#include "arch-s390.h"
+#else
+#error "Unsupported arch"
+#endif
+
+#define BITS_PER_LONG (__WORDSIZE)
+
+#endif
+++ /dev/null
-#ifndef FIO_COMPILER_GCC3_H
-#define FIO_COMPILER_GCC3_H
-
-#if __GNUC_MINOR__ >= 4
-#define __must_check __attribute__((warn_unused_result))
-#endif
-
-#endif
+++ /dev/null
-#ifndef FIO_COMPILER_GCC4_H
-#define FIO_COMPILER_GCC4_H
-
-#define __must_check __attribute__((warn_unused_result))
-
-#endif
+++ /dev/null
-#ifndef FIO_COMPILER_H
-#define FIO_COMPILER_H
-
-#if __GNUC__ >= 4
-#include "compiler-gcc4.h"
-#elif __GNUC__ == 3
-#include "compiler-gcc3.h"
-#else
-#error Compiler too old, need gcc at least gcc 3.x
-#endif
-
-#ifndef __must_check
-#define __must_check
-#endif
-
-#endif
--- /dev/null
+#ifndef FIO_COMPILER_GCC3_H
+#define FIO_COMPILER_GCC3_H
+
+#if __GNUC_MINOR__ >= 4
+#define __must_check __attribute__((warn_unused_result))
+#endif
+
+#endif
--- /dev/null
+#ifndef FIO_COMPILER_GCC4_H
+#define FIO_COMPILER_GCC4_H
+
+#define __must_check __attribute__((warn_unused_result))
+
+#endif
--- /dev/null
+#ifndef FIO_COMPILER_H
+#define FIO_COMPILER_H
+
+#if __GNUC__ >= 4
+#include "compiler-gcc4.h"
+#elif __GNUC__ == 3
+#include "compiler-gcc3.h"
+#else
+#error Compiler too old, need gcc at least gcc 3.x
+#endif
+
+#ifndef __must_check
+#define __must_check
+#endif
+
+#endif
*
*/
#include "../fio.h"
-#include "../os.h"
static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u)
{
#include <assert.h>
#include "../fio.h"
-#include "../os.h"
#ifdef FIO_HAVE_GUASI
#include <assert.h>
#include "../fio.h"
-#include "../os.h"
#ifdef FIO_HAVE_LIBAIO
#include <sys/mman.h>
#include "../fio.h"
-#include "../os.h"
static int fio_mmapio_queue(struct thread_data *td, struct io_u *io_u)
{
#include <sys/poll.h>
#include "../fio.h"
-#include "../os.h"
struct netio_data {
int listenfd;
#include <assert.h>
#include "../fio.h"
-#include "../os.h"
struct null_data {
struct io_u **io_us;
#include <assert.h>
#include "../fio.h"
-#include "../os.h"
#ifdef FIO_HAVE_POSIXAIO
#include <sys/poll.h>
#include "../fio.h"
-#include "../os.h"
#ifdef FIO_HAVE_SGIO
#include <assert.h>
#include "../fio.h"
-#include "../os.h"
/*
* The core of the module is identical to the ones included with fio,
#include <sys/poll.h>
#include "../fio.h"
-#include "../os.h"
#ifdef FIO_HAVE_SPLICE
#include <assert.h>
#include "../fio.h"
-#include "../os.h"
static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
{
#include <asm/unistd.h>
#include "../fio.h"
-#include "../os.h"
#ifdef FIO_HAVE_SYSLET
#include <string.h>
#include "fio.h"
-#include "os.h"
static char run_str[MAX_JOBS + 1];
#include <sys/types.h>
#include "fio.h"
-#include "os.h"
static int extend_file(struct thread_data *td, struct fio_file *f)
{
#include <sys/mman.h>
#include "fio.h"
-#include "os.h"
unsigned long page_mask;
unsigned long page_size;
#include <string.h>
#include <getopt.h>
-#include "compiler.h"
+#include "compiler/compiler.h"
#include "list.h"
#include "rbtree.h"
#include "md5.h"
#include "crc32.h"
-#include "arch.h"
-#include "os.h"
+#include "arch/arch.h"
+#include "os/os.h"
#include "mutex.h"
#ifdef FIO_HAVE_SYSLET
#include <sys/time.h>
#include "fio.h"
-#include "os.h"
#include "hash.h"
#include <assert.h>
#include "fio.h"
-#include "os.h"
/*
* Change this define to play with the timeout handling
#include <assert.h>
#include "fio.h"
-#include "os.h"
static LIST_HEAD(engine_list);
#include <sys/mman.h>
#include "fio.h"
-#include "os.h"
static void *pinned_mem;
+++ /dev/null
-#ifndef FIO_OS_FREEBSD_H
-#define FIO_OS_FREEBSD_H
-
-#include <sys/sysctl.h>
-
-#undef FIO_HAVE_LIBAIO
-#define FIO_HAVE_POSIXAIO
-#undef FIO_HAVE_FADVISE
-#undef FIO_HAVE_CPU_AFFINITY
-#undef FIO_HAVE_DISK_UTIL
-#undef FIO_HAVE_SGIO
-#define FIO_HAVE_ODIRECT
-
-#define OS_MAP_ANON (MAP_ANON)
-
-typedef unsigned long os_cpu_mask_t;
-typedef unsigned int os_random_state_t;
-
-/*
- * FIXME
- */
-static inline int blockdev_size(int fd, unsigned long long *bytes)
-{
- return EINVAL;
-}
-
-static inline int blockdev_invalidate_cache(int fd)
-{
- return EINVAL;
-}
-
-static inline unsigned long long os_phys_mem(void)
-{
- int mib[2] = { CTL_HW, HW_PHYSMEM };
- unsigned long long mem;
- size_t len = sizeof(mem);
-
- sysctl(mib, 2, &mem, &len, NULL, 0);
- return mem;
-}
-
-static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
-{
- srand(seed);
-}
-
-static inline long os_random_long(os_random_state_t *rs)
-{
- long val;
-
- val = rand_r(rs);
- return val;
-}
-
-static inline double os_random_double(os_random_state_t *rs)
-{
- double val;
-
- val = (double) rand_r(rs);
- return val;
-}
-#endif
+++ /dev/null
-#ifndef FIO_OS_LINUX_H
-#define FIO_OS_LINUX_H
-
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <linux/unistd.h>
-#include <linux/raw.h>
-#include <linux/major.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 OS_MAP_ANON (MAP_ANONYMOUS)
-
-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
- */
-#define fadvise(fd, off, len, advice) \
- posix_fadvise((fd), (off_t)(off), (len), (advice))
-
-#define fio_setaffinity(td) \
- sched_setaffinity((td)->pid, sizeof((td)->o.cpumask), &(td)->o.cpumask)
-#define fio_getaffinity(pid, ptr) \
- sched_getaffinity((pid), sizeof(cpu_set_t), (ptr))
-
-static inline int ioprio_set(int which, int who, int ioprio)
-{
- return syscall(__NR_ioprio_set, which, who, ioprio);
-}
-
-/*
- * 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 long 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 (void *) 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_WHO_PROCESS = 1,
- IOPRIO_WHO_PGRP,
- IOPRIO_WHO_USER,
-};
-
-#define IOPRIO_CLASS_SHIFT 13
-
-#ifndef BLKGETSIZE64
-#define BLKGETSIZE64 _IOR(0x12,114,size_t)
-#endif
-
-#ifndef BLKFLSBUF
-#define BLKFLSBUF _IO(0x12,97)
-#endif
-
-static inline int blockdev_invalidate_cache(int fd)
-{
- return ioctl(fd, BLKFLSBUF);
-}
-
-static inline int blockdev_size(int fd, unsigned long long *bytes)
-{
- if (!ioctl(fd, BLKGETSIZE64, bytes))
- return 0;
-
- return errno;
-}
-
-static inline unsigned long long os_phys_mem(void)
-{
- long pagesize, pages;
-
- pagesize = sysconf(_SC_PAGESIZE);
- pages = sysconf(_SC_PHYS_PAGES);
- if (pages == -1 || pagesize == -1)
- return 0;
-
- return (unsigned long long) pages * (unsigned long long) pagesize;
-}
-
-static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
-{
- srand48_r(seed, rs);
-}
-
-static inline long os_random_long(os_random_state_t *rs)
-{
- long val;
-
- lrand48_r(rs, &val);
- return val;
-}
-
-static inline double os_random_double(os_random_state_t *rs)
-{
- double val;
-
- drand48_r(rs, &val);
- return val;
-}
-
-static inline void fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
-{
- struct raw_config_request rq;
- int fd;
-
- if (major(dev) != RAW_MAJOR)
- return;
-
- /*
- * we should be able to find /dev/rawctl or /dev/raw/rawctl
- */
- fd = open("/dev/rawctl", O_RDONLY);
- if (fd < 0) {
- fd = open("/dev/raw/rawctl", O_RDONLY);
- if (fd < 0)
- return;
- }
-
- rq.raw_minor = minor(dev);
- if (ioctl(fd, RAW_GETBIND, &rq) < 0) {
- close(fd);
- return;
- }
-
- close(fd);
- *majdev = rq.block_major;
- *mindev = rq.block_minor;
-}
-
-#endif
+++ /dev/null
-#ifndef FIO_OS_SOLARIS_H
-#define FIO_OS_SOLARIS_H
-
-#undef FIO_HAVE_LIBAIO
-#define FIO_HAVE_POSIXAIO
-#undef FIO_HAVE_FADVISE
-#undef FIO_HAVE_CPU_AFFINITY
-#undef FIO_HAVE_DISK_UTIL
-#undef FIO_HAVE_SGIO
-#undef FIO_HAVE_ODIRECT
-
-#define OS_MAP_ANON (MAP_ANON)
-
-typedef unsigned long os_cpu_mask_t;
-typedef unsigned int os_random_state_t;
-
-/*
- * FIXME
- */
-static inline int blockdev_size(int fd, unsigned long long *bytes)
-{
- return EINVAL;
-}
-
-static inline int blockdev_invalidate_cache(int fd)
-{
- return EINVAL;
-}
-
-static inline unsigned long long os_phys_mem(void)
-{
-#if 0
- int mib[2] = { CTL_HW, HW_PHYSMEM };
- unsigned long long mem;
- size_t len = sizeof(mem);
-
- sysctl(mib, 2, &mem, &len, NULL, 0);
- return mem;
-#else
- return 0;
-#endif
-}
-
-static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
-{
- srand(seed);
-}
-
-static inline long os_random_long(os_random_state_t *rs)
-{
- long val;
-
- val = rand_r(rs);
- return val;
-}
-
-static inline double os_random_double(os_random_state_t *rs)
-{
- double val;
-
- val = (double) rand_r(rs);
- return val;
-}
-
-#endif
+++ /dev/null
-#ifndef FIO_OS_H
-#define FIO_OS_H
-
-#if defined(__linux__)
-#include "os-linux.h"
-#elif defined(__FreeBSD__)
-#include "os-freebsd.h"
-#elif defined(__sun__)
-#include "os-solaris.h"
-#else
-#error "unsupported os"
-#endif
-
-#ifdef FIO_HAVE_LIBAIO
-#include <libaio.h>
-#endif
-
-#ifdef FIO_HAVE_POSIXAIO
-#include <aio.h>
-#endif
-
-#ifdef FIO_HAVE_SGIO
-#include <linux/fs.h>
-#include <scsi/sg.h>
-#endif
-
-#ifndef FIO_HAVE_FADVISE
-#define fadvise(fd, off, len, advice) (0)
-
-#define POSIX_FADV_DONTNEED (0)
-#define POSIX_FADV_SEQUENTIAL (0)
-#define POSIX_FADV_RANDOM (0)
-#endif /* FIO_HAVE_FADVISE */
-
-#ifndef FIO_HAVE_CPU_AFFINITY
-#define fio_setaffinity(td) (0)
-#define fio_getaffinity(pid, mask) (0)
-#endif
-
-#ifndef FIO_HAVE_IOPRIO
-#define ioprio_set(which, who, prio) (0)
-#endif
-
-#ifndef FIO_HAVE_ODIRECT
-#define OS_O_DIRECT 0
-#else
-#define OS_O_DIRECT O_DIRECT
-#endif
-
-#ifndef FIO_HAVE_HUGETLB
-#define SHM_HUGETLB 0
-#define FIO_HUGE_PAGE 0
-#else
-#ifndef FIO_HUGE_PAGE
-#define FIO_HUGE_PAGE 4194304
-#endif
-#endif
-
-#ifndef FIO_HAVE_RAWBIND
-#define fio_lookup_raw(dev, majdev, mindev)
-#endif
-
-#endif
--- /dev/null
+#ifndef FIO_OS_FREEBSD_H
+#define FIO_OS_FREEBSD_H
+
+#include <sys/sysctl.h>
+
+#undef FIO_HAVE_LIBAIO
+#define FIO_HAVE_POSIXAIO
+#undef FIO_HAVE_FADVISE
+#undef FIO_HAVE_CPU_AFFINITY
+#undef FIO_HAVE_DISK_UTIL
+#undef FIO_HAVE_SGIO
+#define FIO_HAVE_ODIRECT
+
+#define OS_MAP_ANON (MAP_ANON)
+
+typedef unsigned long os_cpu_mask_t;
+typedef unsigned int os_random_state_t;
+
+/*
+ * FIXME
+ */
+static inline int blockdev_size(int fd, unsigned long long *bytes)
+{
+ return EINVAL;
+}
+
+static inline int blockdev_invalidate_cache(int fd)
+{
+ return EINVAL;
+}
+
+static inline unsigned long long os_phys_mem(void)
+{
+ int mib[2] = { CTL_HW, HW_PHYSMEM };
+ unsigned long long mem;
+ size_t len = sizeof(mem);
+
+ sysctl(mib, 2, &mem, &len, NULL, 0);
+ return mem;
+}
+
+static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
+{
+ srand(seed);
+}
+
+static inline long os_random_long(os_random_state_t *rs)
+{
+ long val;
+
+ val = rand_r(rs);
+ return val;
+}
+
+static inline double os_random_double(os_random_state_t *rs)
+{
+ double val;
+
+ val = (double) rand_r(rs);
+ return val;
+}
+#endif
--- /dev/null
+#ifndef FIO_OS_LINUX_H
+#define FIO_OS_LINUX_H
+
+#include <sys/ioctl.h>
+#include <sys/uio.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/unistd.h>
+#include <linux/raw.h>
+#include <linux/major.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 OS_MAP_ANON (MAP_ANONYMOUS)
+
+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
+ */
+#define fadvise(fd, off, len, advice) \
+ posix_fadvise((fd), (off_t)(off), (len), (advice))
+
+#define fio_setaffinity(td) \
+ sched_setaffinity((td)->pid, sizeof((td)->o.cpumask), &(td)->o.cpumask)
+#define fio_getaffinity(pid, ptr) \
+ sched_getaffinity((pid), sizeof(cpu_set_t), (ptr))
+
+static inline int ioprio_set(int which, int who, int ioprio)
+{
+ return syscall(__NR_ioprio_set, which, who, ioprio);
+}
+
+/*
+ * 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 long 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 (void *) 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_WHO_PROCESS = 1,
+ IOPRIO_WHO_PGRP,
+ IOPRIO_WHO_USER,
+};
+
+#define IOPRIO_CLASS_SHIFT 13
+
+#ifndef BLKGETSIZE64
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
+#endif
+
+#ifndef BLKFLSBUF
+#define BLKFLSBUF _IO(0x12,97)
+#endif
+
+static inline int blockdev_invalidate_cache(int fd)
+{
+ return ioctl(fd, BLKFLSBUF);
+}
+
+static inline int blockdev_size(int fd, unsigned long long *bytes)
+{
+ if (!ioctl(fd, BLKGETSIZE64, bytes))
+ return 0;
+
+ return errno;
+}
+
+static inline unsigned long long os_phys_mem(void)
+{
+ long pagesize, pages;
+
+ pagesize = sysconf(_SC_PAGESIZE);
+ pages = sysconf(_SC_PHYS_PAGES);
+ if (pages == -1 || pagesize == -1)
+ return 0;
+
+ return (unsigned long long) pages * (unsigned long long) pagesize;
+}
+
+static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
+{
+ srand48_r(seed, rs);
+}
+
+static inline long os_random_long(os_random_state_t *rs)
+{
+ long val;
+
+ lrand48_r(rs, &val);
+ return val;
+}
+
+static inline double os_random_double(os_random_state_t *rs)
+{
+ double val;
+
+ drand48_r(rs, &val);
+ return val;
+}
+
+static inline void fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
+{
+ struct raw_config_request rq;
+ int fd;
+
+ if (major(dev) != RAW_MAJOR)
+ return;
+
+ /*
+ * we should be able to find /dev/rawctl or /dev/raw/rawctl
+ */
+ fd = open("/dev/rawctl", O_RDONLY);
+ if (fd < 0) {
+ fd = open("/dev/raw/rawctl", O_RDONLY);
+ if (fd < 0)
+ return;
+ }
+
+ rq.raw_minor = minor(dev);
+ if (ioctl(fd, RAW_GETBIND, &rq) < 0) {
+ close(fd);
+ return;
+ }
+
+ close(fd);
+ *majdev = rq.block_major;
+ *mindev = rq.block_minor;
+}
+
+#endif
--- /dev/null
+#ifndef FIO_OS_SOLARIS_H
+#define FIO_OS_SOLARIS_H
+
+#undef FIO_HAVE_LIBAIO
+#define FIO_HAVE_POSIXAIO
+#undef FIO_HAVE_FADVISE
+#undef FIO_HAVE_CPU_AFFINITY
+#undef FIO_HAVE_DISK_UTIL
+#undef FIO_HAVE_SGIO
+#undef FIO_HAVE_ODIRECT
+
+#define OS_MAP_ANON (MAP_ANON)
+
+typedef unsigned long os_cpu_mask_t;
+typedef unsigned int os_random_state_t;
+
+/*
+ * FIXME
+ */
+static inline int blockdev_size(int fd, unsigned long long *bytes)
+{
+ return EINVAL;
+}
+
+static inline int blockdev_invalidate_cache(int fd)
+{
+ return EINVAL;
+}
+
+static inline unsigned long long os_phys_mem(void)
+{
+#if 0
+ int mib[2] = { CTL_HW, HW_PHYSMEM };
+ unsigned long long mem;
+ size_t len = sizeof(mem);
+
+ sysctl(mib, 2, &mem, &len, NULL, 0);
+ return mem;
+#else
+ return 0;
+#endif
+}
+
+static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
+{
+ srand(seed);
+}
+
+static inline long os_random_long(os_random_state_t *rs)
+{
+ long val;
+
+ val = rand_r(rs);
+ return val;
+}
+
+static inline double os_random_double(os_random_state_t *rs)
+{
+ double val;
+
+ val = (double) rand_r(rs);
+ return val;
+}
+
+#endif
--- /dev/null
+#ifndef FIO_OS_H
+#define FIO_OS_H
+
+#if defined(__linux__)
+#include "os-linux.h"
+#elif defined(__FreeBSD__)
+#include "os-freebsd.h"
+#elif defined(__sun__)
+#include "os-solaris.h"
+#else
+#error "unsupported os"
+#endif
+
+#ifdef FIO_HAVE_LIBAIO
+#include <libaio.h>
+#endif
+
+#ifdef FIO_HAVE_POSIXAIO
+#include <aio.h>
+#endif
+
+#ifdef FIO_HAVE_SGIO
+#include <linux/fs.h>
+#include <scsi/sg.h>
+#endif
+
+#ifndef FIO_HAVE_FADVISE
+#define fadvise(fd, off, len, advice) (0)
+
+#define POSIX_FADV_DONTNEED (0)
+#define POSIX_FADV_SEQUENTIAL (0)
+#define POSIX_FADV_RANDOM (0)
+#endif /* FIO_HAVE_FADVISE */
+
+#ifndef FIO_HAVE_CPU_AFFINITY
+#define fio_setaffinity(td) (0)
+#define fio_getaffinity(pid, mask) (0)
+#endif
+
+#ifndef FIO_HAVE_IOPRIO
+#define ioprio_set(which, who, prio) (0)
+#endif
+
+#ifndef FIO_HAVE_ODIRECT
+#define OS_O_DIRECT 0
+#else
+#define OS_O_DIRECT O_DIRECT
+#endif
+
+#ifndef FIO_HAVE_HUGETLB
+#define SHM_HUGETLB 0
+#define FIO_HUGE_PAGE 0
+#else
+#ifndef FIO_HUGE_PAGE
+#define FIO_HUGE_PAGE 4194304
+#endif
+#endif
+
+#ifndef FIO_HAVE_RAWBIND
+#define fio_lookup_raw(dev, majdev, mindev)
+#endif
+
+#endif
#include <string.h>
#include "fio.h"
-#include "os.h"
static void fill_random_bytes(struct thread_data *td,
unsigned char *p, unsigned int len)