[PATCH] Change O_DIRECT vs buffered setup
authorJens Axboe <jens.axboe@oracle.com>
Thu, 11 Jan 2007 12:24:44 +0000 (13:24 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 11 Jan 2007 12:24:44 +0000 (13:24 +0100)
Change the default from O_DIRECT IO to normal buffered IO. That makes
more sense, as O_DIRECT is a special case and should be manually
enabled as such.

Do this by adding a option negate switch, so we don't need two sets
of parameters to control these options.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
HOWTO
init.c
parse.c
parse.h

diff --git a/HOWTO b/HOWTO
index 57c0730b13d0ef7ef8b257a97ff56c1181aa53cf..a9ee7ab12be207af57300370476e263af0e740a0 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -277,7 +277,10 @@ iodepth=int        This defines how many io units to keep in flight against
                concurrency.
 
 direct=bool    If value is true, use non-buffered io. This is usually
                concurrency.
 
 direct=bool    If value is true, use non-buffered io. This is usually
-               O_DIRECT. Defaults to true.
+               O_DIRECT.
+
+buffered=bool  If value is true, use buffered io. This is the opposite
+               of the 'direct' option. Defaults to true.
 
 offset=siint   Start io at the given offset in the file. The data before
                the given offset will not be touched. This effectively
 
 offset=siint   Start io at the given offset in the file. The data before
                the given offset will not be touched. This effectively
diff --git a/init.c b/init.c
index c2725261ad8481ee923de2fb5b6e3ac524868e03..5d6b0a904f8348af3ccd649054b24132e29de20d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -151,7 +151,15 @@ static struct fio_option options[] = {
                .name   = "direct",
                .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(odirect),
                .name   = "direct",
                .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(odirect),
-               .help   = "Use O_DIRECT IO",
+               .help   = "Use O_DIRECT IO (negates buffered)",
+               .def    = "0",
+       },
+       {
+               .name   = "buffered",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(odirect),
+               .neg    = 1,
+               .help   = "Use buffered IO (negates direct)",
                .def    = "1",
        },
        {
                .def    = "1",
        },
        {
diff --git a/parse.c b/parse.c
index 886bde6b0c8b1130050234b40c7d047df602cba4..81ffb741094b2ebec9b24e18dff062af2bceced3 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -267,6 +267,9 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                        return 1;
                }
 
                        return 1;
                }
 
+               if (o->neg)
+                       il = !il;
+
                if (fn)
                        ret = fn(data, &il);
                else {
                if (fn)
                        ret = fn(data, &il);
                else {
diff --git a/parse.h b/parse.h
index 4ddb76a6335d6af7834e1209b8517fb125f01d6d..7374c258ab95a339cff8853707a567df2ad68422 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -29,6 +29,7 @@ struct fio_option {
        unsigned int off4;
        unsigned int maxval;            /* max and min value */
        int minval;
        unsigned int off4;
        unsigned int maxval;            /* max and min value */
        int minval;
+       int neg;                        /* negate value stored */
        void *cb;                       /* callback */
        const char *help;               /* help text for option */
        const char *def;                /* default setting */
        void *cb;                       /* callback */
        const char *help;               /* help text for option */
        const char *def;                /* default setting */