diff options
author | Etienne Dechamps <etienne.dechamps@ovh.net> | 2012-09-03 14:56:26 +0200 |
---|---|---|
committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2012-10-04 16:22:07 -0700 |
commit | bbdc6ae49518a4be7230ab673370e9231e2f72e7 (patch) | |
tree | f1e0522a75b9272b1da8a6f5382e0a3b9fbdffe4 /config | |
parent | a6c6839a88b7dc344f3cd8e875a01802b34645cd (diff) |
Add interface for file hole punching.
This adds an interface to "punch holes" (deallocate space) in VFS
files. The interface is identical to the Solaris VOP_SPACE interface.
This interface is necessary for TRIM support on file vdevs.
This is implemented using Linux fallocate(FALLOC_FL_PUNCH_HOLE), which
was introduced in 2.6.38. For a brief time before 2.6.38 this was done
using the truncate_range inode operation, which was quickly deprecated.
This patch only supports FALLOC_FL_PUNCH_HOLE.
This adds support for the truncate_range() inode operation to
VOP_SPACE() for file hole punching. This API is deprecated and removed
in 3.5, so it's only useful for old kernels.
On tmpfs, the truncate_range() inode operation translates to
shmem_truncate_range(). Unfortunately, this function expects the end
offset to be inclusive and aligned to the end of a page. If it is not,
the kernel will stop with a BUG_ON().
This patch fixes the issue by adapting to the constraints set forth by
shmem_truncate_range().
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #168
Diffstat (limited to 'config')
-rw-r--r-- | config/spl-build.m4 | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/config/spl-build.m4 b/config/spl-build.m4 index b7ab54d32..0c7a03cf1 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -72,6 +72,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_4ARGS_VFS_RENAME SPL_AC_VFS_FSYNC SPL_AC_2ARGS_VFS_FSYNC + SPL_AC_INODE_TRUNCATE_RANGE SPL_AC_FS_STRUCT_SPINLOCK SPL_AC_CRED_STRUCT SPL_AC_GROUPS_SEARCH @@ -1993,6 +1994,27 @@ AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [ ]) dnl # +dnl # 3.5 API change, +dnl # inode_operations.truncate_range removed +dnl # (deprecated in favor of FALLOC_FL_PUNCH_HOLE) +dnl # +AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [ + AC_MSG_CHECKING([whether truncate_range() inode operation is available]) + SPL_LINUX_TRY_COMPILE([ + #include <linux/fs.h> + ],[ + struct inode_operations ops; + ops.truncate_range = NULL; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1, + [truncate_range() inode operation is available]) + ],[ + AC_MSG_RESULT(no) + ]) +])) + +dnl # dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5. dnl # Earlier versions of rwsem_is_locked() were inline and had a race dnl # condition. The fixed version is exported as a symbol. The race |