+AC_DEFUN([SPL_AC_KVASPRINTF],
+ [AC_MSG_CHECKING([whether kvasprintf() is available])
+ SPL_LINUX_TRY_COMPILE_SYMBOL([
+ #include <linux/kernel.h>
+ ], [
+ kvasprintf(0, NULL, *((va_list*)NULL));
+ ], [kvasprintf], [], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # 2.6.29 API change,
+dnl # vfs_fsync() funcation added, prior to this use file_fsync().
+dnl #
+AC_DEFUN([SPL_AC_VFS_FSYNC],
+ [AC_MSG_CHECKING([whether vfs_fsync() is available])
+ SPL_LINUX_TRY_COMPILE_SYMBOL([
+ #include <linux/fs.h>
+ ], [
+ (void) vfs_fsync;
+ ], [vfs_fsync], [fs/sync.c], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # 2.6.35 API change,
+dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
+dnl #
+AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
+ AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
+ SPL_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ ],[
+ vfs_fsync(NULL, 0);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # 3.5 API change,
+dnl # inode_operations.truncate_range removed
+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 # Linux 2.6.38 - 3.x API
+dnl #
+AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
+ AC_MSG_CHECKING([whether fops->fallocate() exists])
+ SPL_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ ],[
+ long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
+ struct file_operations fops __attribute__ ((unused)) = {
+ .fallocate = fallocate,
+ };
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # Linux 2.6.x - 2.6.37 API
+dnl #
+AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
+ AC_MSG_CHECKING([whether iops->fallocate() exists])
+ SPL_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ ],[
+ long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
+ struct inode_operations fops __attribute__ ((unused)) = {
+ .fallocate = fallocate,
+ };
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # PaX Linux 2.6.38 - 3.x API
+dnl #
+AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
+ AC_MSG_CHECKING([whether fops->fallocate() exists])
+ SPL_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ ],[
+ long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
+ struct file_operations_no_const fops __attribute__ ((unused)) = {
+ .fallocate = fallocate,
+ };
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # The fallocate callback was moved from the inode_operations
+dnl # structure to the file_operations structure.
+dnl #
+AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
+ SPL_AC_KERNEL_FILE_FALLOCATE
+ SPL_AC_KERNEL_INODE_FALLOCATE
+ SPL_AC_PAX_KERNEL_FILE_FALLOCATE
+])
+
+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
+dnl # condition is fixed by acquiring sem->wait_lock, so we must not
+dnl # call that version while holding sem->wait_lock.
+dnl #
+AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
+ [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
+ SPL_LINUX_TRY_COMPILE_SYMBOL([
+ #include <linux/rwsem.h>
+ int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
+ ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
+ [rwsem_is_locked() acquires sem->wait_lock])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # 2.6.xx API compat,
+dnl # There currently exists no exposed API to partially shrink the dcache.
+dnl # The expected mechanism to shrink the cache is a registered shrinker
+dnl # which is called during memory pressure.
+dnl #
+AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
+ [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
+ SPL_LINUX_TRY_COMPILE_SYMBOL([
+ #include <linux/dcache.h>
+ ], [
+ shrink_dcache_memory(0, 0);
+ ], [shrink_dcache_memory], [fs/dcache.c], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
+ [shrink_dcache_memory() is available])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # 2.6.xx API compat,
+dnl # There currently exists no exposed API to partially shrink the icache.
+dnl # The expected mechanism to shrink the cache is a registered shrinker
+dnl # which is called during memory pressure.
+dnl #
+AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
+ [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
+ SPL_LINUX_TRY_COMPILE_SYMBOL([
+ #include <linux/dcache.h>
+ ], [
+ shrink_icache_memory(0, 0);
+ ], [shrink_icache_memory], [fs/inode.c], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
+ [shrink_icache_memory() is available])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # 2.6.39 API compat,
+dnl # The path_lookup() function has been renamed to kern_path_parent()
+dnl # and the flags argument has been removed. The only behavior now
+dnl # offered is that of LOOKUP_PARENT. The spl already always passed
+dnl # this flag so dropping the flag does not impact us.
+dnl #
+AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
+ SPL_CHECK_SYMBOL_HEADER(
+ [kern_path_parent],
+ [int kern_path_parent(const char \*, struct nameidata \*)],
+ [include/linux/namei.h],
+ [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
+ [kern_path_parent() is available])],
+ [])
+])
+
+dnl #
+dnl # 3.1 API compat,
+dnl # The kern_path_parent() symbol is no longer exported by the kernel.
+dnl # However, it remains the prefered interface and since we still have
+dnl # access to the prototype we dynamically lookup the required address.
+dnl #
+AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
+ [AC_MSG_CHECKING([whether kern_path_parent() is available])
+ SPL_LINUX_TRY_COMPILE_SYMBOL([
+ #include <linux/namei.h>
+ ], [
+ kern_path_parent(NULL, NULL);
+ ], [kern_path_parent], [fs/namei.c], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
+ [kern_path_parent() is available])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # 3.6 API compat,
+dnl # The kern_path_parent() function was replaced by the kern_path_locked()
+dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
+dnl #
+AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
+ SPL_CHECK_SYMBOL_HEADER(
+ [kern_path_locked],
+ [struct dentry \*kern_path_locked(const char \*, struct path \*)],
+ [include/linux/namei.h],
+ [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
+ [kern_path_locked() is available])],