Skip to content

ioctl: remove FICLONE/FICLONERANGE/FIDEDUPERANGE compat #17308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions include/os/linux/zfs/sys/zpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,41 +123,6 @@ extern int zpl_clone_file_range(struct file *src_file, loff_t src_off,
extern int zpl_dedupe_file_range(struct file *src_file, loff_t src_off,
struct file *dst_file, loff_t dst_off, uint64_t len);

/* compat for FICLONE/FICLONERANGE/FIDEDUPERANGE ioctls */
typedef struct {
int64_t fcr_src_fd;
uint64_t fcr_src_offset;
uint64_t fcr_src_length;
uint64_t fcr_dest_offset;
} zfs_ioc_compat_file_clone_range_t;

typedef struct {
int64_t fdri_dest_fd;
uint64_t fdri_dest_offset;
uint64_t fdri_bytes_deduped;
int32_t fdri_status;
uint32_t fdri_reserved;
} zfs_ioc_compat_dedupe_range_info_t;

typedef struct {
uint64_t fdr_src_offset;
uint64_t fdr_src_length;
uint16_t fdr_dest_count;
uint16_t fdr_reserved1;
uint32_t fdr_reserved2;
zfs_ioc_compat_dedupe_range_info_t fdr_info[];
} zfs_ioc_compat_dedupe_range_t;

#define ZFS_IOC_COMPAT_FICLONE _IOW(0x94, 9, int)
#define ZFS_IOC_COMPAT_FICLONERANGE \
_IOW(0x94, 13, zfs_ioc_compat_file_clone_range_t)
#define ZFS_IOC_COMPAT_FIDEDUPERANGE \
_IOWR(0x94, 54, zfs_ioc_compat_dedupe_range_t)

extern long zpl_ioctl_ficlone(struct file *filp, void *arg);
extern long zpl_ioctl_ficlonerange(struct file *filp, void *arg);
extern long zpl_ioctl_fideduperange(struct file *filp, void *arg);


#if defined(HAVE_INODE_TIMESTAMP_TRUNCATE)
#define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip)
Expand Down
6 changes: 0 additions & 6 deletions module/os/linux/zfs/zpl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,12 +1004,6 @@ zpl_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return (zpl_ioctl_getdosflags(filp, (void *)arg));
case ZFS_IOC_SETDOSFLAGS:
return (zpl_ioctl_setdosflags(filp, (void *)arg));
case ZFS_IOC_COMPAT_FICLONE:
return (zpl_ioctl_ficlone(filp, (void *)arg));
case ZFS_IOC_COMPAT_FICLONERANGE:
return (zpl_ioctl_ficlonerange(filp, (void *)arg));
case ZFS_IOC_COMPAT_FIDEDUPERANGE:
return (zpl_ioctl_fideduperange(filp, (void *)arg));
default:
return (-ENOTTY);
}
Expand Down
82 changes: 0 additions & 82 deletions module/os/linux/zfs/zpl_file_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,85 +212,3 @@ zpl_dedupe_file_range(struct file *src_file, loff_t src_off,
return (-EOPNOTSUPP);
}
#endif /* HAVE_VFS_DEDUPE_FILE_RANGE */

/* Entry point for FICLONE, before Linux 4.5. */
long
zpl_ioctl_ficlone(struct file *dst_file, void *arg)
{
unsigned long sfd = (unsigned long)arg;

struct file *src_file = fget(sfd);
if (src_file == NULL)
return (-EBADF);

if (dst_file->f_op != src_file->f_op) {
fput(src_file);
return (-EXDEV);
}

size_t len = i_size_read(file_inode(src_file));

ssize_t ret = zpl_clone_file_range_impl(src_file, 0, dst_file, 0, len);

fput(src_file);

if (ret < 0) {
if (ret == -EOPNOTSUPP)
return (-ENOTTY);
return (ret);
}

if (ret != len)
return (-EINVAL);

return (0);
}

