Skip to content

Commit

Permalink
fix(syncoid): zfs send arg allowlist when sendsource is receivetoken
Browse files Browse the repository at this point in the history
The `runsynccmd` subroutine was not matching the `$sendsource` when a
receive resume token is passed in. All usages that pass in the receive
resume token do not begin with a space; instead, they start with `-t `.

Fixes: jimsalterjrs#918
  • Loading branch information
Deltik committed Apr 24, 2024
1 parent b31ed6e commit afc2d7d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion syncoid
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ sub runsynccmd {

my $disp_pvsize = $pvsize == 0 ? 'UNKNOWN' : readablebytes($pvsize);
my $sendoptions;
if ($sendsource =~ / -t /) {
if ($sendsource =~ /^-t /) {
$sendoptions = getoptionsline(\@sendoptions, ('P','V','e','v'));
} elsif ($sendsource =~ /#/) {
$sendoptions = getoptionsline(\@sendoptions, ('L','V','c','e','w'));
Expand Down
48 changes: 48 additions & 0 deletions tests/syncoid/012_receive_resume_token/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# test verifying syncoid behavior with partial transfers

set -x
set -e

. ../../common/lib.sh

if [ -z "$ALLOW_INVASIVE_TESTS" ]; then
exit 130
fi

POOL_IMAGE="/tmp/jimsalterjrs_sanoid_918.img"
POOL_SIZE="128M"
POOL_NAME="jimsalterjrs_sanoid_918"

truncate -s "${POOL_SIZE}" "${POOL_IMAGE}"

zpool create -f "${POOL_NAME}" "${POOL_IMAGE}"

function cleanUp {
zpool destroy "${POOL_NAME}"
rm -f "${POOL_IMAGE}"
}

# Clean up the pool and image file on exit
trap cleanUp EXIT

zfs create "${POOL_NAME}/source"
zfs snap "${POOL_NAME}/source@empty"
dd if=/dev/urandom of="/${POOL_NAME}/source/garbage.bin" bs=1M count=16
zfs snap "${POOL_NAME}/source@something"

# Simulate interrupted transfer
zfs send -pwR "${POOL_NAME}/source@something" | head --bytes=8M | zfs recv -s "${POOL_NAME}/destination"

# Using syncoid to continue interrupted transfer
../../../syncoid --sendoptions="pw" "${POOL_NAME}/source" "${POOL_NAME}/destination"

# Verify success based on exit status
if [ $? -ne 0 ]; then
echo "Regression detected: syncoid did not handle the resuming correctly."
exit 1
else
echo "Test passed: syncoid resumed transfer successfully."
exit 0
fi

0 comments on commit afc2d7d

Please sign in to comment.