Fix verify
[fio.git] / verify.c
index 8bf14ae05fb08ecb4b960051c8444635219d933c..0a504deb15f2e22ca6ce20a526296cd97102fcb4 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -337,7 +337,7 @@ static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
                if (size > (len - i))
                        size = len - i;
                if (memcmp(buf + i, pattern + mod, size))
-                       // Let the slow compare find the first mismatch byte.
+                       /* Let the slow compare find the first mismatch byte. */
                        break;
                mod = 0;
        }
@@ -551,10 +551,7 @@ static int verify_io_u_crc32c(struct verify_header *hdr, struct vcont *vc)
 
        dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
 
-       if (hdr->verify_type == VERIFY_CRC32C_INTEL)
-               c = crc32c_intel(p, hdr->len - hdr_size(hdr));
-       else
-               c = crc32c(p, hdr->len - hdr_size(hdr));
+       c = crc32c(p, hdr->len - hdr_size(hdr));
 
        if (c == vh->crc32)
                return 0;
@@ -649,12 +646,15 @@ static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
        return ret;
 }
 
-static int verify_hdr_crc(struct verify_header *hdr)
+static int verify_header(struct verify_header *hdr)
 {
        void *p = hdr;
        uint32_t crc;
 
-       crc = crc32(p, sizeof(*hdr) - sizeof(hdr->crc32));
+       if (hdr->magic != FIO_HDR_MAGIC)
+               return 0;
+
+       crc = crc32c(p, offsetof(struct verify_header, crc32));
        if (crc == hdr->crc32)
                return 1;
 
@@ -695,18 +695,10 @@ int verify_io_u(struct thread_data *td, struct io_u *io_u)
                        memswp(p, p + td->o.verify_offset, header_size);
                hdr = p;
 
-               if (hdr->fio_magic == FIO_HDR_MAGIC2) {
-                       if (!verify_hdr_crc(hdr)) {
-                               log_err("fio: bad crc on verify header.\n");
-                               return EILSEQ;
-                       }
-               } else if (hdr->fio_magic == FIO_HDR_MAGIC) {
-                       log_err("fio: v1 headers no longer supported.\n");
-                       log_err("fio: re-run the write workload.\n");
-                       return EILSEQ;
-               } else {
-                       log_err("verify: bad magic header %x, wanted %x at file %s offset %llu, length %u\n",
-                               hdr->fio_magic, FIO_HDR_MAGIC2,
+               if (!verify_header(hdr)) {
+                       log_err("verify: bad magic header %x, wanted %x at "
+                               "file %s offset %llu, length %u\n",
+                               hdr->magic, FIO_HDR_MAGIC,
                                io_u->file->file_name,
                                io_u->offset + hdr_num * hdr->len, hdr->len);
                        return EILSEQ;
@@ -833,10 +825,7 @@ static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len)
 {
        struct vhdr_crc32 *vh = hdr_priv(hdr);
 
-       if (hdr->verify_type == VERIFY_CRC32C_INTEL)
-               vh->crc32 = crc32c_intel(p, len);
-       else
-               vh->crc32 = crc32c(p, len);
+       vh->crc32 = crc32c(p, len);
 }
 
 static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len)
@@ -866,13 +855,11 @@ static void populate_hdr(struct thread_data *td, struct io_u *io_u,
 
        p = (void *) hdr;
 
-       hdr->fio_magic = FIO_HDR_MAGIC2;
-       hdr->len = header_len;
+       hdr->magic = FIO_HDR_MAGIC;
        hdr->verify_type = td->o.verify;
-       hdr->pad1 = 0;
+       hdr->len = header_len;
        hdr->rand_seed = io_u->rand_seed;
-       hdr->pad2 = 0;
-       hdr->crc32 = crc32(p, sizeof(*hdr) - sizeof(hdr->crc32));
+       hdr->crc32 = crc32c(p, offsetof(struct verify_header, crc32));
 
        data_len = header_len - hdr_size(hdr);