#include <sys/stat.h>
#include "fio.h"
+#include "verify.h"
#include "parse.h"
#include "lib/fls.h"
return bsp1->perc < bsp2->perc;
}
-static int str_bssplit_cb(void *data, const char *input)
+static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
{
- struct thread_data *td = data;
- char *fname, *str, *p;
+ struct bssplit *bssplit;
unsigned int i, perc, perc_missing;
unsigned int max_bs, min_bs;
long long val;
+ char *fname;
- p = str = strdup(input);
-
- strip_blank_front(&str);
- strip_blank_end(str);
-
- td->o.bssplit_nr = 4;
- td->o.bssplit = malloc(4 * sizeof(struct bssplit));
+ td->o.bssplit_nr[ddir] = 4;
+ bssplit = malloc(4 * sizeof(struct bssplit));
i = 0;
max_bs = 0;
/*
* grow struct buffer, if needed
*/
- if (i == td->o.bssplit_nr) {
- td->o.bssplit_nr <<= 1;
- td->o.bssplit = realloc(td->o.bssplit,
- td->o.bssplit_nr
+ if (i == td->o.bssplit_nr[ddir]) {
+ td->o.bssplit_nr[ddir] <<= 1;
+ bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
* sizeof(struct bssplit));
}
if (val < min_bs)
min_bs = val;
- td->o.bssplit[i].bs = val;
- td->o.bssplit[i].perc = perc;
+ bssplit[i].bs = val;
+ bssplit[i].perc = perc;
i++;
}
- td->o.bssplit_nr = i;
+ td->o.bssplit_nr[ddir] = i;
/*
* Now check if the percentages add up, and how much is missing
*/
perc = perc_missing = 0;
- for (i = 0; i < td->o.bssplit_nr; i++) {
- struct bssplit *bsp = &td->o.bssplit[i];
+ for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
+ struct bssplit *bsp = &bssplit[i];
if (bsp->perc == (unsigned char) -1)
perc_missing++;
if (perc > 100) {
log_err("fio: bssplit percentages add to more than 100%%\n");
- free(td->o.bssplit);
+ free(bssplit);
return 1;
}
/*
* them.
*/
if (perc_missing) {
- for (i = 0; i < td->o.bssplit_nr; i++) {
- struct bssplit *bsp = &td->o.bssplit[i];
+ for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
+ struct bssplit *bsp = &bssplit[i];
if (bsp->perc == (unsigned char) -1)
bsp->perc = (100 - perc) / perc_missing;
}
}
- td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs;
- td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs;
+ td->o.min_bs[ddir] = min_bs;
+ td->o.max_bs[ddir] = max_bs;
/*
* now sort based on percentages, for ease of lookup
*/
- qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp);
+ qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
+ td->o.bssplit[ddir] = bssplit;
+ return 0;
+
+}
+
+static int str_bssplit_cb(void *data, const char *input)
+{
+ struct thread_data *td = data;
+ char *str, *p, *odir;
+ int ret = 0;
+
+ p = str = strdup(input);
+
+ strip_blank_front(&str);
+ strip_blank_end(str);
+
+ odir = strchr(str, ',');
+ if (odir) {
+ ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
+ if (!ret) {
+ *odir = '\0';
+ ret = bssplit_ddir(td, DDIR_READ, str);
+ }
+ } else {
+ char *op;
+
+ op = strdup(str);
+
+ ret = bssplit_ddir(td, DDIR_READ, str);
+ if (!ret)
+ ret = bssplit_ddir(td, DDIR_WRITE, op);
+
+ free(op);
+ }
free(p);
- return 0;
+ return ret;
}
static int str_rw_cb(void *data, const char *str)
.type = FIO_OPT_STR_STORE,
.off1 = td_var_offset(filename),
.cb = str_filename_cb,
- .prio = 1, /* must come before "directory" */
+ .prio = -1, /* must come after "directory" */
.help = "File(s) to use for the workload",
},
{
.def = "4k",
.parent = "rw",
},
+ {
+ .name = "ba",
+ .alias = "blockalign",
+ .type = FIO_OPT_STR_VAL_INT,
+ .off1 = td_var_offset(ba[DDIR_READ]),
+ .off2 = td_var_offset(ba[DDIR_WRITE]),
+ .minval = 1,
+ .help = "IO block offset alignment",
+ .parent = "rw",
+ },
{
.name = "bsrange",
.alias = "blocksize_range",
.oval = FIO_FSERVICE_RR,
.help = "Round robin select files",
},
+ { .ival = "sequential",
+ .oval = FIO_FSERVICE_SEQ,
+ .help = "Finish one file before moving to the next",
+ },
},
.parent = "nrfiles",
},
.help = "Fsync file after creation",
.def = "1",
},
+ {
+ .name = "create_on_open",
+ .type = FIO_OPT_BOOL,
+ .off1 = td_var_offset(create_on_open),
+ .help = "Create files when they are opened for IO",
+ .def = "0",
+ },
+ {
+ .name = "pre_read",
+ .type = FIO_OPT_BOOL,
+ .off1 = td_var_offset(pre_read),
+ .help = "Preread files before starting official testing",
+ .def = "0",
+ },
{
.name = "cpuload",
.type = FIO_OPT_INT,