[PATCH] fio: pretty close to compiling/working on FreeBSD now
authorJens Axboe <axboe@suse.de>
Mon, 5 Dec 2005 19:26:36 +0000 (20:26 +0100)
committerJens Axboe <axboe@suse.de>
Mon, 5 Dec 2005 19:26:36 +0000 (20:26 +0100)
fio-ini.c
fio.c
fio.h
os-freebsd.h
os-linux.h
os.h

index ecb9aa70c4381fd966c0fc6c36fca844117ad33b..15cc1d890786404171791878b680e503bf5e62c6 100644 (file)
--- a/fio-ini.c
+++ b/fio-ini.c
@@ -7,6 +7,8 @@
 #include <errno.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include "fio.h"
 
@@ -287,6 +289,7 @@ int init_random_state(struct thread_data *td)
 
 static void fill_cpu_mask(cpu_set_t cpumask, int cpu)
 {
+#ifdef FIO_HAVE_CPU_AFFINITY
        unsigned int i;
 
        CPU_ZERO(&cpumask);
@@ -295,6 +298,7 @@ static void fill_cpu_mask(cpu_set_t cpumask, int cpu)
                if ((1 << i) & cpu)
                        CPU_SET(i, &cpumask);
        }
+#endif
 }
 
 static unsigned long get_mult(char c)
@@ -760,7 +764,7 @@ static int fill_def_thread(void)
 {
        memset(&def_thread, 0, sizeof(def_thread));
 
-       if (sched_getaffinity(getpid(), sizeof(cpu_set_t), &def_thread.cpumask) == -1) {
+       if (fio_getaffinity(getpid(), &def_thread.cpumask) == -1) {
                perror("sched_getaffinity");
                return 1;
        }
@@ -791,6 +795,9 @@ static int fill_def_thread(void)
        def_thread.numjobs = DEF_NUMJOBS;
        def_thread.use_thread = DEF_USE_THREAD;
        def_thread.use_mmap = DEF_USE_MMAP;
+#ifdef FIO_HAVE_DISK_UTIL
+       def_thread.do_disk_util = 1;
+#endif
 
        return 0;
 }
diff --git a/fio.c b/fio.c
index 4e32dce8291563521c03388e6ddeb32cb2544b85..ca79cb63756bccbf09ffdedaad419463a4ce8fca 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -28,7 +28,6 @@
 #include <time.h>
 #include <math.h>
 #include <assert.h>
-#include <pthread.h>
 #include <dirent.h>
 #include <libgen.h>
 #include <sys/types.h>
@@ -830,7 +829,7 @@ static void do_sync_io(struct thread_data *td)
                rate_throttle(td, usec, io_u->buflen);
 
                if (check_min_rate(td, &e)) {
-                       td_verror(td, ENODATA);
+                       td_verror(td, ENOMEM);
                        break;
                }
 
@@ -1075,7 +1074,7 @@ static void do_async_io(struct thread_data *td)
                rate_throttle(td, usec, bytes_done);
 
                if (check_min_rate(td, &e)) {
-                       td_verror(td, ENODATA);
+                       td_verror(td, ENOMEM);
                        break;
                }
 
@@ -1638,6 +1637,9 @@ static void init_disk_util(struct thread_data *td)
        dev_t dev;
        char *p, *dir;
 
+       if (!td->do_disk_util)
+               return;
+
        if (!stat(td->file_name, &st)) {
                if (S_ISBLK(st.st_mode))
                        dev = st.st_rdev;
diff --git a/fio.h b/fio.h
index c8bc18e9a5dd5125b4b5db8220ca50ba30b5da27..7ff0ea05a22c1ea638e1cf3de6e25586dbbfd33c 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -3,6 +3,7 @@
 
 #include <sched.h>
 #include <limits.h>
+#include <pthread.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <semaphore.h>
@@ -196,6 +197,8 @@ struct thread_data {
        unsigned long sys_time;
        unsigned long ctx;
 
+       unsigned int do_disk_util;
+
        struct list_head io_hist_list;
 };
 
index 6d000649a561c897f455325adc917bba08757c1e..1f32006703c57c6cf4a92e86d9f28fc89f577622 100644 (file)
@@ -5,7 +5,8 @@
 #define FIO_HAVE_POSIXAIO
 #undef FIO_HAVE_FADVISE
 #undef FIO_HAVE_CPU_AFFINITY
+#undef FIO_HAVE_DISK_UTIL
 
-#define OS_MMAP_ANON           (MMAP_ANON)
+#define OS_MAP_ANON            (MAP_ANON)
 
 #endif
index 06c32a55bdc5af46e1eb095571e4ae7e5bf735ed..fb06edfd9c2ce429e04a0d504ba1e9350b6bfcfd 100644 (file)
@@ -5,6 +5,7 @@
 #define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_FADVISE
 #define FIO_HAVE_CPU_AFFINITY
+#define FIO_HAVE_DISK_UTIL
 
 #define OS_MAP_ANON            (MAP_ANONYMOUS)
 
@@ -18,5 +19,7 @@ typedef cpu_set_t os_cpu_mask_t;
 
 #define fio_setaffinity(td)            \
        sched_setaffinity((td)->pid, sizeof((td)->cpumask), &(td)->cpumask)
+#define fio_getaffinity(pid, ptr)      \
+       sched_getaffinity((pid), sizeof(cpu_set_t), (ptr))
 
 #endif
diff --git a/os.h b/os.h
index 14065cd2de7a11dc28f646416e47e14324f89020..a6de35c0fead30728d9e6e01a3cea5b50d09a6e8 100644 (file)
--- a/os.h
+++ b/os.h
@@ -3,6 +3,8 @@
 
 #if defined(__linux__)
 #include "os-linux.h"
+#elif defined(__FreeBSD__)
+#include "os-freebsd.h"
 #else
 #error "unsupported os"
 #endif
 #endif
 
 #ifndef FIO_HAVE_FADVISE
-static int fadvise(int fd, loff_t offset, size_t len, int advice)
-{
-       return 0;
-}
+#define fadvise(fd, off, len, advice)  (0)
 
 #define POSIX_FADV_DONTNEED    (0)
 #define POSIX_FADV_SEQUENTIAL  (0)
@@ -27,7 +26,8 @@ static int fadvise(int fd, loff_t offset, size_t len, int advice)
 #endif /* FIO_HAVE_FADVISE */
 
 #ifndef FIO_HAVE_CPU_AFFINITY
-#define fio_setaffinity(td)    do { } while (0)
+#define fio_setaffinity(td)            (0)
+#define fio_getaffinity(pid, mask)     (0)
 #endif
 
 struct thread_data;