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" |
6c5b11d3 | 9 | #include "zbd_types.h" |
67bf9823 | 10 | |
78c0d7a0 | 11 | #define FIO_IOOPS_VERSION 31 |
dcefb588 | 12 | |
5a8a6a03 YK |
13 | #ifndef CONFIG_DYNAMIC_ENGINES |
14 | #define FIO_STATIC static | |
15 | #else | |
16 | #define FIO_STATIC | |
17 | #endif | |
18 | ||
dcefb588 JA |
19 | /* |
20 | * io_ops->queue() return values | |
21 | */ | |
d3b07186 | 22 | enum fio_q_status { |
dcefb588 JA |
23 | FIO_Q_COMPLETED = 0, /* completed sync */ |
24 | FIO_Q_QUEUED = 1, /* queued, will complete async */ | |
25 | FIO_Q_BUSY = 2, /* no more room, call ->commit() */ | |
26 | }; | |
27 | ||
28 | struct ioengine_ops { | |
29 | struct flist_head list; | |
43072e8e | 30 | const char *name; |
dcefb588 JA |
31 | int version; |
32 | int flags; | |
f6931a1d | 33 | void *dlhandle; |
dcefb588 JA |
34 | int (*setup)(struct thread_data *); |
35 | int (*init)(struct thread_data *); | |
2041bd34 | 36 | int (*post_init)(struct thread_data *); |
dcefb588 | 37 | int (*prep)(struct thread_data *, struct io_u *); |
d3b07186 | 38 | enum fio_q_status (*queue)(struct thread_data *, struct io_u *); |
dcefb588 | 39 | int (*commit)(struct thread_data *); |
1f440ece | 40 | int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *); |
dcefb588 | 41 | struct io_u *(*event)(struct thread_data *, int); |
5ad7be56 | 42 | char *(*errdetails)(struct io_u *); |
dcefb588 JA |
43 | int (*cancel)(struct thread_data *, struct io_u *); |
44 | void (*cleanup)(struct thread_data *); | |
45 | int (*open_file)(struct thread_data *, struct fio_file *); | |
46 | int (*close_file)(struct thread_data *, struct fio_file *); | |
d9b100fc | 47 | int (*invalidate)(struct thread_data *, struct fio_file *); |
38ef9c90 | 48 | int (*unlink_file)(struct thread_data *, struct fio_file *); |
dcefb588 | 49 | int (*get_file_size)(struct thread_data *, struct fio_file *); |
8c47cc76 | 50 | int (*prepopulate_file)(struct thread_data *, struct fio_file *); |
36d80bc7 | 51 | void (*terminate)(struct thread_data *); |
a6cb85e2 JA |
52 | int (*iomem_alloc)(struct thread_data *, size_t); |
53 | void (*iomem_free)(struct thread_data *); | |
c73ed246 JA |
54 | int (*io_u_init)(struct thread_data *, struct io_u *); |
55 | void (*io_u_free)(struct thread_data *, struct io_u *); | |
6c5b11d3 DLM |
56 | int (*get_zoned_model)(struct thread_data *td, |
57 | struct fio_file *f, enum zbd_zoned_model *); | |
58 | int (*report_zones)(struct thread_data *, struct fio_file *, | |
59 | uint64_t, struct zbd_zone *, unsigned int); | |
60 | int (*reset_wp)(struct thread_data *, struct fio_file *, | |
61 | uint64_t, uint64_t); | |
d2f442bc NC |
62 | int (*get_max_open_zones)(struct thread_data *, struct fio_file *, |
63 | unsigned int *); | |
a7f1b5cd SK |
64 | int (*finish_zone)(struct thread_data *, struct fio_file *, |
65 | uint64_t, uint64_t); | |
de890a1e SL |
66 | int option_struct_size; |
67 | struct fio_option *options; | |
dcefb588 JA |
68 | }; |
69 | ||
2b4f4abe JA |
70 | enum fio_ioengine_flags { |
71 | FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */ | |
72 | FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */ | |
73 | FIO_DISKLESSIO = 1 << 2, /* no disk involved */ | |
74 | FIO_NOEXTEND = 1 << 3, /* engine can't extend file */ | |
93bcfd20 | 75 | FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */ |
2b4f4abe JA |
76 | FIO_UNIDIR = 1 << 5, /* engine is uni-directional */ |
77 | FIO_NOIO = 1 << 6, /* thread does only pseudo IO */ | |
36d80bc7 JA |
78 | FIO_PIPEIO = 1 << 7, /* input/output no seekable */ |
79 | FIO_BARRIER = 1 << 8, /* engine supports barriers */ | |
80 | FIO_MEMALIGN = 1 << 9, /* engine wants aligned memory */ | |
ad705bcb | 81 | FIO_BIT_BASED = 1 << 10, /* engine uses a bit base (e.g. uses Kbit as opposed to KB) */ |
5c57c084 | 82 | FIO_FAKEIO = 1 << 11, /* engine pretends to do IO */ |
132b1ee4 | 83 | FIO_NOSTATS = 1 << 12, /* don't do IO stats */ |
cb9bf647 | 84 | FIO_NOFILEHASH = 1 << 13, /* doesn't hash the files for lookup later. */ |
04ba61df | 85 | FIO_ASYNCIO_SYNC_TRIM |
8bfe330e JA |
86 | = 1 << 14, /* io engine has async ->queue except for trim */ |
87 | FIO_NO_OFFLOAD = 1 << 15, /* no async offload */ | |
4e7e7898 VF |
88 | FIO_ASYNCIO_SETS_ISSUE_TIME |
89 | = 1 << 16, /* async ioengine with commit function that sets issue_time */ | |
f2bcd554 AF |
90 | FIO_SKIPPABLE_IOMEM_ALLOC |
91 | = 1 << 17, /* skip iomem_alloc & iomem_free if job sets mem/iomem */ | |
d72b10e3 | 92 | FIO_RO_NEEDS_RW_OPEN |
f0c8ab1c VF |
93 | = 1 << 18, /* open files in rw mode even if we have a read job; only |
94 | affects ioengines using generic_open_file */ | |
2b4f4abe | 95 | }; |
dcefb588 | 96 | |
a8075704 DG |
97 | /* |
98 | * External engine defined symbol to fill in the engine ops structure | |
99 | */ | |
100 | typedef void (*get_ioengine_t)(struct ioengine_ops **); | |
101 | ||
dcefb588 JA |
102 | /* |
103 | * io engine entry points | |
104 | */ | |
105 | extern int __must_check td_io_init(struct thread_data *); | |
106 | extern int __must_check td_io_prep(struct thread_data *, struct io_u *); | |
d3b07186 | 107 | extern enum fio_q_status __must_check td_io_queue(struct thread_data *, struct io_u *); |
1f440ece | 108 | extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, const struct timespec *); |
a80cb54b | 109 | extern void td_io_commit(struct thread_data *); |
dcefb588 JA |
110 | extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *); |
111 | extern int td_io_close_file(struct thread_data *, struct fio_file *); | |
38ef9c90 | 112 | extern int td_io_unlink_file(struct thread_data *, struct fio_file *); |
dcefb588 JA |
113 | extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *); |
114 | ||
4fedf59a | 115 | extern struct ioengine_ops *load_ioengine(struct thread_data *); |
dcefb588 JA |
116 | extern void register_ioengine(struct ioengine_ops *); |
117 | extern void unregister_ioengine(struct ioengine_ops *); | |
de890a1e | 118 | extern void free_ioengine(struct thread_data *); |
dcefb588 JA |
119 | extern void close_ioengine(struct thread_data *); |
120 | ||
de890a1e SL |
121 | extern int fio_show_ioengine_help(const char *engine); |
122 | ||
dcefb588 | 123 | #endif |