Add option for refilling IO buffers on each submit

If the device looks at whether the data changed, then this can
make a difference.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/io_u.c b/io_u.c
index 92cdd71..06fb3ce 100644
--- a/io_u.c
+++ b/io_u.c
@@ -6,6 +6,7 @@
 #include <assert.h>
 
 #include "fio.h"
+#include "hash.h"
 
 /*
  * Change this define to play with the timeout handling
@@ -780,6 +781,9 @@
 	io_u->endpos = io_u->offset + io_u->buflen;
 	io_u->xfer_buf = io_u->buf;
 	io_u->xfer_buflen = io_u->buflen;
+
+	if (td->o.refill_buffers && io_u->ddir == DDIR_WRITE)
+		io_u_fill_buffer(td, io_u, io_u->xfer_buflen);
 out:
 	if (!td_io_prep(td, io_u)) {
 		fio_gettime(&io_u->start_time, NULL);
@@ -943,6 +947,23 @@
 	add_slat_sample(td, io_u->ddir, slat_time);
 }
 
+/*
+ * "randomly" fill the buffer contents
+ */
+void io_u_fill_buffer(struct thread_data *td, struct io_u *io_u,
+		      unsigned int max_bs)
+{
+	long *ptr = io_u->buf;
+
+	if (!td->o.zero_buffers) {
+		while ((void *) ptr - io_u->buf < max_bs) {
+			*ptr = rand() * GOLDEN_RATIO_PRIME;
+			ptr++;
+		}
+	} else
+		memset(ptr, 0, max_bs);
+}
+
 #ifdef FIO_USE_TIMEOUT
 void io_u_set_timeout(struct thread_data *td)
 {