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