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;
49 #ifdef FIO_HAVE_LIBAIO
52 #ifdef FIO_HAVE_POSIXAIO
59 struct timeval start_time;
60 struct timeval issue_time;
64 unsigned long long offset;
73 struct list_head list;
76 #define FIO_HDR_MAGIC 0xf00baaef
84 struct verify_header {
85 unsigned int fio_magic;
87 unsigned int verify_type;
89 char md5_digest[MD5_HASH_WORDS * 4];
94 struct group_run_stats {
95 unsigned long long max_run[2], min_run[2];
96 unsigned long long max_bw[2], min_bw[2];
97 unsigned long long io_mb[2];
98 unsigned long long agg[2];
114 size_t orig_buffer_size;
115 volatile int terminate;
116 volatile int runstate;
117 volatile int old_runstate;
121 unsigned int sequential;
125 unsigned int odirect;
126 unsigned int thinktime;
127 unsigned int fsync_blocks;
128 unsigned int start_delay;
129 unsigned int timeout;
130 unsigned int io_engine;
131 unsigned int create_file;
132 unsigned int overwrite;
133 unsigned int invalidate_cache;
134 unsigned int bw_avg_time;
135 unsigned int create_serialize;
136 unsigned int create_fsync;
137 unsigned int end_fsync;
139 unsigned long long file_size;
140 unsigned long long real_file_size;
141 unsigned long long file_offset;
142 unsigned long long zone_size;
143 unsigned long long zone_skip;
144 unsigned int sync_io;
145 unsigned int mem_type;
147 unsigned int stonewall;
148 unsigned int numjobs;
149 unsigned int use_thread;
150 unsigned int iodepth;
151 os_cpu_mask_t cpumask;
154 unsigned int read_iolog;
155 unsigned int write_iolog;
156 unsigned int rwmixcycle;
157 unsigned int rwmixread;
160 char iolog_file[256];
164 struct drand48_data bsrange_state;
165 struct drand48_data verify_state;
170 char io_engine_name[16];
171 int (*io_prep)(struct thread_data *, struct io_u *);
172 int (*io_queue)(struct thread_data *, struct io_u *);
173 int (*io_getevents)(struct thread_data *, int, int, struct timespec *);
174 struct io_u *(*io_event)(struct thread_data *, int);
175 int (*io_cancel)(struct thread_data *, struct io_u *);
176 void (*io_cleanup)(struct thread_data *);
177 int (*io_sync)(struct thread_data *);
179 unsigned int cur_depth;
180 struct list_head io_u_freelist;
181 struct list_head io_u_busylist;
184 unsigned int ratemin;
185 unsigned int ratecycle;
186 unsigned long rate_usec_cycle;
187 long rate_pending_usleep;
188 unsigned long rate_bytes;
189 struct timeval lastrate;
191 unsigned long runtime[2]; /* msec */
192 unsigned long long io_size;
193 unsigned long long total_io_size;
195 unsigned long long io_blocks[2];
196 unsigned long long io_bytes[2];
197 unsigned long long zone_bytes;
198 unsigned long long this_io_bytes[2];
199 unsigned long long last_pos;
202 struct drand48_data random_state;
203 unsigned long *file_map;
204 unsigned int num_maps;
207 * bandwidth and latency stats
209 struct io_stat clat_stat[2]; /* completion latency */
210 struct io_stat slat_stat[2]; /* submission latency */
211 struct io_stat bw_stat[2]; /* bandwidth stats */
213 unsigned long long stat_io_bytes[2];
214 struct timeval stat_sample_time[2];
216 struct io_log *slat_log;
217 struct io_log *clat_log;
218 struct io_log *bw_log;
220 struct timeval start; /* start of this loop */
221 struct timeval epoch; /* time job was started */
223 struct rusage ru_start;
224 struct rusage ru_end;
225 unsigned long usr_time;
226 unsigned long sys_time;
229 unsigned int do_disk_util;
230 unsigned int override_sync;
232 struct drand48_data rwmix_state;
233 struct timeval rwmix_switch;
236 struct list_head io_hist_list;
237 struct list_head io_log_list;
240 #define td_verror(td, err) \
244 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, strerror(e)); \
247 extern int parse_jobs_ini(char *);
248 extern int parse_options(int, char **);
249 extern void finish_log(struct thread_data *, struct io_log *, const char *);
250 extern int init_random_state(struct thread_data *);
251 extern struct io_u *__get_io_u(struct thread_data *);
252 extern void put_io_u(struct thread_data *, struct io_u *);
254 extern int rate_quit;
255 extern int write_lat_log;
256 extern int write_bw_log;
257 extern int exitall_on_terminate;
258 extern int thread_number;
262 extern struct thread_data *threads;
270 * What type of allocation to use for io buffers
273 MEM_MALLOC, /* ordinary malloc */
274 MEM_SHM, /* use shared memory segments */
275 MEM_MMAP, /* use anonynomous mmap */
279 * The type of object we are working on
289 FIO_MMAPIO = 1 << 1 | FIO_SYNCIO,
291 FIO_POSIXAIO = 1 << 3,
293 FIO_SPLICEIO = 1 << 5 | FIO_SYNCIO,
296 #define td_read(td) ((td)->ddir == DDIR_READ)
297 #define td_write(td) ((td)->ddir == DDIR_WRITE)
298 #define td_rw(td) ((td)->iomix != 0)
300 #define BLOCKS_PER_MAP (8 * sizeof(long))
301 #define TO_MAP_BLOCK(td, b) ((b) - ((td)->file_offset / (td)->min_bs))
302 #define RAND_MAP_IDX(td, b) (TO_MAP_BLOCK(td, b) / BLOCKS_PER_MAP)
303 #define RAND_MAP_BIT(td, b) (TO_MAP_BLOCK(td, b) & (BLOCKS_PER_MAP - 1))
305 #define MAX_JOBS (1024)
307 struct disk_util_stat {
310 unsigned long long sectors[2];
313 unsigned time_in_queue;
317 struct list_head list;
323 struct disk_util_stat dus;
324 struct disk_util_stat last_dus;
330 struct io_completion_data {
333 int error; /* output */
334 unsigned long bytes_done[2]; /* output */
337 #define DISK_UTIL_MSEC (250)
340 #define min(a, b) ((a) < (b) ? (a) : (b))