4 #include "compiler/compiler.h"
18 #define FIO_IOOPS_VERSION 21
22 IO_U_F_FLIGHT = 1 << 1,
23 IO_U_F_NO_FILE_PUT = 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;
51 unsigned short numberio;
54 * Allocated/set buffer and length
57 unsigned long long offset;
61 * Initial seed for generating the buffer contents
66 * IO engine state, may be different from above when we get
67 * partial transfers / residual data counts
70 unsigned long xfer_buflen;
73 * Parameter related to pre-filled buffers and
74 * their size to handle variable block sizes.
76 unsigned long buf_filled_len;
84 * io engine private data
92 struct flist_head verify_list;
95 * Callback for io completion
97 int (*end_io)(struct thread_data *, struct io_u **);
103 #ifdef CONFIG_POSIXAIO
107 struct sg_io_hdr hdr;
112 #ifdef CONFIG_SOLARISAIO
113 aio_result_t resultp;
115 #ifdef FIO_HAVE_BINJECT
116 struct b_user_cmd buc;
127 * io_ops->queue() return values
130 FIO_Q_COMPLETED = 0, /* completed sync */
131 FIO_Q_QUEUED = 1, /* queued, will complete async */
132 FIO_Q_BUSY = 2, /* no more room, call ->commit() */
135 struct ioengine_ops {
136 struct flist_head list;
140 int (*setup)(struct thread_data *);
141 int (*init)(struct thread_data *);
142 int (*prep)(struct thread_data *, struct io_u *);
143 int (*queue)(struct thread_data *, struct io_u *);
144 int (*commit)(struct thread_data *);
145 int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *);
146 struct io_u *(*event)(struct thread_data *, int);
147 int (*cancel)(struct thread_data *, struct io_u *);
148 void (*cleanup)(struct thread_data *);
149 int (*open_file)(struct thread_data *, struct fio_file *);
150 int (*close_file)(struct thread_data *, struct fio_file *);
151 int (*invalidate)(struct thread_data *, struct fio_file *);
152 int (*unlink_file)(struct thread_data *, struct fio_file *);
153 int (*get_file_size)(struct thread_data *, struct fio_file *);
154 void (*terminate)(struct thread_data *);
155 int (*io_u_init)(struct thread_data *, struct io_u *);
156 void (*io_u_free)(struct thread_data *, struct io_u *);
157 int option_struct_size;
158 struct fio_option *options;
163 enum fio_ioengine_flags {
164 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
165 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
166 FIO_DISKLESSIO = 1 << 2, /* no disk involved */
167 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */
168 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */
169 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */
170 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */
171 FIO_PIPEIO = 1 << 7, /* input/output no seekable */
172 FIO_BARRIER = 1 << 8, /* engine supports barriers */
173 FIO_MEMALIGN = 1 << 9, /* engine wants aligned memory */
174 FIO_BIT_BASED = 1 << 10, /* engine uses a bit base (e.g. uses Kbit as opposed to KB) */
175 FIO_FAKEIO = 1 << 11, /* engine pretends to do IO */
179 * External engine defined symbol to fill in the engine ops structure
181 typedef void (*get_ioengine_t)(struct ioengine_ops **);
184 * io engine entry points
186 extern int __must_check td_io_init(struct thread_data *);
187 extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
188 extern int __must_check td_io_queue(struct thread_data *, struct io_u *);
189 extern int __must_check td_io_sync(struct thread_data *, struct fio_file *);
190 extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, const struct timespec *);
191 extern int __must_check td_io_commit(struct thread_data *);
192 extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
193 extern int td_io_close_file(struct thread_data *, struct fio_file *);
194 extern int td_io_unlink_file(struct thread_data *, struct fio_file *);
195 extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
197 extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
198 extern void register_ioengine(struct ioengine_ops *);
199 extern void unregister_ioengine(struct ioengine_ops *);
200 extern void free_ioengine(struct thread_data *);
201 extern void close_ioengine(struct thread_data *);
203 extern int fio_show_ioengine_help(const char *engine);
208 extern struct io_u *__get_io_u(struct thread_data *);
209 extern struct io_u *get_io_u(struct thread_data *);
210 extern void put_io_u(struct thread_data *, struct io_u *);
211 extern void clear_io_u(struct thread_data *, struct io_u *);
212 extern void requeue_io_u(struct thread_data *, struct io_u **);
213 extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *);
214 extern int __must_check io_u_queued_complete(struct thread_data *, int);
215 extern void io_u_queued(struct thread_data *, struct io_u *);
216 extern void io_u_quiesce(struct thread_data *);
217 extern void io_u_log_error(struct thread_data *, struct io_u *);
218 extern void io_u_mark_depth(struct thread_data *, unsigned int);
219 extern void fill_io_buffer(struct thread_data *, void *, unsigned int, unsigned int);
220 extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int, unsigned int);
221 void io_u_mark_complete(struct thread_data *, unsigned int);
222 void io_u_mark_submit(struct thread_data *, unsigned int);
223 int queue_full(const struct thread_data *);
225 int do_io_u_sync(const struct thread_data *, struct io_u *);
226 int do_io_u_trim(const struct thread_data *, struct io_u *);
229 static inline void dprint_io_u(struct io_u *io_u, const char *p)
231 struct fio_file *f = io_u->file;
233 dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
234 (unsigned long long) io_u->offset,
235 io_u->buflen, io_u->ddir);
236 if (fio_debug & (1 << FD_IO)) {
238 log_info("/%s", f->file_name);
244 #define dprint_io_u(io_u, p)
247 static inline enum fio_ddir acct_ddir(struct io_u *io_u)
249 if (io_u->acct_ddir != -1)
250 return io_u->acct_ddir;
255 static inline void io_u_clear(struct io_u *io_u, unsigned int flags)
257 __sync_fetch_and_and(&io_u->flags, ~flags);
260 static inline void io_u_set(struct io_u *io_u, unsigned int flags)
262 __sync_fetch_and_or(&io_u->flags, flags);