Add support for reserved keywords
[fio.git] / ioengine.h
CommitLineData
dcefb588
JA
1#ifndef FIO_IOENGINE_H
2#define FIO_IOENGINE_H
3
4#define FIO_IOOPS_VERSION 10
5
6enum {
7 IO_U_F_FREE = 1 << 0,
8 IO_U_F_FLIGHT = 1 << 1,
e8462bd8 9 IO_U_F_FREE_DEF = 1 << 2,
dcefb588
JA
10};
11
12/*
13 * The io unit
14 */
15struct io_u {
16 union {
17#ifdef FIO_HAVE_LIBAIO
18 struct iocb iocb;
19#endif
20#ifdef FIO_HAVE_POSIXAIO
21 struct aiocb aiocb;
22#endif
23#ifdef FIO_HAVE_SGIO
24 struct sg_io_hdr hdr;
25#endif
26#ifdef FIO_HAVE_GUASI
27 guasi_req_t greq;
28#endif
29#ifdef FIO_HAVE_SOLARISAIO
30 aio_result_t resultp;
31#endif
32 void *mmap_data;
33 };
34 struct timeval start_time;
35 struct timeval issue_time;
36
37 /*
38 * Allocated/set buffer and length
39 */
40 void *buf;
41 unsigned long buflen;
42 unsigned long long offset;
43
44 /*
45 * IO engine state, may be different from above when we get
46 * partial transfers / residual data counts
47 */
48 void *xfer_buf;
49 unsigned long xfer_buflen;
50
51 unsigned int resid;
52 unsigned int error;
53
54 enum fio_ddir ddir;
55
56 /*
57 * io engine private data
58 */
59 union {
60 unsigned int index;
61 unsigned int seen;
62 void *engine_data;
63 };
64
65 unsigned int flags;
66
67 struct fio_file *file;
68
69 struct flist_head list;
70
71 /*
72 * Callback for io completion
73 */
74 int (*end_io)(struct thread_data *, struct io_u *);
75};
76
77/*
78 * io_ops->queue() return values
79 */
80enum {
81 FIO_Q_COMPLETED = 0, /* completed sync */
82 FIO_Q_QUEUED = 1, /* queued, will complete async */
83 FIO_Q_BUSY = 2, /* no more room, call ->commit() */
84};
85
86struct ioengine_ops {
87 struct flist_head list;
88 char name[16];
89 int version;
90 int flags;
91 int (*setup)(struct thread_data *);
92 int (*init)(struct thread_data *);
93 int (*prep)(struct thread_data *, struct io_u *);
94 int (*queue)(struct thread_data *, struct io_u *);
95 int (*commit)(struct thread_data *);
96 int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *);
97 struct io_u *(*event)(struct thread_data *, int);
98 int (*cancel)(struct thread_data *, struct io_u *);
99 void (*cleanup)(struct thread_data *);
100 int (*open_file)(struct thread_data *, struct fio_file *);
101 int (*close_file)(struct thread_data *, struct fio_file *);
102 int (*get_file_size)(struct thread_data *, struct fio_file *);
103 void *data;
104 void *dlhandle;
105};
106
2b4f4abe
JA
107enum fio_ioengine_flags {
108 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */
109 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */
110 FIO_DISKLESSIO = 1 << 2, /* no disk involved */
111 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */
112 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */
113 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */
114 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */
115 FIO_SIGQUIT = 1 << 7, /* needs SIGQUIT to exit */
9c0d2241 116 FIO_PIPEIO = 1 << 8, /* input/output no seekable */
2b4f4abe 117};
dcefb588
JA
118
119/*
120 * io engine entry points
121 */
122extern int __must_check td_io_init(struct thread_data *);
123extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
124extern int __must_check td_io_queue(struct thread_data *, struct io_u *);
125extern int __must_check td_io_sync(struct thread_data *, struct fio_file *);
126extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *);
127extern int __must_check td_io_commit(struct thread_data *);
128extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
129extern int td_io_close_file(struct thread_data *, struct fio_file *);
130extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
131
132extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
133extern void register_ioengine(struct ioengine_ops *);
134extern void unregister_ioengine(struct ioengine_ops *);
135extern void close_ioengine(struct thread_data *);
136
137/*
138 * io unit handling
139 */
140#define queue_full(td) flist_empty(&(td)->io_u_freelist)
141extern struct io_u *__get_io_u(struct thread_data *);
142extern struct io_u *get_io_u(struct thread_data *);
143extern void put_io_u(struct thread_data *, struct io_u *);
f2bba182 144extern void clear_io_u(struct thread_data *, struct io_u *);
dcefb588 145extern void requeue_io_u(struct thread_data *, struct io_u **);
581e7141
JA
146extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *, unsigned long *);
147extern int __must_check io_u_queued_complete(struct thread_data *, int, unsigned long *);
dcefb588
JA
148extern void io_u_queued(struct thread_data *, struct io_u *);
149extern void io_u_log_error(struct thread_data *, struct io_u *);
150extern void io_u_mark_depth(struct thread_data *, unsigned int);
151extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int);
152void io_u_mark_complete(struct thread_data *, unsigned int);
153void io_u_mark_submit(struct thread_data *, unsigned int);
154
c592b9fe
JA
155#ifdef FIO_INC_DEBUG
156static inline void dprint_io_u(struct io_u *io_u, const char *p)
157{
158 struct fio_file *f = io_u->file;
159
160 dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
161 (unsigned long long) io_u->offset,
162 io_u->buflen, io_u->ddir);
163 if (fio_debug & (1 << FD_IO)) {
164 if (f)
165 log_info("/%s", f->file_name);
166
167 log_info("\n");
168 }
169}
170#else
171#define dprint_io_u(io_u, p)
172#endif
173
dcefb588 174#endif