2 dnl # The *_file_range APIs have a long history:
4 dnl # 2.6.29: BTRFS_IOC_CLONE and BTRFS_IOC_CLONE_RANGE ioctl introduced
5 dnl # 3.12: BTRFS_IOC_FILE_EXTENT_SAME ioctl introduced
7 dnl # 4.5: copy_file_range() syscall introduced, added to VFS
8 dnl # 4.5: BTRFS_IOC_CLONE and BTRFS_IOC_CLONE_RANGE renamed to FICLONE ands
9 dnl # FICLONERANGE, added to VFS as clone_file_range()
10 dnl # 4.5: BTRFS_IOC_FILE_EXTENT_SAME renamed to FIDEDUPERANGE, added to VFS
11 dnl # as dedupe_file_range()
13 dnl # 4.20: VFS clone_file_range() and dedupe_file_range() replaced by
14 dnl # remap_file_range()
16 dnl # 5.3: VFS copy_file_range() expected to do its own fallback,
17 dnl # generic_copy_file_range() added to support it
19 AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE], [
20 ZFS_LINUX_TEST_SRC([vfs_copy_file_range], [
23 static ssize_t test_copy_file_range(struct file *src_file,
24 loff_t src_off, struct file *dst_file, loff_t dst_off,
25 size_t len, unsigned int flags) {
26 (void) src_file; (void) src_off;
27 (void) dst_file; (void) dst_off;
28 (void) len; (void) flags;
32 static const struct file_operations
33 fops __attribute__ ((unused)) = {
34 .copy_file_range = test_copy_file_range,
38 AC_DEFUN([ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE], [
39 AC_MSG_CHECKING([whether fops->copy_file_range() is available])
40 ZFS_LINUX_TEST_RESULT([vfs_copy_file_range], [
42 AC_DEFINE(HAVE_VFS_COPY_FILE_RANGE, 1,
43 [fops->copy_file_range() is available])
49 AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE], [
50 ZFS_LINUX_TEST_SRC([generic_copy_file_range], [
53 struct file *src_file __attribute__ ((unused)) = NULL;
54 loff_t src_off __attribute__ ((unused)) = 0;
55 struct file *dst_file __attribute__ ((unused)) = NULL;
56 loff_t dst_off __attribute__ ((unused)) = 0;
57 size_t len __attribute__ ((unused)) = 0;
58 unsigned int flags __attribute__ ((unused)) = 0;
59 generic_copy_file_range(src_file, src_off, dst_file, dst_off,
63 AC_DEFUN([ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE], [
64 AC_MSG_CHECKING([whether generic_copy_file_range() is available])
65 ZFS_LINUX_TEST_RESULT_SYMBOL([generic_copy_file_range],
66 [generic_copy_file_range], [fs/read_write.c], [
68 AC_DEFINE(HAVE_VFS_GENERIC_COPY_FILE_RANGE, 1,
69 [generic_copy_file_range() is available])
75 AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_CLONE_FILE_RANGE], [
76 ZFS_LINUX_TEST_SRC([vfs_clone_file_range], [
79 static int test_clone_file_range(struct file *src_file,
80 loff_t src_off, struct file *dst_file, loff_t dst_off,
82 (void) src_file; (void) src_off;
83 (void) dst_file; (void) dst_off;
88 static const struct file_operations
89 fops __attribute__ ((unused)) = {
90 .clone_file_range = test_clone_file_range,
94 AC_DEFUN([ZFS_AC_KERNEL_VFS_CLONE_FILE_RANGE], [
95 AC_MSG_CHECKING([whether fops->clone_file_range() is available])
96 ZFS_LINUX_TEST_RESULT([vfs_clone_file_range], [
98 AC_DEFINE(HAVE_VFS_CLONE_FILE_RANGE, 1,
99 [fops->clone_file_range() is available])
105 AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE], [
106 ZFS_LINUX_TEST_SRC([vfs_dedupe_file_range], [
107 #include <linux/fs.h>
109 static int test_dedupe_file_range(struct file *src_file,
110 loff_t src_off, struct file *dst_file, loff_t dst_off,
112 (void) src_file; (void) src_off;
113 (void) dst_file; (void) dst_off;
118 static const struct file_operations
119 fops __attribute__ ((unused)) = {
120 .dedupe_file_range = test_dedupe_file_range,
124 AC_DEFUN([ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE], [
125 AC_MSG_CHECKING([whether fops->dedupe_file_range() is available])
126 ZFS_LINUX_TEST_RESULT([vfs_dedupe_file_range], [
128 AC_DEFINE(HAVE_VFS_DEDUPE_FILE_RANGE, 1,
129 [fops->dedupe_file_range() is available])
135 AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE], [
136 ZFS_LINUX_TEST_SRC([vfs_remap_file_range], [
137 #include <linux/fs.h>
139 static loff_t test_remap_file_range(struct file *src_file,
140 loff_t src_off, struct file *dst_file, loff_t dst_off,
141 loff_t len, unsigned int flags) {
142 (void) src_file; (void) src_off;
143 (void) dst_file; (void) dst_off;
144 (void) len; (void) flags;
148 static const struct file_operations
149 fops __attribute__ ((unused)) = {
150 .remap_file_range = test_remap_file_range,
155 AC_DEFUN([ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE], [
156 AC_MSG_CHECKING([whether fops->remap_file_range() is available])
157 ZFS_LINUX_TEST_RESULT([vfs_remap_file_range], [
159 AC_DEFINE(HAVE_VFS_REMAP_FILE_RANGE, 1,
160 [fops->remap_file_range() is available])