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(file=%2llu) %llu\n",
31 (unsigned long long) s->comps[i].fileno,
32 (unsigned long long) s->comps[i].offset);
36 static void show(struct thread_io_list *s, size_t size)
44 s->no_comps = le64_to_cpu(s->no_comps);
45 s->depth = le32_to_cpu(s->depth);
46 s->nofiles = le32_to_cpu(s->nofiles);
47 s->numberio = le64_to_cpu(s->numberio);
48 s->index = le64_to_cpu(s->index);
50 for (i = 0; i < s->no_comps; i++) {
51 s->comps[i].fileno = le64_to_cpu(s->comps[i].fileno);
52 s->comps[i].offset = le64_to_cpu(s->comps[i].offset);
57 size -= __thread_io_list_sz(s->depth, s->nofiles);
58 s = (void *) s + __thread_io_list_sz(s->depth, s->nofiles);
62 static void show_verify_state(void *buf, size_t size)
64 struct verify_state_hdr *hdr = buf;
65 struct thread_io_list *s;
68 hdr->version = le64_to_cpu(hdr->version);
69 hdr->size = le64_to_cpu(hdr->size);
70 hdr->crc = le64_to_cpu(hdr->crc);
72 printf("Version: %x, Size %u, crc %x\n", (unsigned int) hdr->version,
73 (unsigned int) hdr->size,
74 (unsigned int) hdr->crc);
77 if (hdr->size != size) {
78 log_err("Size mismatch\n");
82 s = buf + sizeof(*hdr);
83 crc = fio_crc32c((unsigned char *) s, hdr->size);
84 if (crc != hdr->crc) {
85 log_err("crc mismatch %x != %x\n", crc, (unsigned int) hdr->crc);
89 if (hdr->version == 0x03)
92 log_err("Unsupported version %d\n", (int) hdr->version);
95 int main(int argc, char *argv[])
104 log_err("Usage: %s <state file>\n", argv[0]);
108 fd = open(argv[1], O_RDONLY);
110 log_err("open %s: %s\n", argv[1], strerror(errno));
114 if (fstat(fd, &sb) < 0) {
115 log_err("stat: %s\n", strerror(errno));
120 buf = malloc(sb.st_size);
121 ret = read(fd, buf, sb.st_size);
123 log_err("read: %s\n", strerror(errno));
126 } else if (ret != sb.st_size) {
127 log_err("Short read\n");
133 show_verify_state(buf, sb.st_size);