6 #include "compiler/compiler.h"
10 #include "dataplacement.h"
12 #define FIO_IOOPS_VERSION 37
14 #ifndef CONFIG_DYNAMIC_ENGINES
15 #define FIO_STATIC static
21 * io_ops->queue() return values
24 FIO_Q_COMPLETED = 0, /* completed sync */
25 FIO_Q_QUEUED = 1, /* queued, will complete async */
26 FIO_Q_BUSY = 2, /* no more room, call ->commit() */
30 struct flist_head list;
35 int (*setup)(struct thread_data *);
36 int (*init)(struct thread_data *);
37 int (*post_init)(struct thread_data *);
38 int (*prep)(struct thread_data *, struct io_u *);
39 enum fio_q_status (*queue)(struct thread_data *, struct io_u *);
40 int (*commit)(struct thread_data *);
41 int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *);
42 struct io_u *(*event)(struct thread_data *, int);
43 char *(*errdetails)(struct thread_data *, struct io_u *);
44 int (*cancel)(struct thread_data *, struct io_u *);
45 void (*cleanup)(struct thread_data *);
46 int (*open_file)(struct thread_data *, struct fio_file *);
47 int (*close_file)(struct thread_data *, struct fio_file *);
48 int (*invalidate)(struct thread_data *, struct fio_file *);
49 int (*unlink_file)(struct thread_data *, struct fio_file *);
50 int (*get_file_size)(struct thread_data *, struct fio_file *);
51 int (*prepopulate_file)(struct thread_data *, struct fio_file *);
52 void (*terminate)(struct thread_data *);
53 int (*iomem_alloc)(struct thread_data *, size_t);
54 void (*iomem_free)(struct thread_data *);
55 int (*io_u_init)(struct thread_data *, struct io_u *);
56 void (*io_u_free)(struct thread_data *, struct io_u *);
57 int (*get_zoned_model)(struct thread_data *td,
58 struct fio_file *f, enum zbd_zoned_model *);
59 int (*report_zones)(struct thread_data *, struct fio_file *,
60 uint64_t, struct zbd_zone *, unsigned int);
61 int (*reset_wp)(struct thread_data *, struct fio_file *,
63 int (*move_zone_wp)(struct thread_data *, struct fio_file *,
64 struct zbd_zone *, uint64_t, const char *);
65 int (*get_max_open_zones)(struct thread_data *, struct fio_file *,
67 int (*get_max_active_zones)(struct thread_data *, struct fio_file *,
69 int (*finish_zone)(struct thread_data *, struct fio_file *,
71 int (*fdp_fetch_ruhs)(struct thread_data *, struct fio_file *,
72 struct fio_ruhs_info *);
73 int option_struct_size;
74 struct fio_option *options;
78 __FIO_SYNCIO = 0, /* io engine has synchronous ->queue */
79 __FIO_RAWIO, /* some sort of direct/raw io */
80 __FIO_DISKLESSIO, /* no disk involved */
81 __FIO_NOEXTEND, /* engine can't extend file */
82 __FIO_NODISKUTIL, /* diskutil can't handle filename */
83 __FIO_UNIDIR, /* engine is uni-directional */
84 __FIO_NOIO, /* thread does only pseudo IO */
85 __FIO_PIPEIO, /* input/output no seekable */
86 __FIO_BARRIER, /* engine supports barriers */
87 __FIO_MEMALIGN, /* engine wants aligned memory */
88 __FIO_BIT_BASED, /* engine uses a bit base (e.g. uses Kbit as opposed to
90 __FIO_FAKEIO, /* engine pretends to do IO */
91 __FIO_NOSTATS, /* don't do IO stats */
92 __FIO_NOFILEHASH, /* doesn't hash the files for lookup later. */
93 __FIO_ASYNCIO_SYNC_TRIM, /* io engine has async ->queue except for trim */
94 __FIO_NO_OFFLOAD, /* no async offload */
95 __FIO_ASYNCIO_SETS_ISSUE_TIME, /* async ioengine with commit function that sets
97 __FIO_SKIPPABLE_IOMEM_ALLOC, /* skip iomem_alloc & iomem_free if job sets mem/iomem */
98 __FIO_RO_NEEDS_RW_OPEN, /* open files in rw mode even if we have a read job; only
99 affects ioengines using generic_open_file */
100 __FIO_MULTI_RANGE_TRIM, /* ioengine supports trim with more than one range */
101 __FIO_ATOMICWRITES, /* ioengine supports atomic writes */
102 __FIO_IOENGINE_F_LAST, /* not a real bit; used to count number of bits */
105 enum fio_ioengine_flags {
106 FIO_SYNCIO = 1 << __FIO_SYNCIO,
107 FIO_RAWIO = 1 << __FIO_RAWIO,
108 FIO_DISKLESSIO = 1 << __FIO_DISKLESSIO,
109 FIO_NOEXTEND = 1 << __FIO_NOEXTEND,
110 FIO_NODISKUTIL = 1 << __FIO_NODISKUTIL,
111 FIO_UNIDIR = 1 << __FIO_UNIDIR,
112 FIO_NOIO = 1 << __FIO_NOIO,
113 FIO_PIPEIO = 1 << __FIO_PIPEIO,
114 FIO_BARRIER = 1 << __FIO_BARRIER,
115 FIO_MEMALIGN = 1 << __FIO_MEMALIGN,
116 FIO_BIT_BASED = 1 << __FIO_BIT_BASED,
117 FIO_FAKEIO = 1 << __FIO_FAKEIO,
118 FIO_NOSTATS = 1 << __FIO_NOSTATS,
119 FIO_NOFILEHASH = 1 << __FIO_NOFILEHASH,
120 FIO_ASYNCIO_SYNC_TRIM = 1 << __FIO_ASYNCIO_SYNC_TRIM,
121 FIO_NO_OFFLOAD = 1 << __FIO_NO_OFFLOAD,
122 FIO_ASYNCIO_SETS_ISSUE_TIME = 1 << __FIO_ASYNCIO_SETS_ISSUE_TIME,
123 FIO_SKIPPABLE_IOMEM_ALLOC = 1 << __FIO_SKIPPABLE_IOMEM_ALLOC,
124 FIO_RO_NEEDS_RW_OPEN = 1 << __FIO_RO_NEEDS_RW_OPEN,
125 FIO_MULTI_RANGE_TRIM = 1 << __FIO_MULTI_RANGE_TRIM,
126 FIO_ATOMICWRITES = 1 << __FIO_ATOMICWRITES,
130 * External engine defined symbol to fill in the engine ops structure
132 typedef void (*get_ioengine_t)(struct ioengine_ops **);
135 * io engine entry points
137 extern int __must_check td_io_init(struct thread_data *);
138 extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
139 extern enum fio_q_status __must_check td_io_queue(struct thread_data *, struct io_u *);
140 extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, const struct timespec *);
141 extern void td_io_commit(struct thread_data *);
142 extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
143 extern int td_io_close_file(struct thread_data *, struct fio_file *);
144 extern int td_io_unlink_file(struct thread_data *, struct fio_file *);
145 extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
147 extern struct ioengine_ops *load_ioengine(struct thread_data *);
148 extern void register_ioengine(struct ioengine_ops *);
149 extern void unregister_ioengine(struct ioengine_ops *);
150 extern void free_ioengine(struct thread_data *);
151 extern void close_ioengine(struct thread_data *);
153 extern int fio_show_ioengine_help(const char *engine);