Improve random verify block sorting
authorJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 08:59:49 +0000 (10:59 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 08:59:49 +0000 (10:59 +0200)
Add an option to control it and also check the nosort flag in file
layout to further catch a case where sorting isn't needed.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
HOWTO
filesetup.c
fio.h
log.c
options.c

diff --git a/HOWTO b/HOWTO
index a5be9dbd3e8d408bbe27491e4b15d76b30e5aa43..7cab05379f612034abdc173f03acb8d7850f902f 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -563,6 +563,14 @@ verify=str If writing to a file, fio can verify the file contents
                system to make sure that the written data is also
                correctly read back.
 
+verifysort=bool        If set, fio will sort written verify blocks when it deems
+               it faster to read them back in a sorted manner. This is
+               often the case when overwriting an existing file, since
+               the blocks are already laid out in the file system. You
+               can ignore this option unless doing huge amounts of really
+               fast IO where the red-black tree sorting CPU time becomes
+               significant.
+               
 stonewall      Wait for preceeding jobs in the job file to exit, before
                starting this one. Can be used to insert serialization
                points in the job file. A stone wall also implies starting
index d8b7401b35e0230d9f40afe53dcbfcd5e84b83e1..a059df66747db6bb8ca3884c874f0ebef3555104 100644 (file)
@@ -249,6 +249,7 @@ static int create_files(struct thread_data *td)
                        if (td->o.unlink)
                                f->flags |= FIO_FILE_UNLINK;
 
+                       f->flags |= FIO_FILE_NOSORT;
                        err = create_file(td, f);
                        if (err)
                                break;
diff --git a/fio.h b/fio.h
index ec08e42350f47b5428e8f166205b1fc680d7155f..ddc7e2397808743cd34e3220664f73ed74eba9c7 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -238,6 +238,7 @@ enum fio_file_flags {
        FIO_FILE_UNLINK         = 1 << 1,       /* unlink on close */
        FIO_FILE_CLOSING        = 1 << 2,       /* file being closed */
        FIO_FILE_EXISTS         = 1 << 3,       /* no need to create */
+       FIO_FILE_NOSORT         = 1 << 4,       /* don't sort verify blocks */
 };
 
 /*
@@ -356,6 +357,7 @@ struct thread_options {
        unsigned int end_fsync;
        unsigned int sync_io;
        unsigned int verify;
+       unsigned int verifysort;
        unsigned int use_thread;
        unsigned int unlink;
        unsigned int do_disk_util;
diff --git a/log.c b/log.c
index 6c7c4d6b2680546663eeac7d179b2e11917b7997..45be5fb6fdb94f718d3603bd769226f50abf7802 100644 (file)
--- a/log.c
+++ b/log.c
@@ -60,7 +60,8 @@ void log_io_piece(struct thread_data *td, struct io_u *io_u)
         * For both these cases, just reading back data in the order we
         * wrote it out is the fastest.
         */
-       if (!td_random(td) || !td->o.overwrite) {
+       if (!td_random(td) || !td->o.overwrite ||
+            (io_u->file->flags & FIO_FILE_NOSORT)) {
                INIT_LIST_HEAD(&ipo->list);
                list_add_tail(&ipo->list, &td->io_hist_list);
                return;
index 5401f90339bf7da688b8e645656cec3a24ee7228..aeba5201e7303a2d83d9e34e7a3110dc0be2f7a4 100644 (file)
--- a/options.c
+++ b/options.c
@@ -538,6 +538,13 @@ static struct fio_option options[] = {
                          },
                },
        },
+       {
+               .name   = "verifysort",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(verifysort),
+               .help   = "Sort written verify blocks for read back",
+               .def    = "1",
+       },
        {
                .name   = "write_iolog",
                .type   = FIO_OPT_STR_STORE,