smalloc: only clear the bitmap, not the whole pool
[fio.git] / verify.h
CommitLineData
4f5af7b2
JA
1#ifndef FIO_VERIFY_H
2#define FIO_VERIFY_H
3
03e20d68
BC
4#include <stdint.h>
5
d3a173a9 6#define FIO_HDR_MAGIC 0xacca
4f5af7b2
JA
7
8enum {
9 VERIFY_NONE = 0, /* no verification */
b638d82f
RP
10 VERIFY_HDR_ONLY, /* verify header only, kept for sake of
11 * compatibility with old configurations
12 * which use 'verify=meta' */
4f5af7b2
JA
13 VERIFY_MD5, /* md5 sum data blocks */
14 VERIFY_CRC64, /* crc64 sum data blocks */
15 VERIFY_CRC32, /* crc32 sum data blocks */
16 VERIFY_CRC32C, /* crc32c sum data blocks */
17 VERIFY_CRC32C_INTEL, /* crc32c sum data blocks with hw */
18 VERIFY_CRC16, /* crc16 sum data blocks */
19 VERIFY_CRC7, /* crc7 sum data blocks */
20 VERIFY_SHA256, /* sha256 sum data blocks */
21 VERIFY_SHA512, /* sha512 sum data blocks */
844ea602 22 VERIFY_XXHASH, /* xxhash sum data blocks */
7c353ceb 23 VERIFY_SHA1, /* sha1 sum data blocks */
92bf48d5 24 VERIFY_PATTERN, /* verify specific patterns */
59245381 25 VERIFY_PATTERN_NO_HDR, /* verify specific patterns, no hdr */
4f5af7b2
JA
26 VERIFY_NULL, /* pretend to verify */
27};
28
29/*
30 * A header structure associated with each checksummed data block. It is
31 * followed by a checksum specific header that contains the verification
32 * data.
33 */
34struct verify_header {
d3a173a9
JA
35 uint16_t magic;
36 uint16_t verify_type;
f65d1c26 37 uint32_t len;
f65d1c26 38 uint64_t rand_seed;
b638d82f
RP
39 uint64_t offset;
40 uint32_t time_sec;
41 uint32_t time_usec;
42 uint16_t thread;
43 uint16_t numberio;
f65d1c26 44 uint32_t crc32;
4f5af7b2
JA
45};
46
47struct vhdr_md5 {
34644af5 48 uint32_t md5_digest[4];
4f5af7b2
JA
49};
50struct vhdr_sha512 {
51 uint8_t sha512[128];
52};
53struct vhdr_sha256 {
bc77f56f 54 uint8_t sha256[64];
4f5af7b2 55};
7c353ceb
JA
56struct vhdr_sha1 {
57 uint32_t sha1[5];
58};
4f5af7b2
JA
59struct vhdr_crc64 {
60 uint64_t crc64;
61};
62struct vhdr_crc32 {
63 uint32_t crc32;
64};
65struct vhdr_crc16 {
66 uint16_t crc16;
67};
68struct vhdr_crc7 {
69 uint8_t crc7;
70};
844ea602
JA
71struct vhdr_xxhash {
72 uint32_t hash;
73};
4f5af7b2
JA
74
75/*
76 * Verify helpers
77 */
78extern void populate_verify_io_u(struct thread_data *, struct io_u *);
79extern int __must_check get_next_verify(struct thread_data *td, struct io_u *);
f8b0bd10
JA
80extern int __must_check verify_io_u(struct thread_data *, struct io_u **);
81extern int verify_io_u_async(struct thread_data *, struct io_u **);
ce35b1ec
JA
82extern void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len, struct io_u *io_u, unsigned long seed, int use_seed);
83extern void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len);
dc5bfbb2 84extern void fio_verify_init(struct thread_data *td);
e8462bd8
JA
85
86/*
87 * Async verify offload
88 */
89extern int verify_async_init(struct thread_data *);
90extern void verify_async_exit(struct thread_data *);
4f5af7b2 91
61b9861d
RP
92/*
93 * Callbacks for pasting formats in the pattern buffer
94 */
95extern int paste_blockoff(char *buf, unsigned int len, void *priv);
96
c3546b53 97struct thread_rand32_state {
ca09be4b
JA
98 uint32_t s[4];
99};
100
c3546b53
JA
101struct thread_rand64_state {
102 uint64_t s[6];
103};
104
105struct thread_rand_state {
106 uint64_t use64;
107 union {
108 struct thread_rand32_state state32;
109 struct thread_rand64_state state64;
110 };
111};
112
ca09be4b
JA
113/*
114 * For dumping current write state
115 */
116struct thread_io_list {
117 uint64_t no_comps;
118 uint64_t depth;
119 uint64_t numberio;
120 uint64_t index;
121 struct thread_rand_state rand;
122 uint8_t name[64];
123 uint64_t offsets[0];
124};
125
c3546b53
JA
126struct thread_io_list_v1 {
127 uint64_t no_comps;
128 uint64_t depth;
129 uint64_t numberio;
130 uint64_t index;
131 struct thread_rand32_state rand;
132 uint8_t name[64];
133 uint64_t offsets[0];
134};
135
ca09be4b
JA
136struct all_io_list {
137 uint64_t threads;
138 struct thread_io_list state[0];
139};
140
c3546b53
JA
141#define VSTATE_HDR_VERSION_V1 0x01
142#define VSTATE_HDR_VERSION 0x02
ca09be4b
JA
143
144struct verify_state_hdr {
145 uint64_t version;
146 uint64_t size;
147 uint64_t crc;
148};
149
150#define IO_LIST_ALL 0xffffffff
151extern struct all_io_list *get_all_io_list(int, size_t *);
152extern void __verify_save_state(struct all_io_list *, const char *);
d264264a 153extern void verify_save_state(int mask);
ca09be4b
JA
154extern int verify_load_state(struct thread_data *, const char *);
155extern void verify_free_state(struct thread_data *);
156extern int verify_state_should_stop(struct thread_data *, struct io_u *);
c3546b53
JA
157extern void verify_convert_assign_state(struct thread_data *, void *, int);
158extern int verify_state_hdr(struct verify_state_hdr *, struct thread_io_list *,
159 int *);
160
161static inline size_t __thread_io_list_sz(uint64_t depth)
162{
163 return sizeof(struct thread_io_list) + depth * sizeof(uint64_t);
164}
ca09be4b
JA
165
166static inline size_t thread_io_list_sz(struct thread_io_list *s)
167{
c3546b53 168 return __thread_io_list_sz(le64_to_cpu(s->depth));
ca09be4b
JA
169}
170
171static inline struct thread_io_list *io_list_next(struct thread_io_list *s)
172{
173 return (void *) s + thread_io_list_sz(s);
174}
175
e499aedc
JA
176static inline void verify_state_gen_name(char *out, size_t size,
177 const char *name, const char *prefix,
178 int num)
ca09be4b 179{
e499aedc
JA
180 snprintf(out, size, "%s-%s-%d-verify.state", prefix, name, num);
181 out[size - 1] = '\0';
ca09be4b
JA
182}
183
4f5af7b2 184#endif