unsigned int header_len);
static void fill_hdr(struct verify_header *hdr, int verify_type, uint32_t len,
uint64_t rand_seed);
+static void __fill_hdr(struct verify_header *hdr, int verify_type, uint32_t len,
+ uint64_t rand_seed);
void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len)
{
switch (verify_type) {
case VERIFY_NONE:
case VERIFY_NULL:
+ case VERIFY_PATTERN:
len = 0;
break;
case VERIFY_MD5:
case VERIFY_SHA1:
len = sizeof(struct vhdr_sha1);
break;
- case VERIFY_PATTERN:
case VERIFY_PATTERN_NO_HDR:
- len = 0;
- break;
+ return 0;
default:
log_err("fio: unknown verify header!\n");
assert(0);
return len + sizeof(struct verify_header);
}
-static inline unsigned int hdr_size(struct verify_header *hdr)
+static inline unsigned int hdr_size(struct thread_data *td,
+ struct verify_header *hdr)
{
+ if (td->o.verify == VERIFY_PATTERN_NO_HDR)
+ return 0;
+
return __hdr_size(hdr->verify_type);
}
struct verify_header shdr;
if (td->o.verify == VERIFY_PATTERN_NO_HDR) {
- fill_hdr(&shdr, td->o.verify, vc->io_u->buflen, 0);
+ __fill_hdr(&shdr, td->o.verify, vc->io_u->buflen, 0);
hdr = &shdr;
}
*/
static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc)
{
- return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(hdr);
+ return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(vc->td, hdr);
}
static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
dprint(FD_VERIFY, "xxhash verify io_u %p, len %u\n", vc->io_u, hdr->len);
state = XXH32_init(1);
- XXH32_update(state, p, hdr->len - hdr_size(hdr));
+ XXH32_update(state, p, hdr->len - hdr_size(vc->td, hdr));
hash = XXH32_digest(state);
if (vh->hash == hash)
dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len);
fio_sha512_init(&sha512_ctx);
- fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(vc->td, hdr));
if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512)))
return 0;
dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len);
fio_sha256_init(&sha256_ctx);
- fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(vc->td, hdr));
fio_sha256_final(&sha256_ctx);
if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256)))
dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len);
fio_sha1_init(&sha1_ctx);
- fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(vc->td, hdr));
fio_sha1_final(&sha1_ctx);
if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1)))
dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = fio_crc7(p, hdr->len - hdr_size(hdr));
+ c = fio_crc7(p, hdr->len - hdr_size(vc->td, hdr));
if (c == vh->crc7)
return 0;
dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = fio_crc16(p, hdr->len - hdr_size(hdr));
+ c = fio_crc16(p, hdr->len - hdr_size(vc->td, hdr));
if (c == vh->crc16)
return 0;
dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = fio_crc64(p, hdr->len - hdr_size(hdr));
+ c = fio_crc64(p, hdr->len - hdr_size(vc->td, hdr));
if (c == vh->crc64)
return 0;
dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = fio_crc32(p, hdr->len - hdr_size(hdr));
+ c = fio_crc32(p, hdr->len - hdr_size(vc->td, hdr));
if (c == vh->crc32)
return 0;
dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = fio_crc32c(p, hdr->len - hdr_size(hdr));
+ c = fio_crc32c(p, hdr->len - hdr_size(vc->td, hdr));
if (c == vh->crc32)
return 0;
dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len);
fio_md5_init(&md5_ctx);
- fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr));
+ fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(vc->td, hdr));
fio_md5_final(&md5_ctx);
if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash)))
fio_md5_final(&md5_ctx);
}
-static void fill_hdr(struct verify_header *hdr, int verify_type, uint32_t len,
- uint64_t rand_seed)
+static void __fill_hdr(struct verify_header *hdr, int verify_type,
+ uint32_t len, uint64_t rand_seed)
{
void *p = hdr;
hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32));
}
+
+static void fill_hdr(struct verify_header *hdr, int verify_type, uint32_t len,
+ uint64_t rand_seed)
+{
+ if (verify_type != VERIFY_PATTERN_NO_HDR)
+ __fill_hdr(hdr, verify_type, len, rand_seed);
+}
+
static void populate_hdr(struct thread_data *td, struct io_u *io_u,
struct verify_header *hdr, unsigned int header_num,
unsigned int header_len)
unsigned int data_len;
void *data, *p;
- if (td->o.verify == VERIFY_PATTERN_NO_HDR)
- return;
-
p = (void *) hdr;
fill_hdr(hdr, td->o.verify, header_len, io_u->rand_seed);
- data_len = header_len - hdr_size(hdr);
+ data_len = header_len - hdr_size(td, hdr);
- data = p + hdr_size(hdr);
+ data = p + hdr_size(td, hdr);
switch (td->o.verify) {
case VERIFY_MD5:
dprint(FD_VERIFY, "fill md5 io_u %p, len %u\n",
fill_sha1(hdr, data, data_len);
break;
case VERIFY_PATTERN:
+ case VERIFY_PATTERN_NO_HDR:
/* nothing to do here */
break;
default:
log_err("fio: bad verify type: %d\n", td->o.verify);
assert(0);
}
- if (td->o.verify_offset)
- memswp(p, p + td->o.verify_offset, hdr_size(hdr));
+
+ if (td->o.verify_offset && hdr_size(td, hdr))
+ memswp(p, p + td->o.verify_offset, hdr_size(td, hdr));
}
/*