4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
24 */
25
26 #include <sys/zfs_context.h>
27 #include <sys/dmu.h>
28 #include <sys/dmu_objset.h>
29 #include <sys/dmu_tx.h>
30 #include <sys/dsl_dataset.h>
31 #include <sys/dsl_dir.h>
32 #include <sys/dsl_prop.h>
33 #include <sys/dsl_synctask.h>
34 #include <sys/spa.h>
35 #include <sys/zap.h>
36 #include <sys/fs/zfs.h>
37
38 #include "zfs_prop.h"
39
40 #define ZPROP_INHERIT_SUFFIX "$inherit"
41 #define ZPROP_RECVD_SUFFIX "$recvd"
42
43 static int
540 char *tbuf = NULL;
541 int err;
542 uint64_t version = spa_version(ds->ds_dir->dd_pool->dp_spa);
543
544 isint = (dodefault(propname, 8, 1, &intval) == 0);
545
546 if (ds->ds_phys != NULL && dsl_dataset_is_snapshot(ds)) {
547 ASSERT(version >= SPA_VERSION_SNAP_PROPS);
548 if (ds->ds_phys->ds_props_obj == 0) {
549 dmu_buf_will_dirty(ds->ds_dbuf, tx);
550 ds->ds_phys->ds_props_obj =
551 zap_create(mos,
552 DMU_OT_DSL_PROPS, DMU_OT_NONE, 0, tx);
553 }
554 zapobj = ds->ds_phys->ds_props_obj;
555 } else {
556 zapobj = ds->ds_dir->dd_phys->dd_props_zapobj;
557 }
558
559 if (version < SPA_VERSION_RECVD_PROPS) {
560 zfs_prop_t prop = zfs_name_to_prop(propname);
561 if (prop == ZFS_PROP_QUOTA || prop == ZFS_PROP_RESERVATION)
562 return;
563
564 if (source & ZPROP_SRC_NONE)
565 source = ZPROP_SRC_NONE;
566 else if (source & ZPROP_SRC_RECEIVED)
567 source = ZPROP_SRC_LOCAL;
568 }
569
570 inheritstr = kmem_asprintf("%s%s", propname, ZPROP_INHERIT_SUFFIX);
571 recvdstr = kmem_asprintf("%s%s", propname, ZPROP_RECVD_SUFFIX);
572
573 switch (source) {
574 case ZPROP_SRC_NONE:
575 /*
576 * revert to received value, if any (inherit -S)
577 * - remove propname
578 * - remove propname$inherit
579 */
580 err = zap_remove(mos, zapobj, propname, tx);
581 ASSERT(err == 0 || err == ENOENT);
582 err = zap_remove(mos, zapobj, inheritstr, tx);
583 ASSERT(err == 0 || err == ENOENT);
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
24 * Copyright (c) 2013 Martin Matuska. All rights reserved.
25 */
26
27 #include <sys/zfs_context.h>
28 #include <sys/dmu.h>
29 #include <sys/dmu_objset.h>
30 #include <sys/dmu_tx.h>
31 #include <sys/dsl_dataset.h>
32 #include <sys/dsl_dir.h>
33 #include <sys/dsl_prop.h>
34 #include <sys/dsl_synctask.h>
35 #include <sys/spa.h>
36 #include <sys/zap.h>
37 #include <sys/fs/zfs.h>
38
39 #include "zfs_prop.h"
40
41 #define ZPROP_INHERIT_SUFFIX "$inherit"
42 #define ZPROP_RECVD_SUFFIX "$recvd"
43
44 static int
541 char *tbuf = NULL;
542 int err;
543 uint64_t version = spa_version(ds->ds_dir->dd_pool->dp_spa);
544
545 isint = (dodefault(propname, 8, 1, &intval) == 0);
546
547 if (ds->ds_phys != NULL && dsl_dataset_is_snapshot(ds)) {
548 ASSERT(version >= SPA_VERSION_SNAP_PROPS);
549 if (ds->ds_phys->ds_props_obj == 0) {
550 dmu_buf_will_dirty(ds->ds_dbuf, tx);
551 ds->ds_phys->ds_props_obj =
552 zap_create(mos,
553 DMU_OT_DSL_PROPS, DMU_OT_NONE, 0, tx);
554 }
555 zapobj = ds->ds_phys->ds_props_obj;
556 } else {
557 zapobj = ds->ds_dir->dd_phys->dd_props_zapobj;
558 }
559
560 if (version < SPA_VERSION_RECVD_PROPS) {
561 if (source & ZPROP_SRC_NONE)
562 source = ZPROP_SRC_NONE;
563 else if (source & ZPROP_SRC_RECEIVED)
564 source = ZPROP_SRC_LOCAL;
565 }
566
567 inheritstr = kmem_asprintf("%s%s", propname, ZPROP_INHERIT_SUFFIX);
568 recvdstr = kmem_asprintf("%s%s", propname, ZPROP_RECVD_SUFFIX);
569
570 switch (source) {
571 case ZPROP_SRC_NONE:
572 /*
573 * revert to received value, if any (inherit -S)
574 * - remove propname
575 * - remove propname$inherit
576 */
577 err = zap_remove(mos, zapobj, propname, tx);
578 ASSERT(err == 0 || err == ENOENT);
579 err = zap_remove(mos, zapobj, inheritstr, tx);
580 ASSERT(err == 0 || err == ENOENT);
|