8 #include <sys/resource.h>
20 unsigned long max_val;
21 unsigned long min_val;
22 unsigned long samples;
31 unsigned long nr_samples;
32 unsigned long max_samples;
33 struct io_sample *log;
37 struct list_head list;
38 unsigned long long offset;
47 #ifdef FIO_HAVE_LIBAIO
50 #ifdef FIO_HAVE_POSIXAIO
54 struct timeval start_time;
55 struct timeval issue_time;
59 unsigned long long offset;
63 struct list_head list;
66 #define FIO_HDR_MAGIC 0xf00baaef
74 struct verify_header {
75 unsigned int fio_magic;
77 unsigned int verify_type;
79 char md5_digest[MD5_HASH_WORDS * 4];
84 struct group_run_stats {
85 unsigned long max_run[2], min_run[2];
86 unsigned long max_bw[2], min_bw[2];
87 unsigned long io_mb[2];
104 size_t orig_buffer_size;
105 volatile int terminate;
106 volatile int runstate;
107 volatile int old_runstate;
110 unsigned int sequential;
114 unsigned int odirect;
115 unsigned int thinktime;
116 unsigned int fsync_blocks;
117 unsigned int start_delay;
118 unsigned int timeout;
119 unsigned int io_engine;
120 unsigned int create_file;
121 unsigned int overwrite;
122 unsigned int invalidate_cache;
123 unsigned int bw_avg_time;
124 unsigned int create_serialize;
125 unsigned int create_fsync;
127 unsigned long long file_size;
128 unsigned long long file_offset;
129 unsigned int sync_io;
130 unsigned int mem_type;
132 unsigned int stonewall;
133 unsigned int numjobs;
134 unsigned int use_thread;
135 unsigned int use_mmap;
136 os_cpu_mask_t cpumask;
138 struct drand48_data bsrange_state;
139 struct drand48_data verify_state;
143 unsigned long long cur_off;
146 void (*io_prep)(struct thread_data *, struct io_u *, int);
147 int (*io_queue)(struct thread_data *, struct io_u *);
148 int (*io_getevents)(struct thread_data *, int, int, struct timespec *);
149 struct io_u *(*io_event)(struct thread_data *, int);
150 int (*io_cancel)(struct thread_data *, struct io_u *);
151 unsigned int aio_depth;
153 unsigned int cur_depth;
154 struct list_head io_u_freelist;
155 struct list_head io_u_busylist;
158 unsigned int ratemin;
159 unsigned int ratecycle;
160 unsigned long rate_usec_cycle;
161 long rate_pending_usleep;
162 unsigned long rate_bytes;
163 struct timeval lastrate;
165 unsigned long runtime; /* sec */
166 unsigned long long io_size;
168 unsigned long io_blocks;
169 unsigned long io_bytes;
170 unsigned long this_io_bytes;
171 unsigned long last_bytes;
174 struct drand48_data random_state;
175 unsigned long *file_map;
176 unsigned int num_maps;
179 * bandwidth and latency stats
181 struct io_stat clat_stat; /* completion latency */
182 struct io_stat slat_stat; /* submission latency */
184 struct io_stat bw_stat; /* bandwidth stats */
185 unsigned long stat_io_bytes;
186 struct timeval stat_sample_time;
188 struct io_log *lat_log;
189 struct io_log *bw_log;
191 struct timeval start; /* start of this loop */
192 struct timeval epoch; /* time job was started */
194 struct rusage ru_start;
195 struct rusage ru_end;
196 unsigned long usr_time;
197 unsigned long sys_time;
200 unsigned int do_disk_util;
202 struct list_head io_hist_list;
205 #define td_verror(td, err) \
209 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, strerror(e)); \
212 extern int parse_jobs_ini(char *);
213 extern int parse_options(int, char **);
214 extern void finish_log(struct thread_data *, struct io_log *, const char *);
215 extern int init_random_state(struct thread_data *);
217 extern int rate_quit;
218 extern int write_lat_log;
219 extern int write_bw_log;
220 extern int exitall_on_terminate;
221 extern int thread_number;
225 extern char run_str[];
227 extern struct thread_data *threads;
235 * What type of allocation to use for io buffers
238 MEM_MALLOC, /* ordinary malloc */
239 MEM_SHM, /* use shared memory segments */
240 MEM_MMAP, /* use anonynomous mmap */
244 * The type of object we are working on
257 #define td_read(td) ((td)->ddir == DDIR_READ)
258 #define td_write(td) ((td)->ddir == DDIR_WRITE)
260 #define BLOCKS_PER_MAP (8 * sizeof(long))
261 #define TO_MAP_BLOCK(td, b) ((b) - ((td)->file_offset / (td)->min_bs))
262 #define RAND_MAP_IDX(td, b) (TO_MAP_BLOCK(td, b) / BLOCKS_PER_MAP)
263 #define RAND_MAP_BIT(td, b) (TO_MAP_BLOCK(td, b) & (BLOCKS_PER_MAP - 1))
265 #define MAX_JOBS (1024)
267 struct disk_util_stat {
270 unsigned long long sectors[2];
273 unsigned time_in_queue;
277 struct list_head list;
283 struct disk_util_stat dus;
284 struct disk_util_stat last_dus;
290 #define DISK_UTIL_MSEC (250)