From c69f6bf3ed1b413562d7aab1aa9c476101348726 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 7 Feb 2018 11:30:59 -0700 Subject: [PATCH] mmap: don't include MADV_FREE in fadvise_hint check This really should be based on invalidate, leave it as it was for now. Fixes: c712c97ab871 ("Let fadvise_hint also apply too mmap engine and madvise") Signed-off-by: Jens Axboe --- engines/mmap.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/engines/mmap.c b/engines/mmap.c index 28d63b7c..ea7179da 100644 --- a/engines/mmap.c +++ b/engines/mmap.c @@ -47,15 +47,6 @@ static bool fio_madvise_file(struct thread_data *td, struct fio_file *f, return false; } } - if (posix_madvise(fmd->mmap_ptr, length, POSIX_MADV_DONTNEED) < 0) { - td_verror(td, errno, "madvise"); - return false; - } - -#ifdef FIO_MADV_FREE - if (f->filetype == FIO_TYPE_BLOCK) - (void) posix_madvise(fmd->mmap_ptr, fmd->mmap_sz, FIO_MADV_FREE); -#endif return true; } @@ -86,6 +77,16 @@ static int fio_mmap_file(struct thread_data *td, struct fio_file *f, if (!fio_madvise_file(td, f, length)) goto err; + if (posix_madvise(fmd->mmap_ptr, length, POSIX_MADV_DONTNEED) < 0) { + td_verror(td, errno, "madvise"); + goto err; + } + +#ifdef FIO_MADV_FREE + if (f->filetype == FIO_TYPE_BLOCK) + (void) posix_madvise(fmd->mmap_ptr, fmd->mmap_sz, FIO_MADV_FREE); +#endif + err: if (td->error && fmd->mmap_ptr) munmap(fmd->mmap_ptr, length); -- 2.25.1