Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Aug 2025 17:55:26 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        Rick Macklem <rick.macklem@gmail.com>
Cc:        FreeBSD CURRENT <freebsd-current@freebsd.org>
Subject:   Re: RFC: Does ZFS block cloning do this?
Message-ID:  <86bjos5tsh.fsf@ltc.des.dev>
In-Reply-To: <CAM5tNy7V7Btem%2ByWNK7oyn9qsk6TrQwuGo1kxqhCstLM4_uh9g@mail.gmail.com> (Rick Macklem's message of "Wed, 6 Aug 2025 08:17:10 -0700")
References:  <CAM5tNy7V7Btem%2ByWNK7oyn9qsk6TrQwuGo1kxqhCstLM4_uh9g@mail.gmail.com>

index | next in thread | previous in thread | raw e-mail

Rick Macklem <rick.macklem@gmail.com> writes:
> NFSv4.2 has a CLONE operation. It is described as doing:
>    The CLONE operation is used to clone file content from a source file
>    specified by the SAVED_FH value into a destination file specified by
>    CURRENT_FH without actually copying the data, e.g., by using a
>    copy-on-write mechanism.
> [...]
> Does ZFS block cloning do this?

The question you should be asking is “does FreeBSD currently provide
something that could be used to implement this” and the answer is
VOP_COPY_FILE_RANGE(9).  It will copy the data if the underlying
filesystem does not provide a no-copy mechanism or if that mechanism
can't be used (e.g. the files are in different pools), but it shouldn't
be difficult to add a flag; calling VOP_COPY_FILE_RANGE() with that flag
would implement intra-server CLONE, and calling it without the flag
would implement intra-server COPY.

Note that VOP_COPY_FILE_RANGE() does not always copy the entire file in
a single operation; you will have to call it in a loop until len is zero
or an error occurs.

DES
-- 
Dag-Erling Smørgrav - des@FreeBSD.org


help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86bjos5tsh.fsf>