Only expose fadvise_hint=noreuse if supported
authorJens Axboe <axboe@kernel.dk>
Fri, 31 Mar 2023 18:52:01 +0000 (12:52 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 31 Mar 2023 18:52:01 +0000 (12:52 -0600)
At least OSX doesn't have this option or define, just make it
available if it's there on the platform we're building on.

Fixes: eb314e7072a0 ("fio: add support for POSIX_FADV_NOREUSE")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
ioengines.c
options.c

index 56759c532543744821078bb3fe5129cba25b49f4..742f97dd32a444196706bebb29ab423a9dfb8a25 100644 (file)
@@ -565,8 +565,10 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                        flags = POSIX_FADV_RANDOM;
                else if (td->o.fadvise_hint == F_ADV_SEQUENTIAL)
                        flags = POSIX_FADV_SEQUENTIAL;
+#ifdef POSIX_FADV_NOREUSE
                else if (td->o.fadvise_hint == F_ADV_NOREUSE)
                        flags = POSIX_FADV_NOREUSE;
+#endif
                else {
                        log_err("fio: unknown fadvise type %d\n",
                                                        td->o.fadvise_hint);
index fe580ebb9d8f9d31ac7bb7ccdb5c872bea310ef1..440bff37cb131fcbc4b8f9e8d10da449d7aa5709 100644 (file)
--- a/options.c
+++ b/options.c
@@ -4,6 +4,7 @@
 #include <ctype.h>
 #include <string.h>
 #include <assert.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <netinet/in.h>
 
@@ -2740,10 +2741,12 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .oval = F_ADV_SEQUENTIAL,
                            .help = "Advise using FADV_SEQUENTIAL",
                          },
+#ifdef POSIX_FADV_NOREUSE
                          { .ival = "noreuse",
                            .oval = F_ADV_NOREUSE,
                            .help = "Advise using FADV_NOREUSE",
                          },
+#endif
                },
                .help   = "Use fadvise() to advise the kernel on IO pattern",
                .def    = "1",