Commit | Line | Data |
---|---|---|
9e9d41d7 JA |
1 | #ifndef FIO_VERIFY_STATE_H |
2 | #define FIO_VERIFY_STATE_H | |
3 | ||
4 | #include <stdint.h> | |
5 | ||
6 | struct thread_rand32_state { | |
7 | uint32_t s[4]; | |
8 | }; | |
9 | ||
10 | struct thread_rand64_state { | |
11 | uint64_t s[6]; | |
12 | }; | |
13 | ||
14 | struct thread_rand_state { | |
15 | uint64_t use64; | |
16 | union { | |
17 | struct thread_rand32_state state32; | |
18 | struct thread_rand64_state state64; | |
19 | }; | |
20 | }; | |
21 | ||
22 | /* | |
23 | * For dumping current write state | |
24 | */ | |
25 | struct thread_io_list { | |
26 | uint64_t no_comps; | |
27 | uint64_t depth; | |
28 | uint64_t numberio; | |
29 | uint64_t index; | |
30 | struct thread_rand_state rand; | |
31 | uint8_t name[64]; | |
32 | uint64_t offsets[0]; | |
33 | }; | |
34 | ||
35 | struct thread_io_list_v1 { | |
36 | uint64_t no_comps; | |
37 | uint64_t depth; | |
38 | uint64_t numberio; | |
39 | uint64_t index; | |
40 | struct thread_rand32_state rand; | |
41 | uint8_t name[64]; | |
42 | uint64_t offsets[0]; | |
43 | }; | |
44 | ||
45 | struct all_io_list { | |
46 | uint64_t threads; | |
47 | struct thread_io_list state[0]; | |
48 | }; | |
49 | ||
50 | #define VSTATE_HDR_VERSION_V1 0x01 | |
51 | #define VSTATE_HDR_VERSION 0x02 | |
52 | ||
53 | struct verify_state_hdr { | |
54 | uint64_t version; | |
55 | uint64_t size; | |
56 | uint64_t crc; | |
57 | }; | |
58 | ||
59 | #define IO_LIST_ALL 0xffffffff | |
60 | ||
17d4fb1d | 61 | struct io_u; |
9e9d41d7 JA |
62 | extern struct all_io_list *get_all_io_list(int, size_t *); |
63 | extern void __verify_save_state(struct all_io_list *, const char *); | |
64 | extern void verify_save_state(int mask); | |
65 | extern int verify_load_state(struct thread_data *, const char *); | |
66 | extern void verify_free_state(struct thread_data *); | |
67 | extern int verify_state_should_stop(struct thread_data *, struct io_u *); | |
68 | extern void verify_convert_assign_state(struct thread_data *, void *, int); | |
69 | extern int verify_state_hdr(struct verify_state_hdr *, struct thread_io_list *, | |
70 | int *); | |
71 | ||
72 | static inline size_t __thread_io_list_sz(uint64_t depth) | |
73 | { | |
74 | return sizeof(struct thread_io_list) + depth * sizeof(uint64_t); | |
75 | } | |
76 | ||
77 | static inline size_t thread_io_list_sz(struct thread_io_list *s) | |
78 | { | |
79 | return __thread_io_list_sz(le64_to_cpu(s->depth)); | |
80 | } | |
81 | ||
82 | static inline struct thread_io_list *io_list_next(struct thread_io_list *s) | |
83 | { | |
84 | return (void *) s + thread_io_list_sz(s); | |
85 | } | |
86 | ||
87 | static inline void verify_state_gen_name(char *out, size_t size, | |
88 | const char *name, const char *prefix, | |
89 | int num) | |
90 | { | |
91 | snprintf(out, size, "%s-%s-%d-verify.state", prefix, name, num); | |
92 | out[size - 1] = '\0'; | |
93 | } | |
94 | ||
95 | #endif |