Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 1 | /* |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 2 | * This file contains job initialization and setup functions. |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 3 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <unistd.h> |
| 7 | #include <fcntl.h> |
| 8 | #include <ctype.h> |
| 9 | #include <string.h> |
| 10 | #include <errno.h> |
| 11 | #include <sys/ipc.h> |
| 12 | #include <sys/shm.h> |
| 13 | #include <sys/types.h> |
| 14 | #include <sys/stat.h> |
| 15 | |
| 16 | #include "fio.h" |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 17 | #include "parse.h" |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 18 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 19 | /* |
| 20 | * The default options |
| 21 | */ |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 22 | #define DEF_BS (4096) |
| 23 | #define DEF_TIMEOUT (0) |
| 24 | #define DEF_RATE_CYCLE (1000) |
| 25 | #define DEF_ODIRECT (1) |
| 26 | #define DEF_IO_ENGINE (FIO_SYNCIO) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 27 | #define DEF_IO_ENGINE_NAME "sync" |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 28 | #define DEF_SEQUENTIAL (1) |
| 29 | #define DEF_RAND_REPEAT (1) |
| 30 | #define DEF_OVERWRITE (1) |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 31 | #define DEF_INVALIDATE (1) |
| 32 | #define DEF_SYNCIO (0) |
| 33 | #define DEF_RANDSEED (0xb1899bedUL) |
| 34 | #define DEF_BWAVGTIME (500) |
| 35 | #define DEF_CREATE_SER (1) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 36 | #define DEF_CREATE_FSYNC (1) |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 37 | #define DEF_LOOPS (1) |
| 38 | #define DEF_VERIFY (0) |
| 39 | #define DEF_STONEWALL (0) |
| 40 | #define DEF_NUMJOBS (1) |
| 41 | #define DEF_USE_THREAD (0) |
| 42 | #define DEF_FILE_SIZE (1024 * 1024 * 1024UL) |
| 43 | #define DEF_ZONE_SIZE (0) |
| 44 | #define DEF_ZONE_SKIP (0) |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 45 | #define DEF_RWMIX_CYCLE (500) |
| 46 | #define DEF_RWMIX_READ (50) |
Jens Axboe | b6f4d88 | 2006-06-02 10:32:51 +0200 | [diff] [blame] | 47 | #define DEF_NICE (0) |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 48 | #define DEF_NR_FILES (1) |
Jens Axboe | f6cbb26 | 2006-10-18 14:16:42 +0200 | [diff] [blame] | 49 | #define DEF_UNLINK (0) |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 50 | #define DEF_WRITE_BW_LOG (0) |
| 51 | #define DEF_WRITE_LAT_LOG (0) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 52 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 53 | static int def_timeout = DEF_TIMEOUT; |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 54 | |
Jens Axboe | f4866ec | 2006-06-13 09:38:36 +0200 | [diff] [blame] | 55 | static char fio_version_string[] = "fio 1.5"; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 56 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 57 | static char **ini_file; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 58 | static int max_jobs = MAX_JOBS; |
| 59 | |
| 60 | struct thread_data def_thread; |
| 61 | struct thread_data *threads = NULL; |
| 62 | |
| 63 | int rate_quit = 0; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 64 | int exitall_on_terminate = 0; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 65 | int terse_output = 0; |
Jens Axboe | c04f7ec | 2006-05-31 10:13:16 +0200 | [diff] [blame] | 66 | unsigned long long mlock_size = 0; |
Jens Axboe | eb8bbf4 | 2006-06-08 21:40:11 +0200 | [diff] [blame] | 67 | FILE *f_out = NULL; |
| 68 | FILE *f_err = NULL; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 69 | |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 70 | static int write_lat_log = DEF_WRITE_LAT_LOG; |
| 71 | static int write_bw_log = DEF_WRITE_BW_LOG; |
| 72 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 73 | /* |
| 74 | * Return a free job structure. |
| 75 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 76 | static struct thread_data *get_new_job(int global, struct thread_data *parent) |
| 77 | { |
| 78 | struct thread_data *td; |
| 79 | |
| 80 | if (global) |
| 81 | return &def_thread; |
| 82 | if (thread_number >= max_jobs) |
| 83 | return NULL; |
| 84 | |
| 85 | td = &threads[thread_number++]; |
Jens Axboe | ddaeaa5 | 2006-06-08 11:00:58 +0200 | [diff] [blame] | 86 | *td = *parent; |
| 87 | td->name[0] = '\0'; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 88 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 89 | td->thread_number = thread_number; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 90 | return td; |
| 91 | } |
| 92 | |
| 93 | static void put_job(struct thread_data *td) |
| 94 | { |
| 95 | memset(&threads[td->thread_number - 1], 0, sizeof(*td)); |
| 96 | thread_number--; |
| 97 | } |
| 98 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 99 | /* |
| 100 | * Adds a job to the list of things todo. Sanitizes the various options |
| 101 | * to make sure we don't have conflicts, and initializes various |
| 102 | * members of td. |
| 103 | */ |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 104 | static int add_job(struct thread_data *td, const char *jobname, int job_add_num) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 105 | { |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 106 | char *ddir_str[] = { "read", "write", "randread", "randwrite", |
| 107 | "rw", NULL, "randrw" }; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 108 | struct stat sb; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 109 | int numjobs, ddir, i; |
| 110 | struct fio_file *f; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 111 | |
| 112 | #ifndef FIO_HAVE_LIBAIO |
| 113 | if (td->io_engine == FIO_LIBAIO) { |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 114 | log_err("Linux libaio not available\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 115 | return 1; |
| 116 | } |
| 117 | #endif |
| 118 | #ifndef FIO_HAVE_POSIXAIO |
| 119 | if (td->io_engine == FIO_POSIXAIO) { |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 120 | log_err("posix aio not available\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 121 | return 1; |
| 122 | } |
| 123 | #endif |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 124 | |
| 125 | /* |
| 126 | * the def_thread is just for options, it's not a real job |
| 127 | */ |
| 128 | if (td == &def_thread) |
| 129 | return 0; |
| 130 | |
Jens Axboe | df64119 | 2006-10-12 07:55:41 +0200 | [diff] [blame] | 131 | /* |
| 132 | * Set default io engine, if none set |
| 133 | */ |
| 134 | if (!td->io_ops) { |
| 135 | td->io_ops = load_ioengine(td, DEF_IO_ENGINE_NAME); |
| 136 | if (!td->io_ops) { |
| 137 | log_err("default engine %s not there?\n", DEF_IO_ENGINE_NAME); |
| 138 | return 1; |
| 139 | } |
| 140 | } |
| 141 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 142 | if (td->io_ops->flags & FIO_SYNCIO) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 143 | td->iodepth = 1; |
| 144 | else { |
| 145 | if (!td->iodepth) |
Jens Axboe | 841ddd1 | 2006-10-20 09:07:46 +0200 | [diff] [blame] | 146 | td->iodepth = td->nr_files; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 147 | } |
| 148 | |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 149 | /* |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 150 | * only really works for sequential io for now, and with 1 file |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 151 | */ |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 152 | if (td->zone_size && !td->sequential && td->nr_files == 1) |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 153 | td->zone_size = 0; |
| 154 | |
Jens Axboe | 9cc935a | 2006-06-13 09:11:18 +0200 | [diff] [blame] | 155 | /* |
| 156 | * Reads can do overwrites, we always need to pre-create the file |
| 157 | */ |
| 158 | if (td_read(td) || td_rw(td)) |
| 159 | td->overwrite = 1; |
| 160 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 161 | td->filetype = FIO_TYPE_FILE; |
Jens Axboe | 0af7b54 | 2006-02-17 10:10:12 +0100 | [diff] [blame] | 162 | if (!stat(jobname, &sb)) { |
| 163 | if (S_ISBLK(sb.st_mode)) |
| 164 | td->filetype = FIO_TYPE_BD; |
| 165 | else if (S_ISCHR(sb.st_mode)) |
| 166 | td->filetype = FIO_TYPE_CHAR; |
| 167 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 168 | |
Jens Axboe | b2a1519 | 2006-10-18 14:10:42 +0200 | [diff] [blame] | 169 | if (td->odirect) |
| 170 | td->io_ops->flags |= FIO_RAWIO; |
| 171 | |
Jens Axboe | 13f8e2d | 2006-10-24 09:29:45 +0200 | [diff] [blame] | 172 | if (td->filename) |
| 173 | td->nr_uniq_files = 1; |
| 174 | else |
| 175 | td->nr_uniq_files = td->nr_files; |
| 176 | |
| 177 | if (td->filetype == FIO_TYPE_FILE || td->filename) { |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 178 | char tmp[PATH_MAX]; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 179 | int len = 0; |
| 180 | int i; |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 181 | |
Jens Axboe | ef899b6 | 2006-06-06 09:31:00 +0200 | [diff] [blame] | 182 | if (td->directory && td->directory[0] != '\0') |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 183 | sprintf(tmp, "%s/", td->directory); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 184 | |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 185 | td->files = malloc(sizeof(struct fio_file) * td->nr_files); |
| 186 | |
| 187 | for_each_file(td, f, i) { |
| 188 | memset(f, 0, sizeof(*f)); |
| 189 | f->fd = -1; |
| 190 | |
Jens Axboe | 13f8e2d | 2006-10-24 09:29:45 +0200 | [diff] [blame] | 191 | if (td->filename) |
| 192 | sprintf(tmp + len, "%s", td->filename); |
| 193 | else |
| 194 | sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i); |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 195 | f->file_name = strdup(tmp); |
| 196 | } |
| 197 | } else { |
| 198 | td->nr_files = 1; |
| 199 | td->files = malloc(sizeof(struct fio_file)); |
| 200 | f = &td->files[0]; |
| 201 | |
| 202 | memset(f, 0, sizeof(*f)); |
| 203 | f->fd = -1; |
| 204 | f->file_name = strdup(jobname); |
| 205 | } |
| 206 | |
| 207 | for_each_file(td, f, i) { |
| 208 | f->file_size = td->total_file_size / td->nr_files; |
| 209 | f->file_offset = td->start_offset; |
| 210 | } |
| 211 | |
Jens Axboe | bbfd6b0 | 2006-06-07 19:42:54 +0200 | [diff] [blame] | 212 | fio_sem_init(&td->mutex, 0); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 213 | |
| 214 | td->clat_stat[0].min_val = td->clat_stat[1].min_val = ULONG_MAX; |
| 215 | td->slat_stat[0].min_val = td->slat_stat[1].min_val = ULONG_MAX; |
| 216 | td->bw_stat[0].min_val = td->bw_stat[1].min_val = ULONG_MAX; |
| 217 | |
| 218 | if (td->min_bs == -1U) |
| 219 | td->min_bs = td->bs; |
| 220 | if (td->max_bs == -1U) |
| 221 | td->max_bs = td->bs; |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 222 | if (td_read(td) && !td_rw(td)) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 223 | td->verify = 0; |
| 224 | |
| 225 | if (td->stonewall && td->thread_number > 1) |
| 226 | groupid++; |
| 227 | |
| 228 | td->groupid = groupid; |
| 229 | |
| 230 | if (setup_rate(td)) |
| 231 | goto err; |
| 232 | |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 233 | if (td->write_lat_log) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 234 | setup_log(&td->slat_log); |
| 235 | setup_log(&td->clat_log); |
| 236 | } |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 237 | if (td->write_bw_log) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 238 | setup_log(&td->bw_log); |
| 239 | |
Jens Axboe | 0145205 | 2006-06-07 10:29:47 +0200 | [diff] [blame] | 240 | if (td->name[0] == '\0') |
| 241 | snprintf(td->name, sizeof(td->name)-1, "client%d", td->thread_number); |
| 242 | |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 243 | ddir = td->ddir + (!td->sequential << 1) + (td->iomix << 2); |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 244 | |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 245 | if (!terse_output) { |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 246 | if (!job_add_num) { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 247 | if (td->io_ops->flags & FIO_CPUIO) |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 248 | fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle); |
| 249 | else |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 250 | 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); |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 251 | } else if (job_add_num == 1) |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 252 | fprintf(f_out, "...\n"); |
| 253 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 254 | |
| 255 | /* |
| 256 | * recurse add identical jobs, clear numjobs and stonewall options |
| 257 | * as they don't apply to sub-jobs |
| 258 | */ |
| 259 | numjobs = td->numjobs; |
| 260 | while (--numjobs) { |
| 261 | struct thread_data *td_new = get_new_job(0, td); |
| 262 | |
| 263 | if (!td_new) |
| 264 | goto err; |
| 265 | |
| 266 | td_new->numjobs = 1; |
| 267 | td_new->stonewall = 0; |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 268 | job_add_num = numjobs - 1; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 269 | |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 270 | if (add_job(td_new, jobname, job_add_num)) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 271 | goto err; |
| 272 | } |
| 273 | return 0; |
| 274 | err: |
| 275 | put_job(td); |
| 276 | return -1; |
| 277 | } |
| 278 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 279 | /* |
| 280 | * Initialize the various random states we need (random io, block size ranges, |
| 281 | * read/write mix, etc). |
| 282 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 283 | int init_random_state(struct thread_data *td) |
| 284 | { |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 285 | unsigned long seeds[4]; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 286 | int fd, num_maps, blocks, i; |
Jens Axboe | 0ab8db8 | 2006-10-18 17:16:23 +0200 | [diff] [blame] | 287 | struct fio_file *f; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 288 | |
Jens Axboe | 1ac267b | 2006-05-31 20:29:00 +0200 | [diff] [blame] | 289 | fd = open("/dev/urandom", O_RDONLY); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 290 | if (fd == -1) { |
| 291 | td_verror(td, errno); |
| 292 | return 1; |
| 293 | } |
| 294 | |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 295 | if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 296 | td_verror(td, EIO); |
| 297 | close(fd); |
| 298 | return 1; |
| 299 | } |
| 300 | |
| 301 | close(fd); |
| 302 | |
Jens Axboe | 6dfd46b | 2006-06-07 13:57:06 +0200 | [diff] [blame] | 303 | os_random_seed(seeds[0], &td->bsrange_state); |
| 304 | os_random_seed(seeds[1], &td->verify_state); |
| 305 | os_random_seed(seeds[2], &td->rwmix_state); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 306 | |
| 307 | if (td->sequential) |
| 308 | return 0; |
| 309 | |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 310 | if (td->rand_repeatable) |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 311 | seeds[3] = DEF_RANDSEED; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 312 | |
Jens Axboe | 0ab8db8 | 2006-10-18 17:16:23 +0200 | [diff] [blame] | 313 | for_each_file(td, f, i) { |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 314 | blocks = (f->file_size + td->min_bs - 1) / td->min_bs; |
| 315 | num_maps = blocks / BLOCKS_PER_MAP; |
| 316 | f->file_map = malloc(num_maps * sizeof(long)); |
| 317 | f->num_maps = num_maps; |
| 318 | memset(f->file_map, 0, num_maps * sizeof(long)); |
| 319 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 320 | |
Jens Axboe | 6dfd46b | 2006-06-07 13:57:06 +0200 | [diff] [blame] | 321 | os_random_seed(seeds[3], &td->random_state); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | static void fill_cpu_mask(os_cpu_mask_t cpumask, int cpu) |
| 326 | { |
| 327 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 328 | unsigned int i; |
| 329 | |
| 330 | CPU_ZERO(&cpumask); |
| 331 | |
| 332 | for (i = 0; i < sizeof(int) * 8; i++) { |
| 333 | if ((1 << i) & cpu) |
| 334 | CPU_SET(i, &cpumask); |
| 335 | } |
| 336 | #endif |
| 337 | } |
| 338 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 339 | static int is_empty_or_comment(char *line) |
| 340 | { |
| 341 | unsigned int i; |
| 342 | |
| 343 | for (i = 0; i < strlen(line); i++) { |
| 344 | if (line[i] == ';') |
| 345 | return 1; |
| 346 | if (!isspace(line[i]) && !iscntrl(line[i])) |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | return 1; |
| 351 | } |
| 352 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 353 | static int str_rw_cb(void *data, char *mem) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 354 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 355 | struct thread_data *td = data; |
| 356 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 357 | if (!strncmp(mem, "read", 4) || !strncmp(mem, "0", 1)) { |
| 358 | td->ddir = DDIR_READ; |
| 359 | td->sequential = 1; |
| 360 | return 0; |
| 361 | } else if (!strncmp(mem, "randread", 8)) { |
| 362 | td->ddir = DDIR_READ; |
| 363 | td->sequential = 0; |
| 364 | return 0; |
| 365 | } else if (!strncmp(mem, "write", 5) || !strncmp(mem, "1", 1)) { |
| 366 | td->ddir = DDIR_WRITE; |
| 367 | td->sequential = 1; |
| 368 | return 0; |
| 369 | } else if (!strncmp(mem, "randwrite", 9)) { |
| 370 | td->ddir = DDIR_WRITE; |
| 371 | td->sequential = 0; |
| 372 | return 0; |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 373 | } else if (!strncmp(mem, "rw", 2)) { |
| 374 | td->ddir = 0; |
| 375 | td->iomix = 1; |
| 376 | td->sequential = 1; |
| 377 | return 0; |
| 378 | } else if (!strncmp(mem, "randrw", 6)) { |
| 379 | td->ddir = 0; |
| 380 | td->iomix = 1; |
| 381 | td->sequential = 0; |
| 382 | return 0; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 383 | } |
| 384 | |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 385 | log_err("fio: data direction: read, write, randread, randwrite, rw, randrw\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 386 | return 1; |
| 387 | } |
| 388 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 389 | static int str_verify_cb(void *data, char *mem) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 390 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 391 | struct thread_data *td = data; |
| 392 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 393 | if (!strncmp(mem, "0", 1)) { |
| 394 | td->verify = VERIFY_NONE; |
| 395 | return 0; |
| 396 | } else if (!strncmp(mem, "md5", 3) || !strncmp(mem, "1", 1)) { |
| 397 | td->verify = VERIFY_MD5; |
| 398 | return 0; |
| 399 | } else if (!strncmp(mem, "crc32", 5)) { |
| 400 | td->verify = VERIFY_CRC32; |
| 401 | return 0; |
| 402 | } |
| 403 | |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 404 | log_err("fio: verify types: md5, crc32\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 405 | return 1; |
| 406 | } |
| 407 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 408 | static int str_mem_cb(void *data, char *mem) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 409 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 410 | struct thread_data *td = data; |
| 411 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 412 | if (!strncmp(mem, "malloc", 6)) { |
| 413 | td->mem_type = MEM_MALLOC; |
| 414 | return 0; |
| 415 | } else if (!strncmp(mem, "shm", 3)) { |
| 416 | td->mem_type = MEM_SHM; |
| 417 | return 0; |
| 418 | } else if (!strncmp(mem, "mmap", 4)) { |
| 419 | td->mem_type = MEM_MMAP; |
| 420 | return 0; |
| 421 | } |
| 422 | |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 423 | log_err("fio: mem type: malloc, shm, mmap\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 424 | return 1; |
| 425 | } |
| 426 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 427 | static int str_ioengine_cb(void *data, char *str) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 428 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 429 | struct thread_data *td = data; |
| 430 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 431 | td->io_ops = load_ioengine(td, str); |
| 432 | if (td->io_ops) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 433 | return 0; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 434 | |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 435 | log_err("fio: ioengine: { linuxaio, aio, libaio }, posixaio, sync, mmap, sgio, splice, cpu\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 436 | return 1; |
| 437 | } |
| 438 | |
Jens Axboe | 0726198 | 2006-06-07 10:51:12 +0200 | [diff] [blame] | 439 | /* |
| 440 | * This is our [ini] type file parser. |
| 441 | */ |
Jens Axboe | 0c7e37a | 2006-06-13 14:53:38 +0200 | [diff] [blame] | 442 | int parse_jobs_ini(char *file, int stonewall_flag) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 443 | { |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 444 | unsigned int prioclass, prio, cpu, global, il; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 445 | unsigned long long ull; |
| 446 | unsigned long ul1, ul2; |
| 447 | struct thread_data *td; |
Jens Axboe | ef899b6 | 2006-06-06 09:31:00 +0200 | [diff] [blame] | 448 | char *string, *name, *tmpbuf; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 449 | fpos_t off; |
| 450 | FILE *f; |
| 451 | char *p; |
Jens Axboe | 0c7e37a | 2006-06-13 14:53:38 +0200 | [diff] [blame] | 452 | int ret = 0, stonewall; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 453 | |
| 454 | f = fopen(file, "r"); |
| 455 | if (!f) { |
Jens Axboe | aea47d4 | 2006-05-26 19:27:29 +0200 | [diff] [blame] | 456 | perror("fopen job file"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 457 | return 1; |
| 458 | } |
| 459 | |
| 460 | string = malloc(4096); |
| 461 | name = malloc(256); |
Jens Axboe | ef899b6 | 2006-06-06 09:31:00 +0200 | [diff] [blame] | 462 | tmpbuf = malloc(4096); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 463 | |
Jens Axboe | 0c7e37a | 2006-06-13 14:53:38 +0200 | [diff] [blame] | 464 | stonewall = stonewall_flag; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 465 | while ((p = fgets(string, 4096, f)) != NULL) { |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 466 | if (ret) |
| 467 | break; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 468 | if (is_empty_or_comment(p)) |
| 469 | continue; |
| 470 | if (sscanf(p, "[%s]", name) != 1) |
| 471 | continue; |
| 472 | |
| 473 | global = !strncmp(name, "global", 6); |
| 474 | |
| 475 | name[strlen(name) - 1] = '\0'; |
| 476 | |
| 477 | td = get_new_job(global, &def_thread); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 478 | if (!td) { |
| 479 | ret = 1; |
| 480 | break; |
| 481 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 482 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 483 | /* |
| 484 | * Seperate multiple job files by a stonewall |
| 485 | */ |
Jens Axboe | f948191 | 2006-06-09 11:37:28 +0200 | [diff] [blame] | 486 | if (!global && stonewall) { |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 487 | td->stonewall = stonewall; |
| 488 | stonewall = 0; |
| 489 | } |
| 490 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 491 | fgetpos(f, &off); |
| 492 | while ((p = fgets(string, 4096, f)) != NULL) { |
| 493 | if (is_empty_or_comment(p)) |
| 494 | continue; |
| 495 | if (strstr(p, "[")) |
| 496 | break; |
Jens Axboe | b6754f9 | 2006-05-30 14:29:32 +0200 | [diff] [blame] | 497 | strip_blank_front(&p); |
Jens Axboe | 4ae3f76 | 2006-05-30 13:35:14 +0200 | [diff] [blame] | 498 | strip_blank_end(p); |
Jens Axboe | aea47d4 | 2006-05-26 19:27:29 +0200 | [diff] [blame] | 499 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 500 | if (!check_int(p, "prio", &prio)) { |
| 501 | #ifndef FIO_HAVE_IOPRIO |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 502 | log_err("io priorities not available\n"); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 503 | ret = 1; |
| 504 | break; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 505 | #endif |
Jens Axboe | 8756e4d | 2006-05-27 20:24:53 +0200 | [diff] [blame] | 506 | td->ioprio |= prio; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 507 | fgetpos(f, &off); |
| 508 | continue; |
| 509 | } |
| 510 | if (!check_int(p, "prioclass", &prioclass)) { |
| 511 | #ifndef FIO_HAVE_IOPRIO |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 512 | log_err("io priorities not available\n"); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 513 | ret = 1; |
| 514 | break; |
Jens Axboe | 5c4e1db | 2006-06-07 14:17:08 +0200 | [diff] [blame] | 515 | #else |
Jens Axboe | 8756e4d | 2006-05-27 20:24:53 +0200 | [diff] [blame] | 516 | td->ioprio |= prioclass << IOPRIO_CLASS_SHIFT; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 517 | fgetpos(f, &off); |
| 518 | continue; |
Jens Axboe | 5c4e1db | 2006-06-07 14:17:08 +0200 | [diff] [blame] | 519 | #endif |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 520 | } |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 521 | if (!check_int(p, "direct", &il)) { |
| 522 | td->odirect = il; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 523 | fgetpos(f, &off); |
| 524 | continue; |
| 525 | } |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 526 | if (!check_int(p, "rand_repeatable", &il)) { |
| 527 | td->rand_repeatable = il; |
| 528 | fgetpos(f, &off); |
| 529 | continue; |
| 530 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 531 | if (!check_int(p, "rate", &td->rate)) { |
| 532 | fgetpos(f, &off); |
| 533 | continue; |
| 534 | } |
| 535 | if (!check_int(p, "ratemin", &td->ratemin)) { |
| 536 | fgetpos(f, &off); |
| 537 | continue; |
| 538 | } |
| 539 | if (!check_int(p, "ratecycle", &td->ratecycle)) { |
| 540 | fgetpos(f, &off); |
| 541 | continue; |
| 542 | } |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 543 | if (!check_int(p, "cpuload", &td->cpuload)) { |
| 544 | fgetpos(f, &off); |
| 545 | continue; |
| 546 | } |
| 547 | if (!check_int(p, "cpuchunks", &td->cpucycle)) { |
| 548 | fgetpos(f, &off); |
| 549 | continue; |
| 550 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 551 | if (!check_int(p, "thinktime", &td->thinktime)) { |
| 552 | fgetpos(f, &off); |
| 553 | continue; |
| 554 | } |
| 555 | if (!check_int(p, "cpumask", &cpu)) { |
| 556 | #ifndef FIO_HAVE_CPU_AFFINITY |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 557 | log_err("cpu affinity not available\n"); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 558 | ret = 1; |
| 559 | break; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 560 | #endif |
| 561 | fill_cpu_mask(td->cpumask, cpu); |
| 562 | fgetpos(f, &off); |
| 563 | continue; |
| 564 | } |
| 565 | if (!check_int(p, "fsync", &td->fsync_blocks)) { |
| 566 | fgetpos(f, &off); |
Jens Axboe | fc1a471 | 2006-05-30 13:04:05 +0200 | [diff] [blame] | 567 | td->end_fsync = 1; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 568 | continue; |
| 569 | } |
| 570 | if (!check_int(p, "startdelay", &td->start_delay)) { |
| 571 | fgetpos(f, &off); |
| 572 | continue; |
| 573 | } |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 574 | if (!check_str_time(p, "timeout", &ull)) { |
Jens Axboe | af959a7 | 2006-07-13 14:36:02 -0700 | [diff] [blame] | 575 | td->timeout = ull; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 576 | fgetpos(f, &off); |
| 577 | continue; |
| 578 | } |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 579 | if (!check_int(p, "invalidate", &il)) { |
| 580 | td->invalidate_cache = il; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 581 | fgetpos(f, &off); |
| 582 | continue; |
| 583 | } |
| 584 | if (!check_int(p, "iodepth", &td->iodepth)) { |
| 585 | fgetpos(f, &off); |
| 586 | continue; |
| 587 | } |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 588 | if (!check_int(p, "sync", &il)) { |
| 589 | td->sync_io = il; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 590 | fgetpos(f, &off); |
| 591 | continue; |
| 592 | } |
| 593 | if (!check_int(p, "bwavgtime", &td->bw_avg_time)) { |
| 594 | fgetpos(f, &off); |
| 595 | continue; |
| 596 | } |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 597 | if (!check_int(p, "create_serialize", &il)) { |
| 598 | td->create_serialize = il; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 599 | fgetpos(f, &off); |
| 600 | continue; |
| 601 | } |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 602 | if (!check_int(p, "create_fsync", &il)) { |
| 603 | td->create_fsync = il; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 604 | fgetpos(f, &off); |
| 605 | continue; |
| 606 | } |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 607 | if (!check_int(p, "end_fsync", &il)) { |
| 608 | td->end_fsync = il; |
Jens Axboe | fc1a471 | 2006-05-30 13:04:05 +0200 | [diff] [blame] | 609 | fgetpos(f, &off); |
| 610 | continue; |
| 611 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 612 | if (!check_int(p, "loops", &td->loops)) { |
| 613 | fgetpos(f, &off); |
| 614 | continue; |
| 615 | } |
| 616 | if (!check_int(p, "numjobs", &td->numjobs)) { |
| 617 | fgetpos(f, &off); |
| 618 | continue; |
| 619 | } |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 620 | if (!check_int(p, "overwrite", &il)) { |
| 621 | td->overwrite = il; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 622 | fgetpos(f, &off); |
| 623 | continue; |
| 624 | } |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 625 | if (!check_int(p, "rwmixcycle", &td->rwmixcycle)) { |
| 626 | fgetpos(f, &off); |
| 627 | continue; |
| 628 | } |
| 629 | if (!check_int(p, "rwmixread", &il)) { |
| 630 | if (il > 100) |
| 631 | il = 100; |
| 632 | td->rwmixread = il; |
| 633 | fgetpos(f, &off); |
| 634 | continue; |
| 635 | } |
| 636 | if (!check_int(p, "rwmixwrite", &il)) { |
| 637 | if (il > 100) |
| 638 | il = 100; |
| 639 | td->rwmixread = 100 - il; |
| 640 | fgetpos(f, &off); |
| 641 | continue; |
| 642 | } |
Jens Axboe | b6f4d88 | 2006-06-02 10:32:51 +0200 | [diff] [blame] | 643 | if (!check_int(p, "nice", &td->nice)) { |
| 644 | fgetpos(f, &off); |
| 645 | continue; |
| 646 | } |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 647 | if (!check_int(p, "nrfiles", &td->nr_files)) { |
| 648 | fgetpos(f, &off); |
| 649 | continue; |
| 650 | } |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 651 | if (!check_range_bytes(p, "bsrange", &ul1, &ul2)) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 652 | if (ul1 > ul2) { |
| 653 | td->max_bs = ul1; |
| 654 | td->min_bs = ul2; |
| 655 | } else { |
| 656 | td->max_bs = ul2; |
| 657 | td->min_bs = ul1; |
| 658 | } |
| 659 | fgetpos(f, &off); |
| 660 | continue; |
| 661 | } |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 662 | if (!check_str_bytes(p, "bs", &ull)) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 663 | td->bs = ull; |
| 664 | fgetpos(f, &off); |
| 665 | continue; |
| 666 | } |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 667 | if (!check_str_bytes(p, "size", &td->total_file_size)) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 668 | fgetpos(f, &off); |
| 669 | continue; |
| 670 | } |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 671 | if (!check_str_bytes(p, "offset", &td->start_offset)) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 672 | fgetpos(f, &off); |
| 673 | continue; |
| 674 | } |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 675 | if (!check_str_bytes(p, "zonesize", &td->zone_size)) { |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 676 | fgetpos(f, &off); |
| 677 | continue; |
| 678 | } |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 679 | if (!check_str_bytes(p, "zoneskip", &td->zone_skip)) { |
Jens Axboe | 20dc95c | 2005-12-09 10:29:35 +0100 | [diff] [blame] | 680 | fgetpos(f, &off); |
| 681 | continue; |
| 682 | } |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 683 | if (!check_str_bytes(p, "lockmem", &mlock_size)) { |
Jens Axboe | c04f7ec | 2006-05-31 10:13:16 +0200 | [diff] [blame] | 684 | fgetpos(f, &off); |
| 685 | continue; |
| 686 | } |
Jens Axboe | ef899b6 | 2006-06-06 09:31:00 +0200 | [diff] [blame] | 687 | if (!check_strstore(p, "directory", tmpbuf)) { |
| 688 | td->directory = strdup(tmpbuf); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 689 | fgetpos(f, &off); |
| 690 | continue; |
| 691 | } |
Jens Axboe | 13f8e2d | 2006-10-24 09:29:45 +0200 | [diff] [blame] | 692 | if (!check_strstore(p, "filename", tmpbuf)) { |
| 693 | td->filename = strdup(tmpbuf); |
| 694 | fgetpos(f, &off); |
| 695 | continue; |
| 696 | } |
Jens Axboe | 0145205 | 2006-06-07 10:29:47 +0200 | [diff] [blame] | 697 | if (!check_strstore(p, "name", tmpbuf)) { |
| 698 | snprintf(td->name, sizeof(td->name)-1, "%s%d", tmpbuf, td->thread_number); |
| 699 | fgetpos(f, &off); |
| 700 | continue; |
| 701 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 702 | if (!check_str(p, "mem", str_mem_cb, td)) { |
| 703 | fgetpos(f, &off); |
| 704 | continue; |
| 705 | } |
| 706 | if (!check_str(p, "verify", str_verify_cb, td)) { |
| 707 | fgetpos(f, &off); |
| 708 | continue; |
| 709 | } |
| 710 | if (!check_str(p, "rw", str_rw_cb, td)) { |
| 711 | fgetpos(f, &off); |
| 712 | continue; |
| 713 | } |
| 714 | if (!check_str(p, "ioengine", str_ioengine_cb, td)) { |
| 715 | fgetpos(f, &off); |
| 716 | continue; |
| 717 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 718 | if (!check_strset(p, "exitall")) { |
| 719 | exitall_on_terminate = 1; |
| 720 | fgetpos(f, &off); |
| 721 | continue; |
| 722 | } |
| 723 | if (!check_strset(p, "stonewall")) { |
| 724 | td->stonewall = 1; |
| 725 | fgetpos(f, &off); |
| 726 | continue; |
| 727 | } |
| 728 | if (!check_strset(p, "thread")) { |
| 729 | td->use_thread = 1; |
| 730 | fgetpos(f, &off); |
| 731 | continue; |
| 732 | } |
Jens Axboe | f6cbb26 | 2006-10-18 14:16:42 +0200 | [diff] [blame] | 733 | if (!check_strset(p, "unlink")) { |
| 734 | td->unlink = 1; |
| 735 | fgetpos(f, &off); |
| 736 | continue; |
| 737 | } |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 738 | if (!check_strset(p, "write_bw_log")) { |
| 739 | td->write_bw_log = 1; |
| 740 | fgetpos(f, &off); |
| 741 | continue; |
| 742 | } |
| 743 | if (!check_strset(p, "write_lat_log")) { |
| 744 | td->write_lat_log = 1; |
| 745 | fgetpos(f, &off); |
| 746 | continue; |
| 747 | } |
Jens Axboe | 80b9feb | 2006-06-07 10:34:49 +0200 | [diff] [blame] | 748 | if (!check_strstore(p, "iolog", tmpbuf)) { |
Jens Axboe | 4f693b9 | 2006-06-07 22:52:28 +0200 | [diff] [blame] | 749 | if (td->write_iolog) { |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 750 | log_err("fio: read iolog overrides given write_iolog\n"); |
Jens Axboe | af8c0b4 | 2006-06-07 22:33:17 +0200 | [diff] [blame] | 751 | free(td->iolog_file); |
Jens Axboe | 4f693b9 | 2006-06-07 22:52:28 +0200 | [diff] [blame] | 752 | td->write_iolog = 0; |
| 753 | } |
Jens Axboe | 80b9feb | 2006-06-07 10:34:49 +0200 | [diff] [blame] | 754 | td->iolog_file = strdup(tmpbuf); |
Jens Axboe | 843a741 | 2006-06-01 21:14:21 -0700 | [diff] [blame] | 755 | td->read_iolog = 1; |
Jens Axboe | 843a741 | 2006-06-01 21:14:21 -0700 | [diff] [blame] | 756 | fgetpos(f, &off); |
| 757 | continue; |
| 758 | } |
Jens Axboe | af8c0b4 | 2006-06-07 22:33:17 +0200 | [diff] [blame] | 759 | if (!check_strstore(p, "write_iolog", tmpbuf)) { |
| 760 | if (!td->read_iolog) { |
| 761 | td->iolog_file = strdup(tmpbuf); |
| 762 | td->write_iolog = 1; |
Jens Axboe | 4f693b9 | 2006-06-07 22:52:28 +0200 | [diff] [blame] | 763 | } else |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 764 | log_err("fio: read iolog overrides given write_iolog\n"); |
Jens Axboe | aea47d4 | 2006-05-26 19:27:29 +0200 | [diff] [blame] | 765 | fgetpos(f, &off); |
| 766 | continue; |
| 767 | } |
Jens Axboe | 80b9feb | 2006-06-07 10:34:49 +0200 | [diff] [blame] | 768 | if (!check_strstore(p, "exec_prerun", tmpbuf)) { |
| 769 | td->exec_prerun = strdup(tmpbuf); |
Jens Axboe | 4e0ba8a | 2006-06-06 09:36:28 +0200 | [diff] [blame] | 770 | fgetpos(f, &off); |
| 771 | continue; |
| 772 | } |
Jens Axboe | 80b9feb | 2006-06-07 10:34:49 +0200 | [diff] [blame] | 773 | if (!check_strstore(p, "exec_postrun", tmpbuf)) { |
| 774 | td->exec_postrun = strdup(tmpbuf); |
Jens Axboe | 4e0ba8a | 2006-06-06 09:36:28 +0200 | [diff] [blame] | 775 | fgetpos(f, &off); |
| 776 | continue; |
| 777 | } |
Jens Axboe | 80b9feb | 2006-06-07 10:34:49 +0200 | [diff] [blame] | 778 | if (!check_strstore(p, "ioscheduler", tmpbuf)) { |
Jens Axboe | 22f78b3 | 2006-06-07 11:30:07 +0200 | [diff] [blame] | 779 | #ifndef FIO_HAVE_IOSCHED_SWITCH |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 780 | log_err("io scheduler switching not available\n"); |
Jens Axboe | 22f78b3 | 2006-06-07 11:30:07 +0200 | [diff] [blame] | 781 | ret = 1; |
| 782 | break; |
| 783 | #else |
Jens Axboe | 80b9feb | 2006-06-07 10:34:49 +0200 | [diff] [blame] | 784 | td->ioscheduler = strdup(tmpbuf); |
Jens Axboe | da86774 | 2006-06-06 10:39:10 -0700 | [diff] [blame] | 785 | fgetpos(f, &off); |
| 786 | continue; |
Jens Axboe | 22f78b3 | 2006-06-07 11:30:07 +0200 | [diff] [blame] | 787 | #endif |
Jens Axboe | da86774 | 2006-06-06 10:39:10 -0700 | [diff] [blame] | 788 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 789 | |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 790 | /* |
| 791 | * Don't break here, continue parsing options so we |
| 792 | * dump all the bad ones. Makes trial/error fixups |
| 793 | * easier on the user. |
| 794 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 795 | printf("Client%d: bad option %s\n",td->thread_number,p); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 796 | ret = 1; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 797 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 798 | |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 799 | if (!ret) { |
| 800 | fsetpos(f, &off); |
| 801 | ret = add_job(td, name, 0); |
| 802 | } |
| 803 | if (ret) |
| 804 | break; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | free(string); |
| 808 | free(name); |
Jens Axboe | ef899b6 | 2006-06-06 09:31:00 +0200 | [diff] [blame] | 809 | free(tmpbuf); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 810 | fclose(f); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 811 | return ret; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | static int fill_def_thread(void) |
| 815 | { |
| 816 | memset(&def_thread, 0, sizeof(def_thread)); |
| 817 | |
| 818 | if (fio_getaffinity(getpid(), &def_thread.cpumask) == -1) { |
| 819 | perror("sched_getaffinity"); |
| 820 | return 1; |
| 821 | } |
| 822 | |
| 823 | /* |
| 824 | * fill globals |
| 825 | */ |
| 826 | def_thread.ddir = DDIR_READ; |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 827 | def_thread.iomix = 0; |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 828 | def_thread.bs = DEF_BS; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 829 | def_thread.min_bs = -1; |
| 830 | def_thread.max_bs = -1; |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 831 | def_thread.odirect = DEF_ODIRECT; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 832 | def_thread.ratecycle = DEF_RATE_CYCLE; |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 833 | def_thread.sequential = DEF_SEQUENTIAL; |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 834 | def_thread.timeout = def_timeout; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 835 | def_thread.overwrite = DEF_OVERWRITE; |
| 836 | def_thread.invalidate_cache = DEF_INVALIDATE; |
| 837 | def_thread.sync_io = DEF_SYNCIO; |
| 838 | def_thread.mem_type = MEM_MALLOC; |
| 839 | def_thread.bw_avg_time = DEF_BWAVGTIME; |
| 840 | def_thread.create_serialize = DEF_CREATE_SER; |
| 841 | def_thread.create_fsync = DEF_CREATE_FSYNC; |
| 842 | def_thread.loops = DEF_LOOPS; |
| 843 | def_thread.verify = DEF_VERIFY; |
| 844 | def_thread.stonewall = DEF_STONEWALL; |
| 845 | def_thread.numjobs = DEF_NUMJOBS; |
| 846 | def_thread.use_thread = DEF_USE_THREAD; |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 847 | def_thread.rwmixcycle = DEF_RWMIX_CYCLE; |
| 848 | def_thread.rwmixread = DEF_RWMIX_READ; |
Jens Axboe | b6f4d88 | 2006-06-02 10:32:51 +0200 | [diff] [blame] | 849 | def_thread.nice = DEF_NICE; |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 850 | def_thread.rand_repeatable = DEF_RAND_REPEAT; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 851 | def_thread.nr_files = DEF_NR_FILES; |
Jens Axboe | f6cbb26 | 2006-10-18 14:16:42 +0200 | [diff] [blame] | 852 | def_thread.unlink = DEF_UNLINK; |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 853 | def_thread.write_bw_log = write_bw_log; |
| 854 | def_thread.write_lat_log = write_lat_log; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 855 | #ifdef FIO_HAVE_DISK_UTIL |
| 856 | def_thread.do_disk_util = 1; |
| 857 | #endif |
| 858 | |
| 859 | return 0; |
| 860 | } |
| 861 | |
Jens Axboe | 0ab8db8 | 2006-10-18 17:16:23 +0200 | [diff] [blame] | 862 | static void usage(void) |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 863 | { |
| 864 | printf("%s\n", fio_version_string); |
Jens Axboe | 47623c7 | 2006-06-12 10:23:28 +0200 | [diff] [blame] | 865 | printf("\t-o Write output to file\n"); |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 866 | printf("\t-t Runtime in seconds\n"); |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 867 | printf("\t-l Generate per-job latency logs\n"); |
| 868 | printf("\t-w Generate per-job bandwidth logs\n"); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 869 | printf("\t-m Minimal (terse) output\n"); |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 870 | printf("\t-v Print version info and exit\n"); |
| 871 | } |
| 872 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 873 | static int parse_cmd_line(int argc, char *argv[]) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 874 | { |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 875 | int c, idx = 1, ini_idx = 0; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 876 | |
Jens Axboe | 2e77841 | 2006-06-16 10:00:50 +0200 | [diff] [blame] | 877 | while ((c = getopt(argc, argv, "t:o:lwvhm")) != EOF) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 878 | switch (c) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 879 | case 't': |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 880 | def_timeout = atoi(optarg); |
Jens Axboe | 774a617 | 2006-08-24 08:44:26 +0200 | [diff] [blame] | 881 | idx = optind; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 882 | break; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 883 | case 'l': |
| 884 | write_lat_log = 1; |
Jens Axboe | 774a617 | 2006-08-24 08:44:26 +0200 | [diff] [blame] | 885 | idx = optind; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 886 | break; |
| 887 | case 'w': |
| 888 | write_bw_log = 1; |
Jens Axboe | 774a617 | 2006-08-24 08:44:26 +0200 | [diff] [blame] | 889 | idx = optind; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 890 | break; |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 891 | case 'o': |
Jens Axboe | eb8bbf4 | 2006-06-08 21:40:11 +0200 | [diff] [blame] | 892 | f_out = fopen(optarg, "w+"); |
| 893 | if (!f_out) { |
| 894 | perror("fopen output"); |
| 895 | exit(1); |
| 896 | } |
| 897 | f_err = f_out; |
Jens Axboe | 774a617 | 2006-08-24 08:44:26 +0200 | [diff] [blame] | 898 | idx = optind; |
Jens Axboe | eb8bbf4 | 2006-06-08 21:40:11 +0200 | [diff] [blame] | 899 | break; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 900 | case 'm': |
| 901 | terse_output = 1; |
Jens Axboe | 774a617 | 2006-08-24 08:44:26 +0200 | [diff] [blame] | 902 | idx = optind; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 903 | break; |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 904 | case 'h': |
Jens Axboe | 0ab8db8 | 2006-10-18 17:16:23 +0200 | [diff] [blame] | 905 | usage(); |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 906 | exit(0); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 907 | case 'v': |
| 908 | printf("%s\n", fio_version_string); |
| 909 | exit(0); |
| 910 | } |
| 911 | } |
Jens Axboe | c9fad89 | 2006-05-27 17:26:50 +0200 | [diff] [blame] | 912 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 913 | while (idx < argc) { |
| 914 | ini_idx++; |
| 915 | ini_file = realloc(ini_file, ini_idx * sizeof(char *)); |
| 916 | ini_file[ini_idx - 1] = strdup(argv[idx]); |
| 917 | idx++; |
| 918 | } |
Jens Axboe | 774a617 | 2006-08-24 08:44:26 +0200 | [diff] [blame] | 919 | |
Jens Axboe | eb8bbf4 | 2006-06-08 21:40:11 +0200 | [diff] [blame] | 920 | if (!f_out) { |
| 921 | f_out = stdout; |
| 922 | f_err = stderr; |
| 923 | } |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 924 | |
| 925 | return ini_idx; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | static void free_shm(void) |
| 929 | { |
| 930 | struct shmid_ds sbuf; |
| 931 | |
| 932 | if (threads) { |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 933 | shmdt((void *) threads); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 934 | threads = NULL; |
| 935 | shmctl(shm_id, IPC_RMID, &sbuf); |
| 936 | } |
| 937 | } |
| 938 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 939 | /* |
| 940 | * The thread area is shared between the main process and the job |
| 941 | * threads/processes. So setup a shared memory segment that will hold |
| 942 | * all the job info. |
| 943 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 944 | static int setup_thread_area(void) |
| 945 | { |
| 946 | /* |
| 947 | * 1024 is too much on some machines, scale max_jobs if |
| 948 | * we get a failure that looks like too large a shm segment |
| 949 | */ |
| 950 | do { |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 951 | size_t size = max_jobs * sizeof(struct thread_data); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 952 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 953 | shm_id = shmget(0, size, IPC_CREAT | 0600); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 954 | if (shm_id != -1) |
| 955 | break; |
| 956 | if (errno != EINVAL) { |
| 957 | perror("shmget"); |
| 958 | break; |
| 959 | } |
| 960 | |
| 961 | max_jobs >>= 1; |
| 962 | } while (max_jobs); |
| 963 | |
| 964 | if (shm_id == -1) |
| 965 | return 1; |
| 966 | |
| 967 | threads = shmat(shm_id, NULL, 0); |
| 968 | if (threads == (void *) -1) { |
| 969 | perror("shmat"); |
| 970 | return 1; |
| 971 | } |
| 972 | |
| 973 | atexit(free_shm); |
| 974 | return 0; |
| 975 | } |
| 976 | |
| 977 | int parse_options(int argc, char *argv[]) |
| 978 | { |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 979 | int job_files, i; |
| 980 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 981 | if (setup_thread_area()) |
| 982 | return 1; |
| 983 | if (fill_def_thread()) |
| 984 | return 1; |
| 985 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 986 | job_files = parse_cmd_line(argc, argv); |
| 987 | if (!job_files) { |
| 988 | log_err("Need job file(s)\n"); |
Jens Axboe | 0ab8db8 | 2006-10-18 17:16:23 +0200 | [diff] [blame] | 989 | usage(); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 990 | return 1; |
| 991 | } |
| 992 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 993 | for (i = 0; i < job_files; i++) { |
| 994 | if (fill_def_thread()) |
| 995 | return 1; |
Jens Axboe | 0c7e37a | 2006-06-13 14:53:38 +0200 | [diff] [blame] | 996 | if (parse_jobs_ini(ini_file[i], i)) |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 997 | return 1; |
Jens Axboe | 88c6ed8 | 2006-06-09 11:28:10 +0200 | [diff] [blame] | 998 | free(ini_file[i]); |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 999 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1000 | |
Jens Axboe | 88c6ed8 | 2006-06-09 11:28:10 +0200 | [diff] [blame] | 1001 | free(ini_file); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1002 | return 0; |
| 1003 | } |