2 * Dump the contents of a verify state file in plain text
14 #include "../verify-state.h"
15 #include "../crc/crc32c.h"
18 static void show_s(struct thread_io_list *s, unsigned int no_s)
22 printf("Thread %u, %s\n", no_s, s->name);
23 printf("Completions: %llu\n", (unsigned long long) s->no_comps);
24 printf("Depth: %llu\n", (unsigned long long) s->depth);
25 printf("Number IOs: %llu\n", (unsigned long long) s->numberio);
26 printf("Index: %llu\n", (unsigned long long) s->index);
28 printf("Completions:\n");
29 for (i = 0; i < s->no_comps; i++)
30 printf("\t%llu\n", (unsigned long long) s->offsets[i]);
33 static void show_verify_state(void *buf, size_t size)
35 struct verify_state_hdr *hdr = buf;
36 struct thread_io_list *s;
40 hdr->version = le64_to_cpu(hdr->version);
41 hdr->size = le64_to_cpu(hdr->size);
42 hdr->crc = le64_to_cpu(hdr->crc);
44 printf("Version: %x, Size %u, crc %x\n", (unsigned int) hdr->version,
45 (unsigned int) hdr->size,
46 (unsigned int) hdr->crc);
49 if (hdr->size != size) {
50 log_err("Size mismatch\n");
54 s = buf + sizeof(*hdr);
55 crc = fio_crc32c((unsigned char *) s, hdr->size);
56 if (crc != hdr->crc) {
57 log_err("crc mismatch %x != %x\n", crc, (unsigned int) hdr->crc);
61 if (hdr->version != 0x02) {
62 log_err("Can only handle version 2 headers\n");
70 s->no_comps = le64_to_cpu(s->no_comps);
71 s->depth = le64_to_cpu(s->depth);
72 s->numberio = le64_to_cpu(s->numberio);
73 s->index = le64_to_cpu(s->index);
75 for (i = 0; i < s->no_comps; i++)
76 s->offsets[i] = le64_to_cpu(s->offsets[i]);
80 size -= __thread_io_list_sz(s->depth);
81 s = (void *) s + __thread_io_list_sz(s->depth);
85 int main(int argc, char *argv[])
94 log_err("Usage: %s <state file>\n", argv[0]);
98 fd = open(argv[1], O_RDONLY);
100 log_err("open %s: %s\n", argv[1], strerror(errno));
104 if (fstat(fd, &sb) < 0) {
105 log_err("stat: %s\n", strerror(errno));
110 buf = malloc(sb.st_size);
111 ret = read(fd, buf, sb.st_size);
113 log_err("read: %s\n", strerror(errno));
116 } else if (ret != sb.st_size) {
117 log_err("Short read\n");
123 show_verify_state(buf, sb.st_size);