From: Jens Axboe Date: Thu, 11 Jan 2007 12:24:44 +0000 (+0100) Subject: [PATCH] Change O_DIRECT vs buffered setup X-Git-Tag: fio-1.12~165 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=76a43db448f9fd5e9f1397428a433466d98e0d5d;hp=03b74b3ec5268e731ed7fcaef31c8c0655acd530;ds=sidebyside [PATCH] Change O_DIRECT vs buffered setup 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 --- diff --git a/HOWTO b/HOWTO index 57c0730b..a9ee7ab1 100644 --- 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 - 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 diff --git a/init.c b/init.c index c2725261..5d6b0a90 100644 --- 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), - .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", }, { diff --git a/parse.c b/parse.c index 886bde6b..81ffb741 100644 --- 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; } + if (o->neg) + il = !il; + if (fn) ret = fn(data, &il); else { diff --git a/parse.h b/parse.h index 4ddb76a6..7374c258 100644 --- 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; + int neg; /* negate value stored */ void *cb; /* callback */ const char *help; /* help text for option */ const char *def; /* default setting */