From aee1dd4d983c64db3c3155290d48f05243e85709 Mon Sep 17 00:00:00 2001 From: LOLi Date: Wed, 11 Oct 2017 00:22:05 +0200 Subject: Fix intra-pool resumable 'zfs send -t ' Because resuming from a token requires "guid" -> "snapshot" mapping we have to walk the whole dataset hierarchy to find the right snapshot to send; when both source and destination exists, for an incremental resumable stream, libzfs gets confused and picks up the wrong snapshot to send from: this results in attempting to send "destination@snap1 -> source@snap2" instead of "source@snap1 -> source@snap2" which fails with a "Invalid cross-device link" error (EXDEV). Fix this by adjusting the logic behind dataset traversal in zfs_iter_children() to pick the right snapshot to send from. Additionally update dry-run 'zfs send -t' to print its output to stderr: this is consistent with other dry-run commands. Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: loli10K Closes #6618 Closes #6619 Closes #6623 --- tests/zfs-tests/tests/functional/rsend/rsend.kshlib | 10 +++++----- tests/zfs-tests/tests/functional/rsend/rsend_019_pos.ksh | 4 ++-- tests/zfs-tests/tests/functional/rsend/rsend_020_pos.ksh | 2 +- tests/zfs-tests/tests/functional/rsend/rsend_021_pos.ksh | 2 +- tests/zfs-tests/tests/functional/rsend/rsend_022_pos.ksh | 2 +- tests/zfs-tests/tests/functional/rsend/rsend_024_pos.ksh | 2 +- tests/zfs-tests/tests/functional/rsend/send-c_resume.ksh | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 7c4b2f07f..909cd1677 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -505,11 +505,13 @@ function test_fs_setup { typeset sendfs=$1 typeset recvfs=$2 + typeset streamfs=$3 typeset sendpool=${sendfs%%/*} typeset recvpool=${recvfs%%/*} datasetexists $sendfs && log_must_busy zfs destroy -r $sendpool datasetexists $recvfs && log_must_busy zfs destroy -r $recvpool + datasetexists $streamfs && log_must_busy zfs destroy -r $streamfs if $(datasetexists $sendfs || zfs create -o compress=lz4 $sendfs); then mk_files 1000 256 0 $sendfs & @@ -538,10 +540,7 @@ function test_fs_setup ">/$sendpool/incremental.zsend" fi - if datasetexists $streamfs; then - log_must_busy zfs destroy -r $streamfs - fi - log_must zfs create -o compress=lz4 $sendpool/stream + log_must zfs create -o compress=lz4 $streamfs } # @@ -655,9 +654,10 @@ function resume_cleanup { typeset sendfs=$1 typeset streamfs=$2 + typeset sendpool=${sendfs%%/*} datasetexists $sendfs && log_must_busy zfs destroy -r $sendfs datasetexists $streamfs && log_must_busy zfs destroy -r $streamfs cleanup_pool $POOL2 - rm -f /$POOL/initial.zsend /$POOL/incremental.zsend + rm -f /$sendpool/initial.zsend /$sendpool/incremental.zsend } diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_019_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_019_pos.ksh index f76bce9d0..1a39832a1 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_019_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_019_pos.ksh @@ -48,8 +48,8 @@ sendfs=$POOL/sendfs recvfs=$POOL3/recvfs streamfs=$POOL2/stream -for sendfs in $POOL2/sendfs $POOL2; do - test_fs_setup $sendfs $recvfs +for sendfs in $POOL2/sendfs $POOL3; do + test_fs_setup $sendfs $recvfs $streamfs resume_test "zfs send -v $sendfs@a" $streamfs $recvfs resume_test "zfs send -v -i @a $sendfs@b" $streamfs $recvfs file_check $sendfs $recvfs diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_020_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_020_pos.ksh index 9f1530b45..a6474a4e5 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_020_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_020_pos.ksh @@ -47,7 +47,7 @@ streamfs=$POOL/stream log_onexit resume_cleanup $sendfs $streamfs -test_fs_setup $sendfs $recvfs +test_fs_setup $sendfs $recvfs $streamfs resume_test "zfs send -D -v $sendfs@a" $streamfs $recvfs file_check $sendfs $recvfs diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_021_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_021_pos.ksh index 54d56c9a6..47b9fdcb6 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_021_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_021_pos.ksh @@ -49,7 +49,7 @@ streamfs=$POOL/stream log_onexit resume_cleanup $sendfs $streamfs -test_fs_setup $sendfs $recvfs +test_fs_setup $sendfs $recvfs $streamfs resume_test "zfs send -v -e $sendfs@a" $streamfs $recvfs resume_test "zfs send -v -e -i @a $sendfs@b" $streamfs $recvfs file_check $sendfs $recvfs diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_022_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_022_pos.ksh index ff51fecaf..28e19b5ec 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_022_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_022_pos.ksh @@ -52,7 +52,7 @@ streamfs=$POOL/stream log_onexit resume_cleanup $sendfs $streamfs -test_fs_setup $sendfs $recvfs +test_fs_setup $sendfs $recvfs $streamfs log_must zfs bookmark $sendfs@a $sendfs#bm_a log_must_busy zfs destroy $sendfs@a log_must zfs receive -v $recvfs