Add option to disable fadvise() hints
authorJens Axboe <jens.axboe@oracle.com>
Thu, 22 Mar 2007 18:24:09 +0000 (19:24 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 22 Mar 2007 18:24:09 +0000 (19:24 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
HOWTO
filesetup.c
fio.h
options.c

diff --git a/HOWTO b/HOWTO
index 051a4554a95ff8a1229d3154a1c6bd31f701c9c6..8312d9315ae3a591b7a85cdd0822c86626ace840 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -240,6 +240,13 @@ rw=str             Type of io pattern. Accepted values are:
 randrepeat=bool        For random IO workloads, seed the generator in a predictable
                way so that results are repeatable across repetitions.
 
 randrepeat=bool        For random IO workloads, seed the generator in a predictable
                way so that results are repeatable across repetitions.
 
+fadvise_hint=bool By default, fio will use fadvise() to advise the kernel
+               on what IO patterns it is likely to issue. Sometimes you
+               want to test specific IO patterns without telling the
+               kernel about it, in which case you can disable this option.
+               If set, fio will use POSIX_FADV_SEQUENTIAL for sequential
+               IO and POSIX_FADV_RANDOM for random IO.
+
 size=siint     The total size of file io for this job. This may describe
                the size of the single file the job uses, or it may be
                divided between the number of files in the job. If the
 size=siint     The total size of file io for this job. This may describe
                the size of the single file the job uses, or it may be
                divided between the number of files in the job. If the
index daae33ff47e36e2357082721f26c93ea82e7ef9d..1426b151085b1553af318cdf58ecdc47ce84fb14 100644 (file)
@@ -403,6 +403,9 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
        if (td->o.invalidate_cache && file_invalidate_cache(td, f))
                goto err;
 
        if (td->o.invalidate_cache && file_invalidate_cache(td, f))
                goto err;
 
+       if (!td->o.fadvise_hint)
+               return 0;
+
        if (!td_random(td)) {
                if (fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_SEQUENTIAL) < 0) {
                        td_verror(td, errno, "fadvise");
        if (!td_random(td)) {
                if (fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_SEQUENTIAL) < 0) {
                        td_verror(td, errno, "fadvise");
diff --git a/fio.h b/fio.h
index c34c00c064126934eec67ae1a543097cc158ce36..d0629ece3fe6d3f2463a22fbc4dd16628c1ce2ae 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -386,6 +386,7 @@ struct thread_options {
        unsigned int nice;
        unsigned int file_service_type;
        unsigned int group_reporting;
        unsigned int nice;
        unsigned int file_service_type;
        unsigned int group_reporting;
+       unsigned int fadvise_hint;
 
        char *read_iolog_file;
        char *write_iolog_file;
 
        char *read_iolog_file;
        char *write_iolog_file;
index 6a015c0d7d167e588955d45fc1e76983fad3b6ef..4f30f2c1991aaf8769e2802d4dceef7cb0d83a34 100644 (file)
--- a/options.c
+++ b/options.c
@@ -246,6 +246,13 @@ static struct fio_option options[] = {
                          },
                },
        },
                          },
                },
        },
+       {
+               .name   = "fadvise_hint",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(fadvise_hint),
+               .help   = "Use fadvise() to advise the kernel on IO pattern",
+               .def    = "1",
+       },
        {
                .name   = "ioengine",
                .type   = FIO_OPT_STR_STORE,
        {
                .name   = "ioengine",
                .type   = FIO_OPT_STR_STORE,