Commit | Line | Data |
---|---|---|
dcefb588 JA |
1 | #ifndef FIO_IOENGINE_H |
2 | #define FIO_IOENGINE_H | |
3 | ||
3d2d14bc SW |
4 | #include <stddef.h> |
5 | ||
41666588 | 6 | #include "compiler/compiler.h" |
3d2d14bc | 7 | #include "flist.h" |
8ef89e0b | 8 | #include "io_u.h" |
67bf9823 | 9 | |
2041bd34 | 10 | #define FIO_IOOPS_VERSION 25 |
dcefb588 | 11 | |
dcefb588 JA |
12 | /* |
13 | * io_ops->queue() return values | |
14 | */ | |
d3b07186 | 15 | enum fio_q_status { |
dcefb588 JA |
16 | FIO_Q_COMPLETED = 0, /* completed sync */ |
17 | FIO_Q_QUEUED = 1, /* queued, will complete async */ | |
18 | FIO_Q_BUSY = 2, /* no more room, call ->commit() */ | |
19 | }; | |
20 | ||
21 | struct ioengine_ops { | |
22 | struct flist_head list; | |
43072e8e | 23 | const char *name; |
dcefb588 JA |
24 | int version; |
25 | int flags; | |
26 | int (*setup)(struct thread_data *); | |
27 | int (*init)(struct thread_data *); | |
2041bd34 | 28 | int (*post_init)(struct thread_data *); |
dcefb588 | 29 | int (*prep)(struct thread_data *, struct io_u *); |
d3b07186 | 30 | enum fio_q_status (*queue)(struct thread_data *, struct io_u *); |
dcefb588 | 31 | int (*commit)(struct thread_data *); |
1f440ece | 32 | int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *); |
dcefb588 | 33 | struct io_u *(*event)(struct thread_data *, int); |
5ad7be56 | 34 | char *(*errdetails)(struct io_u *); |
dcefb588 JA |
35 | int (*cancel)(struct thread_data *, struct io_u *); |
36 | void (*cleanup)(struct thread_data *); | |
37 | int (*open_file)(struct thread_data *, struct fio_file *); | |
38 | int (*close_file)(struct thread_data *, struct fio_file *); | |
d9b100fc | 39 | int (*invalidate)(struct thread_data *, struct fio_file *); |
38ef9c90 | 40 | int (*unlink_file)(struct thread_data *, struct fio_file *); |
dcefb588 | 41 | int (*get_file_size)(struct thread_data *, struct fio_file *); |
36d80bc7 | 42 | void (*terminate)(struct thread_data *); |
a6cb85e2 JA |
43 | int (*iomem_alloc)(struct thread_data *, size_t); |
44 | void (*iomem_free)(struct thread_data *); | |
c73ed246 JA |
45 | int (*io_u_init)(struct thread_data *, struct io_u *); |
46 | void (*io_u_free)(struct thread_data *, struct io_u *); | |
de890a1e SL |
47 | int option_struct_size; |
48 | struct fio_option *options; | |
dcefb588 JA |
49 | }; |
50 | ||
2b4f4abe JA |
51 | enum fio_ioengine_flags { |
52 | FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */ | |
53 | FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */ | |
54 | FIO_DISKLESSIO = 1 << 2, /* no disk involved */ | |
55 | FIO_NOEXTEND = 1 << 3, /* engine can't extend file */ | |
93bcfd20 | 56 | FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */ |
2b4f4abe JA |
57 | FIO_UNIDIR = 1 << 5, /* engine is uni-directional */ |
58 | FIO_NOIO = 1 << 6, /* thread does only pseudo IO */ | |
36d80bc7 JA |
59 | FIO_PIPEIO = 1 << 7, /* input/output no seekable */ |
60 | FIO_BARRIER = 1 << 8, /* engine supports barriers */ | |
61 | FIO_MEMALIGN = 1 << 9, /* engine wants aligned memory */ | |
ad705bcb | 62 | FIO_BIT_BASED = 1 << 10, /* engine uses a bit base (e.g. uses Kbit as opposed to KB) */ |
5c57c084 | 63 | FIO_FAKEIO = 1 << 11, /* engine pretends to do IO */ |
132b1ee4 | 64 | FIO_NOSTATS = 1 << 12, /* don't do IO stats */ |
cb9bf647 | 65 | FIO_NOFILEHASH = 1 << 13, /* doesn't hash the files for lookup later. */ |
04ba61df VF |
66 | FIO_ASYNCIO_SYNC_TRIM |
67 | = 1 << 14 /* io engine has async ->queue except for trim */ | |
2b4f4abe | 68 | }; |
dcefb588 | 69 | |
a8075704 DG |
70 | /* |
71 | * External engine defined symbol to fill in the engine ops structure | |
72 | */ | |
73 | typedef void (*get_ioengine_t)(struct ioengine_ops **); | |
74 | ||
dcefb588 JA |
75 | /* |
76 | * io engine entry points | |
77 | */ | |
78 | extern int __must_check td_io_init(struct thread_data *); | |
79 | extern int __must_check td_io_prep(struct thread_data *, struct io_u *); | |
d3b07186 | 80 | extern enum fio_q_status __must_check td_io_queue(struct thread_data *, struct io_u *); |
1f440ece | 81 | extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, const struct timespec *); |
a80cb54b | 82 | extern void td_io_commit(struct thread_data *); |
dcefb588 JA |
83 | extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *); |
84 | extern int td_io_close_file(struct thread_data *, struct fio_file *); | |
38ef9c90 | 85 | extern int td_io_unlink_file(struct thread_data *, struct fio_file *); |
dcefb588 JA |
86 | extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *); |
87 | ||
4fedf59a | 88 | extern struct ioengine_ops *load_ioengine(struct thread_data *); |
dcefb588 JA |
89 | extern void register_ioengine(struct ioengine_ops *); |
90 | extern void unregister_ioengine(struct ioengine_ops *); | |
de890a1e | 91 | extern void free_ioengine(struct thread_data *); |
dcefb588 JA |
92 | extern void close_ioengine(struct thread_data *); |
93 | ||
de890a1e SL |
94 | extern int fio_show_ioengine_help(const char *engine); |
95 | ||
dcefb588 | 96 | #endif |