[PATCH] fio: various little fixes / docu updates
authorJens Axboe <axboe@suse.de>
Tue, 6 Dec 2005 15:54:46 +0000 (16:54 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 6 Dec 2005 15:54:46 +0000 (16:54 +0100)
README.fio
fio-ini.c
fio-io.c
fio.c
fio.h

index 4e33af3a76d75558a5c585df6a64c0bc0065ea58..66ac18da169843bf8a7869827a62d17aeb1d5dab 100644 (file)
@@ -58,6 +58,7 @@ The <jobs> format is as follows:
                        use crc32 for verifies.
        stonewall       Wait for preceeding jobs to end before running.
        numjobs=x       Create 'x' similar entries for this job
+       thread          Use pthreads instead of forked jobs
 
 
 Examples using a job file
index c9940036a3c507d66f9042c61c17acb3bad317f7..3fa9d09ba1716c29dfa60ad050179faa02da194a 100644 (file)
--- a/fio-ini.c
+++ b/fio-ini.c
@@ -160,8 +160,12 @@ static int add_job(struct thread_data *td, const char *jobname, int prioclass,
        struct stat sb;
        int numjobs;
 
-       if (td == &def_thread)
-               return 0;
+       if (td->io_engine & FIO_SYNCIO)
+               td->iodepth = 1;
+       else {
+               if (!td->iodepth)
+                       td->iodepth = 1;
+       }
 
 #ifndef FIO_HAVE_LIBAIO
        if (td->io_engine == FIO_LIBAIO) {
@@ -179,6 +183,12 @@ static int add_job(struct thread_data *td, const char *jobname, int prioclass,
        td->ioprio = (prioclass << IOPRIO_CLASS_SHIFT) | prio;
 #endif
 
+       /*
+        * the def_thread is just for options, it's not a real job
+        */
+       if (td == &def_thread)
+               return 0;
+
        td->filetype = FIO_TYPE_FILE;
        if (!stat(jobname, &sb) && S_ISBLK(sb.st_mode))
                td->filetype = FIO_TYPE_BD;
@@ -197,13 +207,6 @@ static int add_job(struct thread_data *td, const char *jobname, int prioclass,
        td->slat_stat.min_val = ULONG_MAX;
        td->bw_stat.min_val = ULONG_MAX;
 
-       run_str[td->thread_number - 1] = 'P';
-
-       if ((td->io_engine & FIO_SYNCIO) == 0) {
-               if (!td->iodepth)
-                       td->iodepth = 1;
-       }
-
        if (td->min_bs == -1U)
                td->min_bs = td->bs;
        if (td->max_bs == -1U)
index 92a03b0c34f812f03e1a3e8bcf2240180ac47560..f663dbae2bdfa2174f6ea58255754aa3d332ce57 100644 (file)
--- a/fio-io.c
+++ b/fio-io.c
@@ -1,7 +1,15 @@
+/*
+ * The io parts of the fio tool, includes workers for sync and mmap'ed
+ * io, as well as both posix and linux libaio support.
+ *
+ * sync io is implemented on top of aio.
+ *
+ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
+#include <assert.h>
 #include <sys/mman.h>
 #include "fio.h"
 #include "os.h"
@@ -262,6 +270,12 @@ struct syncio_data {
 static int fio_syncio_getevents(struct thread_data *td, int min, int max,
                                struct timespec *t)
 {
+       assert(max <= 1);
+
+       /*
+        * we can only have one finished io_u for sync io, since the depth
+        * is always 1
+        */
        if (list_empty(&td->io_u_busylist))
                return 0;
 
@@ -272,6 +286,8 @@ static struct io_u *fio_syncio_event(struct thread_data *td, int event)
 {
        struct syncio_data *sd = td->io_data;
 
+       assert(event == 0);
+
        return sd->last_io_u;
 }
 
diff --git a/fio.c b/fio.c
index 7032e8d85eca9849cf14c5cad7f132c218d8557b..546ac98b304cbdfa179c960de640bb322c0b4089 100644 (file)
--- a/fio.c
+++ b/fio.c
 
 int groupid = 0;
 int thread_number = 0;
-char run_str[MAX_JOBS + 1];
+static char run_str[MAX_JOBS + 1];
 int shm_id = 0;
 static LIST_HEAD(disk_list);
+static struct itimerval itimer;
 
 static void update_io_ticks(void);
 static void disk_util_timer_arm(void);
@@ -1546,8 +1547,6 @@ static void init_disk_util(struct thread_data *td)
 
 static void disk_util_timer_arm(void)
 {
-       struct itimerval itimer;
-
        itimer.it_value.tv_sec = 0;
        itimer.it_value.tv_usec = DISK_UTIL_MSEC * 1000;
        setitimer(ITIMER_REAL, &itimer, NULL);
@@ -1854,6 +1853,8 @@ static void run_threads(void)
        for (i = 0; i < thread_number; i++) {
                td = &threads[i];
 
+               run_str[td->thread_number - 1] = 'P';
+
                init_disk_util(td);
 
                if (!td->create_serialize)
@@ -2062,8 +2063,6 @@ static void show_run_stats(void)
 
 int main(int argc, char *argv[])
 {
-       memset(run_str, 0, sizeof(run_str));
-
        if (parse_options(argc, argv))
                return 1;
 
diff --git a/fio.h b/fio.h
index b71c301c751c9c04b51f1604967ae319d27df5c0..de065cd4be7d2b320ab2f7944b9cbee9cce2913a 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -225,8 +225,6 @@ extern int thread_number;
 extern int shm_id;
 extern int groupid;
 
-extern char run_str[];
-
 extern struct thread_data *threads;
 
 enum {