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