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