From e9459e5a14b577ead39d666c051c7ce4db12bc75 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 17 Apr 2007 15:46:32 +0200 Subject: [PATCH] Add zero_buffers option This option will cause all IO buffers to be initialized to all zeroes. The default is to fill them with random data. Signed-off-by: Jens Axboe --- HOWTO | 3 +++ fio.c | 16 ++++++++++------ fio.h | 1 + options.c | 6 ++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/HOWTO b/HOWTO index aeb87ddb..2cc62b22 100644 --- a/HOWTO +++ b/HOWTO @@ -285,6 +285,9 @@ bs_unaligned If this option is given, any byte size value within bsrange may be used as a block range. This typically wont work with direct IO, as that normally requires sector alignment. +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. + 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 c39868dd..4d225f84 100644 --- a/fio.c +++ b/fio.c @@ -593,14 +593,17 @@ static void cleanup_io_u(struct thread_data *td) /* * "randomly" fill the buffer contents */ -static void fill_rand_buf(struct io_u *io_u, int max_bs) +static void fill_io_buf(struct thread_data *td, struct io_u *io_u, int max_bs) { int *ptr = io_u->buf; - while ((void *) ptr - io_u->buf < max_bs) { - *ptr = rand() * 0x9e370001; - ptr++; - } + if (!td->o.zero_buffers) { + while ((void *) ptr - io_u->buf < max_bs) { + *ptr = rand() * 0x9e370001; + ptr++; + } + } else + memset(ptr, 0, max_bs); } static int init_io_u(struct thread_data *td) @@ -641,8 +644,9 @@ static int init_io_u(struct thread_data *td) INIT_LIST_HEAD(&io_u->list); io_u->buf = p + max_bs * i; + if (td_write(td)) - fill_rand_buf(io_u, max_bs); + fill_io_buf(td, io_u, max_bs); io_u->index = i; io_u->flags = IO_U_F_FREE; diff --git a/fio.h b/fio.h index 0893a209..9490edc1 100644 --- a/fio.h +++ b/fio.h @@ -412,6 +412,7 @@ struct thread_options { unsigned int file_service_type; unsigned int group_reporting; unsigned int fadvise_hint; + unsigned int zero_buffers; char *read_iolog_file; char *write_iolog_file; diff --git a/options.c b/options.c index f8e89f38..754eb81f 100644 --- a/options.c +++ b/options.c @@ -826,6 +826,12 @@ static struct fio_option options[] = { .off1 = td_var_offset(group_reporting), .help = "Do reporting on a per-group basis", }, + { + .name = "zero_buffers", + .type = FIO_OPT_STR_SET, + .off1 = td_var_offset(zero_buffers), + .help = "Init IO buffers to all zeroes", + }, { .name = NULL, }, -- 2.25.1