Add zero_buffers option
authorJens Axboe <jens.axboe@oracle.com>
Tue, 17 Apr 2007 13:46:32 +0000 (15:46 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 17 Apr 2007 13:46:32 +0000 (15:46 +0200)
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 <jens.axboe@oracle.com>
HOWTO
fio.c
fio.h
options.c

diff --git a/HOWTO b/HOWTO
index aeb87ddb37cc59cdd057a56bd99ea9f901efbd68..2cc62b2221c6654fad9b577c445f7e89553e5d3c 100644 (file)
--- 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.
 
                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
 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 c39868dd95112a2dea7d3c497e08aeee39953d38..4d225f84b409a7efde36394e05dd296157ad851b 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -593,14 +593,17 @@ static void cleanup_io_u(struct thread_data *td)
 /*
  * "randomly" fill the buffer contents
  */
 /*
  * "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;
 
 {
        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)
 }
 
 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;
                INIT_LIST_HEAD(&io_u->list);
 
                io_u->buf = p + max_bs * i;
+
                if (td_write(td))
                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;
 
                io_u->index = i;
                io_u->flags = IO_U_F_FREE;
diff --git a/fio.h b/fio.h
index 0893a209a5b52148ef7a7a6e0357169a3a672402..9490edc11e1a2ea924f1dea3bf75f2d9e36d0fdf 100644 (file)
--- 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 file_service_type;
        unsigned int group_reporting;
        unsigned int fadvise_hint;
+       unsigned int zero_buffers;
 
        char *read_iolog_file;
        char *write_iolog_file;
 
        char *read_iolog_file;
        char *write_iolog_file;
index f8e89f381bbd171fbed1877066f33c744dd7a6e1..754eb81fccfe1a14f6949f30d07475ea09acc834 100644 (file)
--- 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",
        },
                .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,
        },
        {
                .name = NULL,
        },