#include "fio.h"
#include "parse.h"
+#include "smalloc.h"
+#include "filehash.h"
-static char fio_version_string[] = "fio 1.19";
+static char fio_version_string[] = "fio 1.20-rc3";
#define FIO_RANDSEED (0xb1899bedUL)
int write_bw_log = 0;
int read_only = 0;
-static int def_timeout = 0;
-static int write_lat_log = 0;
+static int def_timeout;
+static int write_lat_log;
static int prev_group_jobs;
* Command line options. These will contain the above, plus a few
* extra that only pertain to fio itself and not jobs.
*/
-static struct option long_options[FIO_NR_OPTIONS] = {
+static struct option l_opts[FIO_NR_OPTIONS] = {
{
.name = "output",
.has_arg = required_argument,
struct thread_options *o = &td->o;
if (read_only && td_write(td)) {
- log_err("fio: job <%s> has write bit set, but fio is in read-only mode\n", td->o.name);
+ log_err("fio: job <%s> has write bit set, but fio is in"
+ " read-only mode\n", td->o.name);
return 1;
}
-
+
if (o->rwmix[DDIR_READ] + o->rwmix[DDIR_WRITE] > 100)
o->rwmix[DDIR_WRITE] = 100 - o->rwmix[DDIR_READ];
o->overwrite = 1;
if (!o->min_bs[DDIR_READ])
- o->min_bs[DDIR_READ]= o->bs[DDIR_READ];
+ o->min_bs[DDIR_READ] = o->bs[DDIR_READ];
if (!o->max_bs[DDIR_READ])
o->max_bs[DDIR_READ] = o->bs[DDIR_READ];
if (!o->min_bs[DDIR_WRITE])
- o->min_bs[DDIR_WRITE]= o->bs[DDIR_WRITE];
+ o->min_bs[DDIR_WRITE] = o->bs[DDIR_WRITE];
if (!o->max_bs[DDIR_WRITE])
o->max_bs[DDIR_WRITE] = o->bs[DDIR_WRITE];
if (o->fill_device && !o->size)
o->size = ULONG_LONG_MAX;
-
+
if (td_rw(td) && td->o.verify != VERIFY_NONE)
log_info("fio: mixed read/write workload with verify. May not "
"work as expected, unless you pre-populated the file\n");
td->io_ops->flags |= FIO_RAWIO;
file_alloced = 0;
- if (!td->o.filename && !td->files_index) {
+ if (!td->o.filename && !td->files_index && !td->o.read_iolog_file) {
file_alloced = 1;
if (td->o.nr_files == 1 && exists_and_not_file(jobname))
add_file(td, jobname);
else {
for (i = 0; i < td->o.nr_files; i++) {
- sprintf(fname, "%s.%d.%d", jobname, td->thread_number, i);
+ sprintf(fname, "%s.%d.%d", jobname,
+ td->thread_number, i);
add_file(td, fname);
}
}
f->real_file_size = -1ULL;
}
- td->mutex = fio_sem_init(0);
+ td->mutex = fio_mutex_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;
if (!terse_output) {
if (!job_add_num) {
- if (!strcmp(td->io_ops->name, "cpuio"))
- log_info("%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->o.name, td->o.cpuload, td->o.cpucycle);
- else {
+ if (!strcmp(td->io_ops->name, "cpuio")) {
+ log_info("%s: ioengine=cpu, cpuload=%u,"
+ " cpucycle=%u\n", td->o.name,
+ td->o.cpuload,
+ td->o.cpucycle);
+ } else {
char *c1, *c2, *c3, *c4;
c1 = to_kmg(td->o.min_bs[DDIR_READ]);
c3 = to_kmg(td->o.min_bs[DDIR_WRITE]);
c4 = to_kmg(td->o.max_bs[DDIR_WRITE]);
- log_info("%s: (g=%d): rw=%s, bs=%s-%s/%s-%s, ioengine=%s, iodepth=%u\n", td->o.name, td->groupid, ddir_str[td->o.td_ddir], c1, c2, c3, c4, td->io_ops->name, td->o.iodepth);
+ log_info("%s: (g=%d): rw=%s, bs=%s-%s/%s-%s,"
+ " ioengine=%s, iodepth=%u\n",
+ td->o.name, td->groupid,
+ ddir_str[td->o.td_ddir],
+ c1, c2, c3, c4,
+ td->io_ops->name,
+ td->o.iodepth);
free(c1);
free(c2);
if (sscanf(p, "[%255s]", name) != 1) {
if (inside_skip)
continue;
- log_err("fio: option <%s> outside of [] job section\n", p);
+ log_err("fio: option <%s> outside of [] job section\n",
+ p);
break;
}
threads = NULL;
shmctl(shm_id, IPC_RMID, &sbuf);
}
+
+ scleanup();
}
/*
* The thread area is shared between the main process and the job
* threads/processes. So setup a shared memory segment that will hold
- * all the job info.
+ * all the job info. We use the end of the region for keeping track of
+ * open files across jobs, for file sharing.
*/
static int setup_thread_area(void)
{
+ void *hash;
+
/*
* 1024 is too much on some machines, scale max_jobs if
* we get a failure that looks like too large a shm segment
do {
size_t size = max_jobs * sizeof(struct thread_data);
+ size += file_hash_size;
+
shm_id = shmget(0, size, IPC_CREAT | 0600);
if (shm_id != -1)
break;
}
memset(threads, 0, max_jobs * sizeof(struct thread_data));
+ hash = (void *) threads + max_jobs * sizeof(struct thread_data);
+ file_hash_init(hash);
atexit(free_shm);
return 0;
}
printf("\t--minimal\tMinimal (terse) output\n");
printf("\t--version\tPrint version info and exit\n");
printf("\t--help\t\tPrint this page\n");
- printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of them\n");
+ printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of"
+ " them\n");
printf("\t--showcmd\tTurn a job file into command line options\n");
printf("\t--eta=when\tWhen ETA estimate should be printed\n");
printf("\t \tMay be \"always\", \"never\" or \"auto\"\n");
- printf("\t--readonly\tTurn on safety read-only checks, preventing writes\n");
+ printf("\t--readonly\tTurn on safety read-only checks, preventing"
+ " writes\n");
printf("\t--section=name\tOnly run specified section in job file\n");
}
{ .name = "verify", .shift = FD_VERIFY },
{ .name = "random", .shift = FD_RANDOM },
{ .name = "parse", .shift = FD_PARSE },
+ { .name = "diskutil", .shift = FD_DISKUTIL },
{ },
};
struct thread_data *td = NULL;
int c, ini_idx = 0, lidx, ret = 0, do_exit = 0, exit_val = 0;
- while ((c = getopt_long_only(argc, argv, "", long_options, &lidx)) != -1) {
+ while ((c = getopt_long_only(argc, argv, "", l_opts, &lidx)) != -1) {
switch (c) {
case 't':
def_timeout = atoi(optarg);
break;
case 'x':
if (!strcmp(optarg, "global")) {
- log_err("fio: can't use global as only section\n");
+ log_err("fio: can't use global as only "
+ "section\n");
do_exit++;
exit_val = 1;
break;
job_section = strdup(optarg);
break;
case FIO_GETOPT_JOB: {
- const char *opt = long_options[lidx].name;
+ const char *opt = l_opts[lidx].name;
char *val = optarg;
if (!strncmp(opt, "name", 4) && td) {
f_out = stdout;
f_err = stderr;
- fio_options_dup_and_init(long_options);
+ fio_options_dup_and_init(l_opts);
if (setup_thread_area())
return 1;