Fail invalid incremental recursive send gracefully

zfs send -R -i snap1 pool/ds@snap1 is an invalid invocation of zfs send
because the incremental source and target snapshots are the same.  We
have an error message for this condition, but we don't make it there
because of a failed assert while iterating through the dataset's
snapshots.

Check for NULL to avoid the assert so we can make it to the error
message.

Test this form of invalid send invocation in rsend tests.  Fix the
rsend_016_neg test while here: log_neg itself doesn't fail the test,
and writing to /dev/null is not supported on all Linux kernels.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #11121 
Closes #12533
This commit is contained in:
Ryan Moeller 2021-10-08 14:14:26 -04:00 committed by GitHub
parent 9d1407e8f2
commit 97bbeeb938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -1059,9 +1059,14 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
nvlist_t *nvfs = fsavl_find(sdd->fsavl, nvlist_t *nvfs = fsavl_find(sdd->fsavl,
zhp->zfs_dmustats.dds_guid, &snapname); zhp->zfs_dmustats.dds_guid, &snapname);
snapprops = fnvlist_lookup_nvlist(nvfs, "snapprops"); if (nvfs != NULL) {
snapprops = fnvlist_lookup_nvlist(snapprops, thissnap); snapprops = fnvlist_lookup_nvlist(nvfs,
exclude = !nvlist_exists(snapprops, "is_clone_origin"); "snapprops");
snapprops = fnvlist_lookup_nvlist(snapprops,
thissnap);
exclude = !nvlist_exists(snapprops,
"is_clone_origin");
}
} else { } else {
exclude = B_TRUE; exclude = B_TRUE;
} }

View File

@ -24,10 +24,22 @@
# #
# Strategy: # Strategy:
# 1. Perform a zfs incremental send from a bookmark that doesn't exist # 1. Perform a zfs incremental send from a bookmark that doesn't exist
# 2. Perform a zfs incremental replication send with incremental source
# same as target (#11121)
# #
verify_runnable "both" verify_runnable "both"
log_neg eval "zfs send -i \#bla $POOl/$FS@final > /dev/null" function cleanup
{
rm -f $TEST_BASE_DIR/devnull
}
log_onexit cleanup
log_mustnot eval "zfs send -i \#bla $POOl/$FS@final > $TEST_BASE_DIR/devnull"
log_must eval "zfs send -R -i snapA $POOL/vol@snapA 2>&1 " \
"> $TEST_BASE_DIR/devnull | grep -q WARNING"
log_pass "Ensure that error conditions cause appropriate failures." log_pass "Ensure that error conditions cause appropriate failures."