6 #define FIO_IOOPS_VERSION 13
10 IO_U_F_FLIGHT = 1 << 1,
11 IO_U_F_FREE_DEF = 1 << 2,
12 IO_U_F_IN_CUR_DEPTH = 1 << 3,
13 IO_U_F_BUSY_OK = 1 << 4,
14 IO_U_F_TRIMMED = 1 << 5,
15 IO_U_F_BARRIER = 1 << 6,
23 #ifdef FIO_HAVE_LIBAIO
26 #ifdef FIO_HAVE_POSIXAIO
35 #ifdef FIO_HAVE_SOLARISAIO
38 #ifdef FIO_HAVE_BINJECT
39 struct b_user_cmd buc;
46 struct timeval start_time;
47 struct timeval issue_time;
50 * Allocated/set buffer and length
54 unsigned long long offset;
57 * Initial seed for generating the buffer contents
59 unsigned long rand_seed;
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
90 struct fio_file *file;
92 struct flist_head list;
95 * Callback for io completion
97 int (*end_io)(struct thread_data *, struct io_u *);
101 * io_ops->queue() return values
104 FIO_Q_COMPLETED = 0, /* completed sync */
105 FIO_Q_QUEUED = 1, /* queued, will complete async */
106 FIO_Q_BUSY = 2, /* no more room, call ->commit() */
109 struct ioengine_ops {
110 struct flist_head list;
114 int (*setup)(struct thread_data *);
115 int (*init)(struct thread_data *);
116 int (*prep)(struct thread_data *, struct io_u *);
117 int (*queue)(struct thread_data *, struct io_u *);
118 int (*commit)(struct thread_data *);
119 int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *);
120 struct io_u *(*event)(struct thread_data *, int);
121 int (*cancel)(struct thread_data *, struct io_u *);
122 void (*cleanup)(struct thread_data *);
123 int (*open_file)(struct thread_data *, struct fio_file *);
124 int (*close_file)(struct thread_data *, struct fio_file *);
125 int (*get_file_size)(struct thread_data *, struct fio_file *);
126 int option_struct_size;
127 struct fio_option *options;
132 enum fio_ioengine_flags {
133 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
134 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
135 FIO_DISKLESSIO = 1 << 2, /* no disk involved */
136 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */
137 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */
138 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */
139 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */
140 FIO_SIGTERM = 1 << 7, /* needs SIGTERM to exit */
141 FIO_PIPEIO = 1 << 8, /* input/output no seekable */
142 FIO_BARRIER = 1 << 9, /* engine supports barriers */
143 FIO_MEMALIGN = 1 << 10, /* engine wants aligned memory */
147 * io engine entry points
149 extern int __must_check td_io_init(struct thread_data *);
150 extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
151 extern int __must_check td_io_queue(struct thread_data *, struct io_u *);
152 extern int __must_check td_io_sync(struct thread_data *, struct fio_file *);
153 extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *);
154 extern int __must_check td_io_commit(struct thread_data *);
155 extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
156 extern int td_io_close_file(struct thread_data *, struct fio_file *);
157 extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
159 extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
160 extern void register_ioengine(struct ioengine_ops *);
161 extern void unregister_ioengine(struct ioengine_ops *);
162 extern void free_ioengine(struct thread_data *);
163 extern void close_ioengine(struct thread_data *);
165 extern int fio_show_ioengine_help(const char *engine);
170 #define queue_full(td) flist_empty(&(td)->io_u_freelist)
171 extern struct io_u *__get_io_u(struct thread_data *);
172 extern struct io_u *get_io_u(struct thread_data *);
173 extern void put_io_u(struct thread_data *, struct io_u *);
174 extern void clear_io_u(struct thread_data *, struct io_u *);
175 extern void requeue_io_u(struct thread_data *, struct io_u **);
176 extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *, unsigned long *);
177 extern int __must_check io_u_queued_complete(struct thread_data *, int, unsigned long *);
178 extern void io_u_queued(struct thread_data *, struct io_u *);
179 extern void io_u_log_error(struct thread_data *, struct io_u *);
180 extern void io_u_mark_depth(struct thread_data *, unsigned int);
181 extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int);
182 void io_u_mark_complete(struct thread_data *, unsigned int);
183 void io_u_mark_submit(struct thread_data *, unsigned int);
185 int do_io_u_sync(struct thread_data *, struct io_u *);
186 int do_io_u_trim(struct thread_data *, struct io_u *);
189 static inline void dprint_io_u(struct io_u *io_u, const char *p)
191 struct fio_file *f = io_u->file;
193 dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
194 (unsigned long long) io_u->offset,
195 io_u->buflen, io_u->ddir);
196 if (fio_debug & (1 << FD_IO)) {
198 log_info("/%s", f->file_name);
204 #define dprint_io_u(io_u, p)