Don't let copy_file_range() use clones

I'm seeing a silly regression in generic/430: now that clones are
implemented, copy_file_range() has started to use them under the hood,
but it only wants to clone a portion of the file, and that's not
something I'm interested in supporting.

To avoid this on newer kernels, set ->copy_file_range() to the generic
implementation. For older kernels, start throwing errors if anything
calls apfs_remap_file_range() for partial ranges. This is the right
thing to do in general, since we don't support that.

Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
This commit is contained in:
Ernesto A. Fernández
2023-03-17 16:38:15 -03:00
parent b00b571757
commit 396650b056
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -1504,6 +1504,10 @@ loff_t apfs_remap_file_range(struct file *src_file, loff_t off, struct file *dst
if (src_inode == dst_inode)
return -EINVAL;
/* We only want to clone whole files, like in the official driver */
if (off != 0 || destoff != 0 || len != 0)
return -EINVAL;
/*
* Clones here work in two steps: first the user creates an empty target
* file, and then the user calls the ioctl, which replaces the file with
+1
View File
@@ -137,6 +137,7 @@ const struct file_operations apfs_file_operations = {
.open = generic_file_open,
.fsync = apfs_fsync,
.unlocked_ioctl = apfs_file_ioctl,
.copy_file_range = generic_copy_file_range,
.remap_file_range = apfs_remap_file_range,
};