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/HOWTO b/HOWTO
index 32e7322..36e42aa 100644
--- a/HOWTO
+++ b/HOWTO
@@ -336,6 +336,11 @@
zero_buffers If this option is given, fio will init the IO buffers to
all zeroes. The default is to fill them with random data.
+refill_buffers If this option is given, fio will refill the IO buffers
+ on every submit. The default is to only fill it at init
+ time and reuse that data. Only makes sense if zero_buffers
+ isn't specified, naturally.
+
nrfiles=int Number of files to use for this job. Defaults to 1.
openfiles=int Number of files to keep open at the same time. Defaults to
diff --git a/fio.c b/fio.c
index b79aa93..c79fad8 100644
--- a/fio.c
+++ b/fio.c
@@ -642,22 +642,6 @@
free_io_mem(td);
}
-/*
- * "randomly" fill the buffer contents
- */
-static void fill_io_buf(struct thread_data *td, struct io_u *io_u, 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);
-}
-
static int init_io_u(struct thread_data *td)
{
struct io_u *io_u;
@@ -700,8 +684,8 @@
if (!(td->io_ops->flags & FIO_NOIO)) {
io_u->buf = p + max_bs * i;
- if (td_write(td))
- fill_io_buf(td, io_u, max_bs);
+ if (td_write(td) && !td->o.refill_buffers)
+ io_u_fill_buffer(td, io_u, max_bs);
}
io_u->index = i;
diff --git a/fio.h b/fio.h
index 47b6d48..25d05bd 100644
--- a/fio.h
+++ b/fio.h
@@ -478,6 +478,7 @@
unsigned int group_reporting;
unsigned int fadvise_hint;
unsigned int zero_buffers;
+ unsigned int refill_buffers;
unsigned int time_based;
char *read_iolog_file;
@@ -907,6 +908,7 @@
extern void io_u_init_timeout(void);
extern void io_u_set_timeout(struct thread_data *);
extern void io_u_mark_depth(struct thread_data *, unsigned int);
+extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int);
/*
* io engine entry points
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)
{
diff --git a/options.c b/options.c
index 8a6a433..ba57e44 100644
--- a/options.c
+++ b/options.c
@@ -1215,6 +1215,12 @@
.off1 = td_var_offset(zero_buffers),
.help = "Init IO buffers to all zeroes",
},
+ {
+ .name = "refill_buffers",
+ .type = FIO_OPT_STR_SET,
+ .off1 = td_var_offset(refill_buffers),
+ .help = "Refill IO buffers on every IO submit",
+ },
#ifdef FIO_HAVE_DISK_UTIL
{
.name = "disk_util",