zfs/include/os/freebsd/zfs/sys
Brian Behlendorf 6dccdf501e
BRT: Fix FICLONE/FICLONERANGE shortened copy
On Linux the ioctl_ficlonerange() and ioctl_ficlone() system calls
are expected to either fully clone the specified range or return an
error.  The range may be for an entire file.  While internally ZFS
supports cloning partial ranges there's no way to return the length
cloned to the caller so we need to make this all or nothing.

As part of this change support for the REMAP_FILE_CAN_SHORTEN flag
has been added.  When REMAP_FILE_CAN_SHORTEN is set zfs_clone_range()
will return a shortened range when encountering pending dirty records.
When it's clear zfs_clone_range() will block and wait for the records
to be written out allowing the blocks to be cloned.

Furthermore, the file range lock is held over the region being cloned
to prevent it from being modified while cloning.  This doesn't quite
provide an atomic semantics since if an error is encountered only a
portion of the range may be cloned.  This will be converted to an
error if REMAP_FILE_CAN_SHORTEN was not provided and returned to the
caller.  However, the destination file range is left in an undefined
state.

A test case has been added which exercises this functionality by
verifying that `cp --reflink=never|auto|always` works correctly.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #15728
Closes #15842
2024-02-05 16:44:45 -08:00
..
arc_os.h FreeBSD: Reduce divergence from in-tree sources 2023-10-09 13:27:18 -07:00
freebsd_crypto.h module: icp: fold away all key formats except CRYPTO_KEY_RAW 2022-02-15 16:25:07 -08:00
freebsd_event.h FreeBSD: Reduce divergence from in-tree sources 2023-10-09 13:27:18 -07:00
vdev_os.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_bootenv_os.h zfs label bootenv should store data as nvlist 2020-09-15 15:42:27 -07:00
zfs_context_os.h FreeBSD: Reduce divergence from in-tree sources 2023-10-09 13:27:18 -07:00
zfs_ctldir.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_dir.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zfs_ioctl_compat.h freebsd: add ifdefs around legacy ioctl support 2022-11-07 15:55:26 -08:00
zfs_vfsops_os.h BRT: Fix FICLONE/FICLONERANGE shortened copy 2024-02-05 16:44:45 -08:00
zfs_vnops_os.h Linux 6.3 compat: idmapped mount API changes 2023-04-10 14:15:36 -07:00
zfs_znode_impl.h Implementation of block cloning for ZFS 2023-03-10 11:59:53 -08:00
zpl.h Add FreeBSD support to OpenZFS 2020-04-14 11:36:28 -07:00