[PATCH] Add thinktime_spin parameter
[fio.git] / init.c
diff --git a/init.c b/init.c
index 32e22dbe87470360b62b31220be87ccaad5b8f3a..9e7fb2c055e62a17ceac9dbf78757d1b83bd357c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -81,7 +81,7 @@ static struct fio_option options[] = {
                .help   = "IO engine to use",
                .def    = "sync",
                .posval = { "sync", "libaio", "posixaio", "mmap", "splice",
-                               "sg", "null", },
+                               "sg", "null", "net", "syslet-rw" },
        },
        {
                .name   = "iodepth",
@@ -330,6 +330,13 @@ static struct fio_option options[] = {
                .help   = "Idle time between IO buffers (usec)",
                .def    = "0",
        },
+       {
+               .name   = "thinktime_spin",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(thinktime_spin),
+               .help   = "Start thinktime by spinning this amount (usec)",
+               .def    = "0",
+       },
        {
                .name   = "thinktime_blocks",
                .type   = FIO_OPT_INT,
@@ -564,6 +571,9 @@ static void put_job(struct thread_data *td)
        if (td == &def_thread)
                return;
 
+       if (td->error)
+               fprintf(f_out, "fio: %s\n", td->verror);
+
        memset(&threads[td->thread_number - 1], 0, sizeof(*td));
        thread_number--;
 }
@@ -628,6 +638,12 @@ static void fixup_options(struct thread_data *td)
         */
        if (td->filetype == FIO_TYPE_CHAR && td->odirect)
                td->odirect = 0;
+
+       /*
+        * thinktime_spin must be less than thinktime
+        */
+       if (td->thinktime_spin > td->thinktime)
+               td->thinktime_spin = td->thinktime;
 }
 
 /*
@@ -636,7 +652,7 @@ static void fixup_options(struct thread_data *td)
 static char *to_kmg(unsigned int val)
 {
        char *buf = malloc(32);
-       char post[] = { 0, 'K', 'M', 'G', 'P', 0 };
+       char post[] = { 0, 'K', 'M', 'G', 'P', 'E', 0 };
        char *p = post;
 
        do {
@@ -676,7 +692,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                td->io_ops->flags |= FIO_RAWIO;
 
        td->filetype = FIO_TYPE_FILE;
-       if (!stat(jobname, &sb)) {
+       if (td->filename && !lstat(td->filename, &sb)) {
                if (S_ISBLK(sb.st_mode))
                        td->filetype = FIO_TYPE_BD;
                else if (S_ISCHR(sb.st_mode))
@@ -694,8 +710,18 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                char tmp[PATH_MAX];
                int len = 0;
 
-               if (td->directory && td->directory[0] != '\0')
+               if (td->directory && td->directory[0] != '\0') {
+                       if (lstat(td->directory, &sb) < 0) {
+                               log_err("fio: %s is not a directory\n", td->directory);
+                               td_verror(td, errno);
+                               return 1;
+                       }
+                       if (!S_ISDIR(sb.st_mode)) {
+                               log_err("fio: %s is not a directory\n", td->directory);
+                               return 1;
+                       }
                        len = sprintf(tmp, "%s/", td->directory);
+               }
 
                td->files = malloc(sizeof(struct fio_file) * td->nr_files);
 
@@ -832,11 +858,11 @@ int init_random_state(struct thread_data *td)
                return 0;
 
        if (td->rand_repeatable)
-               seeds[3] = FIO_RANDSEED;
+               seeds[3] = FIO_RANDSEED * td->thread_number;
 
        if (!td->norandommap) {
                for_each_file(td, f, i) {
-                       blocks = (f->file_size + td->rw_min_bs - 1) / td->rw_min_bs;
+                       blocks = (f->real_file_size + td->rw_min_bs - 1) / td->rw_min_bs;
                        num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP;
                        f->file_map = malloc(num_maps * sizeof(long));
                        f->num_maps = num_maps;