configure: attempt to link against tcmalloc by default if available
[fio.git] / io_u.h
... / ...
CommitLineData
1#ifndef FIO_IO_U
2#define FIO_IO_U
3
4#include "compiler/compiler.h"
5#include "os/os.h"
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,
27};
28
29/*
30 * The io unit
31 */
32struct io_u {
33 struct timespec start_time;
34 struct timespec issue_time;
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 */
54 unsigned long long buflen;
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;
68 unsigned long long xfer_buflen;
69
70 /*
71 * Parameter related to pre-filled buffers and
72 * their size to handle variable block sizes.
73 */
74 unsigned long long buf_filled_len;
75
76 struct io_piece *ipo;
77
78 unsigned long long resid;
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
95#ifdef CONFIG_LINUX_BLKZONED
96 /*
97 * ZBD mode zbd_queue_io callback: called after engine->queue operation
98 * to advance a zone write pointer and eventually unlock the I/O zone.
99 * @q indicates the I/O queue status (busy, queued or completed).
100 * @success == true means that the I/O operation has been queued or
101 * completed successfully.
102 */
103 void (*zbd_queue_io)(struct io_u *, int q, bool success);
104
105 /*
106 * ZBD mode zbd_put_io callback: called in after completion of an I/O
107 * or commit of an async I/O to unlock the I/O target zone.
108 */
109 void (*zbd_put_io)(const struct io_u *);
110#endif
111
112 /*
113 * Callback for io completion
114 */
115 int (*end_io)(struct thread_data *, struct io_u **);
116
117 union {
118#ifdef CONFIG_LIBAIO
119 struct iocb iocb;
120#endif
121#ifdef CONFIG_POSIXAIO
122 os_aiocb_t aiocb;
123#endif
124#ifdef FIO_HAVE_SGIO
125 struct sg_io_hdr hdr;
126#endif
127#ifdef CONFIG_GUASI
128 guasi_req_t greq;
129#endif
130#ifdef CONFIG_SOLARISAIO
131 aio_result_t resultp;
132#endif
133#ifdef CONFIG_RDMA
134 struct ibv_mr *mr;
135#endif
136 void *mmap_data;
137 };
138};
139
140/*
141 * io unit handling
142 */
143extern struct io_u *__get_io_u(struct thread_data *);
144extern struct io_u *get_io_u(struct thread_data *);
145extern void put_io_u(struct thread_data *, struct io_u *);
146extern void clear_io_u(struct thread_data *, struct io_u *);
147extern void requeue_io_u(struct thread_data *, struct io_u **);
148extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *);
149extern int __must_check io_u_queued_complete(struct thread_data *, int);
150extern void io_u_queued(struct thread_data *, struct io_u *);
151extern int io_u_quiesce(struct thread_data *);
152extern void io_u_log_error(struct thread_data *, struct io_u *);
153extern void io_u_mark_depth(struct thread_data *, unsigned int);
154extern void fill_io_buffer(struct thread_data *, void *, unsigned long long, unsigned long long);
155extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned long long, unsigned long long);
156void io_u_mark_complete(struct thread_data *, unsigned int);
157void io_u_mark_submit(struct thread_data *, unsigned int);
158bool queue_full(const struct thread_data *);
159
160int do_io_u_sync(const struct thread_data *, struct io_u *);
161int do_io_u_trim(const struct thread_data *, struct io_u *);
162
163#ifdef FIO_INC_DEBUG
164static inline void dprint_io_u(struct io_u *io_u, const char *p)
165{
166 struct fio_file *f = io_u->file;
167
168 if (f)
169 dprint(FD_IO, "%s: io_u %p: off=0x%llx,len=0x%llx,ddir=%d,file=%s\n",
170 p, io_u,
171 (unsigned long long) io_u->offset,
172 io_u->buflen, io_u->ddir,
173 f->file_name);
174 else
175 dprint(FD_IO, "%s: io_u %p: off=0x%llx,len=0x%llx,ddir=%d\n",
176 p, io_u,
177 (unsigned long long) io_u->offset,
178 io_u->buflen, io_u->ddir);
179}
180#else
181#define dprint_io_u(io_u, p)
182#endif
183
184static 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))
196
197#endif