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