if (td_write(td) && !td->o.refill_buffers)
io_u_fill_buffer(td, io_u, max_bs);
+ else if (td_write(td) && td->o.verify_pattern_bytes) {
+ /*
+ * Fill the buffer with the pattern if we are
+ * going to be doing writes.
+ */
+ fill_pattern(td, io_u->buf, max_bs, io_u);
+ }
}
io_u->index = i;
populate_verify_io_u(td, io_u);
else if (td->o.refill_buffers && io_u->ddir == DDIR_WRITE)
io_u_fill_buffer(td, io_u, io_u->xfer_buflen);
+ else if (io_u->ddir == DDIR_READ) {
+ /*
+ * Reset the buf_filled parameters so next time if the
+ * buffer is used for writes it is refilled.
+ */
+ io_u->buf_filled = 0;
+ io_u->buf_filled_len = 0;
+ }
}
/*
unsigned long buflen;
unsigned long long offset;
+ /*
+ * Parameters related to pre-filled buffers and
+ * their size to handle variable block sizes.
+ */
+ int buf_filled;
+ unsigned long buf_filled_len;
+
/*
* IO engine state, may be different from above when we get
* partial transfers / residual data counts
#include "crc/sha512.h"
#include "crc/sha1.h"
-static void fill_pattern(struct thread_data *td, void *p, unsigned int len)
+void fill_pattern(struct thread_data *td, void *p, unsigned int len, struct io_u *io_u)
{
switch (td->o.verify_pattern_bytes) {
case 0:
fill_random_buf(p, len);
break;
case 1:
+ if (io_u->buf_filled && io_u->buf_filled_len >= len) {
+ dprint(FD_VERIFY, "using already filled verify pattern b=0 len=%u\n", len);
+ return;
+ }
dprint(FD_VERIFY, "fill verify pattern b=0 len=%u\n", len);
memset(p, td->o.verify_pattern[0], len);
+ io_u->buf_filled = 1;
+ io_u->buf_filled_len = len;
break;
default: {
unsigned int i = 0, size = 0;
unsigned char *b = p;
+ if (io_u->buf_filled && io_u->buf_filled_len >= len) {
+ dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n",
+ td->o.verify_pattern_bytes, len);
+ return;
+ }
dprint(FD_VERIFY, "fill verify pattern b=%d len=%u\n",
td->o.verify_pattern_bytes, len);
memcpy(b+i, td->o.verify_pattern, size);
i += size;
}
+ io_u->buf_filled = 1;
+ io_u->buf_filled_len = len;
break;
}
}
if (td->o.verify == VERIFY_NULL)
return;
- fill_pattern(td, p, io_u->buflen);
+ fill_pattern(td, p, io_u->buflen, io_u);
hdr_inc = io_u->buflen;
if (td->o.verify_interval)
extern int __must_check get_next_verify(struct thread_data *td, struct io_u *);
extern int __must_check verify_io_u(struct thread_data *, struct io_u *);
extern int verify_io_u_async(struct thread_data *, struct io_u *);
+extern void fill_pattern(struct thread_data *td, void *p, unsigned int len, struct io_u *io_u);
/*
* Async verify offload