gfio: demo of how to inherit option values into edit window
[fio.git] / ioengine.h
CommitLineData
dcefb588
JA
1#ifndef FIO_IOENGINE_H
2#define FIO_IOENGINE_H
3
ec41265e
JA
4#include "debug.h"
5
de890a1e 6#define FIO_IOOPS_VERSION 13
dcefb588
JA
7
8enum {
0c41214f
RR
9 IO_U_F_FREE = 1 << 0,
10 IO_U_F_FLIGHT = 1 << 1,
11 IO_U_F_FREE_DEF = 1 << 2,
12 IO_U_F_IN_CUR_DEPTH = 1 << 3,
38dad62d 13 IO_U_F_BUSY_OK = 1 << 4,
0d29de83 14 IO_U_F_TRIMMED = 1 << 5,
1ef2b6be 15 IO_U_F_BARRIER = 1 << 6,
82af2a7c 16 IO_U_F_VER_LIST = 1 << 7,
dcefb588
JA
17};
18
19/*
20 * The io unit
21 */
22struct io_u {
23 union {
24#ifdef FIO_HAVE_LIBAIO
25 struct iocb iocb;
26#endif
27#ifdef FIO_HAVE_POSIXAIO
e97c1442 28 os_aiocb_t aiocb;
dcefb588
JA
29#endif
30#ifdef FIO_HAVE_SGIO
31 struct sg_io_hdr hdr;
32#endif
33#ifdef FIO_HAVE_GUASI
34 guasi_req_t greq;
35#endif
36#ifdef FIO_HAVE_SOLARISAIO
37 aio_result_t resultp;
79a43187
JA
38#endif
39#ifdef FIO_HAVE_BINJECT
40 struct b_user_cmd buc;
21b8aee8 41#endif
42#ifdef FIO_HAVE_RDMA
43 struct ibv_mr *mr;
dcefb588
JA
44#endif
45 void *mmap_data;
46 };
47 struct timeval start_time;
48 struct timeval issue_time;
49
50 /*
51 * Allocated/set buffer and length
52 */
53 void *buf;
54 unsigned long buflen;
55 unsigned long long offset;
56
7d9fb455
JA
57 /*
58 * Initial seed for generating the buffer contents
59 */
60 unsigned long rand_seed;
61
dcefb588
JA
62 /*
63 * IO engine state, may be different from above when we get
64 * partial transfers / residual data counts
65 */
66 void *xfer_buf;
67 unsigned long xfer_buflen;
68
95228507
JA
69 /*
70 * Parameter related to pre-filled buffers and
71 * their size to handle variable block sizes.
72 */
73 unsigned long buf_filled_len;
74
dcefb588
JA
75 unsigned int resid;
76 unsigned int error;
77
78 enum fio_ddir ddir;
79
80 /*
81 * io engine private data
82 */
83 union {
84 unsigned int index;
85 unsigned int seen;
86 void *engine_data;
87 };
88
89 unsigned int flags;
90
91 struct fio_file *file;
92
93 struct flist_head list;
94
95 /*
96 * Callback for io completion
97 */
98 int (*end_io)(struct thread_data *, struct io_u *);
99};
100
101/*
102 * io_ops->queue() return values
103 */
104enum {
105 FIO_Q_COMPLETED = 0, /* completed sync */
106 FIO_Q_QUEUED = 1, /* queued, will complete async */
107 FIO_Q_BUSY = 2, /* no more room, call ->commit() */
108};
109
110struct ioengine_ops {
111 struct flist_head list;
112 char name[16];
113 int version;
114 int flags;
115 int (*setup)(struct thread_data *);
116 int (*init)(struct thread_data *);
117 int (*prep)(struct thread_data *, struct io_u *);
118 int (*queue)(struct thread_data *, struct io_u *);
119 int (*commit)(struct thread_data *);
120 int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *);
121 struct io_u *(*event)(struct thread_data *, int);
122 int (*cancel)(struct thread_data *, struct io_u *);
123 void (*cleanup)(struct thread_data *);
124 int (*open_file)(struct thread_data *, struct fio_file *);
125 int (*close_file)(struct thread_data *, struct fio_file *);
126 int (*get_file_size)(struct thread_data *, struct fio_file *);
de890a1e
SL
127 int option_struct_size;
128 struct fio_option *options;
dcefb588
JA
129 void *data;
130 void *dlhandle;
131};
132
2b4f4abe
JA
133enum fio_ioengine_flags {
134 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
135 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
136 FIO_DISKLESSIO = 1 << 2, /* no disk involved */
137 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */
93bcfd20 138 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */
2b4f4abe
JA
139 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */
140 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */
03e20d68 141 FIO_SIGTERM = 1 << 7, /* needs SIGTERM to exit */
9c0d2241 142 FIO_PIPEIO = 1 << 8, /* input/output no seekable */
1ef2b6be 143 FIO_BARRIER = 1 << 9, /* engine supports barriers */
ca7e0ddb 144 FIO_MEMALIGN = 1 << 10, /* engine wants aligned memory */
2b4f4abe 145};
dcefb588
JA
146
147/*
148 * io engine entry points
149 */
150extern int __must_check td_io_init(struct thread_data *);
151extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
152extern int __must_check td_io_queue(struct thread_data *, struct io_u *);
153extern int __must_check td_io_sync(struct thread_data *, struct fio_file *);
154extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *);
155extern int __must_check td_io_commit(struct thread_data *);
156extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
157extern int td_io_close_file(struct thread_data *, struct fio_file *);
158extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
159
160extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
161extern void register_ioengine(struct ioengine_ops *);
162extern void unregister_ioengine(struct ioengine_ops *);
de890a1e 163extern void free_ioengine(struct thread_data *);
dcefb588
JA
164extern void close_ioengine(struct thread_data *);
165
de890a1e
SL
166extern int fio_show_ioengine_help(const char *engine);
167
dcefb588
JA
168/*
169 * io unit handling
170 */
171#define queue_full(td) flist_empty(&(td)->io_u_freelist)
172extern struct io_u *__get_io_u(struct thread_data *);
173extern struct io_u *get_io_u(struct thread_data *);
174extern void put_io_u(struct thread_data *, struct io_u *);
f2bba182 175extern void clear_io_u(struct thread_data *, struct io_u *);
dcefb588 176extern void requeue_io_u(struct thread_data *, struct io_u **);
581e7141
JA
177extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *, unsigned long *);
178extern int __must_check io_u_queued_complete(struct thread_data *, int, unsigned long *);
dcefb588
JA
179extern void io_u_queued(struct thread_data *, struct io_u *);
180extern void io_u_log_error(struct thread_data *, struct io_u *);
181extern void io_u_mark_depth(struct thread_data *, unsigned int);
9c42684e 182extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int, unsigned int);
dcefb588
JA
183void io_u_mark_complete(struct thread_data *, unsigned int);
184void io_u_mark_submit(struct thread_data *, unsigned int);
185
0a28ecda 186int do_io_u_sync(struct thread_data *, struct io_u *);
a5f3027c 187int do_io_u_trim(struct thread_data *, struct io_u *);
44f29692 188
c592b9fe
JA
189#ifdef FIO_INC_DEBUG
190static inline void dprint_io_u(struct io_u *io_u, const char *p)
191{
192 struct fio_file *f = io_u->file;
193
194 dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
195 (unsigned long long) io_u->offset,
196 io_u->buflen, io_u->ddir);
197 if (fio_debug & (1 << FD_IO)) {
198 if (f)
199 log_info("/%s", f->file_name);
200
201 log_info("\n");
202 }
203}
204#else
205#define dprint_io_u(io_u, p)
206#endif
207
dcefb588 208#endif