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> |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 11 | #include <getopt.h> |
| 12 | #include <assert.h> |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 13 | #include <sys/ipc.h> |
| 14 | #include <sys/shm.h> |
| 15 | #include <sys/types.h> |
| 16 | #include <sys/stat.h> |
| 17 | |
| 18 | #include "fio.h" |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 19 | #include "parse.h" |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 20 | |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 21 | #define FIO_RANDSEED (0xb1899bedUL) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 22 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 23 | #define td_var_offset(var) ((size_t) &((struct thread_data *)0)->var) |
| 24 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 25 | static int str_rw_cb(void *, const char *); |
| 26 | static int str_ioengine_cb(void *, const char *); |
| 27 | static int str_mem_cb(void *, const char *); |
| 28 | static int str_verify_cb(void *, const char *); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 29 | static int str_lockmem_cb(void *, unsigned long *); |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 30 | #ifdef FIO_HAVE_IOPRIO |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 31 | static int str_prio_cb(void *, unsigned int *); |
| 32 | static int str_prioclass_cb(void *, unsigned int *); |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 33 | #endif |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 34 | static int str_exitall_cb(void); |
| 35 | static int str_cpumask_cb(void *, unsigned int *); |
| 36 | |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 37 | #define __stringify_1(x) #x |
| 38 | #define __stringify(x) __stringify_1(x) |
| 39 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 40 | /* |
| 41 | * Map of job/command line options |
| 42 | */ |
| 43 | static struct fio_option options[] = { |
| 44 | { |
| 45 | .name = "name", |
| 46 | .type = FIO_OPT_STR_STORE, |
| 47 | .off1 = td_var_offset(name), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 48 | .help = "Name of this job", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 49 | }, |
| 50 | { |
| 51 | .name = "directory", |
| 52 | .type = FIO_OPT_STR_STORE, |
| 53 | .off1 = td_var_offset(directory), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 54 | .help = "Directory to store files in", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 55 | }, |
| 56 | { |
| 57 | .name = "filename", |
| 58 | .type = FIO_OPT_STR_STORE, |
| 59 | .off1 = td_var_offset(filename), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 60 | .help = "Force the use of a specific file", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 61 | }, |
| 62 | { |
| 63 | .name = "rw", |
| 64 | .type = FIO_OPT_STR, |
| 65 | .cb = str_rw_cb, |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 66 | .help = "IO direction", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 67 | .def = "read", |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 68 | .posval = { "read", "write", "randwrite", "randread", "rw", |
| 69 | "randrw", }, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 70 | }, |
| 71 | { |
| 72 | .name = "ioengine", |
| 73 | .type = FIO_OPT_STR, |
| 74 | .cb = str_ioengine_cb, |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 75 | .help = "IO engine to use", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 76 | .def = "sync", |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 77 | .posval = { "sync", "libaio", "posixaio", "mmap", "splice", |
| 78 | "sg", "null", }, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 79 | }, |
| 80 | { |
Jens Axboe | 03b74b3 | 2007-01-11 11:04:31 +0100 | [diff] [blame] | 81 | .name = "iodepth", |
| 82 | .type = FIO_OPT_INT, |
| 83 | .off1 = td_var_offset(iodepth), |
| 84 | .help = "Amount of IO buffers to keep in flight", |
| 85 | .def = "1", |
| 86 | }, |
| 87 | { |
| 88 | .name = "size", |
| 89 | .type = FIO_OPT_STR_VAL, |
| 90 | .off1 = td_var_offset(total_file_size), |
| 91 | .help = "Size of device or file", |
| 92 | }, |
| 93 | { |
| 94 | .name = "bs", |
| 95 | .type = FIO_OPT_STR_VAL_INT, |
| 96 | .off1 = td_var_offset(bs[DDIR_READ]), |
| 97 | .off2 = td_var_offset(bs[DDIR_WRITE]), |
| 98 | .help = "Block size unit", |
| 99 | .def = "4k", |
| 100 | }, |
| 101 | { |
| 102 | .name = "bsrange", |
| 103 | .type = FIO_OPT_RANGE, |
| 104 | .off1 = td_var_offset(min_bs[DDIR_READ]), |
| 105 | .off2 = td_var_offset(max_bs[DDIR_READ]), |
| 106 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), |
| 107 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), |
| 108 | .help = "Set block size range (in more detail than bs)", |
| 109 | }, |
| 110 | { |
| 111 | .name = "bs_unaligned", |
| 112 | .type = FIO_OPT_STR_SET, |
| 113 | .off1 = td_var_offset(bs_unaligned), |
| 114 | .help = "Don't sector align IO buffer sizes", |
| 115 | }, |
| 116 | { |
| 117 | .name = "offset", |
| 118 | .type = FIO_OPT_STR_VAL, |
| 119 | .off1 = td_var_offset(start_offset), |
| 120 | .help = "Start IO from this offset", |
| 121 | .def = "0", |
| 122 | }, |
| 123 | { |
| 124 | .name = "randrepeat", |
| 125 | .type = FIO_OPT_BOOL, |
| 126 | .off1 = td_var_offset(rand_repeatable), |
| 127 | .help = "Use repeatable random IO pattern", |
| 128 | .def = "1", |
| 129 | }, |
| 130 | { |
| 131 | .name = "norandommap", |
| 132 | .type = FIO_OPT_STR_SET, |
| 133 | .off1 = td_var_offset(norandommap), |
| 134 | .help = "Accept potential duplicate random blocks", |
| 135 | }, |
| 136 | { |
| 137 | .name = "nrfiles", |
| 138 | .type = FIO_OPT_INT, |
| 139 | .off1 = td_var_offset(nr_files), |
| 140 | .help = "Split job workload between this number of files", |
| 141 | .def = "1", |
| 142 | }, |
| 143 | { |
| 144 | .name = "fsync", |
| 145 | .type = FIO_OPT_INT, |
| 146 | .off1 = td_var_offset(fsync_blocks), |
| 147 | .help = "Issue fsync for writes every given number of blocks", |
| 148 | .def = "0", |
| 149 | }, |
| 150 | { |
| 151 | .name = "direct", |
| 152 | .type = FIO_OPT_BOOL, |
| 153 | .off1 = td_var_offset(odirect), |
Jens Axboe | 76a43db | 2007-01-11 13:24:44 +0100 | [diff] [blame] | 154 | .help = "Use O_DIRECT IO (negates buffered)", |
| 155 | .def = "0", |
| 156 | }, |
| 157 | { |
| 158 | .name = "buffered", |
| 159 | .type = FIO_OPT_BOOL, |
| 160 | .off1 = td_var_offset(odirect), |
| 161 | .neg = 1, |
| 162 | .help = "Use buffered IO (negates direct)", |
Jens Axboe | 03b74b3 | 2007-01-11 11:04:31 +0100 | [diff] [blame] | 163 | .def = "1", |
| 164 | }, |
| 165 | { |
| 166 | .name = "overwrite", |
| 167 | .type = FIO_OPT_BOOL, |
| 168 | .off1 = td_var_offset(overwrite), |
| 169 | .help = "When writing, set whether to overwrite current data", |
| 170 | .def = "0", |
| 171 | }, |
| 172 | { |
| 173 | .name = "loops", |
| 174 | .type = FIO_OPT_INT, |
| 175 | .off1 = td_var_offset(loops), |
| 176 | .help = "Number of times to run the job", |
| 177 | .def = "1", |
| 178 | }, |
| 179 | { |
| 180 | .name = "numjobs", |
| 181 | .type = FIO_OPT_INT, |
| 182 | .off1 = td_var_offset(numjobs), |
| 183 | .help = "Duplicate this job this many times", |
| 184 | .def = "1", |
| 185 | }, |
| 186 | { |
| 187 | .name = "startdelay", |
| 188 | .type = FIO_OPT_INT, |
| 189 | .off1 = td_var_offset(start_delay), |
| 190 | .help = "Only start job when this period has passed", |
| 191 | .def = "0", |
| 192 | }, |
| 193 | { |
| 194 | .name = "runtime", |
| 195 | .alias = "timeout", |
| 196 | .type = FIO_OPT_STR_VAL_TIME, |
| 197 | .off1 = td_var_offset(timeout), |
| 198 | .help = "Stop workload when this amount of time has passed", |
| 199 | .def = "0", |
| 200 | }, |
| 201 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 202 | .name = "mem", |
| 203 | .type = FIO_OPT_STR, |
| 204 | .cb = str_mem_cb, |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 205 | .help = "Backing type for IO buffers", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 206 | .def = "malloc", |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 207 | .posval = { "malloc", "shm", "shmhuge", "mmap", "mmaphuge", }, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 208 | }, |
| 209 | { |
| 210 | .name = "verify", |
| 211 | .type = FIO_OPT_STR, |
| 212 | .cb = str_verify_cb, |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 213 | .help = "Verify sum function", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 214 | .def = "0", |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 215 | .posval = { "crc32", "md5", }, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 216 | }, |
| 217 | { |
| 218 | .name = "write_iolog", |
Jens Axboe | 076efc7 | 2006-10-27 11:24:25 +0200 | [diff] [blame] | 219 | .type = FIO_OPT_STR_STORE, |
| 220 | .off1 = td_var_offset(write_iolog_file), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 221 | .help = "Store IO pattern to file", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 222 | }, |
| 223 | { |
Jens Axboe | 076efc7 | 2006-10-27 11:24:25 +0200 | [diff] [blame] | 224 | .name = "read_iolog", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 225 | .type = FIO_OPT_STR_STORE, |
Jens Axboe | 076efc7 | 2006-10-27 11:24:25 +0200 | [diff] [blame] | 226 | .off1 = td_var_offset(read_iolog_file), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 227 | .help = "Playback IO pattern from file", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 228 | }, |
| 229 | { |
| 230 | .name = "exec_prerun", |
| 231 | .type = FIO_OPT_STR_STORE, |
| 232 | .off1 = td_var_offset(exec_prerun), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 233 | .help = "Execute this file prior to running job", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 234 | }, |
| 235 | { |
| 236 | .name = "exec_postrun", |
| 237 | .type = FIO_OPT_STR_STORE, |
| 238 | .off1 = td_var_offset(exec_postrun), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 239 | .help = "Execute this file after running job", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 240 | }, |
| 241 | #ifdef FIO_HAVE_IOSCHED_SWITCH |
| 242 | { |
| 243 | .name = "ioscheduler", |
| 244 | .type = FIO_OPT_STR_STORE, |
| 245 | .off1 = td_var_offset(ioscheduler), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 246 | .help = "Use this IO scheduler on the backing device", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 247 | }, |
| 248 | #endif |
| 249 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 250 | .name = "zonesize", |
| 251 | .type = FIO_OPT_STR_VAL, |
| 252 | .off1 = td_var_offset(zone_size), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 253 | .help = "Give size of an IO zone", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 254 | .def = "0", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 255 | }, |
| 256 | { |
| 257 | .name = "zoneskip", |
| 258 | .type = FIO_OPT_STR_VAL, |
| 259 | .off1 = td_var_offset(zone_skip), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 260 | .help = "Space between IO zones", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 261 | .def = "0", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 262 | }, |
| 263 | { |
| 264 | .name = "lockmem", |
| 265 | .type = FIO_OPT_STR_VAL, |
| 266 | .cb = str_lockmem_cb, |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 267 | .help = "Lock down this amount of memory", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 268 | .def = "0", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 269 | }, |
| 270 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 271 | .name = "rwmixcycle", |
| 272 | .type = FIO_OPT_INT, |
| 273 | .off1 = td_var_offset(rwmixcycle), |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 274 | .help = "Cycle period for mixed read/write workloads (msec)", |
| 275 | .def = "500", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 276 | }, |
| 277 | { |
| 278 | .name = "rwmixread", |
| 279 | .type = FIO_OPT_INT, |
| 280 | .off1 = td_var_offset(rwmixread), |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 281 | .maxval = 100, |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 282 | .help = "Percentage of mixed workload that is reads", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 283 | .def = "50", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 284 | }, |
| 285 | { |
| 286 | .name = "rwmixwrite", |
| 287 | .type = FIO_OPT_INT, |
| 288 | .off1 = td_var_offset(rwmixwrite), |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 289 | .maxval = 100, |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 290 | .help = "Percentage of mixed workload that is writes", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 291 | .def = "50", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 292 | }, |
| 293 | { |
| 294 | .name = "nice", |
| 295 | .type = FIO_OPT_INT, |
| 296 | .off1 = td_var_offset(nice), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 297 | .help = "Set job CPU nice value", |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 298 | .minval = -19, |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 299 | .maxval = 20, |
| 300 | .def = "0", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 301 | }, |
| 302 | #ifdef FIO_HAVE_IOPRIO |
| 303 | { |
| 304 | .name = "prio", |
| 305 | .type = FIO_OPT_INT, |
| 306 | .cb = str_prio_cb, |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 307 | .help = "Set job IO priority value", |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 308 | .minval = 0, |
| 309 | .maxval = 7, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 310 | }, |
| 311 | { |
| 312 | .name = "prioclass", |
| 313 | .type = FIO_OPT_INT, |
| 314 | .cb = str_prioclass_cb, |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 315 | .help = "Set job IO priority class", |
Jens Axboe | 15f7918 | 2007-01-10 12:26:18 +0100 | [diff] [blame] | 316 | .minval = 0, |
| 317 | .maxval = 3, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 318 | }, |
| 319 | #endif |
| 320 | { |
| 321 | .name = "thinktime", |
| 322 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 323 | .off1 = td_var_offset(thinktime), |
Jens Axboe | 5fa0f81 | 2007-01-11 14:06:35 +0100 | [diff] [blame] | 324 | .help = "Idle time between IO buffers (usec)", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 325 | .def = "0", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 326 | }, |
| 327 | { |
Jens Axboe | 9c1f743 | 2007-01-03 20:43:19 +0100 | [diff] [blame] | 328 | .name = "thinktime_blocks", |
| 329 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 330 | .off1 = td_var_offset(thinktime_blocks), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 331 | .help = "IO buffer period between 'thinktime'", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 332 | .def = "1", |
Jens Axboe | 9c1f743 | 2007-01-03 20:43:19 +0100 | [diff] [blame] | 333 | }, |
| 334 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 335 | .name = "rate", |
| 336 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 337 | .off1 = td_var_offset(rate), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 338 | .help = "Set bandwidth rate", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 339 | }, |
| 340 | { |
| 341 | .name = "ratemin", |
| 342 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 343 | .off1 = td_var_offset(ratemin), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 344 | .help = "The bottom limit accepted", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 345 | }, |
| 346 | { |
| 347 | .name = "ratecycle", |
| 348 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 349 | .off1 = td_var_offset(ratecycle), |
Jens Axboe | 6da1fa7 | 2007-01-10 11:27:48 +0100 | [diff] [blame] | 350 | .help = "Window average for rate limits (msec)", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 351 | .def = "1000", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 352 | }, |
| 353 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 354 | .name = "invalidate", |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 355 | .type = FIO_OPT_BOOL, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 356 | .off1 = td_var_offset(invalidate_cache), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 357 | .help = "Invalidate buffer/page cache prior to running job", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 358 | .def = "1", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 359 | }, |
| 360 | { |
| 361 | .name = "sync", |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 362 | .type = FIO_OPT_BOOL, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 363 | .off1 = td_var_offset(sync_io), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 364 | .help = "Use O_SYNC for buffered writes", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 365 | .def = "0", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 366 | }, |
| 367 | { |
| 368 | .name = "bwavgtime", |
| 369 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 370 | .off1 = td_var_offset(bw_avg_time), |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 371 | .help = "Time window over which to calculate bandwidth (msec)", |
| 372 | .def = "500", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 373 | }, |
| 374 | { |
| 375 | .name = "create_serialize", |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 376 | .type = FIO_OPT_BOOL, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 377 | .off1 = td_var_offset(create_serialize), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 378 | .help = "Serialize creating of job files", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 379 | .def = "1", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 380 | }, |
| 381 | { |
| 382 | .name = "create_fsync", |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 383 | .type = FIO_OPT_BOOL, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 384 | .off1 = td_var_offset(create_fsync), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 385 | .help = "Fsync file after creation", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 386 | .def = "1", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 387 | }, |
| 388 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 389 | .name = "cpuload", |
| 390 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 391 | .off1 = td_var_offset(cpuload), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 392 | .help = "Use this percentage of CPU", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 393 | }, |
| 394 | { |
| 395 | .name = "cpuchunks", |
| 396 | .type = FIO_OPT_INT, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 397 | .off1 = td_var_offset(cpucycle), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 398 | .help = "Length of the CPU burn cycles", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 399 | }, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 400 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 401 | { |
| 402 | .name = "cpumask", |
| 403 | .type = FIO_OPT_INT, |
| 404 | .cb = str_cpumask_cb, |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 405 | .help = "CPU affinity mask", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 406 | }, |
| 407 | #endif |
| 408 | { |
| 409 | .name = "end_fsync", |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 410 | .type = FIO_OPT_BOOL, |
Jens Axboe | 1304923 | 2007-01-03 20:45:09 +0100 | [diff] [blame] | 411 | .off1 = td_var_offset(end_fsync), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 412 | .help = "Include fsync at the end of job", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 413 | .def = "0", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 414 | }, |
| 415 | { |
| 416 | .name = "unlink", |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 417 | .type = FIO_OPT_BOOL, |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 418 | .off1 = td_var_offset(unlink), |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 419 | .help = "Unlink created files after job has completed", |
| 420 | .def = "1", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 421 | }, |
| 422 | { |
| 423 | .name = "exitall", |
| 424 | .type = FIO_OPT_STR_SET, |
| 425 | .cb = str_exitall_cb, |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 426 | .help = "Terminate all jobs when one exits", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 427 | }, |
| 428 | { |
| 429 | .name = "stonewall", |
| 430 | .type = FIO_OPT_STR_SET, |
| 431 | .off1 = td_var_offset(stonewall), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 432 | .help = "Insert a hard barrier between this job and previous", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 433 | }, |
| 434 | { |
| 435 | .name = "thread", |
| 436 | .type = FIO_OPT_STR_SET, |
Jens Axboe | d9bb3b8 | 2007-01-10 20:30:53 +0100 | [diff] [blame] | 437 | .off1 = td_var_offset(use_thread), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 438 | .help = "Use threads instead of forks", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 439 | }, |
| 440 | { |
| 441 | .name = "write_bw_log", |
| 442 | .type = FIO_OPT_STR_SET, |
| 443 | .off1 = td_var_offset(write_bw_log), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 444 | .help = "Write log of bandwidth during run", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 445 | }, |
| 446 | { |
| 447 | .name = "write_lat_log", |
| 448 | .type = FIO_OPT_STR_SET, |
| 449 | .off1 = td_var_offset(write_lat_log), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 450 | .help = "Write log of latency during run", |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 451 | }, |
| 452 | { |
Jens Axboe | 56bb17f | 2006-12-20 20:27:36 +0100 | [diff] [blame] | 453 | .name = "hugepage-size", |
| 454 | .type = FIO_OPT_STR_VAL, |
| 455 | .off1 = td_var_offset(hugepage_size), |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 456 | .help = "When using hugepages, specify size of each page", |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 457 | .def = __stringify(FIO_HUGE_PAGE), |
Jens Axboe | 56bb17f | 2006-12-20 20:27:36 +0100 | [diff] [blame] | 458 | }, |
| 459 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 460 | .name = NULL, |
| 461 | }, |
| 462 | }; |
| 463 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 464 | #define FIO_JOB_OPTS (sizeof(options) / sizeof(struct fio_option)) |
| 465 | #define FIO_CMD_OPTS (16) |
| 466 | #define FIO_GETOPT_JOB (0x89988998) |
| 467 | |
| 468 | /* |
| 469 | * Command line options. These will contain the above, plus a few |
| 470 | * extra that only pertain to fio itself and not jobs. |
| 471 | */ |
| 472 | static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = { |
| 473 | { |
| 474 | .name = "output", |
| 475 | .has_arg = required_argument, |
| 476 | .val = 'o', |
| 477 | }, |
| 478 | { |
| 479 | .name = "timeout", |
| 480 | .has_arg = required_argument, |
| 481 | .val = 't', |
| 482 | }, |
| 483 | { |
| 484 | .name = "latency-log", |
| 485 | .has_arg = required_argument, |
| 486 | .val = 'l', |
| 487 | }, |
| 488 | { |
| 489 | .name = "bandwidth-log", |
| 490 | .has_arg = required_argument, |
| 491 | .val = 'b', |
| 492 | }, |
| 493 | { |
| 494 | .name = "minimal", |
| 495 | .has_arg = optional_argument, |
| 496 | .val = 'm', |
| 497 | }, |
| 498 | { |
| 499 | .name = "version", |
| 500 | .has_arg = no_argument, |
| 501 | .val = 'v', |
| 502 | }, |
| 503 | { |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 504 | .name = "help", |
| 505 | .has_arg = no_argument, |
| 506 | .val = 'h', |
| 507 | }, |
| 508 | { |
| 509 | .name = "cmdhelp", |
| 510 | .has_arg = required_argument, |
| 511 | .val = 'c', |
| 512 | }, |
| 513 | { |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 514 | .name = NULL, |
| 515 | }, |
| 516 | }; |
| 517 | |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 518 | static int def_timeout = 0; |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 519 | |
Jens Axboe | 5cd033b | 2007-01-09 08:19:01 +0100 | [diff] [blame] | 520 | static char fio_version_string[] = "fio 1.11"; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 521 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 522 | static char **ini_file; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 523 | static int max_jobs = MAX_JOBS; |
| 524 | |
| 525 | struct thread_data def_thread; |
| 526 | struct thread_data *threads = NULL; |
| 527 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 528 | int exitall_on_terminate = 0; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 529 | int terse_output = 0; |
Jens Axboe | c04f7ec | 2006-05-31 10:13:16 +0200 | [diff] [blame] | 530 | unsigned long long mlock_size = 0; |
Jens Axboe | eb8bbf4 | 2006-06-08 21:40:11 +0200 | [diff] [blame] | 531 | FILE *f_out = NULL; |
| 532 | FILE *f_err = NULL; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 533 | |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 534 | static int write_lat_log = 0; |
| 535 | static int write_bw_log = 0; |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 536 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 537 | /* |
| 538 | * Return a free job structure. |
| 539 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 540 | static struct thread_data *get_new_job(int global, struct thread_data *parent) |
| 541 | { |
| 542 | struct thread_data *td; |
| 543 | |
| 544 | if (global) |
| 545 | return &def_thread; |
| 546 | if (thread_number >= max_jobs) |
| 547 | return NULL; |
| 548 | |
| 549 | td = &threads[thread_number++]; |
Jens Axboe | ddaeaa5 | 2006-06-08 11:00:58 +0200 | [diff] [blame] | 550 | *td = *parent; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 551 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 552 | td->thread_number = thread_number; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 553 | return td; |
| 554 | } |
| 555 | |
| 556 | static void put_job(struct thread_data *td) |
| 557 | { |
Jens Axboe | 549577a | 2006-10-30 12:23:41 +0100 | [diff] [blame] | 558 | if (td == &def_thread) |
| 559 | return; |
| 560 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 561 | memset(&threads[td->thread_number - 1], 0, sizeof(*td)); |
| 562 | thread_number--; |
| 563 | } |
| 564 | |
Jens Axboe | dad915e | 2006-10-27 11:10:18 +0200 | [diff] [blame] | 565 | /* |
| 566 | * Lazy way of fixing up options that depend on each other. We could also |
| 567 | * define option callback handlers, but this is easier. |
| 568 | */ |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 569 | static void fixup_options(struct thread_data *td) |
| 570 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 571 | if (!td->rwmixread && td->rwmixwrite) |
| 572 | td->rwmixread = 100 - td->rwmixwrite; |
Jens Axboe | dad915e | 2006-10-27 11:10:18 +0200 | [diff] [blame] | 573 | |
Jens Axboe | 076efc7 | 2006-10-27 11:24:25 +0200 | [diff] [blame] | 574 | if (td->write_iolog_file && td->read_iolog_file) { |
| 575 | log_err("fio: read iolog overrides write_iolog\n"); |
| 576 | free(td->write_iolog_file); |
| 577 | td->write_iolog_file = NULL; |
| 578 | } |
Jens Axboe | 16b462a | 2006-10-30 12:35:18 +0100 | [diff] [blame] | 579 | |
| 580 | if (td->io_ops->flags & FIO_SYNCIO) |
| 581 | td->iodepth = 1; |
| 582 | else { |
| 583 | if (!td->iodepth) |
| 584 | td->iodepth = td->nr_files; |
| 585 | } |
| 586 | |
| 587 | /* |
| 588 | * only really works for sequential io for now, and with 1 file |
| 589 | */ |
| 590 | if (td->zone_size && !td->sequential && td->nr_files == 1) |
| 591 | td->zone_size = 0; |
| 592 | |
| 593 | /* |
| 594 | * Reads can do overwrites, we always need to pre-create the file |
| 595 | */ |
| 596 | if (td_read(td) || td_rw(td)) |
| 597 | td->overwrite = 1; |
| 598 | |
Jens Axboe | a00735e | 2006-11-03 08:58:08 +0100 | [diff] [blame] | 599 | if (!td->min_bs[DDIR_READ]) |
| 600 | td->min_bs[DDIR_READ]= td->bs[DDIR_READ]; |
| 601 | if (!td->max_bs[DDIR_READ]) |
| 602 | td->max_bs[DDIR_READ] = td->bs[DDIR_READ]; |
| 603 | if (!td->min_bs[DDIR_WRITE]) |
Jens Axboe | 75e6f36 | 2006-11-03 08:17:09 +0100 | [diff] [blame] | 604 | td->min_bs[DDIR_WRITE]= td->bs[DDIR_WRITE]; |
Jens Axboe | a00735e | 2006-11-03 08:58:08 +0100 | [diff] [blame] | 605 | if (!td->max_bs[DDIR_WRITE]) |
Jens Axboe | 75e6f36 | 2006-11-03 08:17:09 +0100 | [diff] [blame] | 606 | td->max_bs[DDIR_WRITE] = td->bs[DDIR_WRITE]; |
Jens Axboe | a00735e | 2006-11-03 08:58:08 +0100 | [diff] [blame] | 607 | |
| 608 | td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]); |
| 609 | |
Jens Axboe | 16b462a | 2006-10-30 12:35:18 +0100 | [diff] [blame] | 610 | if (td_read(td) && !td_rw(td)) |
| 611 | td->verify = 0; |
Jens Axboe | bb8895e | 2006-10-30 15:14:48 +0100 | [diff] [blame] | 612 | |
| 613 | if (td->norandommap && td->verify != VERIFY_NONE) { |
| 614 | log_err("fio: norandommap given, verify disabled\n"); |
| 615 | td->verify = VERIFY_NONE; |
| 616 | } |
Jens Axboe | 690adba | 2006-10-30 15:25:09 +0100 | [diff] [blame] | 617 | if (td->bs_unaligned && (td->odirect || td->io_ops->flags & FIO_RAWIO)) |
| 618 | log_err("fio: bs_unaligned may not work with raw io\n"); |
Jens Axboe | e0a2233 | 2006-12-20 12:54:25 +0100 | [diff] [blame] | 619 | |
| 620 | /* |
| 621 | * O_DIRECT and char doesn't mix, clear that flag if necessary. |
| 622 | */ |
| 623 | if (td->filetype == FIO_TYPE_CHAR && td->odirect) |
| 624 | td->odirect = 0; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 625 | } |
| 626 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 627 | /* |
Jens Axboe | f8977ee | 2006-11-06 14:03:03 +0100 | [diff] [blame] | 628 | * This function leaks the buffer |
| 629 | */ |
| 630 | static char *to_kmg(unsigned int val) |
| 631 | { |
| 632 | char *buf = malloc(32); |
Jens Axboe | 245142f | 2006-11-08 12:49:21 +0100 | [diff] [blame] | 633 | char post[] = { 0, 'K', 'M', 'G', 'P', 0 }; |
Jens Axboe | f8977ee | 2006-11-06 14:03:03 +0100 | [diff] [blame] | 634 | char *p = post; |
| 635 | |
Jens Axboe | 245142f | 2006-11-08 12:49:21 +0100 | [diff] [blame] | 636 | do { |
Jens Axboe | f8977ee | 2006-11-06 14:03:03 +0100 | [diff] [blame] | 637 | if (val & 1023) |
| 638 | break; |
| 639 | |
| 640 | val >>= 10; |
| 641 | p++; |
Jens Axboe | 245142f | 2006-11-08 12:49:21 +0100 | [diff] [blame] | 642 | } while (*p); |
Jens Axboe | f8977ee | 2006-11-06 14:03:03 +0100 | [diff] [blame] | 643 | |
| 644 | snprintf(buf, 31, "%u%c", val, *p); |
| 645 | return buf; |
| 646 | } |
| 647 | |
| 648 | /* |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 649 | * Adds a job to the list of things todo. Sanitizes the various options |
| 650 | * to make sure we don't have conflicts, and initializes various |
| 651 | * members of td. |
| 652 | */ |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 653 | 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] | 654 | { |
Jens Axboe | 3c9b60c | 2006-11-07 08:36:14 +0100 | [diff] [blame] | 655 | const char *ddir_str[] = { "read", "write", "randread", "randwrite", |
| 656 | "rw", NULL, "randrw" }; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 657 | struct stat sb; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 658 | int numjobs, ddir, i; |
| 659 | struct fio_file *f; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 660 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 661 | /* |
| 662 | * the def_thread is just for options, it's not a real job |
| 663 | */ |
| 664 | if (td == &def_thread) |
| 665 | return 0; |
| 666 | |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 667 | assert(td->io_ops); |
Jens Axboe | df64119 | 2006-10-12 07:55:41 +0200 | [diff] [blame] | 668 | |
Jens Axboe | 690adba | 2006-10-30 15:25:09 +0100 | [diff] [blame] | 669 | if (td->odirect) |
| 670 | td->io_ops->flags |= FIO_RAWIO; |
| 671 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 672 | td->filetype = FIO_TYPE_FILE; |
Jens Axboe | 0af7b54 | 2006-02-17 10:10:12 +0100 | [diff] [blame] | 673 | if (!stat(jobname, &sb)) { |
| 674 | if (S_ISBLK(sb.st_mode)) |
| 675 | td->filetype = FIO_TYPE_BD; |
| 676 | else if (S_ISCHR(sb.st_mode)) |
| 677 | td->filetype = FIO_TYPE_CHAR; |
| 678 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 679 | |
Jens Axboe | e0a2233 | 2006-12-20 12:54:25 +0100 | [diff] [blame] | 680 | fixup_options(td); |
| 681 | |
Jens Axboe | 13f8e2d | 2006-10-24 09:29:45 +0200 | [diff] [blame] | 682 | if (td->filename) |
| 683 | td->nr_uniq_files = 1; |
| 684 | else |
| 685 | td->nr_uniq_files = td->nr_files; |
| 686 | |
| 687 | if (td->filetype == FIO_TYPE_FILE || td->filename) { |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 688 | char tmp[PATH_MAX]; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 689 | int len = 0; |
Jens Axboe | e9c047a | 2006-06-07 21:13:04 +0200 | [diff] [blame] | 690 | |
Jens Axboe | ef899b6 | 2006-06-06 09:31:00 +0200 | [diff] [blame] | 691 | if (td->directory && td->directory[0] != '\0') |
Jens Axboe | 8aeebd5 | 2007-01-08 10:47:43 +0100 | [diff] [blame] | 692 | len = sprintf(tmp, "%s/", td->directory); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 693 | |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 694 | td->files = malloc(sizeof(struct fio_file) * td->nr_files); |
| 695 | |
| 696 | for_each_file(td, f, i) { |
| 697 | memset(f, 0, sizeof(*f)); |
| 698 | f->fd = -1; |
| 699 | |
Jens Axboe | 13f8e2d | 2006-10-24 09:29:45 +0200 | [diff] [blame] | 700 | if (td->filename) |
| 701 | sprintf(tmp + len, "%s", td->filename); |
| 702 | else |
| 703 | sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i); |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 704 | f->file_name = strdup(tmp); |
| 705 | } |
| 706 | } else { |
| 707 | td->nr_files = 1; |
| 708 | td->files = malloc(sizeof(struct fio_file)); |
| 709 | f = &td->files[0]; |
| 710 | |
| 711 | memset(f, 0, sizeof(*f)); |
| 712 | f->fd = -1; |
| 713 | f->file_name = strdup(jobname); |
| 714 | } |
| 715 | |
| 716 | for_each_file(td, f, i) { |
| 717 | f->file_size = td->total_file_size / td->nr_files; |
| 718 | f->file_offset = td->start_offset; |
| 719 | } |
| 720 | |
Jens Axboe | bbfd6b0 | 2006-06-07 19:42:54 +0200 | [diff] [blame] | 721 | fio_sem_init(&td->mutex, 0); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 722 | |
| 723 | td->clat_stat[0].min_val = td->clat_stat[1].min_val = ULONG_MAX; |
| 724 | td->slat_stat[0].min_val = td->slat_stat[1].min_val = ULONG_MAX; |
| 725 | td->bw_stat[0].min_val = td->bw_stat[1].min_val = ULONG_MAX; |
| 726 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 727 | if (td->stonewall && td->thread_number > 1) |
| 728 | groupid++; |
| 729 | |
| 730 | td->groupid = groupid; |
| 731 | |
| 732 | if (setup_rate(td)) |
| 733 | goto err; |
| 734 | |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 735 | if (td->write_lat_log) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 736 | setup_log(&td->slat_log); |
| 737 | setup_log(&td->clat_log); |
| 738 | } |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 739 | if (td->write_bw_log) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 740 | setup_log(&td->bw_log); |
| 741 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 742 | if (!td->name) |
| 743 | td->name = strdup(jobname); |
Jens Axboe | 0145205 | 2006-06-07 10:29:47 +0200 | [diff] [blame] | 744 | |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 745 | ddir = td->ddir + (!td->sequential << 1) + (td->iomix << 2); |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 746 | |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 747 | if (!terse_output) { |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 748 | if (!job_add_num) { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 749 | if (td->io_ops->flags & FIO_CPUIO) |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 750 | fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle); |
Jens Axboe | f8977ee | 2006-11-06 14:03:03 +0100 | [diff] [blame] | 751 | else { |
| 752 | char *c1, *c2, *c3, *c4; |
| 753 | |
| 754 | c1 = to_kmg(td->min_bs[DDIR_READ]); |
| 755 | c2 = to_kmg(td->max_bs[DDIR_READ]); |
| 756 | c3 = to_kmg(td->min_bs[DDIR_WRITE]); |
| 757 | c4 = to_kmg(td->max_bs[DDIR_WRITE]); |
| 758 | |
Jens Axboe | d56cbab | 2007-01-11 19:24:55 +0100 | [diff] [blame^] | 759 | fprintf(f_out, "%s: (g=%d): rw=%s, bs=%s-%s/%s-%s, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[ddir], c1, c2, c3, c4, td->io_ops->name, td->iodepth); |
Jens Axboe | f8977ee | 2006-11-06 14:03:03 +0100 | [diff] [blame] | 760 | |
| 761 | free(c1); |
| 762 | free(c2); |
| 763 | free(c3); |
| 764 | free(c4); |
| 765 | } |
Jens Axboe | b990b5c | 2006-09-14 09:48:22 +0200 | [diff] [blame] | 766 | } else if (job_add_num == 1) |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 767 | fprintf(f_out, "...\n"); |
| 768 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 769 | |
| 770 | /* |
| 771 | * recurse add identical jobs, clear numjobs and stonewall options |
| 772 | * as they don't apply to sub-jobs |
| 773 | */ |
| 774 | numjobs = td->numjobs; |
| 775 | while (--numjobs) { |
| 776 | struct thread_data *td_new = get_new_job(0, td); |
| 777 | |
| 778 | if (!td_new) |
| 779 | goto err; |
| 780 | |
| 781 | td_new->numjobs = 1; |
| 782 | td_new->stonewall = 0; |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 783 | job_add_num = numjobs - 1; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 784 | |
Jens Axboe | 7515484 | 2006-06-01 13:56:09 +0200 | [diff] [blame] | 785 | if (add_job(td_new, jobname, job_add_num)) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 786 | goto err; |
| 787 | } |
| 788 | return 0; |
| 789 | err: |
| 790 | put_job(td); |
| 791 | return -1; |
| 792 | } |
| 793 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 794 | /* |
| 795 | * Initialize the various random states we need (random io, block size ranges, |
| 796 | * read/write mix, etc). |
| 797 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 798 | int init_random_state(struct thread_data *td) |
| 799 | { |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 800 | unsigned long seeds[4]; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 801 | int fd, num_maps, blocks, i; |
Jens Axboe | 0ab8db8 | 2006-10-18 17:16:23 +0200 | [diff] [blame] | 802 | struct fio_file *f; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 803 | |
Jens Axboe | f48b467 | 2006-10-27 11:30:07 +0200 | [diff] [blame] | 804 | if (td->io_ops->flags & FIO_CPUIO) |
| 805 | return 0; |
| 806 | |
Jens Axboe | 1ac267b | 2006-05-31 20:29:00 +0200 | [diff] [blame] | 807 | fd = open("/dev/urandom", O_RDONLY); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 808 | if (fd == -1) { |
| 809 | td_verror(td, errno); |
| 810 | return 1; |
| 811 | } |
| 812 | |
Jens Axboe | a6ccc7b | 2006-06-02 10:14:15 +0200 | [diff] [blame] | 813 | if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 814 | td_verror(td, EIO); |
| 815 | close(fd); |
| 816 | return 1; |
| 817 | } |
| 818 | |
| 819 | close(fd); |
| 820 | |
Jens Axboe | 6dfd46b | 2006-06-07 13:57:06 +0200 | [diff] [blame] | 821 | os_random_seed(seeds[0], &td->bsrange_state); |
| 822 | os_random_seed(seeds[1], &td->verify_state); |
| 823 | os_random_seed(seeds[2], &td->rwmix_state); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 824 | |
| 825 | if (td->sequential) |
| 826 | return 0; |
| 827 | |
Jens Axboe | 9ebc27e | 2006-06-12 10:21:50 +0200 | [diff] [blame] | 828 | if (td->rand_repeatable) |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 829 | seeds[3] = FIO_RANDSEED; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 830 | |
Jens Axboe | bb8895e | 2006-10-30 15:14:48 +0100 | [diff] [blame] | 831 | if (!td->norandommap) { |
| 832 | for_each_file(td, f, i) { |
Jens Axboe | a00735e | 2006-11-03 08:58:08 +0100 | [diff] [blame] | 833 | blocks = (f->file_size + td->rw_min_bs - 1) / td->rw_min_bs; |
Jens Axboe | c7c280e | 2006-11-02 20:10:33 +0100 | [diff] [blame] | 834 | num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP; |
Jens Axboe | bb8895e | 2006-10-30 15:14:48 +0100 | [diff] [blame] | 835 | f->file_map = malloc(num_maps * sizeof(long)); |
| 836 | f->num_maps = num_maps; |
| 837 | memset(f->file_map, 0, num_maps * sizeof(long)); |
| 838 | } |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 839 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 840 | |
Jens Axboe | 6dfd46b | 2006-06-07 13:57:06 +0200 | [diff] [blame] | 841 | os_random_seed(seeds[3], &td->random_state); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 842 | return 0; |
| 843 | } |
| 844 | |
| 845 | static void fill_cpu_mask(os_cpu_mask_t cpumask, int cpu) |
| 846 | { |
| 847 | #ifdef FIO_HAVE_CPU_AFFINITY |
| 848 | unsigned int i; |
| 849 | |
| 850 | CPU_ZERO(&cpumask); |
| 851 | |
| 852 | for (i = 0; i < sizeof(int) * 8; i++) { |
| 853 | if ((1 << i) & cpu) |
| 854 | CPU_SET(i, &cpumask); |
| 855 | } |
| 856 | #endif |
| 857 | } |
| 858 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 859 | static int is_empty_or_comment(char *line) |
| 860 | { |
| 861 | unsigned int i; |
| 862 | |
| 863 | for (i = 0; i < strlen(line); i++) { |
| 864 | if (line[i] == ';') |
| 865 | return 1; |
| 866 | if (!isspace(line[i]) && !iscntrl(line[i])) |
| 867 | return 0; |
| 868 | } |
| 869 | |
| 870 | return 1; |
| 871 | } |
| 872 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 873 | static int str_rw_cb(void *data, const char *mem) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 874 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 875 | struct thread_data *td = data; |
| 876 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 877 | if (!strncmp(mem, "read", 4) || !strncmp(mem, "0", 1)) { |
| 878 | td->ddir = DDIR_READ; |
| 879 | td->sequential = 1; |
| 880 | return 0; |
| 881 | } else if (!strncmp(mem, "randread", 8)) { |
| 882 | td->ddir = DDIR_READ; |
| 883 | td->sequential = 0; |
| 884 | return 0; |
| 885 | } else if (!strncmp(mem, "write", 5) || !strncmp(mem, "1", 1)) { |
| 886 | td->ddir = DDIR_WRITE; |
| 887 | td->sequential = 1; |
| 888 | return 0; |
| 889 | } else if (!strncmp(mem, "randwrite", 9)) { |
| 890 | td->ddir = DDIR_WRITE; |
| 891 | td->sequential = 0; |
| 892 | return 0; |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 893 | } else if (!strncmp(mem, "rw", 2)) { |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 894 | td->ddir = DDIR_READ; |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 895 | td->iomix = 1; |
| 896 | td->sequential = 1; |
| 897 | return 0; |
| 898 | } else if (!strncmp(mem, "randrw", 6)) { |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 899 | td->ddir = DDIR_READ; |
Jens Axboe | 3d60d1e | 2006-05-25 06:31:06 +0200 | [diff] [blame] | 900 | td->iomix = 1; |
| 901 | td->sequential = 0; |
| 902 | return 0; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 903 | } |
| 904 | |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 905 | log_err("fio: data direction: read, write, randread, randwrite, rw, randrw\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 906 | return 1; |
| 907 | } |
| 908 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 909 | static int str_verify_cb(void *data, const char *mem) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 910 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 911 | struct thread_data *td = data; |
| 912 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 913 | if (!strncmp(mem, "0", 1)) { |
| 914 | td->verify = VERIFY_NONE; |
| 915 | return 0; |
| 916 | } else if (!strncmp(mem, "md5", 3) || !strncmp(mem, "1", 1)) { |
| 917 | td->verify = VERIFY_MD5; |
| 918 | return 0; |
| 919 | } else if (!strncmp(mem, "crc32", 5)) { |
| 920 | td->verify = VERIFY_CRC32; |
| 921 | return 0; |
| 922 | } |
| 923 | |
Jens Axboe | 3b70d7e | 2006-06-08 21:48:46 +0200 | [diff] [blame] | 924 | log_err("fio: verify types: md5, crc32\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 925 | return 1; |
| 926 | } |
| 927 | |
Jens Axboe | 313cb20 | 2006-12-21 09:50:00 +0100 | [diff] [blame] | 928 | /* |
| 929 | * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. |
| 930 | */ |
| 931 | static char *get_mmap_file(const char *str) |
| 932 | { |
| 933 | char *p = strstr(str, ":"); |
| 934 | |
| 935 | if (!p) |
| 936 | return NULL; |
| 937 | |
| 938 | p++; |
| 939 | strip_blank_front(&p); |
| 940 | strip_blank_end(p); |
| 941 | return strdup(p); |
| 942 | } |
| 943 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 944 | static int str_mem_cb(void *data, const char *mem) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 945 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 946 | struct thread_data *td = data; |
| 947 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 948 | if (!strncmp(mem, "malloc", 6)) { |
| 949 | td->mem_type = MEM_MALLOC; |
| 950 | return 0; |
Jens Axboe | d0bdaf4 | 2006-12-20 14:40:44 +0100 | [diff] [blame] | 951 | } else if (!strncmp(mem, "mmaphuge", 8)) { |
| 952 | #ifdef FIO_HAVE_HUGETLB |
Jens Axboe | d0bdaf4 | 2006-12-20 14:40:44 +0100 | [diff] [blame] | 953 | /* |
| 954 | * mmaphuge must be appended with the actual file |
| 955 | */ |
Jens Axboe | 313cb20 | 2006-12-21 09:50:00 +0100 | [diff] [blame] | 956 | td->mmapfile = get_mmap_file(mem); |
| 957 | if (!td->mmapfile) { |
Jens Axboe | d0bdaf4 | 2006-12-20 14:40:44 +0100 | [diff] [blame] | 958 | log_err("fio: mmaphuge:/path/to/file\n"); |
| 959 | return 1; |
| 960 | } |
| 961 | |
Jens Axboe | d0bdaf4 | 2006-12-20 14:40:44 +0100 | [diff] [blame] | 962 | td->mem_type = MEM_MMAPHUGE; |
| 963 | return 0; |
| 964 | #else |
| 965 | log_err("fio: mmaphuge not available\n"); |
| 966 | return 1; |
| 967 | #endif |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 968 | } else if (!strncmp(mem, "mmap", 4)) { |
Jens Axboe | 313cb20 | 2006-12-21 09:50:00 +0100 | [diff] [blame] | 969 | /* |
| 970 | * Check if the user wants file backed memory. It's ok |
| 971 | * if there's no file given, we'll just use anon mamp then. |
| 972 | */ |
| 973 | td->mmapfile = get_mmap_file(mem); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 974 | td->mem_type = MEM_MMAP; |
| 975 | return 0; |
Jens Axboe | 74b025b | 2006-12-19 15:18:14 +0100 | [diff] [blame] | 976 | } else if (!strncmp(mem, "shmhuge", 7)) { |
| 977 | #ifdef FIO_HAVE_HUGETLB |
| 978 | td->mem_type = MEM_SHMHUGE; |
| 979 | return 0; |
| 980 | #else |
| 981 | log_err("fio: shmhuge not available\n"); |
| 982 | return 1; |
| 983 | #endif |
Jens Axboe | 0268b8b | 2006-12-20 12:48:23 +0100 | [diff] [blame] | 984 | } else if (!strncmp(mem, "shm", 3)) { |
| 985 | td->mem_type = MEM_SHM; |
| 986 | return 0; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 987 | } |
| 988 | |
Jens Axboe | d0bdaf4 | 2006-12-20 14:40:44 +0100 | [diff] [blame] | 989 | log_err("fio: mem type: malloc, shm, shmhuge, mmap, mmaphuge\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 990 | return 1; |
| 991 | } |
| 992 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 993 | static int str_ioengine_cb(void *data, const char *str) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 994 | { |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 995 | struct thread_data *td = data; |
| 996 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 997 | td->io_ops = load_ioengine(td, str); |
| 998 | if (td->io_ops) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 999 | return 0; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1000 | |
Jens Axboe | 08aae9a | 2006-11-24 12:43:49 +0100 | [diff] [blame] | 1001 | log_err("fio: ioengine= libaio, posixaio, sync, mmap, sgio, splice, cpu, null\n"); |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 1002 | log_err("fio: or specify path to dynamic ioengine module\n"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1003 | return 1; |
| 1004 | } |
| 1005 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 1006 | static int str_lockmem_cb(void fio_unused *data, unsigned long *val) |
| 1007 | { |
| 1008 | mlock_size = *val; |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 1012 | #ifdef FIO_HAVE_IOPRIO |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 1013 | static int str_prioclass_cb(void *data, unsigned int *val) |
| 1014 | { |
| 1015 | struct thread_data *td = data; |
| 1016 | |
| 1017 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; |
| 1018 | return 0; |
| 1019 | } |
| 1020 | |
| 1021 | static int str_prio_cb(void *data, unsigned int *val) |
| 1022 | { |
| 1023 | struct thread_data *td = data; |
| 1024 | |
| 1025 | td->ioprio |= *val; |
| 1026 | return 0; |
| 1027 | } |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 1028 | #endif |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 1029 | |
| 1030 | static int str_exitall_cb(void) |
| 1031 | { |
| 1032 | exitall_on_terminate = 1; |
| 1033 | return 0; |
| 1034 | } |
| 1035 | |
| 1036 | static int str_cpumask_cb(void *data, unsigned int *val) |
| 1037 | { |
| 1038 | struct thread_data *td = data; |
| 1039 | |
| 1040 | fill_cpu_mask(td->cpumask, *val); |
| 1041 | return 0; |
| 1042 | } |
| 1043 | |
Jens Axboe | 0726198 | 2006-06-07 10:51:12 +0200 | [diff] [blame] | 1044 | /* |
| 1045 | * This is our [ini] type file parser. |
| 1046 | */ |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 1047 | static int parse_jobs_ini(char *file, int stonewall_flag) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1048 | { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 1049 | unsigned int global; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1050 | struct thread_data *td; |
Jens Axboe | fee3bb4 | 2006-10-30 13:32:08 +0100 | [diff] [blame] | 1051 | char *string, *name; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1052 | fpos_t off; |
| 1053 | FILE *f; |
| 1054 | char *p; |
Jens Axboe | 0c7e37a | 2006-06-13 14:53:38 +0200 | [diff] [blame] | 1055 | int ret = 0, stonewall; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1056 | |
| 1057 | f = fopen(file, "r"); |
| 1058 | if (!f) { |
Jens Axboe | aea47d4 | 2006-05-26 19:27:29 +0200 | [diff] [blame] | 1059 | perror("fopen job file"); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1060 | return 1; |
| 1061 | } |
| 1062 | |
| 1063 | string = malloc(4096); |
| 1064 | name = malloc(256); |
Jens Axboe | fee3bb4 | 2006-10-30 13:32:08 +0100 | [diff] [blame] | 1065 | memset(name, 0, 256); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1066 | |
Jens Axboe | 0c7e37a | 2006-06-13 14:53:38 +0200 | [diff] [blame] | 1067 | stonewall = stonewall_flag; |
Jens Axboe | 7c124ac | 2006-10-30 13:36:52 +0100 | [diff] [blame] | 1068 | do { |
| 1069 | p = fgets(string, 4095, f); |
| 1070 | if (!p) |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 1071 | break; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1072 | if (is_empty_or_comment(p)) |
| 1073 | continue; |
Jens Axboe | fee3bb4 | 2006-10-30 13:32:08 +0100 | [diff] [blame] | 1074 | if (sscanf(p, "[%255s]", name) != 1) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1075 | continue; |
| 1076 | |
| 1077 | global = !strncmp(name, "global", 6); |
| 1078 | |
| 1079 | name[strlen(name) - 1] = '\0'; |
| 1080 | |
| 1081 | td = get_new_job(global, &def_thread); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 1082 | if (!td) { |
| 1083 | ret = 1; |
| 1084 | break; |
| 1085 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1086 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1087 | /* |
| 1088 | * Seperate multiple job files by a stonewall |
| 1089 | */ |
Jens Axboe | f948191 | 2006-06-09 11:37:28 +0200 | [diff] [blame] | 1090 | if (!global && stonewall) { |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1091 | td->stonewall = stonewall; |
| 1092 | stonewall = 0; |
| 1093 | } |
| 1094 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1095 | fgetpos(f, &off); |
| 1096 | while ((p = fgets(string, 4096, f)) != NULL) { |
| 1097 | if (is_empty_or_comment(p)) |
| 1098 | continue; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 1099 | |
Jens Axboe | b6754f9 | 2006-05-30 14:29:32 +0200 | [diff] [blame] | 1100 | strip_blank_front(&p); |
Jens Axboe | 7c124ac | 2006-10-30 13:36:52 +0100 | [diff] [blame] | 1101 | |
| 1102 | if (p[0] == '[') |
| 1103 | break; |
| 1104 | |
Jens Axboe | 4ae3f76 | 2006-05-30 13:35:14 +0200 | [diff] [blame] | 1105 | strip_blank_end(p); |
Jens Axboe | aea47d4 | 2006-05-26 19:27:29 +0200 | [diff] [blame] | 1106 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 1107 | fgetpos(f, &off); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1108 | |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 1109 | /* |
| 1110 | * Don't break here, continue parsing options so we |
| 1111 | * dump all the bad ones. Makes trial/error fixups |
| 1112 | * easier on the user. |
| 1113 | */ |
Jens Axboe | 7c124ac | 2006-10-30 13:36:52 +0100 | [diff] [blame] | 1114 | ret |= parse_option(p, options, td); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1115 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1116 | |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 1117 | if (!ret) { |
| 1118 | fsetpos(f, &off); |
| 1119 | ret = add_job(td, name, 0); |
Jens Axboe | b1508cf | 2006-11-02 09:12:40 +0100 | [diff] [blame] | 1120 | } else { |
| 1121 | log_err("fio: job %s dropped\n", name); |
| 1122 | put_job(td); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 1123 | } |
Jens Axboe | 7c124ac | 2006-10-30 13:36:52 +0100 | [diff] [blame] | 1124 | } while (!ret); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1125 | |
| 1126 | free(string); |
| 1127 | free(name); |
| 1128 | fclose(f); |
Jens Axboe | 45410ac | 2006-06-07 11:10:39 +0200 | [diff] [blame] | 1129 | return ret; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | static int fill_def_thread(void) |
| 1133 | { |
| 1134 | memset(&def_thread, 0, sizeof(def_thread)); |
| 1135 | |
| 1136 | if (fio_getaffinity(getpid(), &def_thread.cpumask) == -1) { |
| 1137 | perror("sched_getaffinity"); |
| 1138 | return 1; |
| 1139 | } |
| 1140 | |
| 1141 | /* |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 1142 | * fill default options |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1143 | */ |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 1144 | fill_default_options(&def_thread, options); |
| 1145 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1146 | def_thread.timeout = def_timeout; |
Jens Axboe | ec94ec5 | 2006-10-20 10:59:19 +0200 | [diff] [blame] | 1147 | def_thread.write_bw_log = write_bw_log; |
| 1148 | def_thread.write_lat_log = write_lat_log; |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 1149 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1150 | #ifdef FIO_HAVE_DISK_UTIL |
| 1151 | def_thread.do_disk_util = 1; |
| 1152 | #endif |
| 1153 | |
| 1154 | return 0; |
| 1155 | } |
| 1156 | |
Jens Axboe | 0ab8db8 | 2006-10-18 17:16:23 +0200 | [diff] [blame] | 1157 | static void usage(void) |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 1158 | { |
| 1159 | printf("%s\n", fio_version_string); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1160 | printf("\t--output\tWrite output to file\n"); |
| 1161 | printf("\t--timeout\tRuntime in seconds\n"); |
| 1162 | printf("\t--latency-log\tGenerate per-job latency logs\n"); |
| 1163 | printf("\t--bandwidth-log\tGenerate per-job bandwidth logs\n"); |
| 1164 | printf("\t--minimal\tMinimal (terse) output\n"); |
| 1165 | printf("\t--version\tPrint version info and exit\n"); |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 1166 | printf("\t--help\t\tPrint this page\n"); |
| 1167 | printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of them\n"); |
Jens Axboe | 4785f99 | 2006-05-26 03:59:10 +0200 | [diff] [blame] | 1168 | } |
| 1169 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1170 | static int parse_cmd_line(int argc, char *argv[]) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1171 | { |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1172 | struct thread_data *td = NULL; |
Jens Axboe | c2b1e75 | 2006-10-30 09:03:13 +0100 | [diff] [blame] | 1173 | int c, ini_idx = 0, lidx, ret; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1174 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1175 | while ((c = getopt_long(argc, argv, "", long_options, &lidx)) != -1) { |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1176 | switch (c) { |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1177 | case 't': |
| 1178 | def_timeout = atoi(optarg); |
| 1179 | break; |
| 1180 | case 'l': |
| 1181 | write_lat_log = 1; |
| 1182 | break; |
| 1183 | case 'w': |
| 1184 | write_bw_log = 1; |
| 1185 | break; |
| 1186 | case 'o': |
| 1187 | f_out = fopen(optarg, "w+"); |
| 1188 | if (!f_out) { |
| 1189 | perror("fopen output"); |
| 1190 | exit(1); |
| 1191 | } |
| 1192 | f_err = f_out; |
| 1193 | break; |
| 1194 | case 'm': |
| 1195 | terse_output = 1; |
| 1196 | break; |
| 1197 | case 'h': |
| 1198 | usage(); |
| 1199 | exit(0); |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 1200 | case 'c': |
Jens Axboe | 29fc6af | 2007-01-09 21:22:02 +0100 | [diff] [blame] | 1201 | ret = show_cmd_help(options, optarg); |
| 1202 | exit(ret); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1203 | case 'v': |
| 1204 | printf("%s\n", fio_version_string); |
| 1205 | exit(0); |
| 1206 | case FIO_GETOPT_JOB: { |
| 1207 | const char *opt = long_options[lidx].name; |
| 1208 | char *val = optarg; |
| 1209 | |
Jens Axboe | c2b1e75 | 2006-10-30 09:03:13 +0100 | [diff] [blame] | 1210 | if (!strncmp(opt, "name", 4) && td) { |
| 1211 | ret = add_job(td, td->name ?: "fio", 0); |
| 1212 | if (ret) { |
| 1213 | put_job(td); |
| 1214 | return 0; |
| 1215 | } |
| 1216 | td = NULL; |
| 1217 | } |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1218 | if (!td) { |
Jens Axboe | 38d0adb | 2006-10-30 12:21:25 +0100 | [diff] [blame] | 1219 | int global = !strncmp(val, "global", 6); |
Jens Axboe | c2b1e75 | 2006-10-30 09:03:13 +0100 | [diff] [blame] | 1220 | |
| 1221 | td = get_new_job(global, &def_thread); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1222 | if (!td) |
| 1223 | return 0; |
| 1224 | } |
Jens Axboe | 38d0adb | 2006-10-30 12:21:25 +0100 | [diff] [blame] | 1225 | |
Jens Axboe | b1508cf | 2006-11-02 09:12:40 +0100 | [diff] [blame] | 1226 | ret = parse_cmd_option(opt, val, options, td); |
| 1227 | if (ret) { |
| 1228 | log_err("fio: job dropped\n"); |
| 1229 | put_job(td); |
| 1230 | td = NULL; |
| 1231 | } |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1232 | break; |
| 1233 | } |
| 1234 | default: |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1235 | break; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1236 | } |
| 1237 | } |
Jens Axboe | c9fad89 | 2006-05-27 17:26:50 +0200 | [diff] [blame] | 1238 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1239 | if (td) { |
Jens Axboe | c2b1e75 | 2006-10-30 09:03:13 +0100 | [diff] [blame] | 1240 | ret = add_job(td, td->name ?: "fio", 0); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1241 | if (ret) |
| 1242 | put_job(td); |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1243 | } |
Jens Axboe | 774a617 | 2006-08-24 08:44:26 +0200 | [diff] [blame] | 1244 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1245 | while (optind < argc) { |
| 1246 | ini_idx++; |
| 1247 | ini_file = realloc(ini_file, ini_idx * sizeof(char *)); |
| 1248 | ini_file[ini_idx - 1] = strdup(argv[optind]); |
| 1249 | optind++; |
Jens Axboe | eb8bbf4 | 2006-06-08 21:40:11 +0200 | [diff] [blame] | 1250 | } |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1251 | |
| 1252 | return ini_idx; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | static void free_shm(void) |
| 1256 | { |
| 1257 | struct shmid_ds sbuf; |
| 1258 | |
| 1259 | if (threads) { |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 1260 | shmdt((void *) threads); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1261 | threads = NULL; |
| 1262 | shmctl(shm_id, IPC_RMID, &sbuf); |
| 1263 | } |
| 1264 | } |
| 1265 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 1266 | /* |
| 1267 | * The thread area is shared between the main process and the job |
| 1268 | * threads/processes. So setup a shared memory segment that will hold |
| 1269 | * all the job info. |
| 1270 | */ |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1271 | static int setup_thread_area(void) |
| 1272 | { |
| 1273 | /* |
| 1274 | * 1024 is too much on some machines, scale max_jobs if |
| 1275 | * we get a failure that looks like too large a shm segment |
| 1276 | */ |
| 1277 | do { |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 1278 | size_t size = max_jobs * sizeof(struct thread_data); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1279 | |
Jens Axboe | 906c8d7 | 2006-06-13 09:37:56 +0200 | [diff] [blame] | 1280 | shm_id = shmget(0, size, IPC_CREAT | 0600); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1281 | if (shm_id != -1) |
| 1282 | break; |
| 1283 | if (errno != EINVAL) { |
| 1284 | perror("shmget"); |
| 1285 | break; |
| 1286 | } |
| 1287 | |
| 1288 | max_jobs >>= 1; |
| 1289 | } while (max_jobs); |
| 1290 | |
| 1291 | if (shm_id == -1) |
| 1292 | return 1; |
| 1293 | |
| 1294 | threads = shmat(shm_id, NULL, 0); |
| 1295 | if (threads == (void *) -1) { |
| 1296 | perror("shmat"); |
| 1297 | return 1; |
| 1298 | } |
| 1299 | |
| 1300 | atexit(free_shm); |
| 1301 | return 0; |
| 1302 | } |
| 1303 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1304 | /* |
| 1305 | * Copy the fio options into the long options map, so we mirror |
| 1306 | * job and cmd line options. |
| 1307 | */ |
| 1308 | static void dupe_job_options(void) |
| 1309 | { |
| 1310 | struct fio_option *o; |
| 1311 | unsigned int i; |
| 1312 | |
| 1313 | i = 0; |
| 1314 | while (long_options[i].name) |
| 1315 | i++; |
| 1316 | |
| 1317 | o = &options[0]; |
| 1318 | while (o->name) { |
| 1319 | long_options[i].name = o->name; |
| 1320 | long_options[i].val = FIO_GETOPT_JOB; |
| 1321 | if (o->type == FIO_OPT_STR_SET) |
| 1322 | long_options[i].has_arg = no_argument; |
| 1323 | else |
| 1324 | long_options[i].has_arg = required_argument; |
| 1325 | |
| 1326 | i++; |
| 1327 | o++; |
| 1328 | assert(i < FIO_JOB_OPTS + FIO_CMD_OPTS); |
| 1329 | } |
| 1330 | } |
| 1331 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1332 | int parse_options(int argc, char *argv[]) |
| 1333 | { |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1334 | int job_files, i; |
| 1335 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1336 | f_out = stdout; |
| 1337 | f_err = stderr; |
| 1338 | |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 1339 | options_init(options); |
| 1340 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1341 | dupe_job_options(); |
| 1342 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1343 | if (setup_thread_area()) |
| 1344 | return 1; |
| 1345 | if (fill_def_thread()) |
| 1346 | return 1; |
| 1347 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1348 | job_files = parse_cmd_line(argc, argv); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1349 | |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1350 | for (i = 0; i < job_files; i++) { |
| 1351 | if (fill_def_thread()) |
| 1352 | return 1; |
Jens Axboe | 0c7e37a | 2006-06-13 14:53:38 +0200 | [diff] [blame] | 1353 | if (parse_jobs_ini(ini_file[i], i)) |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1354 | return 1; |
Jens Axboe | 88c6ed8 | 2006-06-09 11:28:10 +0200 | [diff] [blame] | 1355 | free(ini_file[i]); |
Jens Axboe | 972cfd2 | 2006-06-09 11:08:56 +0200 | [diff] [blame] | 1356 | } |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1357 | |
Jens Axboe | 88c6ed8 | 2006-06-09 11:28:10 +0200 | [diff] [blame] | 1358 | free(ini_file); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1359 | |
| 1360 | if (!thread_number) { |
| 1361 | log_err("No jobs defined(s)\n"); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 1362 | return 1; |
| 1363 | } |
| 1364 | |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1365 | return 0; |
| 1366 | } |