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