-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix raw sends on encrypted datasets when copying back snapshots #11221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
tests/zfs-tests/tests/functional/userquota/userspace_send_encrypted.ksh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright 2020, George Amanakis <[email protected]>. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib | ||
|
||
# | ||
# DESCRIPTION: | ||
# Sending raw encrypted datasets back to the source dataset succeeds. | ||
# | ||
# | ||
# STRATEGY: | ||
# 1. Create encrypted source dataset, set userquota and write a file | ||
# 2. Create base and an additional snapshot (s1) | ||
# 3. Unmount the source dataset | ||
# 4. Raw send the base snapshot to a new target dataset | ||
# 5. Raw send incrementally the s1 snapshot to the new target dataset | ||
# 6. Mount both source and target datasets | ||
# 7. Verify encrypted datasets support 'zfs userspace' and 'zfs groupspace' | ||
# and the accounting is done correctly | ||
# | ||
|
||
function cleanup | ||
{ | ||
destroy_pool $POOLNAME | ||
rm -f $FILEDEV | ||
} | ||
|
||
function log_must_unsupported | ||
{ | ||
log_must_retry "unsupported" 3 "$@" | ||
(( $? != 0 )) && log_fail | ||
} | ||
|
||
log_onexit cleanup | ||
|
||
FILEDEV="$TEST_BASE_DIR/userspace_encrypted" | ||
POOLNAME="testpool$$" | ||
ENC_SOURCE="$POOLNAME/source" | ||
ENC_TARGET="$POOLNAME/target" | ||
|
||
log_assert "Sending raw encrypted datasets back to the source dataset succeeds." | ||
|
||
# Setup | ||
truncate -s 200m $FILEDEV | ||
log_must zpool create -o feature@encryption=enabled $POOLNAME \ | ||
$FILEDEV | ||
|
||
# Create encrypted source dataset | ||
log_must eval "echo 'password' | zfs create -o encryption=on" \ | ||
"-o keyformat=passphrase -o keylocation=prompt " \ | ||
"$ENC_SOURCE" | ||
|
||
# Set user quota and write file | ||
log_must zfs set userquota@$QUSER1=50m $ENC_SOURCE | ||
mkmount_writable $ENC_SOURCE | ||
mntpnt=$(get_prop mountpoint $ENC_SOURCE) | ||
log_must user_run $QUSER1 mkfile 20m /$mntpnt/file | ||
sync | ||
|
||
# Snapshot, raw send to new dataset | ||
log_must zfs snap $ENC_SOURCE@base | ||
log_must zfs snap $ENC_SOURCE@s1 | ||
log_must zfs umount $ENC_SOURCE | ||
log_must eval "zfs send -w $ENC_SOURCE@base | zfs recv " \ | ||
"$ENC_TARGET" | ||
|
||
log_must eval "zfs send -w -i @base $ENC_SOURCE@s1 | zfs recv " \ | ||
"$ENC_TARGET" | ||
|
||
log_must zfs destroy $ENC_SOURCE@s1 | ||
log_must eval "zfs send -w -i @base $ENC_TARGET@s1 | zfs recv " \ | ||
"$ENC_SOURCE" | ||
|
||
# Mount encrypted datasets and verify they support 'zfs userspace' and | ||
# 'zfs groupspace' and the accounting is done correctly | ||
log_must zfs mount $ENC_SOURCE | ||
log_must eval "echo password | zfs load-key $ENC_TARGET" | ||
log_must zfs mount $ENC_TARGET | ||
sync | ||
|
||
src_uspace=$(( $(zfs userspace -Hp $ENC_SOURCE | grep $QUSER1 | \ | ||
awk '{print $4}')/1024/1024)) | ||
tgt_uspace=$(( $(zfs userspace -Hp $ENC_TARGET | grep $QUSER1 | \ | ||
awk '{print $4}')/1024/1024)) | ||
log_must test "$src_uspace" -eq "$tgt_uspace" | ||
|
||
src_uquota=$(zfs userspace -Hp $ENC_SOURCE | grep $QUSER1 | awk '{print $5}') | ||
tgt_uquota=$(zfs userspace -Hp $ENC_TARGET | grep $QUSER1 | awk '{print $5}') | ||
log_must test "$src_uquota" -eq "$tgt_uquota" | ||
|
||
# Cleanup | ||
cleanup | ||
|
||
log_pass "Sending raw encrypted datasets back to the source dataset succeeds." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.