From: Tomohiro Kusumi Date: Thu, 14 Jul 2016 12:27:42 +0000 (+0900) Subject: Add os_trim() support for DragonFlyBSD X-Git-Tag: fio-2.13~17 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=c9a4e0c80470640f5d6e48dc827d28fffef1cadc;p=fio.git Add os_trim() support for DragonFlyBSD It has the same interface as Linux kernel with a different ioctl name. Signed-off-by: Tomohiro Kusumi Signed-off-by: Jens Axboe --- diff --git a/Makefile b/Makefile index c617d6f4..a9cd151f 100644 --- a/Makefile +++ b/Makefile @@ -157,6 +157,7 @@ ifeq ($(CONFIG_TARGET_OS), NetBSD) LDFLAGS += -rdynamic endif ifeq ($(CONFIG_TARGET_OS), DragonFly) + SOURCE += trim.c LIBS += -lpthread -lrt LDFLAGS += -rdynamic endif diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h index b67c660f..d776d1f7 100644 --- a/os/os-dragonfly.h +++ b/os/os-dragonfly.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "../file.h" @@ -16,6 +17,7 @@ #define FIO_USE_GENERIC_RAND #define FIO_USE_GENERIC_INIT_RANDOM_STATE #define FIO_HAVE_FS_STAT +#define FIO_HAVE_TRIM #define FIO_HAVE_CHARDEV_SIZE #define FIO_HAVE_GETTID @@ -84,6 +86,20 @@ static inline unsigned long long get_fs_free_size(const char *path) return ret; } +static inline int os_trim(int fd, unsigned long long start, + unsigned long long len) +{ + off_t range[2]; + + range[0] = start; + range[1] = len; + + if (!ioctl(fd, IOCTLTRIM, range)) + return 0; + + return errno; +} + #ifdef MADV_FREE #define FIO_MADV_FREE MADV_FREE #endif