4 #include "compiler/compiler.h"
9 #define FIO_IOOPS_VERSION 14
13 IO_U_F_FLIGHT = 1 << 1,
14 IO_U_F_FREE_DEF = 1 << 2,
15 IO_U_F_IN_CUR_DEPTH = 1 << 3,
16 IO_U_F_BUSY_OK = 1 << 4,
17 IO_U_F_TRIMMED = 1 << 5,
18 IO_U_F_BARRIER = 1 << 6,
19 IO_U_F_VER_LIST = 1 << 7,
29 #ifdef FIO_HAVE_LIBAIO
32 #ifdef FIO_HAVE_POSIXAIO
41 #ifdef FIO_HAVE_SOLARISAIO
44 #ifdef FIO_HAVE_BINJECT
45 struct b_user_cmd buc;
52 struct timeval start_time;
53 struct timeval issue_time;
55 struct fio_file *file;
60 * Allocated/set buffer and length
63 unsigned long long offset;
67 * Initial seed for generating the buffer contents
69 unsigned long rand_seed;
72 * IO engine state, may be different from above when we get
73 * partial transfers / residual data counts
76 unsigned long xfer_buflen;
79 * Parameter related to pre-filled buffers and
80 * their size to handle variable block sizes.
82 unsigned long buf_filled_len;
88 * io engine private data
96 struct flist_head list;
99 * Callback for io completion
101 int (*end_io)(struct thread_data *, struct io_u *);
105 * io_ops->queue() return values
108 FIO_Q_COMPLETED = 0, /* completed sync */
109 FIO_Q_QUEUED = 1, /* queued, will complete async */
110 FIO_Q_BUSY = 2, /* no more room, call ->commit() */
113 struct ioengine_ops {
114 struct flist_head list;
118 int (*setup)(struct thread_data *);
119 int (*init)(struct thread_data *);
120 int (*prep)(struct thread_data *, struct io_u *);
121 int (*queue)(struct thread_data *, struct io_u *);
122 int (*commit)(struct thread_data *);
123 int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *);
124 struct io_u *(*event)(struct thread_data *, int);
125 int (*cancel)(struct thread_data *, struct io_u *);
126 void (*cleanup)(struct thread_data *);
127 int (*open_file)(struct thread_data *, struct fio_file *);
128 int (*close_file)(struct thread_data *, struct fio_file *);
129 int (*get_file_size)(struct thread_data *, struct fio_file *);
130 void (*terminate)(struct thread_data *);
131 int (*io_u_init)(struct thread_data *, struct io_u *);
132 void (*io_u_free)(struct thread_data *, struct io_u *);
133 int option_struct_size;
134 struct fio_option *options;
139 enum fio_ioengine_flags {
140 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
141 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
142 FIO_DISKLESSIO = 1 << 2, /* no disk involved */
143 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */
144 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */
145 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */
146 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */
147 FIO_PIPEIO = 1 << 7, /* input/output no seekable */
148 FIO_BARRIER = 1 << 8, /* engine supports barriers */
149 FIO_MEMALIGN = 1 << 9, /* engine wants aligned memory */
153 * io engine entry points
155 extern int __must_check td_io_init(struct thread_data *);
156 extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
157 extern int __must_check td_io_queue(struct thread_data *, struct io_u *);
158 extern int __must_check td_io_sync(struct thread_data *, struct fio_file *);
159 extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *);
160 extern int __must_check td_io_commit(struct thread_data *);
161 extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
162 extern int td_io_close_file(struct thread_data *, struct fio_file *);
163 extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
165 extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
166 extern void register_ioengine(struct ioengine_ops *);
167 extern void unregister_ioengine(struct ioengine_ops *);
168 extern void free_ioengine(struct thread_data *);
169 extern void close_ioengine(struct thread_data *);
171 extern int fio_show_ioengine_help(const char *engine);
176 #define queue_full(td) flist_empty(&(td)->io_u_freelist)
177 extern struct io_u *__get_io_u(struct thread_data *);
178 extern struct io_u *get_io_u(struct thread_data *);
179 extern void put_io_u(struct thread_data *, struct io_u *);
180 extern void clear_io_u(struct thread_data *, struct io_u *);
181 extern void requeue_io_u(struct thread_data *, struct io_u **);
182 extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *, unsigned long *);
183 extern int __must_check io_u_queued_complete(struct thread_data *, int, unsigned long *);
184 extern void io_u_queued(struct thread_data *, struct io_u *);
185 extern void io_u_log_error(struct thread_data *, struct io_u *);
186 extern void io_u_mark_depth(struct thread_data *, unsigned int);
187 extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int, unsigned int);
188 void io_u_mark_complete(struct thread_data *, unsigned int);
189 void io_u_mark_submit(struct thread_data *, unsigned int);
191 int do_io_u_sync(struct thread_data *, struct io_u *);
192 int do_io_u_trim(struct thread_data *, struct io_u *);
195 static inline void dprint_io_u(struct io_u *io_u, const char *p)
197 struct fio_file *f = io_u->file;
199 dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
200 (unsigned long long) io_u->offset,
201 io_u->buflen, io_u->ddir);
202 if (fio_debug & (1 << FD_IO)) {
204 log_info("/%s", f->file_name);
210 #define dprint_io_u(io_u, p)