aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndriy Gapon <[email protected]>2019-09-03 20:56:55 +0300
committerBrian Behlendorf <[email protected]>2019-09-03 10:56:55 -0700
commitebeb6f23bf7e8fe6732a05267ed1cab4c38d3b23 (patch)
treecaa4d1dddd3c3b60a1e614c7b134876b1afa2979
parent1a504d27df4657d394d9a924c2e7796b692ff993 (diff)
Always refuse receving non-resume stream when resume state exists
This fixes a hole in the situation where the resume state is left from receiving a new dataset and, so, the state is set on the dataset itself (as opposed to %recv child). Additionally, distinguish incremental and resume streams in error messages. Reviewed-by: Matt Ahrens <[email protected]> Reviewed-by: Tom Caputi <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Andriy Gapon <[email protected]> Closes #9252
-rw-r--r--lib/libzfs/libzfs_sendrecv.c15
-rw-r--r--module/zfs/dmu_recv.c10
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index c178296f6..e63404b8a 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -4598,11 +4598,18 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
}
} else {
/*
- * if the fs does not exist, look for it based on the
- * fromsnap GUID
+ * If the fs does not exist, look for it based on the
+ * fromsnap GUID.
*/
- (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
- "cannot receive incremental stream"));
+ if (resuming) {
+ (void) snprintf(errbuf, sizeof (errbuf),
+ dgettext(TEXT_DOMAIN,
+ "cannot receive resume stream"));
+ } else {
+ (void) snprintf(errbuf, sizeof (errbuf),
+ dgettext(TEXT_DOMAIN,
+ "cannot receive incremental stream"));
+ }
(void) strcpy(name, destsnap);
*strchr(name, '@') = '\0';
diff --git a/module/zfs/dmu_recv.c b/module/zfs/dmu_recv.c
index fe401ec2e..49b8c0acf 100644
--- a/module/zfs/dmu_recv.c
+++ b/module/zfs/dmu_recv.c
@@ -350,21 +350,25 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
boolean_t raw = (featureflags & DMU_BACKUP_FEATURE_RAW) != 0;
boolean_t embed = (featureflags & DMU_BACKUP_FEATURE_EMBED_DATA) != 0;
- /* temporary clone name must not exist */
+ /* Temporary clone name must not exist. */
error = zap_lookup(dp->dp_meta_objset,
dsl_dir_phys(ds->ds_dir)->dd_child_dir_zapobj, recv_clone_name,
8, 1, &val);
if (error != ENOENT)
return (error == 0 ? SET_ERROR(EBUSY) : error);
- /* new snapshot name must not exist */
+ /* Resume state must not be set. */
+ if (dsl_dataset_has_resume_receive_state(ds))
+ return (SET_ERROR(EBUSY));
+
+ /* New snapshot name must not exist. */
error = zap_lookup(dp->dp_meta_objset,
dsl_dataset_phys(ds)->ds_snapnames_zapobj,
drba->drba_cookie->drc_tosnap, 8, 1, &val);
if (error != ENOENT)
return (error == 0 ? SET_ERROR(EEXIST) : error);
- /* must not have children if receiving a ZVOL */
+ /* Must not have children if receiving a ZVOL. */
error = zap_count(dp->dp_meta_objset,
dsl_dir_phys(ds->ds_dir)->dd_child_dir_zapobj, &children);
if (error != 0)