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