8 #include <sys/resource.h>
23 unsigned long max_val;
24 unsigned long min_val;
25 unsigned long samples;
35 unsigned long nr_samples;
36 unsigned long max_samples;
37 struct io_sample *log;
41 struct list_head list;
42 unsigned long long offset;
52 #ifdef FIO_HAVE_LIBAIO
55 #ifdef FIO_HAVE_POSIXAIO
62 struct timeval start_time;
63 struct timeval issue_time;
67 unsigned long long offset;
76 struct list_head list;
79 #define FIO_HDR_MAGIC 0xf00baaef
87 struct verify_header {
88 unsigned int fio_magic;
90 unsigned int verify_type;
92 char md5_digest[MD5_HASH_WORDS * 4];
97 struct group_run_stats {
98 unsigned long long max_run[2], min_run[2];
99 unsigned long long max_bw[2], min_bw[2];
100 unsigned long long io_kb[2];
101 unsigned long long agg[2];
117 size_t orig_buffer_size;
118 volatile int terminate;
119 volatile int runstate;
120 volatile int old_runstate;
124 unsigned int sequential;
128 unsigned int odirect;
129 unsigned int thinktime;
130 unsigned int fsync_blocks;
131 unsigned int start_delay;
132 unsigned int timeout;
133 unsigned int io_engine;
134 unsigned int create_file;
135 unsigned int overwrite;
136 unsigned int invalidate_cache;
137 unsigned int bw_avg_time;
138 unsigned int create_serialize;
139 unsigned int create_fsync;
140 unsigned int end_fsync;
142 unsigned long long file_size;
143 unsigned long long real_file_size;
144 unsigned long long file_offset;
145 unsigned long long zone_size;
146 unsigned long long zone_skip;
147 unsigned int sync_io;
148 unsigned int mem_type;
150 unsigned int stonewall;
151 unsigned int numjobs;
152 unsigned int use_thread;
153 unsigned int iodepth;
154 os_cpu_mask_t cpumask;
157 unsigned int read_iolog;
158 unsigned int write_iolog;
159 unsigned int rwmixcycle;
160 unsigned int rwmixread;
171 struct drand48_data bsrange_state;
172 struct drand48_data verify_state;
177 char io_engine_name[16];
178 int (*io_prep)(struct thread_data *, struct io_u *);
179 int (*io_queue)(struct thread_data *, struct io_u *);
180 int (*io_getevents)(struct thread_data *, int, int, struct timespec *);
181 struct io_u *(*io_event)(struct thread_data *, int);
182 int (*io_cancel)(struct thread_data *, struct io_u *);
183 void (*io_cleanup)(struct thread_data *);
184 int (*io_sync)(struct thread_data *);
186 unsigned int cur_depth;
187 struct list_head io_u_freelist;
188 struct list_head io_u_busylist;
191 unsigned int ratemin;
192 unsigned int ratecycle;
193 unsigned long rate_usec_cycle;
194 long rate_pending_usleep;
195 unsigned long rate_bytes;
196 struct timeval lastrate;
198 unsigned long runtime[2]; /* msec */
199 unsigned long long io_size;
200 unsigned long long total_io_size;
202 unsigned long long io_blocks[2];
203 unsigned long long io_bytes[2];
204 unsigned long long zone_bytes;
205 unsigned long long this_io_bytes[2];
206 unsigned long long last_pos;
209 struct drand48_data random_state;
210 unsigned long *file_map;
211 unsigned int num_maps;
214 * bandwidth and latency stats
216 struct io_stat clat_stat[2]; /* completion latency */
217 struct io_stat slat_stat[2]; /* submission latency */
218 struct io_stat bw_stat[2]; /* bandwidth stats */
220 unsigned long long stat_io_bytes[2];
221 struct timeval stat_sample_time[2];
223 struct io_log *slat_log;
224 struct io_log *clat_log;
225 struct io_log *bw_log;
227 struct timeval start; /* start of this loop */
228 struct timeval epoch; /* time job was started */
230 struct rusage ru_start;
231 struct rusage ru_end;
232 unsigned long usr_time;
233 unsigned long sys_time;
236 unsigned int do_disk_util;
237 unsigned int override_sync;
239 struct drand48_data rwmix_state;
240 struct timeval rwmix_switch;
244 * Pre-run and post-run shell
249 struct list_head io_hist_list;
250 struct list_head io_log_list;
253 #define td_verror(td, err) \
257 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, strerror(e)); \
260 extern int parse_jobs_ini(char *);
261 extern int parse_options(int, char **);
262 extern void finish_log(struct thread_data *, struct io_log *, const char *);
263 extern int init_random_state(struct thread_data *);
264 extern struct io_u *__get_io_u(struct thread_data *);
265 extern void put_io_u(struct thread_data *, struct io_u *);
267 extern int rate_quit;
268 extern int write_lat_log;
269 extern int write_bw_log;
270 extern int exitall_on_terminate;
271 extern int thread_number;
275 extern struct thread_data *threads;
283 * What type of allocation to use for io buffers
286 MEM_MALLOC, /* ordinary malloc */
287 MEM_SHM, /* use shared memory segments */
288 MEM_MMAP, /* use anonynomous mmap */
292 * The type of object we are working on
302 FIO_MMAPIO = 1 << 1 | FIO_SYNCIO,
304 FIO_POSIXAIO = 1 << 3,
306 FIO_SPLICEIO = 1 << 5 | FIO_SYNCIO,
309 #define td_read(td) ((td)->ddir == DDIR_READ)
310 #define td_write(td) ((td)->ddir == DDIR_WRITE)
311 #define td_rw(td) ((td)->iomix != 0)
313 #define BLOCKS_PER_MAP (8 * sizeof(long))
314 #define TO_MAP_BLOCK(td, b) ((b) - ((td)->file_offset / (td)->min_bs))
315 #define RAND_MAP_IDX(td, b) (TO_MAP_BLOCK(td, b) / BLOCKS_PER_MAP)
316 #define RAND_MAP_BIT(td, b) (TO_MAP_BLOCK(td, b) & (BLOCKS_PER_MAP - 1))
318 #define MAX_JOBS (1024)
320 struct disk_util_stat {
323 unsigned long long sectors[2];
326 unsigned time_in_queue;
330 struct list_head list;
336 struct disk_util_stat dus;
337 struct disk_util_stat last_dus;
343 struct io_completion_data {
346 int error; /* output */
347 unsigned long bytes_done[2]; /* output */
350 #define DISK_UTIL_MSEC (250)
353 #define min(a, b) ((a) < (b) ? (a) : (b))