Commit | Line | Data |
---|---|---|
8ef89e0b TK |
1 | #ifndef FIO_IO_U |
2 | #define FIO_IO_U | |
3 | ||
4 | #include "compiler/compiler.h" | |
5 | #include "os/os.h" | |
8ef89e0b TK |
6 | #include "io_ddir.h" |
7 | #include "debug.h" | |
8 | #include "file.h" | |
9 | #include "workqueue.h" | |
10 | ||
11 | #ifdef CONFIG_LIBAIO | |
12 | #include <libaio.h> | |
13 | #endif | |
8ef89e0b TK |
14 | |
15 | enum { | |
16 | IO_U_F_FREE = 1 << 0, | |
17 | IO_U_F_FLIGHT = 1 << 1, | |
18 | IO_U_F_NO_FILE_PUT = 1 << 2, | |
19 | IO_U_F_IN_CUR_DEPTH = 1 << 3, | |
20 | IO_U_F_BUSY_OK = 1 << 4, | |
21 | IO_U_F_TRIMMED = 1 << 5, | |
22 | IO_U_F_BARRIER = 1 << 6, | |
23 | IO_U_F_VER_LIST = 1 << 7, | |
03ec570f | 24 | IO_U_F_HIGH_PRIO = 1 << 8, |
8ef89e0b TK |
25 | }; |
26 | ||
27 | /* | |
28 | * The io unit | |
29 | */ | |
30 | struct io_u { | |
8b6a404c VF |
31 | struct timespec start_time; |
32 | struct timespec issue_time; | |
8ef89e0b TK |
33 | |
34 | struct fio_file *file; | |
35 | unsigned int flags; | |
36 | enum fio_ddir ddir; | |
37 | ||
38 | /* | |
39 | * For replay workloads, we may want to account as a different | |
40 | * IO type than what is being submitted. | |
41 | */ | |
42 | enum fio_ddir acct_ddir; | |
43 | ||
44 | /* | |
45 | * Write generation | |
46 | */ | |
47 | unsigned short numberio; | |
48 | ||
03ec570f DLM |
49 | /* |
50 | * IO priority. | |
51 | */ | |
52 | unsigned short ioprio; | |
53 | ||
8ef89e0b TK |
54 | /* |
55 | * Allocated/set buffer and length | |
56 | */ | |
5fff9543 | 57 | unsigned long long buflen; |
4fff54cc JA |
58 | unsigned long long offset; /* is really ->xfer_offset... */ |
59 | unsigned long long verify_offset; /* is really ->offset */ | |
8ef89e0b TK |
60 | void *buf; |
61 | ||
62 | /* | |
63 | * Initial seed for generating the buffer contents | |
64 | */ | |
65 | uint64_t rand_seed; | |
66 | ||
67 | /* | |
68 | * IO engine state, may be different from above when we get | |
69 | * partial transfers / residual data counts | |
70 | */ | |
71 | void *xfer_buf; | |
5fff9543 | 72 | unsigned long long xfer_buflen; |
8ef89e0b TK |
73 | |
74 | /* | |
75 | * Parameter related to pre-filled buffers and | |
76 | * their size to handle variable block sizes. | |
77 | */ | |
5fff9543 | 78 | unsigned long long buf_filled_len; |
8ef89e0b TK |
79 | |
80 | struct io_piece *ipo; | |
81 | ||
daa89913 | 82 | unsigned long long resid; |
8ef89e0b TK |
83 | unsigned int error; |
84 | ||
85 | /* | |
86 | * io engine private data | |
87 | */ | |
88 | union { | |
89 | unsigned int index; | |
90 | unsigned int seen; | |
91 | void *engine_data; | |
92 | }; | |
93 | ||
94 | union { | |
95 | struct flist_head verify_list; | |
96 | struct workqueue_work work; | |
97 | }; | |
98 | ||
99952ca7 | 99 | /* |
d9ed3e63 DLM |
100 | * ZBD mode zbd_queue_io callback: called after engine->queue operation |
101 | * to advance a zone write pointer and eventually unlock the I/O zone. | |
102 | * @q indicates the I/O queue status (busy, queued or completed). | |
103 | * @success == true means that the I/O operation has been queued or | |
104 | * completed successfully. | |
99952ca7 | 105 | */ |
b2da58c4 SK |
106 | void (*zbd_queue_io)(struct thread_data *td, struct io_u *, int q, |
107 | bool success); | |
d9ed3e63 DLM |
108 | |
109 | /* | |
110 | * ZBD mode zbd_put_io callback: called in after completion of an I/O | |
111 | * or commit of an async I/O to unlock the I/O target zone. | |
112 | */ | |
b2da58c4 | 113 | void (*zbd_put_io)(struct thread_data *td, const struct io_u *); |
99952ca7 | 114 | |
8ef89e0b TK |
115 | /* |
116 | * Callback for io completion | |
117 | */ | |
118 | int (*end_io)(struct thread_data *, struct io_u **); | |
119 | ||
120 | union { | |
121 | #ifdef CONFIG_LIBAIO | |
122 | struct iocb iocb; | |
123 | #endif | |
124 | #ifdef CONFIG_POSIXAIO | |
125 | os_aiocb_t aiocb; | |
126 | #endif | |
127 | #ifdef FIO_HAVE_SGIO | |
128 | struct sg_io_hdr hdr; | |
129 | #endif | |
8ef89e0b TK |
130 | #ifdef CONFIG_SOLARISAIO |
131 | aio_result_t resultp; | |
132 | #endif | |
8ef89e0b TK |
133 | #ifdef CONFIG_RDMA |
134 | struct ibv_mr *mr; | |
135 | #endif | |
136 | void *mmap_data; | |
137 | }; | |
138 | }; | |
139 | ||
140 | /* | |
141 | * io unit handling | |
142 | */ | |
143 | extern struct io_u *__get_io_u(struct thread_data *); | |
144 | extern struct io_u *get_io_u(struct thread_data *); | |
145 | extern void put_io_u(struct thread_data *, struct io_u *); | |
146 | extern void clear_io_u(struct thread_data *, struct io_u *); | |
147 | extern void requeue_io_u(struct thread_data *, struct io_u **); | |
148 | extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *); | |
149 | extern int __must_check io_u_queued_complete(struct thread_data *, int); | |
150 | extern void io_u_queued(struct thread_data *, struct io_u *); | |
151 | extern int io_u_quiesce(struct thread_data *); | |
152 | extern void io_u_log_error(struct thread_data *, struct io_u *); | |
153 | extern void io_u_mark_depth(struct thread_data *, unsigned int); | |
5fff9543 JF |
154 | extern void fill_io_buffer(struct thread_data *, void *, unsigned long long, unsigned long long); |
155 | extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned long long, unsigned long long); | |
8ef89e0b TK |
156 | void io_u_mark_complete(struct thread_data *, unsigned int); |
157 | void io_u_mark_submit(struct thread_data *, unsigned int); | |
158 | bool queue_full(const struct thread_data *); | |
159 | ||
160 | int do_io_u_sync(const struct thread_data *, struct io_u *); | |
161 | int do_io_u_trim(const struct thread_data *, struct io_u *); | |
162 | ||
163 | #ifdef FIO_INC_DEBUG | |
164 | static inline void dprint_io_u(struct io_u *io_u, const char *p) | |
165 | { | |
166 | struct fio_file *f = io_u->file; | |
167 | ||
8ef89e0b | 168 | if (f) |
5fff9543 | 169 | dprint(FD_IO, "%s: io_u %p: off=0x%llx,len=0x%llx,ddir=%d,file=%s\n", |
e5f9a813 RE |
170 | p, io_u, |
171 | (unsigned long long) io_u->offset, | |
172 | io_u->buflen, io_u->ddir, | |
173 | f->file_name); | |
174 | else | |
5fff9543 | 175 | dprint(FD_IO, "%s: io_u %p: off=0x%llx,len=0x%llx,ddir=%d\n", |
e5f9a813 RE |
176 | p, io_u, |
177 | (unsigned long long) io_u->offset, | |
178 | io_u->buflen, io_u->ddir); | |
8ef89e0b TK |
179 | } |
180 | #else | |
181 | #define dprint_io_u(io_u, p) | |
182 | #endif | |
183 | ||
184 | static inline enum fio_ddir acct_ddir(struct io_u *io_u) | |
185 | { | |
186 | if (io_u->acct_ddir != -1) | |
187 | return io_u->acct_ddir; | |
188 | ||
189 | return io_u->ddir; | |
190 | } | |
191 | ||
192 | #define io_u_clear(td, io_u, val) \ | |
193 | td_flags_clear((td), &(io_u->flags), (val)) | |
194 | #define io_u_set(td, io_u, val) \ | |
195 | td_flags_set((td), &(io_u)->flags, (val)) | |
03ec570f | 196 | #define io_u_is_high_prio(io_u) (io_u->flags & IO_U_F_HIGH_PRIO) |
8ef89e0b TK |
197 | |
198 | #endif |