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