Fix bug with numjobs > 1, directory and filename given
[fio.git] / init.c
diff --git a/init.c b/init.c
index e38d67786a1a80284c1886a90b3e083a19afc5e1..1e0eeccfdc6e5dcbf0b95b0fa479e111108826f6 100644 (file)
--- a/init.c
+++ b/init.c
@@ -171,8 +171,8 @@ static int fixup_options(struct thread_data *td)
 {
        struct thread_options *o = &td->o;
 
-       if (!o->rwmixread && o->rwmixwrite)
-               o->rwmixread = 100 - o->rwmixwrite;
+       if (o->rwmix[DDIR_READ] + o->rwmix[DDIR_WRITE] > 100)
+               o->rwmix[DDIR_WRITE] = 100 - o->rwmix[DDIR_READ];
 
        if (o->write_iolog_file && o->read_iolog_file) {
                log_err("fio: read iolog overrides write_iolog\n");
@@ -323,9 +323,7 @@ static int exists_and_not_file(const char *filename)
 static int init_random_state(struct thread_data *td)
 {
        unsigned long seeds[6];
-       int fd, num_maps, blocks;
-       struct fio_file *f;
-       unsigned int i;
+       int fd;
 
        fd = open("/dev/urandom", O_RDONLY);
        if (fd == -1) {
@@ -356,25 +354,10 @@ static int init_random_state(struct thread_data *td)
        if (td->o.rand_repeatable)
                seeds[4] = FIO_RANDSEED * td->thread_number;
 
-       if (!td->o.norandommap) {
-               for_each_file(td, f, i) {
-                       blocks = (f->real_file_size + td->o.rw_min_bs - 1) / td->o.rw_min_bs;
-                       num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP;
-                       f->file_map = malloc(num_maps * sizeof(long));
-                       if (!f->file_map) {
-                               log_err("fio: failed allocating random map. If running a large number of jobs, try the 'norandommap' option\n");
-                               return 1;
-                       }
-                       f->num_maps = num_maps;
-                       memset(f->file_map, 0, num_maps * sizeof(long));
-               }
-       }
-
        os_random_seed(seeds[4], &td->random_state);
        return 0;
 }
 
-
 /*
  * Adds a job to the list of things todo. Sanitizes the various options
  * to make sure we don't have conflicts, and initializes various
@@ -385,7 +368,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        const char *ddir_str[] = { NULL, "read", "write", "rw", NULL,
                                   "randread", "randwrite", "randrw" };
        unsigned int i;
-       struct fio_file *f;
        const char *engine;
        char fname[PATH_MAX];
        int numjobs, file_alloced;
@@ -428,20 +410,15 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (fixup_options(td))
                goto err;
 
-       for_each_file(td, f, i) {
-               if (td->o.directory && f->filetype == FIO_TYPE_FILE) {
-                       sprintf(fname, "%s/%s", td->o.directory, f->file_name);
-                       f->file_name = strdup(fname);
-               }
-       }
-               
        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;
        td->ts.bw_stat[0].min_val = td->ts.bw_stat[1].min_val = ULONG_MAX;
+       td->ddir_nr = td->o.ddir_nr;
 
-       if ((td->o.stonewall || td->o.numjobs > 1) && prev_group_jobs) {
+       if ((td->o.stonewall || td->o.numjobs > 1 || td->o.new_group)
+            && prev_group_jobs) {
                prev_group_jobs = 0;
                groupid++;
        }
@@ -514,11 +491,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        goto err;
        }
 
-       if (td->o.numjobs > 1) {
-               groupid++;
-               prev_group_jobs = 0;
-       }
-
        return 0;
 err:
        put_job(td);