summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormm <mm@FreeBSD.org>2010-05-23 21:02:43 +0000
committermm <mm@FreeBSD.org>2010-05-23 21:02:43 +0000
commit9b8a28a2fd714c704ecbfb5af5b8bdd620a83e3c (patch)
treed5a87fcc9d055d9d56bed88698efc85bb67ea3b8
parent0741f43d5e5defdd320755fa68cdb9669ac13b32 (diff)
downloadFreeBSD-src-9b8a28a2fd714c704ecbfb5af5b8bdd620a83e3c.zip
FreeBSD-src-9b8a28a2fd714c704ecbfb5af5b8bdd620a83e3c.tar.gz
Fix zfs receive temporarily changing unchanged stream properties.
Fix possible panic with zfs_enable_datasets. OpenSolaris onnv revision: 8536:33bd5de3260e Approved by: pjd, delphij (mentor) Obtained from: OpenSolaris (Bug ID 6748561, 6757075) MFC after: 3 days
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c10
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c13
2 files changed, 14 insertions, 9 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
index 76ab7ac..ea8523d 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1209,10 +1209,12 @@ zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags)
/*
* And mount all the datasets, keeping track of which ones
- * succeeded or failed. By using zfs_alloc(), the good pointer
- * will always be non-NULL.
+ * succeeded or failed.
*/
- good = zfs_alloc(zhp->zpool_hdl, cb.cb_used * sizeof (int));
+ if ((good = zfs_alloc(zhp->zpool_hdl,
+ cb.cb_used * sizeof (int))) == NULL)
+ goto out;
+
ret = 0;
for (i = 0; i < cb.cb_used; i++) {
if (zfs_mount(cb.cb_datasets[i], mntopts, flags) != 0)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
index a9ce5ab..75f1ad0 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
@@ -92,7 +92,7 @@ typedef struct zfs_ioc_vec {
boolean_t zvec_his_log;
} zfs_ioc_vec_t;
-static void clear_props(char *dataset, nvlist_t *props);
+static void clear_props(char *dataset, nvlist_t *props, nvlist_t *newprops);
static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
boolean_t *);
int zfs_set_prop_nvlist(const char *, nvlist_t *);
@@ -1645,7 +1645,7 @@ zfs_ioc_set_prop(zfs_cmd_t *zc)
if (dmu_objset_open(zc->zc_name, DMU_OST_ANY,
DS_MODE_USER | DS_MODE_READONLY, &os) == 0) {
if (dsl_prop_get_all(os, &origprops, TRUE) == 0) {
- clear_props(zc->zc_name, origprops);
+ clear_props(zc->zc_name, origprops, nvl);
nvlist_free(origprops);
}
dmu_objset_close(os);
@@ -2425,7 +2425,7 @@ zfs_ioc_rename(zfs_cmd_t *zc)
}
static void
-clear_props(char *dataset, nvlist_t *props)
+clear_props(char *dataset, nvlist_t *props, nvlist_t *newprops)
{
zfs_cmd_t *zc;
nvpair_t *prop;
@@ -2436,6 +2436,9 @@ clear_props(char *dataset, nvlist_t *props)
(void) strcpy(zc->zc_name, dataset);
for (prop = nvlist_next_nvpair(props, NULL); prop;
prop = nvlist_next_nvpair(props, prop)) {
+ if (newprops != NULL &&
+ nvlist_exists(newprops, nvpair_name(prop)))
+ continue;
(void) strcpy(zc->zc_value, nvpair_name(prop));
if (zfs_secpolicy_inherit(zc, CRED()) == 0)
(void) zfs_ioc_inherit_prop(zc);
@@ -2543,7 +2546,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
* so that the properties are applied to the new data.
*/
if (props) {
- clear_props(tofs, origprops);
+ clear_props(tofs, origprops, props);
/*
* XXX - Note, this is all-or-nothing; should be best-effort.
*/
@@ -2582,7 +2585,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
* On error, restore the original props.
*/
if (error && props) {
- clear_props(tofs, props);
+ clear_props(tofs, props, NULL);
(void) zfs_set_prop_nvlist(tofs, origprops);
}
out:
OpenPOWER on IntegriCloud