summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libzpool/kernel.c4
-rw-r--r--module/os/linux/zfs/vdev_file.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c
index 6123b5d6a..cd6553eeb 100644
--- a/lib/libzpool/kernel.c
+++ b/lib/libzpool/kernel.c
@@ -1346,7 +1346,11 @@ zfs_file_fsync(zfs_file_t *fp, int flags)
int
zfs_file_fallocate(zfs_file_t *fp, int mode, loff_t offset, loff_t len)
{
+#ifdef __linux__
return (fallocate(fp->f_fd, mode, offset, len));
+#else
+ return (EOPNOTSUPP);
+#endif
}
/*
diff --git a/module/os/linux/zfs/vdev_file.c b/module/os/linux/zfs/vdev_file.c
index fba5cdced..592ba2b4a 100644
--- a/module/os/linux/zfs/vdev_file.c
+++ b/module/os/linux/zfs/vdev_file.c
@@ -36,9 +36,9 @@
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <sys/zfs_file.h>
-
+#ifdef _KERNEL
#include <linux/falloc.h>
-
+#endif
/*
* Virtual device vector for files.
*/
@@ -268,10 +268,12 @@ vdev_file_io_start(zio_t *zio)
zio_execute(zio);
return;
} else if (zio->io_type == ZIO_TYPE_TRIM) {
- int mode;
+ int mode = 0;
ASSERT3U(zio->io_size, !=, 0);
+#ifdef __linux__
mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
+#endif
zio->io_error = zfs_file_fallocate(vf->vf_file,
mode, zio->io_offset, zio->io_size);
zio_execute(zio);