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