verify: increase state file name and log error on failure
[fio.git] / verify-state.h
... / ...
CommitLineData
1#ifndef FIO_VERIFY_STATE_H
2#define FIO_VERIFY_STATE_H
3
4#include <stdint.h>
5
6struct thread_rand32_state {
7 uint32_t s[4];
8};
9
10struct thread_rand64_state {
11 uint64_t s[6];
12};
13
14struct 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 */
25struct file_comp {
26 uint64_t fileno;
27 uint64_t offset;
28};
29
30struct thread_io_list {
31 uint64_t no_comps;
32 uint32_t depth;
33 uint32_t nofiles;
34 uint64_t numberio;
35 uint64_t index;
36 struct thread_rand_state rand;
37 uint8_t name[64];
38 struct file_comp comps[0];
39};
40
41struct all_io_list {
42 uint64_t threads;
43 struct thread_io_list state[0];
44};
45
46#define VSTATE_HDR_VERSION 0x03
47
48struct verify_state_hdr {
49 uint64_t version;
50 uint64_t size;
51 uint64_t crc;
52};
53
54#define IO_LIST_ALL 0xffffffff
55
56struct io_u;
57extern struct all_io_list *get_all_io_list(int, size_t *);
58extern void __verify_save_state(struct all_io_list *, const char *);
59extern void verify_save_state(int mask);
60extern int verify_load_state(struct thread_data *, const char *);
61extern void verify_free_state(struct thread_data *);
62extern int verify_state_should_stop(struct thread_data *, struct io_u *);
63extern void verify_assign_state(struct thread_data *, void *);
64extern int verify_state_hdr(struct verify_state_hdr *, struct thread_io_list *);
65
66static inline size_t __thread_io_list_sz(uint32_t depth, uint32_t nofiles)
67{
68 return sizeof(struct thread_io_list) + depth * nofiles * sizeof(struct file_comp);
69}
70
71static inline size_t thread_io_list_sz(struct thread_io_list *s)
72{
73 return __thread_io_list_sz(le32_to_cpu(s->depth), le32_to_cpu(s->nofiles));
74}
75
76static inline struct thread_io_list *io_list_next(struct thread_io_list *s)
77{
78 return (void *) s + thread_io_list_sz(s);
79}
80
81static inline void verify_state_gen_name(char *out, size_t size,
82 const char *name, const char *prefix,
83 int num)
84{
85 snprintf(out, size, "%s-%s-%d-verify.state", prefix, name, num);
86 out[size - 1] = '\0';
87}
88
89#endif