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