debug: fix inverted logic in fio_did_warn()
[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"
6#include "log.h"
7#include "io_ddir.h"
8#include "debug.h"
9#include "file.h"
10#include "workqueue.h"
11
12#ifdef CONFIG_LIBAIO
13#include <libaio.h>
14#endif
15#ifdef CONFIG_GUASI
16#include <guasi.h>
17#endif
18
19enum {
20 IO_U_F_FREE = 1 << 0,
21 IO_U_F_FLIGHT = 1 << 1,
22 IO_U_F_NO_FILE_PUT = 1 << 2,
23 IO_U_F_IN_CUR_DEPTH = 1 << 3,
24 IO_U_F_BUSY_OK = 1 << 4,
25 IO_U_F_TRIMMED = 1 << 5,
26 IO_U_F_BARRIER = 1 << 6,
27 IO_U_F_VER_LIST = 1 << 7,
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 */
55 unsigned long buflen;
56 unsigned long long offset;
57 void *buf;
58
59 /*
60 * Initial seed for generating the buffer contents
61 */
62 uint64_t rand_seed;
63
64 /*
65 * IO engine state, may be different from above when we get
66 * partial transfers / residual data counts
67 */
68 void *xfer_buf;
69 unsigned long xfer_buflen;
70
71 /*
72 * Parameter related to pre-filled buffers and
73 * their size to handle variable block sizes.
74 */
75 unsigned long buf_filled_len;
76
77 struct io_piece *ipo;
78
79 unsigned int resid;
80 unsigned int error;
81
82 /*
83 * io engine private data
84 */
85 union {
86 unsigned int index;
87 unsigned int seen;
88 void *engine_data;
89 };
90
91 union {
92 struct flist_head verify_list;
93 struct workqueue_work work;
94 };
95
96 /*
97 * Callback for io completion
98 */
99 int (*end_io)(struct thread_data *, struct io_u **);
100
101 union {
102#ifdef CONFIG_LIBAIO
103 struct iocb iocb;
104#endif
105#ifdef CONFIG_POSIXAIO
106 os_aiocb_t aiocb;
107#endif
108#ifdef FIO_HAVE_SGIO
109 struct sg_io_hdr hdr;
110#endif
111#ifdef CONFIG_GUASI
112 guasi_req_t greq;
113#endif
114#ifdef CONFIG_SOLARISAIO
115 aio_result_t resultp;
116#endif
117#ifdef FIO_HAVE_BINJECT
118 struct b_user_cmd buc;
119#endif
120#ifdef CONFIG_RDMA
121 struct ibv_mr *mr;
122#endif
123 void *mmap_data;
124 };
125};
126
127/*
128 * io unit handling
129 */
130extern struct io_u *__get_io_u(struct thread_data *);
131extern struct io_u *get_io_u(struct thread_data *);
132extern void put_io_u(struct thread_data *, struct io_u *);
133extern void clear_io_u(struct thread_data *, struct io_u *);
134extern void requeue_io_u(struct thread_data *, struct io_u **);
135extern int __must_check io_u_sync_complete(struct thread_data *, struct io_u *);
136extern int __must_check io_u_queued_complete(struct thread_data *, int);
137extern void io_u_queued(struct thread_data *, struct io_u *);
138extern int io_u_quiesce(struct thread_data *);
139extern void io_u_log_error(struct thread_data *, struct io_u *);
140extern void io_u_mark_depth(struct thread_data *, unsigned int);
141extern void fill_io_buffer(struct thread_data *, void *, unsigned int, unsigned int);
142extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int, unsigned int);
143void io_u_mark_complete(struct thread_data *, unsigned int);
144void io_u_mark_submit(struct thread_data *, unsigned int);
145bool queue_full(const struct thread_data *);
146
147int do_io_u_sync(const struct thread_data *, struct io_u *);
148int do_io_u_trim(const struct thread_data *, struct io_u *);
149
150#ifdef FIO_INC_DEBUG
151static inline void dprint_io_u(struct io_u *io_u, const char *p)
152{
153 struct fio_file *f = io_u->file;
154
8ef89e0b 155 if (f)
e5f9a813
RE
156 dprint(FD_IO, "%s: io_u %p: off=0x%llx,len=0x%lx,ddir=%d,file=%s\n",
157 p, io_u,
158 (unsigned long long) io_u->offset,
159 io_u->buflen, io_u->ddir,
160 f->file_name);
161 else
162 dprint(FD_IO, "%s: io_u %p: off=0x%llx,len=0x%lx,ddir=%d\n",
163 p, io_u,
164 (unsigned long long) io_u->offset,
165 io_u->buflen, io_u->ddir);
8ef89e0b
TK
166}
167#else
168#define dprint_io_u(io_u, p)
169#endif
170
171static inline enum fio_ddir acct_ddir(struct io_u *io_u)
172{
173 if (io_u->acct_ddir != -1)
174 return io_u->acct_ddir;
175
176 return io_u->ddir;
177}
178
179#define io_u_clear(td, io_u, val) \
180 td_flags_clear((td), &(io_u->flags), (val))
181#define io_u_set(td, io_u, val) \
182 td_flags_set((td), &(io_u)->flags, (val))
183
184#endif