Add option to disable fadvise() hints

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/HOWTO b/HOWTO
index 051a455..8312d93 100644
--- a/HOWTO
+++ b/HOWTO
@@ -240,6 +240,13 @@
 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 daae33f..1426b15 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -403,6 +403,9 @@
 	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 c34c00c..d0629ec 100644
--- a/fio.h
+++ b/fio.h
@@ -386,6 +386,7 @@
 	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 6a015c0..4f30f2c 100644
--- a/options.c
+++ b/options.c
@@ -247,6 +247,13 @@
 		},
 	},
 	{
+		.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,
 		.off1	= td_var_offset(ioengine),