8 #include <sys/resource.h>
20 unsigned long max_val;
21 unsigned long min_val;
22 unsigned long samples;
32 unsigned long nr_samples;
33 unsigned long max_samples;
34 struct io_sample *log;
38 struct list_head list;
39 unsigned long long offset;
48 #ifdef FIO_HAVE_LIBAIO
51 #ifdef FIO_HAVE_POSIXAIO
58 struct timeval start_time;
59 struct timeval issue_time;
63 unsigned long long offset;
72 struct list_head list;
75 #define FIO_HDR_MAGIC 0xf00baaef
83 struct verify_header {
84 unsigned int fio_magic;
86 unsigned int verify_type;
88 char md5_digest[MD5_HASH_WORDS * 4];
93 struct group_run_stats {
94 unsigned long long max_run[2], min_run[2];
95 unsigned long long max_bw[2], min_bw[2];
96 unsigned long long io_mb[2];
97 unsigned long long agg[2];
113 size_t orig_buffer_size;
114 volatile int terminate;
115 volatile int runstate;
116 volatile int old_runstate;
120 unsigned int sequential;
124 unsigned int odirect;
125 unsigned int thinktime;
126 unsigned int fsync_blocks;
127 unsigned int start_delay;
128 unsigned int timeout;
129 unsigned int io_engine;
130 unsigned int create_file;
131 unsigned int overwrite;
132 unsigned int invalidate_cache;
133 unsigned int bw_avg_time;
134 unsigned int create_serialize;
135 unsigned int create_fsync;
137 unsigned long long file_size;
138 unsigned long long real_file_size;
139 unsigned long long file_offset;
140 unsigned long long zone_size;
141 unsigned long long zone_skip;
142 unsigned int sync_io;
143 unsigned int mem_type;
145 unsigned int stonewall;
146 unsigned int numjobs;
147 unsigned int use_thread;
148 unsigned int iodepth;
149 os_cpu_mask_t cpumask;
152 struct drand48_data bsrange_state;
153 struct drand48_data verify_state;
158 char io_engine_name[16];
159 int (*io_prep)(struct thread_data *, struct io_u *);
160 int (*io_queue)(struct thread_data *, struct io_u *);
161 int (*io_getevents)(struct thread_data *, int, int, struct timespec *);
162 struct io_u *(*io_event)(struct thread_data *, int);
163 int (*io_cancel)(struct thread_data *, struct io_u *);
164 void (*io_cleanup)(struct thread_data *);
165 int (*io_sync)(struct thread_data *);
167 unsigned int cur_depth;
168 struct list_head io_u_freelist;
169 struct list_head io_u_busylist;
172 unsigned int ratemin;
173 unsigned int ratecycle;
174 unsigned long rate_usec_cycle;
175 long rate_pending_usleep;
176 unsigned long rate_bytes;
177 struct timeval lastrate;
179 unsigned long runtime[2]; /* msec */
180 unsigned long long io_size;
181 unsigned long long total_io_size;
183 unsigned long long io_blocks[2];
184 unsigned long long io_bytes[2];
185 unsigned long long zone_bytes;
186 unsigned long long this_io_bytes[2];
187 unsigned long long last_pos;
190 struct drand48_data random_state;
191 unsigned long *file_map;
192 unsigned int num_maps;
195 * bandwidth and latency stats
197 struct io_stat clat_stat[2]; /* completion latency */
198 struct io_stat slat_stat[2]; /* submission latency */
199 struct io_stat bw_stat[2]; /* bandwidth stats */
201 unsigned long long stat_io_bytes[2];
202 struct timeval stat_sample_time[2];
204 struct io_log *slat_log;
205 struct io_log *clat_log;
206 struct io_log *bw_log;
208 struct timeval start; /* start of this loop */
209 struct timeval epoch; /* time job was started */
211 struct rusage ru_start;
212 struct rusage ru_end;
213 unsigned long usr_time;
214 unsigned long sys_time;
217 unsigned int do_disk_util;
218 unsigned int override_sync;
220 struct list_head io_hist_list;
223 #define td_verror(td, err) \
227 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, strerror(e)); \
230 extern int parse_jobs_ini(char *);
231 extern int parse_options(int, char **);
232 extern void finish_log(struct thread_data *, struct io_log *, const char *);
233 extern int init_random_state(struct thread_data *);
234 extern struct io_u *__get_io_u(struct thread_data *);
235 extern void put_io_u(struct thread_data *, struct io_u *);
237 extern int rate_quit;
238 extern int write_lat_log;
239 extern int write_bw_log;
240 extern int exitall_on_terminate;
241 extern int thread_number;
245 extern struct thread_data *threads;
253 * What type of allocation to use for io buffers
256 MEM_MALLOC, /* ordinary malloc */
257 MEM_SHM, /* use shared memory segments */
258 MEM_MMAP, /* use anonynomous mmap */
262 * The type of object we are working on
272 FIO_MMAPIO = 1 << 1 | FIO_SYNCIO,
274 FIO_POSIXAIO = 1 << 3,
278 #define td_read(td) ((td)->ddir == DDIR_READ)
279 #define td_write(td) ((td)->ddir == DDIR_WRITE)
280 #define td_rw(td) ((td)->iomix != 0)
282 #define BLOCKS_PER_MAP (8 * sizeof(long))
283 #define TO_MAP_BLOCK(td, b) ((b) - ((td)->file_offset / (td)->min_bs))
284 #define RAND_MAP_IDX(td, b) (TO_MAP_BLOCK(td, b) / BLOCKS_PER_MAP)
285 #define RAND_MAP_BIT(td, b) (TO_MAP_BLOCK(td, b) & (BLOCKS_PER_MAP - 1))
287 #define MAX_JOBS (1024)
289 struct disk_util_stat {
292 unsigned long long sectors[2];
295 unsigned time_in_queue;
299 struct list_head list;
305 struct disk_util_stat dus;
306 struct disk_util_stat last_dus;
312 struct io_completion_data {
315 int error; /* output */
316 unsigned long bytes_done[2]; /* output */
319 #define DISK_UTIL_MSEC (250)
322 #define min(a, b) ((a) < (b) ? (a) : (b))