Commit | Line | Data |
---|---|---|
2866c82d | 1 | /* |
da751ca9 JA |
2 | * libaio engine |
3 | * | |
4 | * IO engine using the Linux native aio interface. | |
2866c82d JA |
5 | * |
6 | */ | |
2866c82d JA |
7 | #include <stdlib.h> |
8 | #include <unistd.h> | |
9 | #include <errno.h> | |
67bf9823 | 10 | #include <libaio.h> |
5f350952 JA |
11 | |
12 | #include "../fio.h" | |
0f38bbef | 13 | #include "../lib/pow2.h" |
d220c761 | 14 | #include "../optgroup.h" |
90a8c9b2 | 15 | #include "../lib/memalign.h" |
2866c82d | 16 | |
ee636f3f JA |
17 | #ifndef IOCB_FLAG_HIPRI |
18 | #define IOCB_FLAG_HIPRI (1 << 2) | |
19 | #endif | |
2da0f5d5 | 20 | |
3c3168e9 | 21 | #ifndef IOCTX_FLAG_USERIOCB |
2da0f5d5 JA |
22 | #define IOCTX_FLAG_USERIOCB (1 << 0) |
23 | #endif | |
24 | #ifndef IOCTX_FLAG_IOPOLL | |
25 | #define IOCTX_FLAG_IOPOLL (1 << 1) | |
3c3168e9 | 26 | #endif |
2041bd34 JA |
27 | #ifndef IOCTX_FLAG_FIXEDBUFS |
28 | #define IOCTX_FLAG_FIXEDBUFS (1 << 2) | |
29 | #endif | |
a391d73d | 30 | |
0fc2e103 JA |
31 | static int fio_libaio_commit(struct thread_data *td); |
32 | ||
2866c82d JA |
33 | struct libaio_data { |
34 | io_context_t aio_ctx; | |
35 | struct io_event *aio_events; | |
755200a3 | 36 | struct iocb **iocbs; |
7e77dd02 | 37 | struct io_u **io_us; |
acd45e02 | 38 | |
3c3168e9 JA |
39 | struct iocb *user_iocbs; |
40 | struct io_u **io_u_index; | |
41 | ||
acd45e02 JA |
42 | /* |
43 | * Basic ring buffer. 'head' is incremented in _queue(), and | |
44 | * 'tail' is incremented in _commit(). We keep 'queued' so | |
45 | * that we know if the ring is full or empty, when | |
46 | * 'head' == 'tail'. 'entries' is the ring size, and | |
47 | * 'is_pow2' is just an optimization to use AND instead of | |
48 | * modulus to get the remainder on ring increment. | |
49 | */ | |
50 | int is_pow2; | |
51 | unsigned int entries; | |
52 | unsigned int queued; | |
53 | unsigned int head; | |
54 | unsigned int tail; | |
2866c82d JA |
55 | }; |
56 | ||
de890a1e | 57 | struct libaio_options { |
a1f871c7 | 58 | void *pad; |
de890a1e | 59 | unsigned int userspace_reap; |
a391d73d | 60 | unsigned int hipri; |
3c3168e9 | 61 | unsigned int useriocb; |
2041bd34 | 62 | unsigned int fixedbufs; |
de890a1e SL |
63 | }; |
64 | ||
65 | static struct fio_option options[] = { | |
66 | { | |
67 | .name = "userspace_reap", | |
e8b0e958 | 68 | .lname = "Libaio userspace reaping", |
de890a1e SL |
69 | .type = FIO_OPT_STR_SET, |
70 | .off1 = offsetof(struct libaio_options, userspace_reap), | |
71 | .help = "Use alternative user-space reap implementation", | |
e90a0adf | 72 | .category = FIO_OPT_C_ENGINE, |
5a3cd5f3 | 73 | .group = FIO_OPT_G_LIBAIO, |
de890a1e | 74 | }, |
a391d73d JA |
75 | { |
76 | .name = "hipri", | |
ee636f3f | 77 | .lname = "High Priority", |
a391d73d JA |
78 | .type = FIO_OPT_STR_SET, |
79 | .off1 = offsetof(struct libaio_options, hipri), | |
6acc46d8 | 80 | .help = "Use polled IO completions", |
a391d73d JA |
81 | .category = FIO_OPT_C_ENGINE, |
82 | .group = FIO_OPT_G_LIBAIO, | |
83 | }, | |
3c3168e9 JA |
84 | { |
85 | .name = "useriocb", | |
86 | .lname = "User IOCBs", | |
87 | .type = FIO_OPT_STR_SET, | |
88 | .off1 = offsetof(struct libaio_options, useriocb), | |
89 | .help = "Use user mapped IOCBs", | |
90 | .category = FIO_OPT_C_ENGINE, | |
91 | .group = FIO_OPT_G_LIBAIO, | |
92 | }, | |
2041bd34 JA |
93 | { |
94 | .name = "fixedbufs", | |
95 | .lname = "Fixed (pre-mapped) IO buffers", | |
96 | .type = FIO_OPT_STR_SET, | |
97 | .off1 = offsetof(struct libaio_options, fixedbufs), | |
98 | .help = "Pre map IO buffers", | |
99 | .category = FIO_OPT_C_ENGINE, | |
100 | .group = FIO_OPT_G_LIBAIO, | |
101 | }, | |
de890a1e SL |
102 | { |
103 | .name = NULL, | |
104 | }, | |
105 | }; | |
106 | ||
acd45e02 JA |
107 | static inline void ring_inc(struct libaio_data *ld, unsigned int *val, |
108 | unsigned int add) | |
109 | { | |
110 | if (ld->is_pow2) | |
111 | *val = (*val + add) & (ld->entries - 1); | |
112 | else | |
113 | *val = (*val + add) % ld->entries; | |
114 | } | |
115 | ||
7a16dd02 | 116 | static int fio_libaio_prep(struct thread_data fio_unused *td, struct io_u *io_u) |
2866c82d | 117 | { |
3c3168e9 | 118 | struct libaio_data *ld = td->io_ops_data; |
53cdc686 | 119 | struct fio_file *f = io_u->file; |
a391d73d | 120 | struct libaio_options *o = td->eo; |
3c3168e9 JA |
121 | struct iocb *iocb; |
122 | ||
123 | if (o->useriocb) | |
124 | iocb = &ld->user_iocbs[io_u->index]; | |
125 | else | |
126 | iocb = &io_u->iocb; | |
53cdc686 | 127 | |
90a8c9b2 JA |
128 | iocb->u.c.flags = 0; |
129 | ||
a391d73d | 130 | if (io_u->ddir == DDIR_READ) { |
3c3168e9 | 131 | io_prep_pread(iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset); |
a391d73d | 132 | if (o->hipri) |
3c3168e9 | 133 | iocb->u.c.flags |= IOCB_FLAG_HIPRI; |
a391d73d | 134 | } else if (io_u->ddir == DDIR_WRITE) { |
3c3168e9 | 135 | io_prep_pwrite(iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset); |
a391d73d | 136 | if (o->hipri) |
3c3168e9 | 137 | iocb->u.c.flags |= IOCB_FLAG_HIPRI; |
a391d73d | 138 | } else if (ddir_sync(io_u->ddir)) |
3c3168e9 | 139 | io_prep_fsync(iocb, f->fd); |
2866c82d JA |
140 | |
141 | return 0; | |
142 | } | |
143 | ||
144 | static struct io_u *fio_libaio_event(struct thread_data *td, int event) | |
145 | { | |
565e784d | 146 | struct libaio_data *ld = td->io_ops_data; |
3c3168e9 | 147 | struct libaio_options *o = td->eo; |
f423479d JA |
148 | struct io_event *ev; |
149 | struct io_u *io_u; | |
2866c82d | 150 | |
f423479d | 151 | ev = ld->aio_events + event; |
3c3168e9 JA |
152 | if (o->useriocb) { |
153 | int index = (int) (uintptr_t) ev->obj; | |
154 | io_u = ld->io_u_index[index]; | |
155 | } else | |
156 | io_u = container_of(ev->obj, struct io_u, iocb); | |
f423479d JA |
157 | |
158 | if (ev->res != io_u->xfer_buflen) { | |
159 | if (ev->res > io_u->xfer_buflen) | |
160 | io_u->error = -ev->res; | |
161 | else | |
162 | io_u->resid = io_u->xfer_buflen - ev->res; | |
163 | } else | |
164 | io_u->error = 0; | |
165 | ||
166 | return io_u; | |
2866c82d JA |
167 | } |
168 | ||
675012f0 DE |
169 | struct aio_ring { |
170 | unsigned id; /** kernel internal index number */ | |
171 | unsigned nr; /** number of io_events */ | |
172 | unsigned head; | |
173 | unsigned tail; | |
c44b1ff5 | 174 | |
675012f0 DE |
175 | unsigned magic; |
176 | unsigned compat_features; | |
177 | unsigned incompat_features; | |
178 | unsigned header_length; /** size of aio_ring */ | |
179 | ||
180 | struct io_event events[0]; | |
181 | }; | |
182 | ||
183 | #define AIO_RING_MAGIC 0xa10a10a1 | |
184 | ||
185 | static int user_io_getevents(io_context_t aio_ctx, unsigned int max, | |
c44b1ff5 | 186 | struct io_event *events) |
675012f0 DE |
187 | { |
188 | long i = 0; | |
189 | unsigned head; | |
c44b1ff5 | 190 | struct aio_ring *ring = (struct aio_ring*) aio_ctx; |
675012f0 DE |
191 | |
192 | while (i < max) { | |
193 | head = ring->head; | |
194 | ||
195 | if (head == ring->tail) { | |
196 | /* There are no more completions */ | |
197 | break; | |
198 | } else { | |
199 | /* There is another completion to reap */ | |
200 | events[i] = ring->events[head]; | |
201 | read_barrier(); | |
c44b1ff5 | 202 | ring->head = (head + 1) % ring->nr; |
675012f0 DE |
203 | i++; |
204 | } | |
205 | } | |
206 | ||
207 | return i; | |
208 | } | |
209 | ||
e7d2e616 | 210 | static int fio_libaio_getevents(struct thread_data *td, unsigned int min, |
1f440ece | 211 | unsigned int max, const struct timespec *t) |
2866c82d | 212 | { |
565e784d | 213 | struct libaio_data *ld = td->io_ops_data; |
de890a1e | 214 | struct libaio_options *o = td->eo; |
82407585 | 215 | unsigned actual_min = td->o.iodepth_batch_complete_min == 0 ? 0 : min; |
1f440ece | 216 | struct timespec __lt, *lt = NULL; |
0b7fdba7 | 217 | int r, events = 0; |
2866c82d | 218 | |
1f440ece JA |
219 | if (t) { |
220 | __lt = *t; | |
221 | lt = &__lt; | |
222 | } | |
223 | ||
2866c82d | 224 | do { |
de890a1e | 225 | if (o->userspace_reap == 1 |
675012f0 DE |
226 | && actual_min == 0 |
227 | && ((struct aio_ring *)(ld->aio_ctx))->magic | |
228 | == AIO_RING_MAGIC) { | |
229 | r = user_io_getevents(ld->aio_ctx, max, | |
230 | ld->aio_events + events); | |
231 | } else { | |
232 | r = io_getevents(ld->aio_ctx, actual_min, | |
1f440ece | 233 | max, ld->aio_events + events, lt); |
675012f0 | 234 | } |
3441a52d | 235 | if (r > 0) |
0b7fdba7 | 236 | events += r; |
3441a52d | 237 | else if ((min && r == 0) || r == -EAGAIN) { |
0fc2e103 | 238 | fio_libaio_commit(td); |
6347e43d JA |
239 | if (actual_min) |
240 | usleep(10); | |
0fc2e103 | 241 | } else if (r != -EINTR) |
a31dc2dd | 242 | break; |
0b7fdba7 DE |
243 | } while (events < min); |
244 | ||
245 | return r < 0 ? r : events; | |
2866c82d JA |
246 | } |
247 | ||
2e4ef4fb JA |
248 | static enum fio_q_status fio_libaio_queue(struct thread_data *td, |
249 | struct io_u *io_u) | |
2866c82d | 250 | { |
565e784d | 251 | struct libaio_data *ld = td->io_ops_data; |
3c3168e9 | 252 | struct libaio_options *o = td->eo; |
2866c82d | 253 | |
7101d9c2 JA |
254 | fio_ro_check(td, io_u); |
255 | ||
acd45e02 | 256 | if (ld->queued == td->o.iodepth) |
755200a3 JA |
257 | return FIO_Q_BUSY; |
258 | ||
259 | /* | |
260 | * fsync is tricky, since it can fail and we need to do it | |
261 | * serialized with other io. the reason is that linux doesn't | |
262 | * support aio fsync yet. So return busy for the case where we | |
263 | * have pending io, to let fio complete those first. | |
264 | */ | |
f011531e | 265 | if (ddir_sync(io_u->ddir)) { |
acd45e02 | 266 | if (ld->queued) |
755200a3 | 267 | return FIO_Q_BUSY; |
5f9099ea | 268 | |
f011531e | 269 | do_io_u_sync(td, io_u); |
755200a3 JA |
270 | return FIO_Q_COMPLETED; |
271 | } | |
272 | ||
a5f3027c | 273 | if (io_u->ddir == DDIR_TRIM) { |
acd45e02 | 274 | if (ld->queued) |
a5f3027c JA |
275 | return FIO_Q_BUSY; |
276 | ||
277 | do_io_u_trim(td, io_u); | |
c0681c9d VF |
278 | io_u_mark_submit(td, 1); |
279 | io_u_mark_complete(td, 1); | |
a5f3027c JA |
280 | return FIO_Q_COMPLETED; |
281 | } | |
282 | ||
3c3168e9 JA |
283 | if (o->useriocb) |
284 | ld->iocbs[ld->head] = (struct iocb *) (uintptr_t) io_u->index; | |
285 | else | |
286 | ld->iocbs[ld->head] = &io_u->iocb; | |
287 | ||
acd45e02 JA |
288 | ld->io_us[ld->head] = io_u; |
289 | ring_inc(ld, &ld->head, 1); | |
290 | ld->queued++; | |
755200a3 JA |
291 | return FIO_Q_QUEUED; |
292 | } | |
293 | ||
7e77dd02 JA |
294 | static void fio_libaio_queued(struct thread_data *td, struct io_u **io_us, |
295 | unsigned int nr) | |
296 | { | |
8b6a404c | 297 | struct timespec now; |
7e77dd02 JA |
298 | unsigned int i; |
299 | ||
12d9d841 JA |
300 | if (!fio_fill_issue_time(td)) |
301 | return; | |
302 | ||
7e77dd02 JA |
303 | fio_gettime(&now, NULL); |
304 | ||
305 | for (i = 0; i < nr; i++) { | |
306 | struct io_u *io_u = io_us[i]; | |
307 | ||
308 | memcpy(&io_u->issue_time, &now, sizeof(now)); | |
309 | io_u_queued(td, io_u); | |
310 | } | |
311 | } | |
312 | ||
755200a3 JA |
313 | static int fio_libaio_commit(struct thread_data *td) |
314 | { | |
565e784d | 315 | struct libaio_data *ld = td->io_ops_data; |
755200a3 | 316 | struct iocb **iocbs; |
7e77dd02 | 317 | struct io_u **io_us; |
8b6a404c | 318 | struct timespec ts; |
a120ca7f | 319 | int ret, wait_start = 0; |
755200a3 | 320 | |
acd45e02 | 321 | if (!ld->queued) |
755200a3 JA |
322 | return 0; |
323 | ||
2866c82d | 324 | do { |
acd45e02 JA |
325 | long nr = ld->queued; |
326 | ||
327 | nr = min((unsigned int) nr, ld->entries - ld->tail); | |
328 | io_us = ld->io_us + ld->tail; | |
329 | iocbs = ld->iocbs + ld->tail; | |
330 | ||
331 | ret = io_submit(ld->aio_ctx, nr, iocbs); | |
5e00c2c4 | 332 | if (ret > 0) { |
7e77dd02 | 333 | fio_libaio_queued(td, io_us, ret); |
838bc709 | 334 | io_u_mark_submit(td, ret); |
acd45e02 JA |
335 | |
336 | ld->queued -= ret; | |
337 | ring_inc(ld, &ld->tail, ret); | |
5e00c2c4 | 338 | ret = 0; |
e3b4e568 | 339 | wait_start = 0; |
acd45e02 | 340 | } else if (ret == -EINTR || !ret) { |
838bc709 JA |
341 | if (!ret) |
342 | io_u_mark_submit(td, ret); | |
e3b4e568 | 343 | wait_start = 0; |
2866c82d | 344 | continue; |
acd45e02 JA |
345 | } else if (ret == -EAGAIN) { |
346 | /* | |
347 | * If we get EAGAIN, we should break out without | |
348 | * error and let the upper layer reap some | |
a120ca7f JA |
349 | * events for us. If we have no queued IO, we |
350 | * must loop here. If we loop for more than 30s, | |
351 | * just error out, something must be buggy in the | |
352 | * IO path. | |
acd45e02 | 353 | */ |
a120ca7f JA |
354 | if (ld->queued) { |
355 | ret = 0; | |
356 | break; | |
357 | } | |
358 | if (!wait_start) { | |
8b6a404c | 359 | fio_gettime(&ts, NULL); |
d36b072d | 360 | wait_start = 1; |
8b6a404c | 361 | } else if (mtime_since_now(&ts) > 30000) { |
a120ca7f JA |
362 | log_err("fio: aio appears to be stalled, giving up\n"); |
363 | break; | |
364 | } | |
365 | usleep(1); | |
366 | continue; | |
a31dc2dd JA |
367 | } else if (ret == -ENOMEM) { |
368 | /* | |
369 | * If we get -ENOMEM, reap events if we can. If | |
370 | * we cannot, treat it as a fatal event since there's | |
371 | * nothing we can do about it. | |
372 | */ | |
373 | if (ld->queued) | |
374 | ret = 0; | |
375 | break; | |
838bc709 | 376 | } else |
2866c82d | 377 | break; |
2c3a4ae9 | 378 | } while (ld->queued); |
2866c82d | 379 | |
36167d82 | 380 | return ret; |
2866c82d JA |
381 | } |
382 | ||
383 | static int fio_libaio_cancel(struct thread_data *td, struct io_u *io_u) | |
384 | { | |
565e784d | 385 | struct libaio_data *ld = td->io_ops_data; |
2866c82d JA |
386 | |
387 | return io_cancel(ld->aio_ctx, &io_u->iocb, ld->aio_events); | |
388 | } | |
389 | ||
390 | static void fio_libaio_cleanup(struct thread_data *td) | |
391 | { | |
565e784d | 392 | struct libaio_data *ld = td->io_ops_data; |
2866c82d JA |
393 | |
394 | if (ld) { | |
f24c2649 JA |
395 | /* |
396 | * Work-around to avoid huge RCU stalls at exit time. If we | |
397 | * don't do this here, then it'll be torn down by exit_aio(). | |
398 | * But for that case we can parallellize the freeing, thus | |
399 | * speeding it up a lot. | |
400 | */ | |
401 | if (!(td->flags & TD_F_CHILD)) | |
402 | io_destroy(ld->aio_ctx); | |
7e77dd02 JA |
403 | free(ld->aio_events); |
404 | free(ld->iocbs); | |
405 | free(ld->io_us); | |
90a8c9b2 JA |
406 | if (ld->user_iocbs) { |
407 | size_t size = td->o.iodepth * sizeof(struct iocb); | |
408 | fio_memfree(ld->user_iocbs, size, false); | |
409 | } | |
2866c82d | 410 | free(ld); |
2866c82d JA |
411 | } |
412 | } | |
413 | ||
e65ef959 | 414 | static int fio_libaio_old_queue_init(struct libaio_data *ld, unsigned int depth, |
2041bd34 | 415 | bool hipri, bool useriocb, bool fixedbufs) |
ebec344d | 416 | { |
ebec344d JA |
417 | if (hipri) { |
418 | log_err("fio: polled aio not available on your platform\n"); | |
419 | return 1; | |
420 | } | |
3c3168e9 JA |
421 | if (useriocb) { |
422 | log_err("fio: user mapped iocbs not available on your platform\n"); | |
423 | return 1; | |
424 | } | |
2041bd34 JA |
425 | if (fixedbufs) { |
426 | log_err("fio: fixed buffers not available on your platform\n"); | |
427 | return 1; | |
428 | } | |
3c3168e9 | 429 | |
ebec344d | 430 | return io_queue_init(depth, &ld->aio_ctx); |
e65ef959 JA |
431 | } |
432 | ||
433 | static int fio_libaio_queue_init(struct libaio_data *ld, unsigned int depth, | |
2041bd34 | 434 | bool hipri, bool useriocb, bool fixedbufs) |
e65ef959 JA |
435 | { |
436 | #ifdef __NR_sys_io_setup2 | |
437 | int ret, flags = 0; | |
438 | ||
439 | if (hipri) | |
440 | flags |= IOCTX_FLAG_IOPOLL; | |
441 | if (useriocb) | |
442 | flags |= IOCTX_FLAG_USERIOCB; | |
2041bd34 JA |
443 | if (fixedbufs) |
444 | flags |= IOCTX_FLAG_FIXEDBUFS; | |
e65ef959 JA |
445 | |
446 | ret = syscall(__NR_sys_io_setup2, depth, flags, ld->user_iocbs, | |
447 | &ld->aio_ctx); | |
448 | if (!ret) | |
449 | return 0; | |
0fcbc009 | 450 | /* fall through to old syscall */ |
ebec344d | 451 | #endif |
2041bd34 JA |
452 | return fio_libaio_old_queue_init(ld, depth, hipri, useriocb, fixedbufs); |
453 | } | |
454 | ||
455 | static int fio_libaio_post_init(struct thread_data *td) | |
456 | { | |
457 | struct libaio_data *ld = td->io_ops_data; | |
458 | struct libaio_options *o = td->eo; | |
459 | struct io_u *io_u; | |
460 | struct iocb *iocb; | |
461 | int err = 0; | |
462 | ||
463 | if (o->fixedbufs) { | |
464 | int i; | |
465 | ||
466 | for (i = 0; i < td->o.iodepth; i++) { | |
467 | io_u = ld->io_u_index[i]; | |
468 | iocb = &ld->user_iocbs[i]; | |
469 | iocb->u.c.buf = io_u->buf; | |
c36210b4 | 470 | iocb->u.c.nbytes = td_max_bs(td); |
2041bd34 JA |
471 | } |
472 | } | |
473 | ||
474 | err = fio_libaio_queue_init(ld, td->o.iodepth, o->hipri, o->useriocb, | |
475 | o->fixedbufs); | |
476 | if (err) { | |
477 | td_verror(td, -err, "io_queue_init"); | |
478 | return 1; | |
479 | } | |
480 | ||
481 | return 0; | |
ebec344d JA |
482 | } |
483 | ||
2866c82d JA |
484 | static int fio_libaio_init(struct thread_data *td) |
485 | { | |
c90e1017 | 486 | struct libaio_options *o = td->eo; |
acd45e02 | 487 | struct libaio_data *ld; |
2866c82d | 488 | |
acd45e02 | 489 | ld = calloc(1, sizeof(*ld)); |
c1db2dce | 490 | |
3c3168e9 JA |
491 | if (o->useriocb) { |
492 | size_t size; | |
3c3168e9 JA |
493 | |
494 | ld->io_u_index = calloc(td->o.iodepth, sizeof(struct io_u *)); | |
495 | size = td->o.iodepth * sizeof(struct iocb); | |
90a8c9b2 JA |
496 | ld->user_iocbs = fio_memalign(page_size, size, false); |
497 | memset(ld->user_iocbs, 0, size); | |
3c3168e9 JA |
498 | } |
499 | ||
acd45e02 JA |
500 | ld->entries = td->o.iodepth; |
501 | ld->is_pow2 = is_power_of_2(ld->entries); | |
502 | ld->aio_events = calloc(ld->entries, sizeof(struct io_event)); | |
503 | ld->iocbs = calloc(ld->entries, sizeof(struct iocb *)); | |
504 | ld->io_us = calloc(ld->entries, sizeof(struct io_u *)); | |
755200a3 | 505 | |
565e784d | 506 | td->io_ops_data = ld; |
2866c82d JA |
507 | return 0; |
508 | } | |
509 | ||
3c3168e9 JA |
510 | static int fio_libaio_io_u_init(struct thread_data *td, struct io_u *io_u) |
511 | { | |
512 | struct libaio_options *o = td->eo; | |
513 | ||
514 | if (o->useriocb) { | |
515 | struct libaio_data *ld = td->io_ops_data; | |
516 | ||
517 | ld->io_u_index[io_u->index] = io_u; | |
518 | } | |
519 | ||
520 | return 0; | |
521 | } | |
522 | ||
5f350952 | 523 | static struct ioengine_ops ioengine = { |
de890a1e SL |
524 | .name = "libaio", |
525 | .version = FIO_IOOPS_VERSION, | |
526 | .init = fio_libaio_init, | |
2041bd34 | 527 | .post_init = fio_libaio_post_init, |
3c3168e9 | 528 | .io_u_init = fio_libaio_io_u_init, |
de890a1e SL |
529 | .prep = fio_libaio_prep, |
530 | .queue = fio_libaio_queue, | |
531 | .commit = fio_libaio_commit, | |
532 | .cancel = fio_libaio_cancel, | |
533 | .getevents = fio_libaio_getevents, | |
534 | .event = fio_libaio_event, | |
535 | .cleanup = fio_libaio_cleanup, | |
536 | .open_file = generic_open_file, | |
537 | .close_file = generic_close_file, | |
538 | .get_file_size = generic_get_file_size, | |
539 | .options = options, | |
540 | .option_struct_size = sizeof(struct libaio_options), | |
2866c82d | 541 | }; |
34cfcdaf | 542 | |
5f350952 JA |
543 | static void fio_init fio_libaio_register(void) |
544 | { | |
545 | register_ioengine(&ioengine); | |
546 | } | |
547 | ||
548 | static void fio_exit fio_libaio_unregister(void) | |
549 | { | |
550 | unregister_ioengine(&ioengine); | |
551 | } |