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