lib/ffz: remove dead store
[fio.git] / verify-state.h
CommitLineData
9e9d41d7
JA
1#ifndef FIO_VERIFY_STATE_H
2#define FIO_VERIFY_STATE_H
3
4#include <stdint.h>
e139c0c0 5#include <string.h>
a86f6d07 6#include <limits.h>
9e9d41d7
JA
7
8struct thread_rand32_state {
9 uint32_t s[4];
10};
11
12struct thread_rand64_state {
13 uint64_t s[6];
14};
15
16struct thread_rand_state {
17 uint64_t use64;
18 union {
19 struct thread_rand32_state state32;
20 struct thread_rand64_state state64;
21 };
22};
23
24/*
25 * For dumping current write state
26 */
94a6e1bb
JA
27struct file_comp {
28 uint64_t fileno;
29 uint64_t offset;
9e9d41d7
JA
30};
31
94a6e1bb 32struct thread_io_list {
9e9d41d7 33 uint64_t no_comps;
94a6e1bb
JA
34 uint32_t depth;
35 uint32_t nofiles;
9e9d41d7
JA
36 uint64_t numberio;
37 uint64_t index;
94a6e1bb 38 struct thread_rand_state rand;
9e9d41d7 39 uint8_t name[64];
94a6e1bb 40 struct file_comp comps[0];
9e9d41d7
JA
41};
42
43struct all_io_list {
44 uint64_t threads;
45 struct thread_io_list state[0];
46};
47
94a6e1bb 48#define VSTATE_HDR_VERSION 0x03
9e9d41d7
JA
49
50struct verify_state_hdr {
51 uint64_t version;
52 uint64_t size;
53 uint64_t crc;
54};
55
56#define IO_LIST_ALL 0xffffffff
57
17d4fb1d 58struct io_u;
9e9d41d7
JA
59extern struct all_io_list *get_all_io_list(int, size_t *);
60extern void __verify_save_state(struct all_io_list *, const char *);
61extern void verify_save_state(int mask);
62extern int verify_load_state(struct thread_data *, const char *);
63extern void verify_free_state(struct thread_data *);
64extern int verify_state_should_stop(struct thread_data *, struct io_u *);
94a6e1bb
JA
65extern void verify_assign_state(struct thread_data *, void *);
66extern int verify_state_hdr(struct verify_state_hdr *, struct thread_io_list *);
9e9d41d7 67
94a6e1bb 68static inline size_t __thread_io_list_sz(uint32_t depth, uint32_t nofiles)
9e9d41d7 69{
94a6e1bb 70 return sizeof(struct thread_io_list) + depth * nofiles * sizeof(struct file_comp);
9e9d41d7
JA
71}
72
73static inline size_t thread_io_list_sz(struct thread_io_list *s)
74{
94a6e1bb 75 return __thread_io_list_sz(le32_to_cpu(s->depth), le32_to_cpu(s->nofiles));
9e9d41d7
JA
76}
77
78static inline struct thread_io_list *io_list_next(struct thread_io_list *s)
79{
d637b8b8 80 return (struct thread_io_list *)((char *) s + thread_io_list_sz(s));
9e9d41d7
JA
81}
82
83static inline void verify_state_gen_name(char *out, size_t size,
84 const char *name, const char *prefix,
85 int num)
86{
f5d1c719 87 char ename[PATH_MAX];
e139c0c0
JA
88 char *ptr;
89
e139c0c0
JA
90 /*
91 * Escape '/', just turn them into '.'
92 */
f5d1c719 93 ptr = ename;
5c8f0ba5
JA
94 do {
95 *ptr = *name;
e139c0c0
JA
96 if (*ptr == '\0')
97 break;
5c8f0ba5
JA
98 else if (*ptr == '/')
99 *ptr = '.';
100 ptr++;
101 name++;
102 } while (1);
f5d1c719
JA
103
104 snprintf(out, size, "%s-%s-%d-verify.state", prefix, ename, num);
105 out[size - 1] = '\0';
9e9d41d7
JA
106}
107
108#endif