[PATCH] Make fio build again on "crippled" platforms
[fio.git] / init.c
diff --git a/init.c b/init.c
index 3532c49d968a7436699b8c9a3e75d9d5ed0d2a2e..3c27ea55aa09107a9a62595aa658c86ce11871c5 100644 (file)
--- a/init.c
+++ b/init.c
@@ -60,8 +60,10 @@ static int str_ioengine_cb(void *, const char *);
 static int str_mem_cb(void *, const char *);
 static int str_verify_cb(void *, const char *);
 static int str_lockmem_cb(void *, unsigned long *);
+#ifdef FIO_HAVE_IOPRIO
 static int str_prio_cb(void *, unsigned int *);
 static int str_prioclass_cb(void *, unsigned int *);
+#endif
 static int str_exitall_cb(void);
 static int str_cpumask_cb(void *, unsigned int *);
 
@@ -138,8 +140,18 @@ static struct fio_option options[] = {
        },
        {
                .name   = "bs",
-               .type   = FIO_OPT_STR_VAL,
-               .off1   = td_var_offset(bs),
+               .type   = FIO_OPT_STR_VAL_INT,
+               .off1   = td_var_offset(bs[DDIR_READ]),
+       },
+       {
+               .name   = "read_bs",
+               .type   = FIO_OPT_STR_VAL_INT,
+               .off1   = td_var_offset(bs[DDIR_READ]),
+       },
+       {
+               .name   = "write_bs",
+               .type   = FIO_OPT_STR_VAL_INT,
+               .off1   = td_var_offset(bs[DDIR_WRITE]),
        },
        {
                .name   = "offset",
@@ -164,8 +176,20 @@ static struct fio_option options[] = {
        {
                .name   = "bsrange",
                .type   = FIO_OPT_RANGE,
-               .off1   = td_var_offset(min_bs),
-               .off2   = td_var_offset(max_bs),
+               .off1   = td_var_offset(min_bs[DDIR_READ]),
+               .off2   = td_var_offset(max_bs[DDIR_READ]),
+       },
+       {
+               .name   = "read_bsrange",
+               .type   = FIO_OPT_RANGE,
+               .off1   = td_var_offset(min_bs[DDIR_READ]),
+               .off2   = td_var_offset(max_bs[DDIR_READ]),
+       },
+       {
+               .name   = "write_bsrange",
+               .type   = FIO_OPT_RANGE,
+               .off1   = td_var_offset(min_bs[DDIR_WRITE]),
+               .off2   = td_var_offset(max_bs[DDIR_WRITE]),
        },
        {
                .name   = "nrfiles",
@@ -484,10 +508,19 @@ static void fixup_options(struct thread_data *td)
        if (td_read(td) || td_rw(td))
                td->overwrite = 1;
 
-       if (!td->min_bs)
-               td->min_bs = td->bs;
-       if (!td->max_bs)
-               td->max_bs = td->bs;
+       if (td->bs[DDIR_READ] != DEF_BS)
+               td->bs[DDIR_WRITE] = td->bs[DDIR_READ];
+       if (!td->min_bs[DDIR_READ])
+               td->min_bs[DDIR_READ]= td->bs[DDIR_READ];
+       if (!td->max_bs[DDIR_READ])
+               td->max_bs[DDIR_READ] = td->bs[DDIR_READ];
+       if (!td->min_bs[DDIR_WRITE])
+               td->min_bs[DDIR_WRITE]= td->bs[DDIR_WRITE];
+       if (!td->max_bs[DDIR_WRITE])
+               td->max_bs[DDIR_WRITE] = td->bs[DDIR_WRITE];
+
+       td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]);
+
        if (td_read(td) && !td_rw(td))
                td->verify = 0;
 
@@ -512,19 +545,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        int numjobs, ddir, i;
        struct fio_file *f;
 
-#ifndef FIO_HAVE_LIBAIO
-       if (td->io_engine == FIO_LIBAIO) {
-               log_err("Linux libaio not available\n");
-               return 1;
-       }
-#endif
-#ifndef FIO_HAVE_POSIXAIO
-       if (td->io_engine == FIO_POSIXAIO) {
-               log_err("posix aio not available\n");
-               return 1;
-       }
-#endif
-
        /*
         * the def_thread is just for options, it's not a real job
         */
@@ -626,7 +646,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        if (td->io_ops->flags & FIO_CPUIO)
                                fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle);
                        else
-                               fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_ops->name, td->iodepth);
+                               fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d/%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs[DDIR_READ], td->max_bs[DDIR_READ], td->min_bs[DDIR_WRITE], td->max_bs[DDIR_WRITE], td->rate, td->io_ops->name, td->iodepth);
                } else if (job_add_num == 1)
                        fprintf(f_out, "...\n");
        }
@@ -694,7 +714,7 @@ int init_random_state(struct thread_data *td)
 
        if (!td->norandommap) {
                for_each_file(td, f, i) {
-                       blocks = (f->file_size + td->min_bs - 1) / td->min_bs;
+                       blocks = (f->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;
@@ -826,6 +846,7 @@ static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
        return 0;
 }
 
+#ifdef FIO_HAVE_IOPRIO
 static int str_prioclass_cb(void *data, unsigned int *val)
 {
        struct thread_data *td = data;
@@ -841,6 +862,7 @@ static int str_prio_cb(void *data, unsigned int *val)
        td->ioprio |= *val;
        return 0;
 }
+#endif
 
 static int str_exitall_cb(void)
 {
@@ -958,9 +980,10 @@ static int fill_def_thread(void)
         */
        def_thread.ddir = DDIR_READ;
        def_thread.iomix = 0;
-       def_thread.bs = DEF_BS;
-       def_thread.min_bs = 0;
-       def_thread.max_bs = 0;
+       def_thread.bs[DDIR_READ] = DEF_BS;
+       def_thread.bs[DDIR_WRITE] = DEF_BS;
+       def_thread.min_bs[DDIR_READ] = def_thread.min_bs[DDIR_WRITE] = 0;
+       def_thread.max_bs[DDIR_READ] = def_thread.max_bs[DDIR_WRITE] = 0;
        def_thread.odirect = DEF_ODIRECT;
        def_thread.ratecycle = DEF_RATE_CYCLE;
        def_thread.sequential = DEF_SEQUENTIAL;