Fio version 1.14
[fio.git] / init.c
diff --git a/init.c b/init.c
index 66a50b03dbb8187b88db9fee3f6865a1fd0b26e7..9fc8ff740fd85013f57e94c217addc4b6a28214b 100644 (file)
--- a/init.c
+++ b/init.c
@@ -33,6 +33,7 @@ static int str_cpumask_cb(void *, unsigned int *);
 static int str_fst_cb(void *, const char *);
 static int str_filename_cb(void *, const char *);
 static int str_directory_cb(void *, const char *);
+static int str_opendir_cb(void *, const char *);
 
 #define __stringify_1(x)       #x
 #define __stringify(x)         __stringify_1(x)
@@ -67,6 +68,13 @@ static struct fio_option options[] = {
                .cb     = str_filename_cb,
                .help   = "File(s) to use for the workload",
        },
+       {
+               .name   = "opendir",
+               .type   = FIO_OPT_STR_STORE,
+               .off1   = td_var_offset(opendir),
+               .cb     = str_opendir_cb,
+               .help   = "Recursively add files from this directory and down",
+       },
        {
                .name   = "rw",
                .type   = FIO_OPT_STR,
@@ -499,6 +507,13 @@ static struct fio_option options[] = {
                .help   = "Include fsync at the end of job",
                .def    = "0",
        },
+       {
+               .name   = "fsync_on_close",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(fsync_on_close),
+               .help   = "fsync files on close",
+               .def    = "0",
+       },
        {
                .name   = "unlink",
                .type   = FIO_OPT_BOOL,
@@ -610,7 +625,7 @@ static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = {
 
 static int def_timeout = 0;
 
-static char fio_version_string[] = "fio 1.13";
+static char fio_version_string[] = "fio 1.14";
 
 static char **ini_file;
 static int max_jobs = MAX_JOBS;
@@ -752,9 +767,10 @@ static void fixup_options(struct thread_data *td)
        if (td->iodepth_batch > td->iodepth || !td->iodepth_batch)
                td->iodepth_batch = td->iodepth;
 
-       if (!td->nr_files)
-               td->nr_files = td->open_files;
-       else if (td->open_files > td->nr_files || !td->open_files)
+       if (td->nr_files > td->files_index)
+               td->nr_files = td->files_index;
+
+       if (td->open_files > td->nr_files || !td->open_files)
                td->open_files = td->nr_files;
 }
 
@@ -829,12 +845,16 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (td->odirect)
                td->io_ops->flags |= FIO_RAWIO;
 
-       if (!td->filename) {
+       if (!td->filename && !td->files_index) {
                td->filename = strdup(jobname);
 
-               for (i = 0; i < td->nr_files; i++) {
-                       sprintf(fname, "%s.%d.%d", td->filename, td->thread_number, i);
-                       add_file(td, fname);
+               if (td->nr_files == 1)
+                       add_file(td, td->filename);
+               else {
+                       for (i = 0; i < td->nr_files; i++) {
+                               sprintf(fname, "%s.%d.%d", td->filename, td->thread_number, i);
+                               add_file(td, fname);
+                       }
                }
        }
 
@@ -845,9 +865,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        sprintf(fname, "%s/%s", td->directory, f->file_name);
                        f->file_name = strdup(fname);
                }
-
-               f->file_size = td->total_file_size / td->nr_files;
-               f->file_offset = td->start_offset;
        }
                
        td->mutex = fio_sem_init(0);
@@ -1103,15 +1120,24 @@ static int str_fst_cb(void *data, const char *str)
 static int str_filename_cb(void *data, const char *input)
 {
        struct thread_data *td = data;
-       char *fname, *str;
+       char *fname, *str, *p;
+
+       p = str = strdup(input);
+
+       strip_blank_front(&str);
+       strip_blank_end(str);
+
+       if (!td->files_index)
+               td->nr_files = 0;
 
-       td->nr_files = 0;
-       str = strdup(input);
        while ((fname = strsep(&str, ":")) != NULL) {
+               if (!strlen(fname))
+                       break;
                add_file(td, fname);
                td->nr_files++;
        }
 
+       free(p);
        return 0;
 }
 
@@ -1133,6 +1159,16 @@ static int str_directory_cb(void *data, const char fio_unused *str)
        return 0;
 }
 
+static int str_opendir_cb(void *data, const char fio_unused *str)
+{
+       struct thread_data *td = data;
+
+       if (!td->files_index)
+               td->nr_files = 0;
+
+       return add_dir_files(td, td->opendir);
+}
+
 /*
  * This is our [ini] type file parser.
  */