All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Add os_trim() support for DragonFlyBSD
@ 2016-07-14 12:27 Tomohiro Kusumi
  2016-07-14 12:27 ` [PATCH 2/2] Add os_trim() support for FreeBSD Tomohiro Kusumi
  2016-07-14 15:31 ` [PATCH 1/2] Add os_trim() support for DragonFlyBSD Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Tomohiro Kusumi @ 2016-07-14 12:27 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

It has the same interface as Linux kernel with a different ioctl name.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
---
 Makefile          |  1 +
 os/os-dragonfly.h | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/Makefile b/Makefile
index c617d6f..a9cd151 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 b67c660..d776d1f 100644
--- a/os/os-dragonfly.h
+++ b/os/os-dragonfly.h
@@ -9,6 +9,7 @@
 #include <sys/sysctl.h>
 #include <sys/statvfs.h>
 #include <sys/diskslice.h>
+#include <sys/ioctl_compat.h>
 
 #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
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Add os_trim() support for FreeBSD
  2016-07-14 12:27 [PATCH 1/2] Add os_trim() support for DragonFlyBSD Tomohiro Kusumi
@ 2016-07-14 12:27 ` Tomohiro Kusumi
  2016-07-14 15:31 ` [PATCH 1/2] Add os_trim() support for DragonFlyBSD Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Tomohiro Kusumi @ 2016-07-14 12:27 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

It has the same interface as Linux kernel with a different ioctl name.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
---
 Makefile        |  1 +
 os/os-freebsd.h | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/Makefile b/Makefile
index a9cd151..b54f7e9 100644
--- a/Makefile
+++ b/Makefile
@@ -145,6 +145,7 @@ ifeq ($(CONFIG_TARGET_OS), SunOS)
   CPPFLAGS += -D__EXTENSIONS__
 endif
 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
+  SOURCE += trim.c
   LIBS	 += -lpthread -lrt
   LDFLAGS += -rdynamic
 endif
diff --git a/os/os-freebsd.h b/os/os-freebsd.h
index fa00bb8..ac408c9 100644
--- a/os/os-freebsd.h
+++ b/os/os-freebsd.h
@@ -19,6 +19,7 @@
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_HAVE_FS_STAT
+#define FIO_HAVE_TRIM
 #define FIO_HAVE_GETTID
 #define FIO_HAVE_CPU_AFFINITY
 
@@ -114,6 +115,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, DIOCGDELETE, range))
+		return 0;
+
+	return errno;
+}
+
 #ifdef MADV_FREE
 #define FIO_MADV_FREE	MADV_FREE
 #endif
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Add os_trim() support for DragonFlyBSD
  2016-07-14 12:27 [PATCH 1/2] Add os_trim() support for DragonFlyBSD Tomohiro Kusumi
  2016-07-14 12:27 ` [PATCH 2/2] Add os_trim() support for FreeBSD Tomohiro Kusumi
@ 2016-07-14 15:31 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2016-07-14 15:31 UTC (permalink / raw)
  To: Tomohiro Kusumi, fio

On 07/14/2016 05:27 AM, Tomohiro Kusumi wrote:
> It has the same interface as Linux kernel with a different ioctl name.

Thanks, applied this and 2/2.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-14 15:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-14 12:27 [PATCH 1/2] Add os_trim() support for DragonFlyBSD Tomohiro Kusumi
2016-07-14 12:27 ` [PATCH 2/2] Add os_trim() support for FreeBSD Tomohiro Kusumi
2016-07-14 15:31 ` [PATCH 1/2] Add os_trim() support for DragonFlyBSD Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.