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