{ .ival = "randwrite",
.oval = TD_DDIR_RANDWRITE,
.help = "Random write",
- },
+ },
{ .ival = "rw",
.oval = TD_DDIR_RW,
.help = "Sequential read and write mix",
.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",
.name = "verify",
.type = FIO_OPT_STR,
.off1 = td_var_offset(verify),
- .help = "Verify sum function",
+ .help = "Verify data written",
.def = "0",
.posval = {
{ .ival = "0",
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;
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;
return p;
}
+static int exists_and_not_file(const char *filename)
+{
+ struct stat sb;
+
+ if (lstat(filename, &sb) == -1)
+ return 0;
+
+ if (S_ISREG(sb.st_mode))
+ return 0;
+
+ 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
struct fio_file *f;
const char *engine;
char fname[PATH_MAX];
- int numjobs;
+ int numjobs, file_alloced;
/*
* the def_thread is just for options, it's not a real job
if (td->odirect)
td->io_ops->flags |= FIO_RAWIO;
+ file_alloced = 0;
if (!td->filename && !td->files_index) {
- td->filename = strdup(jobname);
+ file_alloced = 1;
- if (td->nr_files == 1)
- add_file(td, td->filename);
+ if (td->nr_files == 1 && exists_and_not_file(jobname))
+ add_file(td, jobname);
else {
for (i = 0; i < td->nr_files; i++) {
- sprintf(fname, "%s.%d.%d", td->filename, td->thread_number, i);
+ sprintf(fname, "%s.%d.%d", jobname, td->thread_number, i);
add_file(td, fname);
}
}
td->groupid = groupid;
prev_group_jobs++;
+ if (init_random_state(td))
+ goto err;
+
if (setup_rate(td))
goto err;
td_new->numjobs = 1;
td_new->stonewall = 0;
+
+ if (file_alloced) {
+ td_new->filename = NULL;
+ td_new->files_index = 0;
+ td_new->files = NULL;
+ }
+
job_add_num = numjobs - 1;
if (add_job(td_new, jobname, job_add_num))
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