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