From d2f3ac3592a5674fefa082cb439cc72355d2fed0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 22 Mar 2007 19:24:09 +0100 Subject: [PATCH] Add option to disable fadvise() hints Signed-off-by: Jens Axboe --- HOWTO | 7 +++++++ filesetup.c | 3 +++ fio.h | 1 + options.c | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/HOWTO b/HOWTO index 051a4554..8312d931 100644 --- 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. +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 diff --git a/filesetup.c b/filesetup.c index daae33ff..1426b151 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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.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"); diff --git a/fio.h b/fio.h index c34c00c0..d0629ece 100644 --- 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 fadvise_hint; char *read_iolog_file; char *write_iolog_file; diff --git a/options.c b/options.c index 6a015c0d..4f30f2c1 100644 --- 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, -- 2.25.1