Add a real semaphore implemtation
[fio.git] / init.c
diff --git a/init.c b/init.c
index af7f2c8f14ec1cce773e3b3cc94c88f07382377c..c75bed21d670b29fae359c917af5aaed12331334 100644 (file)
--- a/init.c
+++ b/init.c
@@ -181,6 +181,12 @@ static struct fio_option options[] = {
                .help   = "Split job workload between this number of files",
                .def    = "1",
        },
+       {
+               .name   = "openfiles",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(open_files),
+               .help   = "Number of files to keep open at the same time",
+       },
        {
                .name   = "file_service_type",
                .type   = FIO_OPT_STR,
@@ -530,6 +536,12 @@ static struct fio_option options[] = {
                .help   = "When using hugepages, specify size of each page",
                .def    = __stringify(FIO_HUGE_PAGE),
        },
+       {
+               .name   = "group_reporting",
+               .type   = FIO_OPT_STR_SET,
+               .off1   = td_var_offset(group_reporting),
+               .help   = "Do reporting on a per-group basis",
+       },
        {
                .name = NULL,
        },
@@ -668,13 +680,13 @@ static void fixup_options(struct thread_data *td)
                td->iodepth = 1;
        else {
                if (!td->iodepth)
-                       td->iodepth = td->nr_files;
+                       td->iodepth = td->open_files;
        }
 
        /*
         * only really works for sequential io for now, and with 1 file
         */
-       if (td->zone_size && td_random(td) && td->nr_files == 1)
+       if (td->zone_size && td_random(td) && td->open_files == 1)
                td->zone_size = 0;
 
        /*
@@ -736,6 +748,9 @@ static void fixup_options(struct thread_data *td)
         */
        if (td->iodepth_batch > td->iodepth || !td->iodepth_batch)
                td->iodepth_batch = td->iodepth;
+
+       if (td->open_files > td->nr_files || !td->open_files)
+               td->open_files = td->nr_files;
 }
 
 /*
@@ -796,7 +811,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (td->filename)
                td->nr_uniq_files = 1;
        else
-               td->nr_uniq_files = td->nr_files;
+               td->nr_uniq_files = td->open_files;
 
        if (td->filetype == FIO_TYPE_FILE || td->filename) {
                char tmp[PATH_MAX];
@@ -815,7 +830,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        len = sprintf(tmp, "%s/", td->directory);
                }
 
-               td->files = malloc(sizeof(struct fio_file) * td->nr_files);
+               td->files = malloc(sizeof(struct fio_file) * td->open_files);
 
                for_each_file(td, f, i) {
                        memset(f, 0, sizeof(*f));
@@ -828,7 +843,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        f->file_name = strdup(tmp);
                }
        } else {
-               td->nr_files = 1;
+               td->open_files = td->nr_files = 1;
                td->files = malloc(sizeof(struct fio_file));
                f = &td->files[0];
 
@@ -842,7 +857,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                f->file_offset = td->start_offset;
        }
                
-       fio_sem_init(&td->mutex, 0);
+       td->mutex = fio_sem_init(0);
 
        td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX;
        td->ts.slat_stat[0].min_val = td->ts.slat_stat[1].min_val = ULONG_MAX;