Commit | Line | Data |
---|---|---|
dcefb588 JA |
1 | #ifndef FIO_IOENGINE_H |
2 | #define FIO_IOENGINE_H | |
3 | ||
4 | #define FIO_IOOPS_VERSION 10 | |
5 | ||
6 | enum { | |
7 | IO_U_F_FREE = 1 << 0, | |
8 | IO_U_F_FLIGHT = 1 << 1, | |
9 | }; | |
10 | ||
11 | /* | |
12 | * The io unit | |
13 | */ | |
14 | struct io_u { | |
15 | union { | |
16 | #ifdef FIO_HAVE_LIBAIO | |
17 | struct iocb iocb; | |
18 | #endif | |
19 | #ifdef FIO_HAVE_POSIXAIO | |
20 | struct aiocb aiocb; | |
21 | #endif | |
22 | #ifdef FIO_HAVE_SGIO | |
23 | struct sg_io_hdr hdr; | |
24 | #endif | |
25 | #ifdef FIO_HAVE_GUASI | |
26 | guasi_req_t greq; | |
27 | #endif | |
28 | #ifdef FIO_HAVE_SOLARISAIO | |
29 | aio_result_t resultp; | |
30 | #endif | |
31 | void *mmap_data; | |
32 | }; | |
33 | struct timeval start_time; | |
34 | struct timeval issue_time; | |
35 | ||
36 | /* | |
37 | * Allocated/set buffer and length | |
38 | */ | |
39 | void *buf; | |
40 | unsigned long buflen; | |
41 | unsigned long long offset; | |
42 | ||
43 | /* | |
44 | * IO engine state, may be different from above when we get | |
45 | * partial transfers / residual data counts | |
46 | */ | |
47 | void *xfer_buf; | |
48 | unsigned long xfer_buflen; | |
49 | ||
50 | unsigned int resid; | |
51 | unsigned int error; | |
52 | ||
53 | enum fio_ddir ddir; | |
54 | ||
55 | /* | |
56 | * io engine private data | |
57 | */ | |
58 | union { | |
59 | unsigned int index; | |
60 | unsigned int seen; | |
61 | void *engine_data; | |
62 | }; | |
63 | ||
64 | unsigned int flags; | |
65 | ||
66 | struct fio_file *file; | |
67 | ||
68 | struct flist_head list; | |
69 | ||
70 | /* | |
71 | * Callback for io completion | |
72 | */ | |
73 | int (*end_io)(struct thread_data *, struct io_u *); | |
74 | }; | |
75 | ||
76 | /* | |
77 | * io_ops->queue() return values | |
78 | */ | |
79 | enum { | |
80 | FIO_Q_COMPLETED = 0, /* completed sync */ | |
81 | FIO_Q_QUEUED = 1, /* queued, will complete async */ | |
82 | FIO_Q_BUSY = 2, /* no more room, call ->commit() */ | |
83 | }; | |
84 | ||
85 | struct ioengine_ops { | |
86 | struct flist_head list; | |
87 | char name[16]; | |
88 | int version; | |
89 | int flags; | |
90 | int (*setup)(struct thread_data *); | |
91 | int (*init)(struct thread_data *); | |
92 | int (*prep)(struct thread_data *, struct io_u *); | |
93 | int (*queue)(struct thread_data *, struct io_u *); | |
94 | int (*commit)(struct thread_data *); | |
95 | int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *); | |
96 | struct io_u *(*event)(struct thread_data *, int); | |
97 | int (*cancel)(struct thread_data *, struct io_u *); | |
98 | void (*cleanup)(struct thread_data *); | |
99 | int (*open_file)(struct thread_data *, struct fio_file *); | |
100 | int (*close_file)(struct thread_data *, struct fio_file *); | |
101 | int (*get_file_size)(struct thread_data *, struct fio_file *); | |
102 | void *data; | |
103 | void *dlhandle; | |
104 | }; | |
105 | ||
106 | ||
107 | /* | |
108 | * io engine entry points | |
109 | */ | |
110 | extern int __must_check td_io_init(struct thread_data *); | |
111 | extern int __must_check td_io_prep(struct thread_data *, struct io_u *); | |
112 | extern int __must_check td_io_queue(struct thread_data *, struct io_u *); | |
113 | extern int __must_check td_io_sync(struct thread_data *, struct fio_file *); | |
114 | extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *); | |
115 | extern int __must_check td_io_commit(struct thread_data *); | |
116 | extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *); | |
117 | extern int td_io_close_file(struct thread_data *, struct fio_file *); | |
118 | extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *); | |
119 | ||
120 | extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *); | |
121 | extern void register_ioengine(struct ioengine_ops *); | |
122 | extern void unregister_ioengine(struct ioengine_ops *); | |
123 | extern void close_ioengine(struct thread_data *); | |
124 | ||
125 | /* | |
126 | * io unit handling | |
127 | */ | |
128 | #define queue_full(td) flist_empty(&(td)->io_u_freelist) | |
129 | extern struct io_u *__get_io_u(struct thread_data *); | |
130 | extern struct io_u *get_io_u(struct thread_data *); | |
131 | extern void put_io_u(struct thread_data *, struct io_u *); | |
132 | extern void requeue_io_u(struct thread_data *, struct io_u **); | |
133 | extern long __must_check io_u_sync_complete(struct thread_data *, struct io_u *); | |
134 | extern long __must_check io_u_queued_complete(struct thread_data *, int); | |
135 | extern void io_u_queued(struct thread_data *, struct io_u *); | |
136 | extern void io_u_log_error(struct thread_data *, struct io_u *); | |
137 | extern void io_u_mark_depth(struct thread_data *, unsigned int); | |
138 | extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int); | |
139 | void io_u_mark_complete(struct thread_data *, unsigned int); | |
140 | void io_u_mark_submit(struct thread_data *, unsigned int); | |
141 | ||
142 | #endif |