Enforce "-F" flag on resuming recv of full/newfs on existing dataset

When receiving full/newfs on existing dataset, then it should be done
with "-F" flag. Its enforced for initial receive in checks done in
zfs_receive_one function of libzfs. Similarly, on resuming full/newfs
recv on existing dataset, it should be done with "-F" flag.

When dataset doesn't exist, then full/new recv is done on newly created
dataset and it's marked INCONSISTENT. But when receiving on existing
dataset, recv is first done on %recv and its marked INCONSISTENT.
Existing dataset is not marked INCONSISTENT. Resume of full/newfs
receive with dataset not INCONSISTENT indicates that its resuming newfs
on existing dataset. So, enforce "-F" flag in this case.

Also return an error from dmu_recv_resume_begin_check() in zfs kernel,
when its resuming full/newfs recv without force.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@nutanix.com>
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #13856
Closes #13857
This commit is contained in:
Jitendra Patidar
2022-09-28 05:04:27 +05:30
committed by GitHub
parent a2163a96ae
commit 3ed9d6883b
9 changed files with 127 additions and 3 deletions
+1
View File
@@ -1780,6 +1780,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/rsend/rsend_027_pos.ksh \
functional/rsend/rsend_028_neg.ksh \
functional/rsend/rsend_029_neg.ksh \
functional/rsend/rsend_030_pos.ksh \
functional/rsend/send-c_embedded_blocks.ksh \
functional/rsend/send-c_incremental.ksh \
functional/rsend/send-c_lz4_disabled.ksh \
+66
View File
@@ -0,0 +1,66 @@
#!/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 (c) 2022 by Nutanix. All rights reserved.
#
. $STF_SUITE/tests/functional/rsend/rsend.kshlib
#
# Description:
# Verify resumability of full ZFS send/receive on existing dataset
#
# Strategy:
# 1. Start a full ZFS send with redirect output to a file
# 2. Mess up the contents of the stream state file on disk
# 3. Try ZFS receive, which should fail with a checksum mismatch error
# 4. ZFS send to the stream state file again using the receive_resume_token
# 5. Verify ZFS receive without "-F" option (force recvflag) fails.
# 6. Verify ZFS receive with "-F" option completes successfully.
# 7. Repeat steps on an incremental ZFS send. It should complete
# successfully without "-F" option.
#
verify_runnable "both"
sendfs=$POOL/sendfs
recvfs=$POOL2/recvfs
streamfs=$POOL/stream
log_assert "Verify resumability of full ZFS send/receive on existing dataset"
log_onexit resume_cleanup $sendfs $streamfs
test_fs_setup $sendfs $recvfs $streamfs
# Full send/recv on existing dataset
log_must zfs create -o readonly=on $recvfs
log_must eval "zfs send -c -v $sendfs@a >/$streamfs/1"
mess_send_file /$streamfs/1
log_mustnot eval "zfs recv -suvF $recvfs </$streamfs/1"
token=$(get_prop receive_resume_token $recvfs)
log_must eval "zfs send -t $token >/$streamfs/2"
log_mustnot eval "zfs recv -suv $recvfs </$streamfs/2"
log_must eval "zfs recv -suvF $recvfs </$streamfs/2"
file_check $sendfs $recvfs
# Incremental send/recv
log_must eval "zfs send -c -v -i @a $sendfs@b >/$streamfs/3"
mess_send_file /$streamfs/3
log_mustnot eval "zfs recv -suvF $recvfs </$streamfs/3"
token=$(get_prop receive_resume_token $recvfs)
log_must eval "zfs send -t $token >/$streamfs/4"
log_must eval "zfs recv -suv $recvfs </$streamfs/4"
file_check $sendfs $recvfs
log_pass "Verify resumability of full ZFS send/receive on existing dataset"