4 #include "compiler/compiler.h"
18 #define FIO_IOOPS_VERSION 19
22 IO_U_F_FLIGHT = 1 << 1,
23 IO_U_F_FREE_DEF = 1 << 2,
24 IO_U_F_IN_CUR_DEPTH = 1 << 3,
25 IO_U_F_BUSY_OK = 1 << 4,
26 IO_U_F_TRIMMED = 1 << 5,
27 IO_U_F_BARRIER = 1 << 6,
28 IO_U_F_VER_LIST = 1 << 7,
35 struct timeval start_time;
36 struct timeval issue_time;
38 struct fio_file *file;
43 * For replay workloads, we may want to account as a different
44 * IO type than what is being submitted.
46 enum fio_ddir acct_ddir;
49 * Allocated/set buffer and length
52 unsigned long long offset;
53 unsigned short numberio;
57 * Initial seed for generating the buffer contents
62 * IO engine state, may be different from above when we get
63 * partial transfers / residual data counts
66 unsigned long xfer_buflen;
69 * Parameter related to pre-filled buffers and
70 * their size to handle variable block sizes.
72 unsigned long buf_filled_len;
80 * io engine private data
88 struct flist_head verify_list;
91 * Callback for io completion
93 int (*end_io)(struct thread_data *, struct io_u *);
99 #ifdef CONFIG_POSIXAIO
103 struct sg_io_hdr hdr;
108 #ifdef CONFIG_SOLARISAIO
109 aio_result_t resultp;
111 #ifdef FIO_HAVE_BINJECT
112 struct b_user_cmd buc;
122 * io_ops->queue() return values
125 FIO_Q_COMPLETED = 0, /* completed sync */
126 FIO_Q_QUEUED = 1, /* queued, will complete async */
127 FIO_Q_BUSY = 2, /* no more room, call ->commit() */
130 struct ioengine_ops {
131 struct flist_head list;
135 int (*setup)(struct thread_data *);
136 int (*init)(struct thread_data *);
137 int (*prep)(struct thread_data *, struct io_u *);
138 int (*queue)(struct thread_data *, struct io_u *);
139 int (*commit)(struct thread_data *);
140 int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *);
141 struct io_u *(*event)(struct thread_data *, int);
142 int (*cancel)(struct thread_data *, struct io_u *);
143 void (*cleanup)(struct thread_data *);
144 int (*open_file)(struct thread_data *, struct fio_file *);
145 int (*close_file)(struct thread_data *, struct fio_file *);
146 int (*invalidate)(struct thread_data *, struct fio_file *);
147 int (*get_file_size)(struct thread_data *, struct fio_file *);
148 void (*terminate)(struct thread_data *);
149 int (*io_u_init)(struct thread_data *, struct io_u *);
150 void (*io_u_free)(struct thread_data *, struct io_u *);
151 int option_struct_size;
152 struct fio_option *options;
157 enum fio_ioengine_flags {
158 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
159 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
160 FIO_DISKLESSIO = 1 << 2, /* no disk involved */
161 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */
162 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */
163 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */
164 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */
165 FIO_PIPEIO = 1 << 7, /* input/output no seekable */
166 FIO_BARRIER = 1 << 8, /* engine supports barriers */
167 FIO_MEMALIGN = 1 << 9, /* engine wants aligned memory */
168 FIO_BIT_BASED = 1 << 10, /* engine uses a bit base (e.g. uses Kbit as opposed to KB) */
172 * External engine defined symbol to fill in the engine ops structure
174 typedef void (*get_ioengine_t)(struct ioengine_ops **);
177 * io engine entry points
179 extern int __must_check td_io_init(struct thread_data *);
180 extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
181 extern int __must_check td_io_queue(struct thread_data *, struct io_u *);
182 extern int __must_check td_io_sync(struct thread_data *, struct fio_file *);
183 extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *);
184 extern int __must_check td_io_commit(struct thread_data *);
185 extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
186 extern int td_io_close_file(struct thread_data *, struct fio_file *);
187 extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
189 extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
190 extern void register_ioengine(struct ioengine_ops *);
191 extern void unregister_ioengine(struct ioengine_ops *);
192 extern void free_ioengine(struct thread_data *);
193 extern void close_ioengine(struct thread_data *);
195 extern int fio_show_ioengine_help(const char *engine);
200 extern struct io_u *__get_io_u(struct thread_data *);
201 extern struct io_u *get_io_u(struct thread_data *);
202 extern void put_io_u(struct thread_data *, struct io_u *);
203 extern void clear_io_u(struct thread_data *, struct io_u *);
204 extern void requeue_io_u(struct thread_data *, struct io_u **);
205 extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *, uint64_t *);
206 extern int __must_check io_u_queued_complete(struct thread_data *, int, uint64_t *);
207 extern void io_u_queued(struct thread_data *, struct io_u *);
208 extern void io_u_quiesce(struct thread_data *);
209 extern void io_u_log_error(struct thread_data *, struct io_u *);
210 extern void io_u_mark_depth(struct thread_data *, unsigned int);
211 extern void fill_io_buffer(struct thread_data *, void *, unsigned int, unsigned int);
212 extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int, unsigned int);
213 void io_u_mark_complete(struct thread_data *, unsigned int);
214 void io_u_mark_submit(struct thread_data *, unsigned int);
215 int queue_full(struct thread_data *);
217 int do_io_u_sync(struct thread_data *, struct io_u *);
218 int do_io_u_trim(struct thread_data *, struct io_u *);
221 static inline void dprint_io_u(struct io_u *io_u, const char *p)
223 struct fio_file *f = io_u->file;
225 dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
226 (unsigned long long) io_u->offset,
227 io_u->buflen, io_u->ddir);
228 if (fio_debug & (1 << FD_IO)) {
230 log_info("/%s", f->file_name);
236 #define dprint_io_u(io_u, p)
239 static inline enum fio_ddir acct_ddir(struct io_u *io_u)
241 if (io_u->acct_ddir != -1)
242 return io_u->acct_ddir;