mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Add support to decode a resume token
Adding a new subcommand to zstream called token. This now allows users to decode a resume token to retrieve the toname field. This can be useful for tools that need this information. The syntax works as follows zstream token <resume_token>. Reviewed-by: Matt Ahrens <matt@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Paul Zuchowski <pzuchowski@datto.com> Signed-off-by: Tony Perkins <tperkins@datto.com> Closes #10558
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
#
|
||||
# Copyright (c) 2013, 2018 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2020 by Datto Inc. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -657,6 +658,21 @@ function resume_test
|
||||
log_must zfs recv -suv $recvfs </$streamfs/$stream_num
|
||||
}
|
||||
|
||||
function get_resume_token
|
||||
{
|
||||
sendcmd=$1
|
||||
streamfs=$2
|
||||
recvfs=$3
|
||||
|
||||
log_must eval "$sendcmd > /$streamfs/1"
|
||||
mess_send_file /$streamfs/1
|
||||
log_mustnot zfs recv -suv $recvfs < /$streamfs/1 2>&1
|
||||
token=$(zfs get -Hp -o value receive_resume_token $recvfs)
|
||||
echo "$token" > /$streamfs/resume_token
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Setup filesystems for the resumable send/receive tests
|
||||
#
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2020 by Datto, Inc. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/tests/functional/rsend/rsend.kshlib
|
||||
@@ -26,6 +27,9 @@
|
||||
# 1. Create a full compressed send stream
|
||||
# 2. Verify zstreamdump shows this stream has the relevant features
|
||||
# 3. Verify zstreamdump's accounting of logical and compressed size is correct
|
||||
# 4. Verify the toname from a resume token
|
||||
# 5. Verify it fails with corrupted resume token
|
||||
# 6. Verify it fails with missing resume token
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
@@ -34,8 +38,11 @@ log_assert "Verify zstreamdump correctly interprets compressed send streams."
|
||||
log_onexit cleanup_pool $POOL2
|
||||
|
||||
typeset sendfs=$POOL2/fs
|
||||
typeset streamfs=$POOL2/fs2
|
||||
typeset recvfs=$POOL2/fs3
|
||||
|
||||
log_must zfs create -o compress=lz4 $sendfs
|
||||
log_must zfs create -o compress=lz4 $streamfs
|
||||
typeset dir=$(get_prop mountpoint $sendfs)
|
||||
write_compressible $dir 16m
|
||||
log_must zfs snapshot $sendfs@full
|
||||
@@ -56,4 +63,13 @@ csize_prop=$(get_prop used $sendfs)
|
||||
within_percent $csize $csize_prop 90 || log_fail \
|
||||
"$csize and $csize_prop differed by too much"
|
||||
|
||||
x=$(get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs)
|
||||
resume_token=$(cat /$streamfs/resume_token)
|
||||
to_name_fs=$sendfs
|
||||
log_must eval "zstream token $resume_token | grep $to_name_fs"
|
||||
|
||||
bad_resume_token="1-1162e8285b-100789c6360"
|
||||
log_mustnot eval "zstream token $bad_resume_token 2>&1"
|
||||
log_mustnot eval "zstream token 2>&1"
|
||||
|
||||
log_pass "zstreamdump correctly interprets compressed send streams."
|
||||
|
||||
Reference in New Issue
Block a user