#define ALIGN(buf) (char *) (((unsigned long) (buf) + MASK) & ~(MASK))
-static int sequential = DEF_SEQUENTIAL;
static int write_stat = DEF_WRITESTAT;
static int repeatable = DEF_RAND_REPEAT;
-static int timeout = DEF_TIMEOUT;
-static int odirect = DEF_ODIRECT;
-static int global_bs = DEF_BS;
static int rate_quit = 1;
static int thread_number;
static int shm_id;
-static cpu_set_t def_cpumask;
-
enum {
DDIR_READ = 0,
DDIR_WRITE,
unsigned int delay_sleep;
unsigned int fsync_blocks;
unsigned int start_delay;
+ unsigned int timeout;
unsigned int use_aio;
cpu_set_t cpumask;
};
static struct thread_data *threads;
+static struct thread_data def_thread;
static sem_t startup_sem;
return 0;
}
-static struct thread_data *get_new_job(void)
+static struct thread_data *get_new_job(int global)
{
struct thread_data *td;
+ if (global)
+ return &def_thread;
if (thread_number >= MAX_JOBS)
return NULL;
memset(td, 0, sizeof(*td));
td->thread_number = thread_number;
- td->ddir = DDIR_READ;
- td->bs = global_bs;
- td->odirect = 1;
- td->delay_sleep = 0;
- td->rate = 0;
- td->ratecycle = DEF_RATE_CYCLE;
- td->sequential = sequential;
- td->ioprio = 0;
- td->use_aio = 0;
- td->aio_depth = 0;
- td->aio_cur_depth = 0;
- memcpy(&td->cpumask, &def_cpumask, sizeof(td->cpumask));
+ td->ddir = def_thread.ddir;
+ td->bs = def_thread.bs;
+ td->odirect = def_thread.odirect;
+ td->ratecycle = def_thread.ratecycle;
+ td->sequential = def_thread.sequential;
+ memcpy(&td->cpumask, &def_thread.cpumask, sizeof(td->cpumask));
return td;
}
static int add_job(struct thread_data *td, const char *filename, int prioclass,
int prio)
{
+ if (td == &def_thread)
+ return 0;
+
strcpy(td->file_name, filename);
td->stat_fd = -1;
sem_init(&td->mutex, 1, 0);
filename[0] = 0;
- td = get_new_job();
+ td = get_new_job(0);
if (!td)
break;
unsigned int i;
for (i = 0; i < strlen(line); i++) {
- if (!isspace(line[i]) && !iscntrl(line[i]))
- return 0;
if (line[i] == ';')
+ return 1;
+ if (!isspace(line[i]) && !iscntrl(line[i]))
return 0;
}
static int parse_jobs_ini(char *file)
{
- unsigned int prioclass, prio, cpu;
+ unsigned int prioclass, prio, cpu, global;
struct thread_data *td;
char *string, *name;
fpos_t off;
if (sscanf(p, "[%s]", name) != 1)
continue;
+ global = !strncmp(name, "global", 6);
+
name[strlen(name) - 1] = '\0';
- td = get_new_job();
+ td = get_new_job(global);
if (!td)
break;
switch (*parm) {
case 's':
parm++;
- sequential = !!atoi(parm);
+ def_thread.sequential = !!atoi(parm);
break;
case 'b':
parm++;
- global_bs = atoi(parm);
- global_bs <<= 10;
- if (!global_bs) {
+ def_thread.bs = atoi(parm);
+ def_thread.bs <<= 10;
+ if (!def_thread.bs) {
printf("bad block size\n");
- global_bs = DEF_BS;
+ def_thread.bs = DEF_BS;
}
break;
case 't':
parm++;
- timeout = atoi(parm);
+ def_thread.timeout = atoi(parm);
break;
case 'w':
parm++;
break;
case 'o':
parm++;
- odirect = !!atoi(parm);
+ def_thread.odirect = !!atoi(parm);
break;
case 'f':
if (i + 1 >= argc) {
signal(SIGINT, sig_handler);
- if (timeout) {
+ if (def_thread.timeout) {
signal(SIGALRM, sig_handler);
- alarm(timeout);
+ alarm(def_thread.timeout);
}
todo = thread_number;
atexit(free_shm);
- if (sched_getaffinity(getpid(), sizeof(def_cpumask), &def_cpumask) == -1) {
+ if (sched_getaffinity(getpid(), sizeof(cpu_set_t), &def_thread.cpumask) == -1) {
perror("sched_getaffinity");
return 1;
}
+ /*
+ * fill globals
+ */
+ def_thread.ddir = DDIR_READ;
+ def_thread.bs = DEF_BS;
+ def_thread.odirect = 1;
+ def_thread.ratecycle = DEF_RATE_CYCLE;
+ def_thread.sequential = 1;
+ def_thread.timeout = DEF_TIMEOUT;
+
i = parse_options(argc, argv);
if (ini_file) {
return 1;
}
- printf("%s: %s, bs=%uKiB, timeo=%u, write_stat=%u, odirect=%d\n", argv[0], sequential ? "sequential" : "random", global_bs >> 10, timeout, write_stat, odirect);
+ printf("%s: %s, bs=%uKiB, timeo=%u, write_stat=%u, odirect=%d\n", argv[0], def_thread.sequential ? "sequential" : "random", def_thread.bs >> 10, def_thread.timeout, write_stat, def_thread.odirect);
run_threads(argv);