HomeFreeBSD

vfs: Add support for file cloning to VOP_COPY_FILE_RANGE

Description

vfs: Add support for file cloning to VOP_COPY_FILE_RANGE

NFSv4 has a separate CLONE operation from COPY with
a couple of semantics differences. Unlike COPY, CLONE
must complete the "copy on write" and cannot return
partially copied. It also is required to use offsets (and
the length if not to EOF) that are aligned to a buffer
boundary.

Since VOP_COPY_FILE_RANGE() can already do "copy on write"
for file systems that support it, such as ZFS with block
cloning enabled, all this patch does is add a flag called
COPY_FILE_RANGE_CLONE so that it will conform to the
rule that it must do a "copy on write" to completion.

The patch also adds a new pathconf(2) name _PC_CLONE_BLKSIZE,
which acquires the blocksize requirement for cloning and
returns 0 for file systems that do not support the
"copy on write" feature. (This is needed for the NFSv4.2
clone_blksize attribute.)

This patch will allow the implementation of CLONE
for NFSv4.2.

Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D51808

Details

Provenance
rmacklemAuthored on Aug 8 2025, 12:52 AM
Reviewer
asomers
Differential Revision
D51808: vfs: Add support for file cloning to VOP_COPY_FILE_RANGE
Parents
rGe4c0ecba44b2: 15.0: Update main to -PRERELEASE
Branches
Unknown
Tags
Unknown