From e116f2b90f110334e77741227ad4e4600302c718 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 4 Jun 2008 15:14:24 +0200 Subject: [PATCH] Add directio support to Solaris Signed-off-by: Jens Axboe --- ioengines.c | 15 +++++++++++++++ os/os-solaris.h | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/ioengines.c b/ioengines.c index 1a7a6301..8975591d 100644 --- a/ioengines.c +++ b/ioengines.c @@ -367,6 +367,21 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) if (f->file_map) memset(f->file_map, 0, f->num_maps * sizeof(int)); +#ifdef FIO_OS_DIRECTIO + /* + * Some OS's have a distinct call to mark the file non-buffered, + * instead of using O_DIRECT (Solaris) + */ + if (td->o.odirect) { + int ret = fio_set_odirect(f->fd); + + if (ret) { + td_verror(td, ret, "fio_set_odirect"); + goto err; + } + } +#endif + done: log_file(td, f, FIO_LOG_OPEN_FILE); return 0; diff --git a/os/os-solaris.h b/os/os-solaris.h index ac22bff1..866e0c0e 100644 --- a/os/os-solaris.h +++ b/os/os-solaris.h @@ -1,6 +1,9 @@ #ifndef FIO_OS_SOLARIS_H #define FIO_OS_SOLARIS_H +#include +#include + #define FIO_HAVE_POSIXAIO #define FIO_HAVE_SOLARISAIO #define FIO_HAVE_FALLOCATE @@ -51,4 +54,14 @@ static inline long os_random_long(os_random_state_t *rs) return val; } +#define FIO_OS_DIRECTIO +extern int directio(int, int); +static inline int fio_set_odirect(int fd) +{ + if (directio(fd, DIRECTIO_ON) < 0) + return errno; + + return 0; +} + #endif -- 2.25.1