mmap: don't include MADV_FREE in fadvise_hint check
[fio.git] / engines / mmap.c
index 28d63b7c30642e5700e6218cd901e3874e4d76c6..ea7179da2325ece1b0fd7772271d74fff4e90a3e 100644 (file)
@@ -47,15 +47,6 @@ static bool fio_madvise_file(struct thread_data *td, struct fio_file *f,
                        return false;
                }
        }
                        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;
 }
 
        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 (!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);
 err:
        if (td->error && fmd->mmap_ptr)
                munmap(fmd->mmap_ptr, length);