/* Entry point for FICLONERANGE, before Linux 4.5. */
long
zpl_ioctl_ficlonerange(struct file *dst_file, void __user *arg)
{
zfs_ioc_compat_file_clone_range_t fcr;

if (copy_from_user(&fcr, arg, sizeof (fcr)))
return (-EFAULT);

struct file *src_file = fget(fcr.fcr_src_fd);
if (src_file == NULL)
return (-EBADF);

if (dst_file->f_op != src_file->f_op) {
fput(src_file);
return (-EXDEV);
}

size_t len = fcr.fcr_src_length;
if (len == 0)
len = i_size_read(file_inode(src_file)) - fcr.fcr_src_offset;

ssize_t ret = zpl_clone_file_range_impl(src_file, fcr.fcr_src_offset,
dst_file, fcr.fcr_dest_offset, len);

fput(src_file);

if (ret < 0) {
if (ret == -EOPNOTSUPP)
return (-ENOTTY);
return (ret);
}

if (ret != len)
return (-EINVAL);

return (0);
}

/* Entry point for FIDEDUPERANGE, before Linux 4.5. */
long
zpl_ioctl_fideduperange(struct file *filp, void *arg)
{
(void) arg;

/* No support for dedup yet */
return (-ENOTTY);
}
7 changes: 0 additions & 7 deletions tests/zfs-tests/tests/functional/bclone/bclone_common.kshlib
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ export RECORDSIZE=$(zfs get -Hp -o value recordsize $TESTPOOL/$TESTFS)
MINBLKSIZE1=512
MINBLKSIZE2=1024

function verify_block_cloning
{
if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi
}

function verify_crossfs_block_cloning
{
if is_linux && [[ $(linux_version) -lt $(linux_version "5.3") ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify various corner cases in block cloning across datasets"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify various corner cases in block cloning across datasets"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning properly clones regular files across datasets"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning properly clones small files (with embedded blocks) across datasets"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning properly clones sparse files (files with holes) across datasets"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning across datasets with different properties"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning across datasets with different checksum properties"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning across datasets with different compression properties"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning across datasets with different copies properties"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning across datasets with different recordsize properties"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

verify_runnable "both"

verify_block_cloning
verify_crossfs_block_cloning

log_assert "Verify block cloning with all sync property settings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

verify_runnable "both"

verify_block_cloning

log_assert "Verify various corner cases in block cloning within the same dataset"

# Disable compression to make sure we won't use embedded blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

verify_runnable "both"

verify_block_cloning

log_assert "Verify various corner cases in block cloning within the same dataset"

# Disable compression to make sure we won't use embedded blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

verify_runnable "both"

verify_block_cloning

log_assert "Verify block cloning properly clones regular files within the same dataset"

# Disable compression to make sure we won't use embedded blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

verify_runnable "both"

verify_block_cloning

log_assert "Verify block cloning properly clones small files (with embedded blocks) within the same dataset"

# Enable ZLE compression to make sure what is the maximum amount of data we
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

verify_runnable "both"

verify_block_cloning

log_assert "Verify block cloning properly clones sparse files (files with holes) within the same dataset"

# Compression doesn't matter here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

VDIR=$TEST_BASE_DIR/disk-bclone
VDEV="$VDIR/a"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

VDIR=$TEST_BASE_DIR/disk-bclone
VDEV="$VDIR/a"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

claim="The copy_file_range syscall can clone whole files."

log_assert $claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

claim="copy_file_range will fall back to copy when cloning not possible."

log_assert $claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

claim="copy_file_range will fall back to copy when cloning on same txg"

log_assert $claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

claim="The copy_file_range syscall can clone parts of a file."

log_assert $claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

claim="The copy_file_range syscall copies files when block cloning is disabled."

log_assert $claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

claim="The first clone at a large offset is functional"

log_assert $claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

VDIR=$TEST_BASE_DIR/disk-bclone
VDEV="$VDIR/a $VDIR/b $VDIR/c"
LDEV="$VDIR/e $VDIR/f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@

verify_runnable "global"

if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

export VDIR=$TEST_BASE_DIR/disk-bclone
export VDEV="$VDIR/a $VDIR/b $VDIR/c"
export LDEV="$VDIR/e $VDIR/f"
Expand Down
Loading