Skip to content

Commit

Permalink
Fix block cloning between unencrypted and encrypted datasets
Browse files Browse the repository at this point in the history
When copying data to or from an encrypted dataset, block cloning
should be used only when it is the same dataset. The current code
checked only if the source was encrypted and the check should
happen more early to avoid unnecessary operations.

We may relax this condition in the future by supporting block cloning
between encrypted datasets using the same key.

Fixes #15464

Signed-off-by:  Martin Matuska <[email protected]>
  • Loading branch information
mmatuska committed Oct 30, 2023
1 parent 043c6ee commit 1b435a9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,17 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,

ASSERT(!outzfsvfs->z_replay);

/*
* If source and destination are not the same filesystem
* neither may be encrypted.
* TODO: Support of cloning encrypted datasets with identical keys
*/
if (inzfsvfs != outzfsvfs &&
(inos->os_encrypted || outos->os_encrypted)) {
zfs_exit_two(inzfsvfs, outzfsvfs, FTAG);
return (SET_ERROR(EXDEV));
}

error = zfs_verify_zp(inzp);
if (error == 0)
error = zfs_verify_zp(outzp);
Expand Down

0 comments on commit 1b435a9

Please sign in to comment.