Use log_info() throughout
[fio.git] / init.c
diff --git a/init.c b/init.c
index 1c62c5ad10af97a2ed1c610323ceccfddde89646..4af00ff98b2273d9788312de6640caf80b157dd7 100644 (file)
--- a/init.c
+++ b/init.c
@@ -183,7 +183,14 @@ static struct fio_option options[] = {
                .name   = "size",
                .type   = FIO_OPT_STR_VAL,
                .off1   = td_var_offset(total_file_size),
-               .help   = "Size of device or file",
+               .help   = "Total size of device or files",
+       },
+       {
+               .name   = "filesize",
+               .type   = FIO_OPT_STR_VAL,
+               .off1   = td_var_offset(file_size_low),
+               .off2   = td_var_offset(file_size_high),
+               .help   = "Size of individual files",
        },
        {
                .name   = "bs",
@@ -696,7 +703,7 @@ static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = {
 
 static int def_timeout = 0;
 
-static char fio_version_string[] = "fio 1.14";
+static char fio_version_string[] = "fio 1.14a";
 
 static char **ini_file;
 static int max_jobs = MAX_JOBS;
@@ -750,7 +757,7 @@ static void put_job(struct thread_data *td)
                return;
 
        if (td->error)
-               fprintf(f_out, "fio: %s\n", td->verror);
+               log_info("fio: %s\n", td->verror);
 
        memset(&threads[td->thread_number - 1], 0, sizeof(*td));
        thread_number--;
@@ -801,6 +808,9 @@ static void fixup_options(struct thread_data *td)
 
        td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]);
 
+       if (!td->file_size_high)
+               td->file_size_high = td->file_size_low;
+
        if (td_read(td) && !td_rw(td))
                td->verify = 0;
 
@@ -893,6 +903,65 @@ static int exists_and_not_file(const char *filename)
        return 1;
 }
 
+/*
+ * Initialize the various random states we need (random io, block size ranges,
+ * read/write mix, etc).
+ */
+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;
+
+       fd = open("/dev/urandom", O_RDONLY);
+       if (fd == -1) {
+               td_verror(td, errno, "open");
+               return 1;
+       }
+
+       if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
+               td_verror(td, EIO, "read");
+               close(fd);
+               return 1;
+       }
+
+       close(fd);
+
+       os_random_seed(seeds[0], &td->bsrange_state);
+       os_random_seed(seeds[1], &td->verify_state);
+       os_random_seed(seeds[2], &td->rwmix_state);
+
+       if (td->file_service_type == FIO_FSERVICE_RANDOM)
+               os_random_seed(seeds[3], &td->next_file_state);
+
+       os_random_seed(seeds[5], &td->file_size_state);
+
+       if (!td_random(td))
+               return 0;
+
+       if (td->rand_repeatable)
+               seeds[4] = FIO_RANDSEED * td->thread_number;
+
+       if (!td->norandommap) {
+               for_each_file(td, f, i) {
+                       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));
+                       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
@@ -966,6 +1035,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        td->groupid = groupid;
        prev_group_jobs++;
 
+       if (init_random_state(td))
+               goto err;
+
        if (setup_rate(td))
                goto err;
 
@@ -982,7 +1054,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (!terse_output) {
                if (!job_add_num) {
                        if (!strcmp(td->io_ops->name, "cpuio"))
-                               fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle);
+                               log_info("%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle);
                        else {
                                char *c1, *c2, *c3, *c4;
 
@@ -991,7 +1063,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                                c3 = to_kmg(td->min_bs[DDIR_WRITE]);
                                c4 = to_kmg(td->max_bs[DDIR_WRITE]);
 
-                               fprintf(f_out, "%s: (g=%d): rw=%s, bs=%s-%s/%s-%s, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[td->td_ddir], c1, c2, c3, c4, td->io_ops->name, td->iodepth);
+                               log_info("%s: (g=%d): rw=%s, bs=%s-%s/%s-%s, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[td->td_ddir], c1, c2, c3, c4, td->io_ops->name, td->iodepth);
 
                                free(c1);
                                free(c2);
@@ -999,7 +1071,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                                free(c4);
                        }
                } else if (job_add_num == 1)
-                       fprintf(f_out, "...\n");
+                       log_info("...\n");
        }
 
        /*
@@ -1039,65 +1111,6 @@ err:
        return -1;
 }
 
-/*
- * Initialize the various random states we need (random io, block size ranges,
- * read/write mix, etc).
- */
-int init_random_state(struct thread_data *td)
-{
-       unsigned long seeds[5];
-       int fd, num_maps, blocks;
-       struct fio_file *f;
-       unsigned int i;
-
-       if (td->io_ops->flags & FIO_DISKLESSIO)
-               return 0;
-
-       fd = open("/dev/urandom", O_RDONLY);
-       if (fd == -1) {
-               td_verror(td, errno, "open");
-               return 1;
-       }
-
-       if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
-               td_verror(td, EIO, "read");
-               close(fd);
-               return 1;
-       }
-
-       close(fd);
-
-       os_random_seed(seeds[0], &td->bsrange_state);
-       os_random_seed(seeds[1], &td->verify_state);
-       os_random_seed(seeds[2], &td->rwmix_state);
-
-       if (td->file_service_type == FIO_FSERVICE_RANDOM)
-               os_random_seed(seeds[3], &td->next_file_state);
-
-       if (!td_random(td))
-               return 0;
-
-       if (td->rand_repeatable)
-               seeds[4] = FIO_RANDSEED * td->thread_number;
-
-       if (!td->norandommap) {
-               for_each_file(td, f, i) {
-                       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));
-                       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;
-}
-
 static void fill_cpu_mask(os_cpu_mask_t cpumask, int cpu)
 {
 #ifdef FIO_HAVE_CPU_AFFINITY