Re: RFC: Does ZFS block cloning do this?
- In reply to: Dag-Erling_Smørgrav : "Re: RFC: Does ZFS block cloning do this?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 06 Aug 2025 15:58:09 UTC
On Wed, Aug 6, 2025 at 8:55 AM Dag-Erling Smørgrav <des@freebsd.org> wrote: > > 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. Yes, as I just posted, I think a flag should be sufficient. > > 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. For the CLONE case (indicated by the flag) it would need to run to completion. (It can only be allowed if that is guaranteed to not take more than 1-2sec. That is why NFSv4.2 has a separate CLONE operation.) rick > > DES > -- > Dag-Erling Smørgrav - des@FreeBSD.org