mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
optimize recv_fix_encryption_hierarchy()
recv_fix_encryption_hierarchy() in its present state goes through all stream filesystems, and for each one traverses the snapshots in order to find one that exists locally. This happens by calling guid_to_name() for each snapshot, which iterates through all children of the filesystem. This results in CPU utilization of 100% for several minutes (for ~1000 filesystems on a Ryzen 4350G) for 1 thread at the end of a raw receive (-w, regardless whether encrypted or not, dryrun or not). Fix this by following a different logic: using the top_fs name, call gather_nvlist() to gather the nvlists for all local filesystems. For each one filesystem, go through the snapshots to find the corresponding stream's filesystem (since we know the snapshots guid and can search with it in stream_avl for the stream's fs). Then go on to fix the encryption roots and locations as in its present state. Avoiding guid_to_name() iteratively makes recv_fix_encryption_hierarchy() significantly faster (from several minutes to seconds for ~1000 filesystems on a Ryzen 4350G). Another problem is the following: in case we have promoted a clone of the filesystem outside the top filesystem specified in zfs send, zfs receive does not fail but returns an error: recv_incremental_replication() fails to find its origin and errors out with needagain=1. This results in recv_fix_hierarchy() not being called which may render some children of the top fs not mountable since their encryption root was not updated. To circumvent this make recv_incremental_replication() silently ignore this error. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes #16929
This commit is contained in:
committed by
Ameer Hamza
parent
a0f8d3c584
commit
7784947923
@@ -61,16 +61,17 @@ log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/fs-before-R"
|
||||
dstds=$(get_dst_ds $POOL/$FS $POOL2)
|
||||
log_must cmp_ds_subs $POOL/$FS $dstds
|
||||
|
||||
log_must verify_encryption_root $POOL/$FS $POOL/$FS
|
||||
log_must verify_keylocation $POOL/$FS "prompt"
|
||||
log_must verify_origin $POOL/$FS "-"
|
||||
log_must verify_encryption_root $POOL2/$FS $POOL2/$FS
|
||||
log_must verify_keylocation $POOL2/$FS "prompt"
|
||||
log_must verify_origin $POOL2/$FS "-"
|
||||
|
||||
log_must verify_encryption_root $POOL/clone $POOL/$FS
|
||||
log_must verify_keylocation $POOL/clone "none"
|
||||
log_must verify_origin $POOL/clone "$POOL/$FS@snap"
|
||||
log_must verify_encryption_root $POOL2/clone $POOL2/$FS
|
||||
log_must verify_keylocation $POOL2/clone "none"
|
||||
log_must verify_origin $POOL2/clone "$POOL2/$FS@snap"
|
||||
|
||||
log_must verify_encryption_root $POOL/$FS/child $POOL/$FS
|
||||
log_must verify_keylocation $POOL/$FS/child "none"
|
||||
log_must verify_encryption_root $POOL2/$FS/child $POOL2/$FS
|
||||
log_must verify_keylocation $POOL2/$FS/child "none"
|
||||
|
||||
# Alter the hierarchy and re-send
|
||||
log_must eval "echo $PASSPHRASE1 | zfs change-key -o keyformat=passphrase" \
|
||||
@@ -93,4 +94,20 @@ log_must verify_origin $POOL/clone "-"
|
||||
log_must verify_encryption_root $POOL/$FS/child $POOL/$FS/child
|
||||
log_must verify_keylocation $POOL/$FS/child "prompt"
|
||||
|
||||
log_must verify_encryption_root $POOL2 "-"
|
||||
log_must verify_encryption_root $POOL2/clone $POOL2/clone
|
||||
log_must verify_encryption_root $POOL2/$FS $POOL2/clone
|
||||
log_must verify_encryption_root $POOL2/$FS/child $POOL2/$FS/child
|
||||
|
||||
log_must verify_keylocation $POOL2 "none"
|
||||
log_must verify_keylocation $POOL2/clone "prompt"
|
||||
log_must verify_keylocation $POOL2/$FS "none"
|
||||
log_must verify_keylocation $POOL2/$FS/child "prompt"
|
||||
|
||||
log_must verify_origin $POOL2 "-"
|
||||
log_must verify_origin $POOL2/clone "-"
|
||||
log_must verify_origin $POOL2/$FS "$POOL2/clone@snap"
|
||||
log_must verify_origin $POOL2/$FS/child "-"
|
||||
log_must zfs list
|
||||
|
||||
log_pass "Raw recursive sends preserve filesystem structure."
|
||||
|
||||
Reference in New Issue
Block a user