1dnl #
2dnl # EL7 have backported copy_file_range and clone_file_range and
3dnl # added them to an "extended" file_operations struct.
4dnl #
5dnl # We're testing for both functions in one here, because they will only
6dnl # ever appear together and we don't want to match a similar method in
7dnl # some future vendor kernel.
8dnl #
9AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_FILE_OPERATIONS_EXTEND], [
10	ZFS_LINUX_TEST_SRC([vfs_file_operations_extend], [
11		#include <linux/fs.h>
12
13		static ssize_t test_copy_file_range(struct file *src_file,
14		    loff_t src_off, struct file *dst_file, loff_t dst_off,
15		    size_t len, unsigned int flags) {
16			(void) src_file; (void) src_off;
17			(void) dst_file; (void) dst_off;
18			(void) len; (void) flags;
19			return (0);
20		}
21
22		static int test_clone_file_range(struct file *src_file,
23		    loff_t src_off, struct file *dst_file, loff_t dst_off,
24		    u64 len) {
25			(void) src_file; (void) src_off;
26			(void) dst_file; (void) dst_off;
27			(void) len;
28			return (0);
29		}
30
31		static const struct file_operations_extend
32		    fops __attribute__ ((unused)) = {
33			.kabi_fops = {},
34			.copy_file_range = test_copy_file_range,
35			.clone_file_range = test_clone_file_range,
36		};
37	],[])
38])
39AC_DEFUN([ZFS_AC_KERNEL_VFS_FILE_OPERATIONS_EXTEND], [
40	AC_MSG_CHECKING([whether file_operations_extend takes \
41.copy_file_range() and .clone_file_range()])
42	ZFS_LINUX_TEST_RESULT([vfs_file_operations_extend], [
43		AC_MSG_RESULT([yes])
44		AC_DEFINE(HAVE_VFS_FILE_OPERATIONS_EXTEND, 1,
45		    [file_operations_extend takes .copy_file_range()
46		    and .clone_file_range()])
47	],[
48		AC_MSG_RESULT([no])
49	])
50])
51