aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPrawn <[email protected]>2021-04-27 02:23:51 +0200
committerGitHub <[email protected]>2021-04-26 17:23:51 -0700
commitb0269cd8ced242e66afc4fa856d62be29bb5a4ff (patch)
tree5ff26efa41462f799863868890fa85cae7575eb0 /lib
parentf172f759b913ca1d0bbee02c6edd8d92d213480d (diff)
receive: don't fail inheriting (-x) properties on wrong dataset type
Receiving datasets while blanket inheriting properties like zfs receive -x mountpoint can generally be desirable, e.g. to avoid unexpected mounts on backup hosts. Currently this will fail to receive zvols due to the mountpoint property being applicable to filesystems only. This limitation currently requires operators to special-case their minds and tools for zvols. This change gets rid of this limitation for inherit (-x) by Spiting up the dataset type handling: Warnings for inheriting (-x), errors for overriding (-o). Reviewed-by: Paul Dagnelie <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: InsanePrawn <[email protected]> Closes #11416 Closes #11840 Closes #11864
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_sendrecv.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index 7db7cf74f..511895d18 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -3951,24 +3951,6 @@ zfs_setup_cmdline_props(libzfs_handle_t *hdl, zfs_type_t type,
if (prop == ZFS_PROP_ORIGIN)
continue;
- /*
- * we're trying to override or exclude a property that does not
- * make sense for this type of dataset, but we don't want to
- * fail if the receive is recursive: this comes in handy when
- * the send stream contains, for instance, a child ZVOL and
- * we're trying to receive it with "-o atime=on"
- */
- if (!zfs_prop_valid_for_type(prop, type, B_FALSE) &&
- !zfs_prop_user(name)) {
- if (recursive)
- continue;
- zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
- "property '%s' does not apply to datasets of this "
- "type"), name);
- ret = zfs_error(hdl, EZFS_BADPROP, errbuf);
- goto error;
- }
-
/* raw streams can't override encryption properties */
if ((zfs_prop_encryption_key_param(prop) ||
prop == ZFS_PROP_ENCRYPTION) && raw) {
@@ -3997,6 +3979,16 @@ zfs_setup_cmdline_props(libzfs_handle_t *hdl, zfs_type_t type,
* a property: this is done by forcing an explicit
* inherit on the destination so the effective value is
* not the one we received from the send stream.
+ */
+ if (!zfs_prop_valid_for_type(prop, type, B_FALSE) &&
+ !zfs_prop_user(name)) {
+ (void) fprintf(stderr, dgettext(TEXT_DOMAIN,
+ "Warning: %s: property '%s' does not "
+ "apply to datasets of this type\n"),
+ fsname, name);
+ continue;
+ }
+ /*
* We do this only if the property is not already
* locally-set, in which case its value will take
* priority over the received anyway.
@@ -4024,6 +4016,24 @@ zfs_setup_cmdline_props(libzfs_handle_t *hdl, zfs_type_t type,
fnvlist_add_nvpair(*oxprops, nvp);
break;
case DATA_TYPE_STRING: /* -o property=value */
+ /*
+ * we're trying to override a property that does not
+ * make sense for this type of dataset, but we don't
+ * want to fail if the receive is recursive: this comes
+ * in handy when the send stream contains, for
+ * instance, a child ZVOL and we're trying to receive
+ * it with "-o atime=on"
+ */
+ if (!zfs_prop_valid_for_type(prop, type, B_FALSE) &&
+ !zfs_prop_user(name)) {
+ if (recursive)
+ continue;
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "property '%s' does not apply to datasets "
+ "of this type"), name);
+ ret = zfs_error(hdl, EZFS_BADPROP, errbuf);
+ goto error;
+ }
fnvlist_add_nvpair(oprops, nvp);
break;
default: