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