7 #include <sys/resource.h>
19 unsigned long max_val;
20 unsigned long min_val;
21 unsigned long samples;
30 unsigned long nr_samples;
31 unsigned long max_samples;
32 struct io_sample *log;
36 struct list_head list;
37 unsigned long long offset;
46 #ifdef FIO_HAVE_LIBAIO
49 #ifdef FIO_HAVE_POSIXAIO
53 struct timeval start_time;
54 struct timeval issue_time;
58 unsigned long long offset;
62 struct list_head list;
65 #define FIO_HDR_MAGIC 0xf00baaef
73 struct verify_header {
74 unsigned int fio_magic;
76 unsigned int verify_type;
78 char md5_digest[MD5_HASH_WORDS * 4];
83 struct group_run_stats {
84 unsigned long max_run[2], min_run[2];
85 unsigned long max_bw[2], min_bw[2];
86 unsigned long io_mb[2];
103 size_t orig_buffer_size;
104 volatile int terminate;
105 volatile int runstate;
106 volatile int old_runstate;
109 unsigned int sequential;
113 unsigned int odirect;
114 unsigned int thinktime;
115 unsigned int fsync_blocks;
116 unsigned int start_delay;
117 unsigned int timeout;
118 unsigned int io_engine;
119 unsigned int create_file;
120 unsigned int overwrite;
121 unsigned int invalidate_cache;
122 unsigned int bw_avg_time;
123 unsigned int create_serialize;
124 unsigned int create_fsync;
126 unsigned long long file_size;
127 unsigned long long file_offset;
128 unsigned int sync_io;
129 unsigned int mem_type;
131 unsigned int stonewall;
132 unsigned int numjobs;
133 unsigned int use_thread;
134 unsigned int use_mmap;
135 os_cpu_mask_t cpumask;
137 struct drand48_data bsrange_state;
138 struct drand48_data verify_state;
142 unsigned long long cur_off;
145 void (*io_prep)(struct thread_data *, struct io_u *, int);
146 int (*io_queue)(struct thread_data *, struct io_u *);
147 int (*io_getevents)(struct thread_data *, int, int, struct timespec *);
148 struct io_u *(*io_event)(struct thread_data *, int);
149 int (*io_cancel)(struct thread_data *, struct io_u *);
150 unsigned int aio_depth;
152 unsigned int cur_depth;
153 struct list_head io_u_freelist;
154 struct list_head io_u_busylist;
157 unsigned int ratemin;
158 unsigned int ratecycle;
159 unsigned long rate_usec_cycle;
160 long rate_pending_usleep;
161 unsigned long rate_bytes;
162 struct timeval lastrate;
164 unsigned long runtime; /* sec */
165 unsigned long long io_size;
167 unsigned long io_blocks;
168 unsigned long io_bytes;
169 unsigned long this_io_bytes;
170 unsigned long last_bytes;
173 struct drand48_data random_state;
174 unsigned long *file_map;
175 unsigned int num_maps;
178 * bandwidth and latency stats
180 struct io_stat clat_stat; /* completion latency */
181 struct io_stat slat_stat; /* submission latency */
183 struct io_stat bw_stat; /* bandwidth stats */
184 unsigned long stat_io_bytes;
185 struct timeval stat_sample_time;
187 struct io_log *lat_log;
188 struct io_log *bw_log;
190 struct timeval start; /* start of this loop */
191 struct timeval epoch; /* time job was started */
193 struct rusage ru_start;
194 struct rusage ru_end;
195 unsigned long usr_time;
196 unsigned long sys_time;
199 struct list_head io_hist_list;
202 #define td_verror(td, err) \
206 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, strerror(e)); \
209 extern int parse_jobs_ini(char *);
210 extern int parse_options(int, char **);
211 extern void finish_log(struct thread_data *, struct io_log *, const char *);
212 extern int init_random_state(struct thread_data *);
214 extern int rate_quit;
215 extern int write_lat_log;
216 extern int write_bw_log;
217 extern int exitall_on_terminate;
218 extern int thread_number;
222 extern char run_str[];
224 extern struct thread_data *threads;
232 * What type of allocation to use for io buffers
235 MEM_MALLOC, /* ordinary malloc */
236 MEM_SHM, /* use shared memory segments */
237 MEM_MMAP, /* use anonynomous mmap */
241 * The type of object we are working on
254 #define td_read(td) ((td)->ddir == DDIR_READ)
255 #define td_write(td) ((td)->ddir == DDIR_WRITE)
257 #define BLOCKS_PER_MAP (8 * sizeof(long))
258 #define TO_MAP_BLOCK(td, b) ((b) - ((td)->file_offset / (td)->min_bs))
259 #define RAND_MAP_IDX(td, b) (TO_MAP_BLOCK(td, b) / BLOCKS_PER_MAP)
260 #define RAND_MAP_BIT(td, b) (TO_MAP_BLOCK(td, b) & (BLOCKS_PER_MAP - 1))
262 #define MAX_JOBS (1024)
264 struct disk_util_stat {
267 unsigned long long sectors[2];
270 unsigned time_in_queue;
274 struct list_head list;
280 struct disk_util_stat dus;
281 struct disk_util_stat last_dus;
287 #define DISK_UTIL_MSEC (250)