Block cloning between datasets

(posting this here because it involves a TrueNAS system, though I think the answers are more general ZFS)

I have a legacy dataset that has been upgraded from the FreeNAS days to the current release of TrueNAS Community. It’s time to reorganize and move some files out of my monolithic dataset into different sets in the same pool. I have backups that I am using to do this. I tried copying groups of directories from the old dataset to a new one (in the same pool) using cp -r --reflink=always but it fails even though block cloning is enabled on the pool.

Questions:

  1. does block cloning work between datasets (I thought yes)?
  2. If yes, what should I start looking at to get cp w/ --reflink=always to work (speed and diskspace are my motivators here)
  3. as a last resort can I just us mv to shift directories & files from one dataset to another?

-ck

1 Like

If cp --reflink=always works within a dataset, but not across dataset boundaries, I am unaware of any tunable or config setting that would change that behavior. To the best of my knowledge, ZFS block cloning is either enabled or not, there’s no further configurability.

It’s my understanding that block cloning across datasets works properly under FreeBSD, but has not worked on Linux since kernel 4.5. On Linux, the relevant system call is ioctl(FICLONE), which cp --reflink=always uses, and which fails if called across dataset (or other filesystem) boundaries.

There’s another system call ioctl(FIDEDUPERANGE) which is useful for block-level deduplicating files–OpenZFS does not currently support that system call at all, and if a copy or dedup utility depends on that system call with no fallbacks to others, it will fail every time (whether inside the same filesystem boundary or not).

1 Like

This isn’t quite what I hoped to hear, but it’s great to have this confirmed. Thanks, Jim.
-ck

1 Like