annotate usr/src/uts/common/fs/zfs/zfs_ioctl.c @ 13980:d7059eb1884c

3598 want to dtrace when errors are generated in zfs Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Approved by: Garrett D'Amore <garrett@damore.org>
author Matthew Ahrens <mahrens@delphix.com>
date Fri, 08 Mar 2013 10:41:28 -0800
parents 4972ab336f54
children 6a5a2f4a47db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
1485
e971e58d18f6 6322005 support for persistent offline
lling
parents: 1356
diff changeset
5 * Common Development and Distribution License (the "License").
e971e58d18f6 6322005 support for persistent offline
lling
parents: 1356
diff changeset
6 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
7 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
10 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
11 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
12 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
18 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
19 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
20 */
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
21
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
22 /*
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
13492
83d135508f56 1346 zfs incremental receive may leave behind temporary clones
Martin Matuska <mm@FreeBSD.org>
parents: 13061
diff changeset
24 * Portions Copyright 2011 Martin Matuska
13514
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
26 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
27 * Copyright (c) 2013 by Delphix. All rights reserved.
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
28 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
29 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
30
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
31 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
32 * ZFS ioctls.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
33 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
34 * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
35 * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
36 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
37 * There are two ways that we handle ioctls: the legacy way where almost
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
38 * all of the logic is in the ioctl callback, and the new way where most
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
39 * of the marshalling is handled in the common entry point, zfsdev_ioctl().
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
40 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
41 * Non-legacy ioctls should be registered by calling
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
42 * zfs_ioctl_register() from zfs_ioctl_init(). The ioctl is invoked
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
43 * from userland by lzc_ioctl().
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
44 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
45 * The registration arguments are as follows:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
46 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
47 * const char *name
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
48 * The name of the ioctl. This is used for history logging. If the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
49 * ioctl returns successfully (the callback returns 0), and allow_log
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
50 * is true, then a history log entry will be recorded with the input &
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
51 * output nvlists. The log entry can be printed with "zpool history -i".
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
52 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
53 * zfs_ioc_t ioc
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
54 * The ioctl request number, which userland will pass to ioctl(2).
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
55 * The ioctl numbers can change from release to release, because
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
56 * the caller (libzfs) must be matched to the kernel.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
57 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
58 * zfs_secpolicy_func_t *secpolicy
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
59 * This function will be called before the zfs_ioc_func_t, to
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
60 * determine if this operation is permitted. It should return EPERM
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
61 * on failure, and 0 on success. Checks include determining if the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
62 * dataset is visible in this zone, and if the user has either all
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
63 * zfs privileges in the zone (SYS_MOUNT), or has been granted permission
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
64 * to do this operation on this dataset with "zfs allow".
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
65 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
66 * zfs_ioc_namecheck_t namecheck
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
67 * This specifies what to expect in the zfs_cmd_t:zc_name -- a pool
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
68 * name, a dataset name, or nothing. If the name is not well-formed,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
69 * the ioctl will fail and the callback will not be called.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
70 * Therefore, the callback can assume that the name is well-formed
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
71 * (e.g. is null-terminated, doesn't have more than one '@' character,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
72 * doesn't have invalid characters).
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
73 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
74 * zfs_ioc_poolcheck_t pool_check
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
75 * This specifies requirements on the pool state. If the pool does
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
76 * not meet them (is suspended or is readonly), the ioctl will fail
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
77 * and the callback will not be called. If any checks are specified
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
78 * (i.e. it is not POOL_CHECK_NONE), namecheck must not be NO_NAME.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
79 * Multiple checks can be or-ed together (e.g. POOL_CHECK_SUSPENDED |
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
80 * POOL_CHECK_READONLY).
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
81 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
82 * boolean_t smush_outnvlist
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
83 * If smush_outnvlist is true, then the output is presumed to be a
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
84 * list of errors, and it will be "smushed" down to fit into the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
85 * caller's buffer, by removing some entries and replacing them with a
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
86 * single "N_MORE_ERRORS" entry indicating how many were removed. See
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
87 * nvlist_smush() for details. If smush_outnvlist is false, and the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
88 * outnvlist does not fit into the userland-provided buffer, then the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
89 * ioctl will fail with ENOMEM.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
90 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
91 * zfs_ioc_func_t *func
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
92 * The callback function that will perform the operation.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
93 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
94 * The callback should return 0 on success, or an error number on
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
95 * failure. If the function fails, the userland ioctl will return -1,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
96 * and errno will be set to the callback's return value. The callback
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
97 * will be called with the following arguments:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
98 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
99 * const char *name
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
100 * The name of the pool or dataset to operate on, from
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
101 * zfs_cmd_t:zc_name. The 'namecheck' argument specifies the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
102 * expected type (pool, dataset, or none).
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
103 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
104 * nvlist_t *innvl
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
105 * The input nvlist, deserialized from zfs_cmd_t:zc_nvlist_src. Or
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
106 * NULL if no input nvlist was provided. Changes to this nvlist are
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
107 * ignored. If the input nvlist could not be deserialized, the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
108 * ioctl will fail and the callback will not be called.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
109 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
110 * nvlist_t *outnvl
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
111 * The output nvlist, initially empty. The callback can fill it in,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
112 * and it will be returned to userland by serializing it into
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
113 * zfs_cmd_t:zc_nvlist_dst. If it is non-empty, and serialization
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
114 * fails (e.g. because the caller didn't supply a large enough
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
115 * buffer), then the overall ioctl will fail. See the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
116 * 'smush_nvlist' argument above for additional behaviors.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
117 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
118 * There are two typical uses of the output nvlist:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
119 * - To return state, e.g. property values. In this case,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
120 * smush_outnvlist should be false. If the buffer was not large
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
121 * enough, the caller will reallocate a larger buffer and try
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
122 * the ioctl again.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
123 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
124 * - To return multiple errors from an ioctl which makes on-disk
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
125 * changes. In this case, smush_outnvlist should be true.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
126 * Ioctls which make on-disk modifications should generally not
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
127 * use the outnvl if they succeed, because the caller can not
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
128 * distinguish between the operation failing, and
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
129 * deserialization failing.
13514
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
130 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
131
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
132 #include <sys/types.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
133 #include <sys/param.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
134 #include <sys/errno.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
135 #include <sys/uio.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
136 #include <sys/buf.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
137 #include <sys/modctl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
138 #include <sys/open.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
139 #include <sys/file.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
140 #include <sys/kmem.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
141 #include <sys/conf.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
142 #include <sys/cmn_err.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
143 #include <sys/stat.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
144 #include <sys/zfs_ioctl.h>
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
145 #include <sys/zfs_vfsops.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
146 #include <sys/zfs_znode.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
147 #include <sys/zap.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
148 #include <sys/spa.h>
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
149 #include <sys/spa_impl.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
150 #include <sys/vdev.h>
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
151 #include <sys/priv_impl.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
152 #include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
153 #include <sys/dsl_dir.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
154 #include <sys/dsl_dataset.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
155 #include <sys/dsl_prop.h>
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
156 #include <sys/dsl_deleg.h>
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
157 #include <sys/dmu_objset.h>
13686
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
158 #include <sys/dmu_impl.h>
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
159 #include <sys/dmu_tx.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
160 #include <sys/ddi.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
161 #include <sys/sunddi.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
162 #include <sys/sunldi.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
163 #include <sys/policy.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
164 #include <sys/zone.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
165 #include <sys/nvpair.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
166 #include <sys/pathname.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
167 #include <sys/mount.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
168 #include <sys/sdt.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
169 #include <sys/fs/zfs.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
170 #include <sys/zfs_ctldir.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
171 #include <sys/zfs_dir.h>
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
172 #include <sys/zfs_onexit.h>
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
173 #include <sys/zvol.h>
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
174 #include <sys/dsl_scan.h>
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
175 #include <sharefs/share.h>
5326
6752aa2bd5bc 6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents: 5147
diff changeset
176 #include <sys/dmu_objset.h>
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
177 #include <sys/dmu_send.h>
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
178 #include <sys/dsl_destroy.h>
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
179 #include <sys/dsl_userhold.h>
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
180 #include <sys/zfeature.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
181
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
182 #include "zfs_namecheck.h"
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
183 #include "zfs_prop.h"
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
184 #include "zfs_deleg.h"
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
185 #include "zfs_comutil.h"
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
186
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
187 extern struct modlfs zfs_modlfs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
188
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
189 extern void zfs_init(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
190 extern void zfs_fini(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
191
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
192 ldi_ident_t zfs_li = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
193 dev_info_t *zfs_dip;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
194
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
195 uint_t zfs_fsyncer_key;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
196 extern uint_t rrw_tsd_key;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
197 static uint_t zfs_allow_log_key;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
198
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
199 typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
200 typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
201 typedef int zfs_secpolicy_func_t(zfs_cmd_t *, nvlist_t *, cred_t *);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
202
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
203 typedef enum {
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
204 NO_NAME,
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
205 POOL_NAME,
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
206 DATASET_NAME
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
207 } zfs_ioc_namecheck_t;
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
208
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
209 typedef enum {
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
210 POOL_CHECK_NONE = 1 << 0,
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
211 POOL_CHECK_SUSPENDED = 1 << 1,
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
212 POOL_CHECK_READONLY = 1 << 2,
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
213 } zfs_ioc_poolcheck_t;
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
214
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
215 typedef struct zfs_ioc_vec {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
216 zfs_ioc_legacy_func_t *zvec_legacy_func;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
217 zfs_ioc_func_t *zvec_func;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
218 zfs_secpolicy_func_t *zvec_secpolicy;
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
219 zfs_ioc_namecheck_t zvec_namecheck;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
220 boolean_t zvec_allow_log;
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
221 zfs_ioc_poolcheck_t zvec_pool_check;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
222 boolean_t zvec_smush_outnvlist;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
223 const char *zvec_name;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
224 } zfs_ioc_vec_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
225
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
226 /* This array is indexed by zfs_userquota_prop_t */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
227 static const char *userquota_perms[] = {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
228 ZFS_DELEG_PERM_USERUSED,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
229 ZFS_DELEG_PERM_USERQUOTA,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
230 ZFS_DELEG_PERM_GROUPUSED,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
231 ZFS_DELEG_PERM_GROUPQUOTA,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
232 };
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
233
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
234 static int zfs_ioc_userspace_upgrade(zfs_cmd_t *zc);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
235 static int zfs_check_settable(const char *name, nvpair_t *property,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
236 cred_t *cr);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
237 static int zfs_check_clearable(char *dataset, nvlist_t *props,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
238 nvlist_t **errors);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
239 static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
240 boolean_t *);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
241 int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t *);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
242 static int get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
243
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
244 static int zfs_prop_activate_feature(spa_t *spa, zfeature_info_t *feature);
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
245
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
246 /* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
247 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
248 __dprintf(const char *file, const char *func, int line, const char *fmt, ...)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
249 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
250 const char *newfile;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
251 char buf[512];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
252 va_list adx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
253
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
254 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
255 * Get rid of annoying "../common/" prefix to filename.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
256 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
257 newfile = strrchr(file, '/');
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
258 if (newfile != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
259 newfile = newfile + 1; /* Get rid of leading / */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
260 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
261 newfile = file;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
262 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
263
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
264 va_start(adx, fmt);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
265 (void) vsnprintf(buf, sizeof (buf), fmt, adx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
266 va_end(adx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
267
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
268 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
269 * To get this data, use the zfs-dprintf probe as so:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
270 * dtrace -q -n 'zfs-dprintf \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
271 * /stringof(arg0) == "dbuf.c"/ \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
272 * {printf("%s: %s", stringof(arg1), stringof(arg3))}'
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
273 * arg0 = file name
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
274 * arg1 = function name
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
275 * arg2 = line number
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
276 * arg3 = message
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
277 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
278 DTRACE_PROBE4(zfs__dprintf,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
279 char *, newfile, char *, func, int, line, char *, buf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
280 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
281
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
282 static void
4715
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
283 history_str_free(char *buf)
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
284 {
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
285 kmem_free(buf, HIS_MAX_RECORD_LEN);
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
286 }
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
287
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
288 static char *
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
289 history_str_get(zfs_cmd_t *zc)
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
290 {
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
291 char *buf;
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
292
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
293 if (zc->zc_history == NULL)
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
294 return (NULL);
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
295
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
296 buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP);
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
297 if (copyinstr((void *)(uintptr_t)zc->zc_history,
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
298 buf, HIS_MAX_RECORD_LEN, NULL) != 0) {
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
299 history_str_free(buf);
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
300 return (NULL);
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
301 }
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
302
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
303 buf[HIS_MAX_RECORD_LEN -1] = '\0';
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
304
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
305 return (buf);
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
306 }
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
307
5375
c682f8c5f5e3 6622822 can not create clone on old version pool
timh
parents: 5367
diff changeset
308 /*
7042
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
309 * Check to see if the named dataset is currently defined as bootable
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
310 */
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
311 static boolean_t
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
312 zfs_is_bootfs(const char *name)
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
313 {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
314 objset_t *os;
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
315
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
316 if (dmu_objset_hold(name, FTAG, &os) == 0) {
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
317 boolean_t ret;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
318 ret = (dmu_objset_id(os) == spa_bootfs(dmu_objset_spa(os)));
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
319 dmu_objset_rele(os, FTAG);
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
320 return (ret);
7042
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
321 }
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
322 return (B_FALSE);
7042
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
323 }
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
324
46fc4b6db23e 6721094 Setting certain properties on root pools should not be allowed
gw25295
parents: 6865
diff changeset
325 /*
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
326 * zfs_earlier_version
5375
c682f8c5f5e3 6622822 can not create clone on old version pool
timh
parents: 5367
diff changeset
327 *
c682f8c5f5e3 6622822 can not create clone on old version pool
timh
parents: 5367
diff changeset
328 * Return non-zero if the spa version is less than requested version.
c682f8c5f5e3 6622822 can not create clone on old version pool
timh
parents: 5367
diff changeset
329 */
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
330 static int
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
331 zfs_earlier_version(const char *name, int version)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
332 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
333 spa_t *spa;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
334
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
335 if (spa_open(name, &spa, FTAG) == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
336 if (spa_version(spa) < version) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
337 spa_close(spa, FTAG);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
338 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
339 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
340 spa_close(spa, FTAG);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
341 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
342 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
343 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
344
5977
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
345 /*
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
346 * zpl_earlier_version
5977
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
347 *
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
348 * Return TRUE if the ZPL version is less than requested version.
5977
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
349 */
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
350 static boolean_t
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
351 zpl_earlier_version(const char *name, int version)
5977
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
352 {
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
353 objset_t *os;
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
354 boolean_t rc = B_TRUE;
5977
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
355
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
356 if (dmu_objset_hold(name, FTAG, &os) == 0) {
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
357 uint64_t zplversion;
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
358
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
359 if (dmu_objset_type(os) != DMU_OST_ZFS) {
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
360 dmu_objset_rele(os, FTAG);
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
361 return (B_TRUE);
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
362 }
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
363 /* XXX reading from non-owned objset */
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
364 if (zfs_get_zplprop(os, ZFS_PROP_VERSION, &zplversion) == 0)
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
365 rc = zplversion < version;
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
366 dmu_objset_rele(os, FTAG);
5977
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
367 }
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
368 return (rc);
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
369 }
33727f49aeaa 6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents: 5663
diff changeset
370
4715
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
371 static void
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
372 zfs_log_history(zfs_cmd_t *zc)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
373 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
374 spa_t *spa;
4603
c7840c367d00 6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents: 4577
diff changeset
375 char *buf;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
376
4715
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
377 if ((buf = history_str_get(zc)) == NULL)
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
378 return;
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
379
4715
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
380 if (spa_open(zc->zc_name, &spa, FTAG) == 0) {
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
381 if (spa_version(spa) >= SPA_VERSION_ZPOOL_HISTORY)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
382 (void) spa_history_log(spa, buf);
4715
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
383 spa_close(spa, FTAG);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
384 }
4715
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
385 history_str_free(buf);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
386 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
387
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
388 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
389 * Policy for top-level read operations (list pools). Requires no privileges,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
390 * and can be used in the local zone, as there is no associated dataset.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
391 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
392 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
393 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
394 zfs_secpolicy_none(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
395 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
396 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
397 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
398
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
399 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
400 * Policy for dataset read operations (list children, get statistics). Requires
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
401 * no privileges, but must be visible in the local zone.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
402 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
403 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
404 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
405 zfs_secpolicy_read(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
406 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
407 if (INGLOBALZONE(curproc) ||
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
408 zone_dataset_visible(zc->zc_name, NULL))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
409 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
410
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
411 return (SET_ERROR(ENOENT));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
412 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
413
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
414 static int
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
415 zfs_dozonecheck_impl(const char *dataset, uint64_t zoned, cred_t *cr)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
416 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
417 int writable = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
418
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
419 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
420 * The dataset must be visible by this zone -- check this first
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
421 * so they don't see EPERM on something they shouldn't know about.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
422 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
423 if (!INGLOBALZONE(curproc) &&
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
424 !zone_dataset_visible(dataset, &writable))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
425 return (SET_ERROR(ENOENT));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
426
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
427 if (INGLOBALZONE(curproc)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
428 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
429 * If the fs is zoned, only root can access it from the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
430 * global zone.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
431 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
432 if (secpolicy_zfs(cr) && zoned)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
433 return (SET_ERROR(EPERM));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
434 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
435 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
436 * If we are in a local zone, the 'zoned' property must be set.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
437 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
438 if (!zoned)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
439 return (SET_ERROR(EPERM));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
440
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
441 /* must be writable by this zone */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
442 if (!writable)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
443 return (SET_ERROR(EPERM));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
444 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
445 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
446 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
447
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
448 static int
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
449 zfs_dozonecheck(const char *dataset, cred_t *cr)
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
450 {
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
451 uint64_t zoned;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
452
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
453 if (dsl_prop_get_integer(dataset, "zoned", &zoned, NULL))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
454 return (SET_ERROR(ENOENT));
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
455
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
456 return (zfs_dozonecheck_impl(dataset, zoned, cr));
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
457 }
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
458
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
459 static int
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
460 zfs_dozonecheck_ds(const char *dataset, dsl_dataset_t *ds, cred_t *cr)
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
461 {
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
462 uint64_t zoned;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
463
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
464 if (dsl_prop_get_int_ds(ds, "zoned", &zoned))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
465 return (SET_ERROR(ENOENT));
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
466
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
467 return (zfs_dozonecheck_impl(dataset, zoned, cr));
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
468 }
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
469
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
470 static int
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
471 zfs_secpolicy_write_perms_ds(const char *name, dsl_dataset_t *ds,
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
472 const char *perm, cred_t *cr)
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
473 {
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
474 int error;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
475
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
476 error = zfs_dozonecheck_ds(name, ds, cr);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
477 if (error == 0) {
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
478 error = secpolicy_zfs(cr);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
479 if (error != 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
480 error = dsl_deleg_access_impl(ds, perm, cr);
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
481 }
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
482 return (error);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
483 }
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
484
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
485 static int
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
486 zfs_secpolicy_write_perms(const char *name, const char *perm, cred_t *cr)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
487 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
488 int error;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
489 dsl_dataset_t *ds;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
490 dsl_pool_t *dp;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
491
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
492 error = dsl_pool_hold(name, FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
493 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
494 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
495
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
496 error = dsl_dataset_hold(dp, name, FTAG, &ds);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
497 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
498 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
499 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
500 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
501
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
502 error = zfs_secpolicy_write_perms_ds(name, ds, perm, cr);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
503
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
504 dsl_dataset_rele(ds, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
505 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
506 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
507 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
508
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
509 /*
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
510 * Policy for setting the security label property.
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
511 *
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
512 * Returns 0 for success, non-zero for access and other errors.
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
513 */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
514 static int
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
515 zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
516 {
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
517 char ds_hexsl[MAXNAMELEN];
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
518 bslabel_t ds_sl, new_sl;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
519 boolean_t new_default = FALSE;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
520 uint64_t zoned;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
521 int needed_priv = -1;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
522 int error;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
523
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
524 /* First get the existing dataset label. */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
525 error = dsl_prop_get(name, zfs_prop_to_name(ZFS_PROP_MLSLABEL),
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
526 1, sizeof (ds_hexsl), &ds_hexsl, NULL);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
527 if (error != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
528 return (SET_ERROR(EPERM));
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
529
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
530 if (strcasecmp(strval, ZFS_MLSLABEL_DEFAULT) == 0)
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
531 new_default = TRUE;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
532
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
533 /* The label must be translatable */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
534 if (!new_default && (hexstr_to_label(strval, &new_sl) != 0))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
535 return (SET_ERROR(EINVAL));
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
536
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
537 /*
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
538 * In a non-global zone, disallow attempts to set a label that
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
539 * doesn't match that of the zone; otherwise no other checks
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
540 * are needed.
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
541 */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
542 if (!INGLOBALZONE(curproc)) {
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
543 if (new_default || !blequal(&new_sl, CR_SL(CRED())))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
544 return (SET_ERROR(EPERM));
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
545 return (0);
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
546 }
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
547
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
548 /*
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
549 * For global-zone datasets (i.e., those whose zoned property is
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
550 * "off", verify that the specified new label is valid for the
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
551 * global zone.
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
552 */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
553 if (dsl_prop_get_integer(name,
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
554 zfs_prop_to_name(ZFS_PROP_ZONED), &zoned, NULL))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
555 return (SET_ERROR(EPERM));
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
556 if (!zoned) {
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
557 if (zfs_check_global_label(name, strval) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
558 return (SET_ERROR(EPERM));
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
559 }
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
560
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
561 /*
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
562 * If the existing dataset label is nondefault, check if the
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
563 * dataset is mounted (label cannot be changed while mounted).
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
564 * Get the zfsvfs; if there isn't one, then the dataset isn't
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
565 * mounted (or isn't a dataset, doesn't exist, ...).
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
566 */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
567 if (strcasecmp(ds_hexsl, ZFS_MLSLABEL_DEFAULT) != 0) {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
568 objset_t *os;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
569 static char *setsl_tag = "setsl_tag";
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
570
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
571 /*
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
572 * Try to own the dataset; abort if there is any error,
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
573 * (e.g., already mounted, in use, or other error).
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
574 */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
575 error = dmu_objset_own(name, DMU_OST_ZFS, B_TRUE,
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
576 setsl_tag, &os);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
577 if (error != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
578 return (SET_ERROR(EPERM));
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
579
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
580 dmu_objset_disown(os, setsl_tag);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
581
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
582 if (new_default) {
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
583 needed_priv = PRIV_FILE_DOWNGRADE_SL;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
584 goto out_check;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
585 }
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
586
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
587 if (hexstr_to_label(strval, &new_sl) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
588 return (SET_ERROR(EPERM));
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
589
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
590 if (blstrictdom(&ds_sl, &new_sl))
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
591 needed_priv = PRIV_FILE_DOWNGRADE_SL;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
592 else if (blstrictdom(&new_sl, &ds_sl))
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
593 needed_priv = PRIV_FILE_UPGRADE_SL;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
594 } else {
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
595 /* dataset currently has a default label */
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
596 if (!new_default)
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
597 needed_priv = PRIV_FILE_UPGRADE_SL;
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
598 }
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
599
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
600 out_check:
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
601 if (needed_priv != -1)
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
602 return (PRIV_POLICY(cr, needed_priv, B_FALSE, EPERM, NULL));
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
603 return (0);
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
604 }
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
605
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
606 static int
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
607 zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
608 cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
609 {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
610 char *strval;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
611
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
612 /*
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
613 * Check permissions for special properties.
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
614 */
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
615 switch (prop) {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
616 case ZFS_PROP_ZONED:
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
617 /*
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
618 * Disallow setting of 'zoned' from within a local zone.
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
619 */
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
620 if (!INGLOBALZONE(curproc))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
621 return (SET_ERROR(EPERM));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
622 break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
623
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
624 case ZFS_PROP_QUOTA:
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
625 if (!INGLOBALZONE(curproc)) {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
626 uint64_t zoned;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
627 char setpoint[MAXNAMELEN];
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
628 /*
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
629 * Unprivileged users are allowed to modify the
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
630 * quota on things *under* (ie. contained by)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
631 * the thing they own.
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
632 */
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
633 if (dsl_prop_get_integer(dsname, "zoned", &zoned,
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
634 setpoint))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
635 return (SET_ERROR(EPERM));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
636 if (!zoned || strlen(dsname) <= strlen(setpoint))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
637 return (SET_ERROR(EPERM));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
638 }
4670
002728040e28 6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents: 4611
diff changeset
639 break;
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
640
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
641 case ZFS_PROP_MLSLABEL:
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
642 if (!is_system_labeled())
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
643 return (SET_ERROR(EPERM));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
644
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
645 if (nvpair_value_string(propval, &strval) == 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
646 int err;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
647
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
648 err = zfs_set_slabel_policy(dsname, strval, CRED());
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
649 if (err != 0)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
650 return (err);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
651 }
10972
807794d41b3a PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents: 10969
diff changeset
652 break;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
653 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
654
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
655 return (zfs_secpolicy_write_perms(dsname, zfs_prop_to_name(prop), cr));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
656 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
657
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
658 /* ARGSUSED */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
659 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
660 zfs_secpolicy_set_fsacl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
661 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
662 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
663
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
664 error = zfs_dozonecheck(zc->zc_name, cr);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
665 if (error != 0)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
666 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
667
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
668 /*
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
669 * permission to set permissions will be evaluated later in
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
670 * dsl_deleg_can_allow()
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
671 */
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
672 return (0);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
673 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
674
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
675 /* ARGSUSED */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
676 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
677 zfs_secpolicy_rollback(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
678 {
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
679 return (zfs_secpolicy_write_perms(zc->zc_name,
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
680 ZFS_DELEG_PERM_ROLLBACK, cr));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
681 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
682
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
683 /* ARGSUSED */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
684 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
685 zfs_secpolicy_send(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
686 {
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
687 dsl_pool_t *dp;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
688 dsl_dataset_t *ds;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
689 char *cp;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
690 int error;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
691
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
692 /*
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
693 * Generate the current snapshot name from the given objsetid, then
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
694 * use that name for the secpolicy/zone checks.
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
695 */
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
696 cp = strchr(zc->zc_name, '@');
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
697 if (cp == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
698 return (SET_ERROR(EINVAL));
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
699 error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
700 if (error != 0)
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
701 return (error);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
702
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
703 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &ds);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
704 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
705 dsl_pool_rele(dp, FTAG);
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
706 return (error);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
707 }
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
708
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
709 dsl_dataset_name(ds, zc->zc_name);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
710
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
711 error = zfs_secpolicy_write_perms_ds(zc->zc_name, ds,
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
712 ZFS_DELEG_PERM_SEND, cr);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
713 dsl_dataset_rele(ds, FTAG);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
714 dsl_pool_rele(dp, FTAG);
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
715
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
716 return (error);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
717 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
718
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
719 /* ARGSUSED */
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
720 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
721 zfs_secpolicy_send_new(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
722 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
723 return (zfs_secpolicy_write_perms(zc->zc_name,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
724 ZFS_DELEG_PERM_SEND, cr));
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
725 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
726
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
727 /* ARGSUSED */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
728 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
729 zfs_secpolicy_deleg_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
730 {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
731 vnode_t *vp;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
732 int error;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
733
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
734 if ((error = lookupname(zc->zc_value, UIO_SYSSPACE,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
735 NO_FOLLOW, NULL, &vp)) != 0)
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
736 return (error);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
737
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
738 /* Now make sure mntpnt and dataset are ZFS */
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
739
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
740 if (vp->v_vfsp->vfs_fstype != zfsfstype ||
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
741 (strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
742 zc->zc_name) != 0)) {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
743 VN_RELE(vp);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
744 return (SET_ERROR(EPERM));
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
745 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
746
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
747 VN_RELE(vp);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
748 return (dsl_deleg_access(zc->zc_name,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
749 ZFS_DELEG_PERM_SHARE, cr));
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
750 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
751
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
752 int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
753 zfs_secpolicy_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
754 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
755 if (!INGLOBALZONE(curproc))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
756 return (SET_ERROR(EPERM));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
757
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
758 if (secpolicy_nfs(cr) == 0) {
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
759 return (0);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
760 } else {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
761 return (zfs_secpolicy_deleg_share(zc, innvl, cr));
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
762 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
763 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
764
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
765 int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
766 zfs_secpolicy_smb_acl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
767 {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
768 if (!INGLOBALZONE(curproc))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
769 return (SET_ERROR(EPERM));
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
770
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
771 if (secpolicy_smb(cr) == 0) {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
772 return (0);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
773 } else {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
774 return (zfs_secpolicy_deleg_share(zc, innvl, cr));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
775 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
776 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
777
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
778 static int
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
779 zfs_get_parent(const char *datasetname, char *parent, int parentsize)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
780 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
781 char *cp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
782
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
783 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
784 * Remove the @bla or /bla from the end of the name to get the parent.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
785 */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
786 (void) strncpy(parent, datasetname, parentsize);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
787 cp = strrchr(parent, '@');
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
788 if (cp != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
789 cp[0] = '\0';
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
790 } else {
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
791 cp = strrchr(parent, '/');
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
792 if (cp == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
793 return (SET_ERROR(ENOENT));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
794 cp[0] = '\0';
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
795 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
796
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
797 return (0);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
798 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
799
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
800 int
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
801 zfs_secpolicy_destroy_perms(const char *name, cred_t *cr)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
802 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
803 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
804
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
805 if ((error = zfs_secpolicy_write_perms(name,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
806 ZFS_DELEG_PERM_MOUNT, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
807 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
808
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
809 return (zfs_secpolicy_write_perms(name, ZFS_DELEG_PERM_DESTROY, cr));
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
810 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
811
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
812 /* ARGSUSED */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
813 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
814 zfs_secpolicy_destroy(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
815 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
816 return (zfs_secpolicy_destroy_perms(zc->zc_name, cr));
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
817 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
818
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
819 /*
11314
489ae7372a1f 6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents: 11209
diff changeset
820 * Destroying snapshots with delegated permissions requires
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
821 * descendant mount and destroy permissions.
11314
489ae7372a1f 6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents: 11209
diff changeset
822 */
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
823 /* ARGSUSED */
11314
489ae7372a1f 6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents: 11209
diff changeset
824 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
825 zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
11314
489ae7372a1f 6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents: 11209
diff changeset
826 {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
827 nvlist_t *snaps;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
828 nvpair_t *pair, *nextpair;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
829 int error = 0;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
830
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
831 if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
832 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
833 for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
834 pair = nextpair) {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
835 dsl_pool_t *dp;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
836 dsl_dataset_t *ds;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
837
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
838 error = dsl_pool_hold(nvpair_name(pair), FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
839 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
840 break;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
841 nextpair = nvlist_next_nvpair(snaps, pair);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
842 error = dsl_dataset_hold(dp, nvpair_name(pair), FTAG, &ds);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
843 if (error == 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
844 dsl_dataset_rele(ds, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
845 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
846
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
847 if (error == 0) {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
848 error = zfs_secpolicy_destroy_perms(nvpair_name(pair),
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
849 cr);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
850 } else if (error == ENOENT) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
851 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
852 * Ignore any snapshots that don't exist (we consider
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
853 * them "already destroyed"). Remove the name from the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
854 * nvl here in case the snapshot is created between
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
855 * now and when we try to destroy it (in which case
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
856 * we don't want to destroy it since we haven't
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
857 * checked for permission).
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
858 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
859 fnvlist_remove_nvpair(snaps, pair);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
860 error = 0;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
861 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
862 if (error != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
863 break;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
864 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
865
11314
489ae7372a1f 6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents: 11209
diff changeset
866 return (error);
489ae7372a1f 6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents: 11209
diff changeset
867 }
489ae7372a1f 6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents: 11209
diff changeset
868
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
869 int
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
870 zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
871 {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
872 char parentname[MAXNAMELEN];
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
873 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
874
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
875 if ((error = zfs_secpolicy_write_perms(from,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
876 ZFS_DELEG_PERM_RENAME, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
877 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
878
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
879 if ((error = zfs_secpolicy_write_perms(from,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
880 ZFS_DELEG_PERM_MOUNT, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
881 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
882
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
883 if ((error = zfs_get_parent(to, parentname,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
884 sizeof (parentname))) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
885 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
886
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
887 if ((error = zfs_secpolicy_write_perms(parentname,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
888 ZFS_DELEG_PERM_CREATE, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
889 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
890
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
891 if ((error = zfs_secpolicy_write_perms(parentname,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
892 ZFS_DELEG_PERM_MOUNT, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
893 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
894
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
895 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
896 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
897
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
898 /* ARGSUSED */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
899 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
900 zfs_secpolicy_rename(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
901 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
902 return (zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr));
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
903 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
904
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
905 /* ARGSUSED */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
906 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
907 zfs_secpolicy_promote(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
908 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
909 dsl_pool_t *dp;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
910 dsl_dataset_t *clone;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
911 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
912
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
913 error = zfs_secpolicy_write_perms(zc->zc_name,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
914 ZFS_DELEG_PERM_PROMOTE, cr);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
915 if (error != 0)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
916 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
917
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
918 error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
919 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
920 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
921
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
922 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &clone);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
923
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
924 if (error == 0) {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
925 char parentname[MAXNAMELEN];
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
926 dsl_dataset_t *origin = NULL;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
927 dsl_dir_t *dd;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
928 dd = clone->ds_dir;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
929
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
930 error = dsl_dataset_hold_obj(dd->dd_pool,
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
931 dd->dd_phys->dd_origin_obj, FTAG, &origin);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
932 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
933 dsl_dataset_rele(clone, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
934 dsl_pool_rele(dp, FTAG);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
935 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
936 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
937
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
938 error = zfs_secpolicy_write_perms_ds(zc->zc_name, clone,
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
939 ZFS_DELEG_PERM_MOUNT, cr);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
940
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
941 dsl_dataset_name(origin, parentname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
942 if (error == 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
943 error = zfs_secpolicy_write_perms_ds(parentname, origin,
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
944 ZFS_DELEG_PERM_PROMOTE, cr);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
945 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
946 dsl_dataset_rele(clone, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
947 dsl_dataset_rele(origin, FTAG);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
948 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
949 dsl_pool_rele(dp, FTAG);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
950 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
951 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
952
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
953 /* ARGSUSED */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
954 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
955 zfs_secpolicy_recv(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
956 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
957 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
958
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
959 if ((error = zfs_secpolicy_write_perms(zc->zc_name,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
960 ZFS_DELEG_PERM_RECEIVE, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
961 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
962
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
963 if ((error = zfs_secpolicy_write_perms(zc->zc_name,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
964 ZFS_DELEG_PERM_MOUNT, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
965 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
966
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
967 return (zfs_secpolicy_write_perms(zc->zc_name,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
968 ZFS_DELEG_PERM_CREATE, cr));
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
969 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
970
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
971 int
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
972 zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
973 {
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
974 return (zfs_secpolicy_write_perms(name,
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
975 ZFS_DELEG_PERM_SNAPSHOT, cr));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
976 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
977
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
978 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
979 * Check for permission to create each snapshot in the nvlist.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
980 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
981 /* ARGSUSED */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
982 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
983 zfs_secpolicy_snapshot(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
984 {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
985 nvlist_t *snaps;
13952
7a22d0770fc8 3522 zfs module should not allow uninitialized variables
George Wilson <george.wilson@delphix.com>
parents: 13921
diff changeset
986 int error = 0;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
987 nvpair_t *pair;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
988
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
989 if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
990 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
991 for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
992 pair = nvlist_next_nvpair(snaps, pair)) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
993 char *name = nvpair_name(pair);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
994 char *atp = strchr(name, '@');
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
995
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
996 if (atp == NULL) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
997 error = SET_ERROR(EINVAL);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
998 break;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
999 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1000 *atp = '\0';
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1001 error = zfs_secpolicy_snapshot_perms(name, cr);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1002 *atp = '@';
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1003 if (error != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1004 break;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1005 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1006 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1007 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1008
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1009 /* ARGSUSED */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1010 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1011 zfs_secpolicy_log_history(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1012 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1013 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1014 * Even root must have a proper TSD so that we know what pool
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1015 * to log to.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1016 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1017 if (tsd_get(zfs_allow_log_key) == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1018 return (SET_ERROR(EPERM));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1019 return (0);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1020 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1021
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1022 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1023 zfs_secpolicy_create_clone(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1024 {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1025 char parentname[MAXNAMELEN];
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1026 int error;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1027 char *origin;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1028
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1029 if ((error = zfs_get_parent(zc->zc_name, parentname,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1030 sizeof (parentname))) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1031 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1032
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1033 if (nvlist_lookup_string(innvl, "origin", &origin) == 0 &&
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1034 (error = zfs_secpolicy_write_perms(origin,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1035 ZFS_DELEG_PERM_CLONE, cr)) != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1036 return (error);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1037
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1038 if ((error = zfs_secpolicy_write_perms(parentname,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1039 ZFS_DELEG_PERM_CREATE, cr)) != 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1040 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1041
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1042 return (zfs_secpolicy_write_perms(parentname,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1043 ZFS_DELEG_PERM_MOUNT, cr));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1044 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1045
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1046 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1047 * Policy for pool operations - create/destroy pools, add vdevs, etc. Requires
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1048 * SYS_CONFIG privilege, which is not available in a local zone.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1049 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1050 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1051 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1052 zfs_secpolicy_config(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1053 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1054 if (secpolicy_sys_config(cr, B_FALSE) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1055 return (SET_ERROR(EPERM));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1056
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1057 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1058 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1059
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1060 /*
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1061 * Policy for object to name lookups.
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1062 */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1063 /* ARGSUSED */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1064 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1065 zfs_secpolicy_diff(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1066 {
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1067 int error;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1068
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1069 if ((error = secpolicy_sys_config(cr, B_FALSE)) == 0)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1070 return (0);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1071
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1072 error = zfs_secpolicy_write_perms(zc->zc_name, ZFS_DELEG_PERM_DIFF, cr);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1073 return (error);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1074 }
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1075
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1076 /*
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1077 * Policy for fault injection. Requires all privileges.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1078 */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1079 /* ARGSUSED */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1080 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1081 zfs_secpolicy_inject(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1082 {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1083 return (secpolicy_zinject(cr));
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1084 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1085
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1086 /* ARGSUSED */
4849
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1087 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1088 zfs_secpolicy_inherit_prop(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
4849
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1089 {
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1090 zfs_prop_t prop = zfs_name_to_prop(zc->zc_value);
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1091
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1092 if (prop == ZPROP_INVAL) {
4849
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1093 if (!zfs_prop_user(zc->zc_value))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1094 return (SET_ERROR(EINVAL));
4849
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1095 return (zfs_secpolicy_write_perms(zc->zc_name,
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1096 ZFS_DELEG_PERM_USERPROP, cr));
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1097 } else {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1098 return (zfs_secpolicy_setprop(zc->zc_name, prop,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1099 NULL, cr));
4849
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1100 }
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1101 }
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
1102
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1103 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1104 zfs_secpolicy_userspace_one(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1105 {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1106 int err = zfs_secpolicy_read(zc, innvl, cr);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1107 if (err)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1108 return (err);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1109
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1110 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1111 return (SET_ERROR(EINVAL));
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1112
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1113 if (zc->zc_value[0] == 0) {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1114 /*
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1115 * They are asking about a posix uid/gid. If it's
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1116 * themself, allow it.
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1117 */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1118 if (zc->zc_objset_type == ZFS_PROP_USERUSED ||
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1119 zc->zc_objset_type == ZFS_PROP_USERQUOTA) {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1120 if (zc->zc_guid == crgetuid(cr))
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1121 return (0);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1122 } else {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1123 if (groupmember(zc->zc_guid, cr))
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1124 return (0);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1125 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1126 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1127
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1128 return (zfs_secpolicy_write_perms(zc->zc_name,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1129 userquota_perms[zc->zc_objset_type], cr));
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1130 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1131
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1132 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1133 zfs_secpolicy_userspace_many(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1134 {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1135 int err = zfs_secpolicy_read(zc, innvl, cr);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1136 if (err)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1137 return (err);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1138
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1139 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1140 return (SET_ERROR(EINVAL));
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1141
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1142 return (zfs_secpolicy_write_perms(zc->zc_name,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1143 userquota_perms[zc->zc_objset_type], cr));
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1144 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1145
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1146 /* ARGSUSED */
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1147 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1148 zfs_secpolicy_userspace_upgrade(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1149 {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1150 return (zfs_secpolicy_setprop(zc->zc_name, ZFS_PROP_VERSION,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1151 NULL, cr));
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1152 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1153
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1154 /* ARGSUSED */
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1155 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1156 zfs_secpolicy_hold(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1157 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1158 nvpair_t *pair;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1159 nvlist_t *holds;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1160 int error;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1161
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1162 error = nvlist_lookup_nvlist(innvl, "holds", &holds);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1163 if (error != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1164 return (SET_ERROR(EINVAL));
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1165
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1166 for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1167 pair = nvlist_next_nvpair(holds, pair)) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1168 char fsname[MAXNAMELEN];
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1169 error = dmu_fsname(nvpair_name(pair), fsname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1170 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1171 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1172 error = zfs_secpolicy_write_perms(fsname,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1173 ZFS_DELEG_PERM_HOLD, cr);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1174 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1175 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1176 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1177 return (0);
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1178 }
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1179
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1180 /* ARGSUSED */
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1181 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1182 zfs_secpolicy_release(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1183 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1184 nvpair_t *pair;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1185 int error;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1186
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1187 for (pair = nvlist_next_nvpair(innvl, NULL); pair != NULL;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1188 pair = nvlist_next_nvpair(innvl, pair)) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1189 char fsname[MAXNAMELEN];
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1190 error = dmu_fsname(nvpair_name(pair), fsname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1191 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1192 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1193 error = zfs_secpolicy_write_perms(fsname,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1194 ZFS_DELEG_PERM_RELEASE, cr);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1195 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1196 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1197 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1198 return (0);
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1199 }
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
1200
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1201 /*
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1202 * Policy for allowing temporary snapshots to be taken or released
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1203 */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1204 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1205 zfs_secpolicy_tmp_snapshot(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1206 {
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1207 /*
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1208 * A temporary snapshot is the same as a snapshot,
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1209 * hold, destroy and release all rolled into one.
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1210 * Delegated diff alone is sufficient that we allow this.
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1211 */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1212 int error;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1213
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1214 if ((error = zfs_secpolicy_write_perms(zc->zc_name,
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1215 ZFS_DELEG_PERM_DIFF, cr)) == 0)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1216 return (0);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1217
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1218 error = zfs_secpolicy_snapshot_perms(zc->zc_name, cr);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1219 if (error == 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1220 error = zfs_secpolicy_hold(zc, innvl, cr);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1221 if (error == 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1222 error = zfs_secpolicy_release(zc, innvl, cr);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1223 if (error == 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1224 error = zfs_secpolicy_destroy(zc, innvl, cr);
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1225 return (error);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1226 }
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1227
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1228 /*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1229 * Returns the nvlist as specified by the user in the zfs_cmd_t.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1230 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1231 static int
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1232 get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1233 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1234 char *packed;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1235 int error;
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1236 nvlist_t *list = NULL;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1237
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1238 /*
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1239 * Read in and unpack the user-supplied nvlist.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1240 */
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1241 if (size == 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1242 return (SET_ERROR(EINVAL));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1243
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1244 packed = kmem_alloc(size, KM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1245
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1246 if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size,
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1247 iflag)) != 0) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1248 kmem_free(packed, size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1249 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1250 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1251
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1252 if ((error = nvlist_unpack(packed, size, &list, 0)) != 0) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1253 kmem_free(packed, size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1254 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1255 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1256
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1257 kmem_free(packed, size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1258
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1259 *nvp = list;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1260 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1261 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1262
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1263 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1264 * Reduce the size of this nvlist until it can be serialized in 'max' bytes.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1265 * Entries will be removed from the end of the nvlist, and one int32 entry
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1266 * named "N_MORE_ERRORS" will be added indicating how many entries were
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1267 * removed.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1268 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1269 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1270 nvlist_smush(nvlist_t *errors, size_t max)
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1271 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1272 size_t size;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1273
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1274 size = fnvlist_size(errors);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1275
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1276 if (size > max) {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1277 nvpair_t *more_errors;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1278 int n = 0;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1279
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1280 if (max < 1024)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1281 return (SET_ERROR(ENOMEM));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1282
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1283 fnvlist_add_int32(errors, ZPROP_N_MORE_ERRORS, 0);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1284 more_errors = nvlist_prev_nvpair(errors, NULL);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1285
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1286 do {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1287 nvpair_t *pair = nvlist_prev_nvpair(errors,
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1288 more_errors);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1289 fnvlist_remove_nvpair(errors, pair);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1290 n++;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1291 size = fnvlist_size(errors);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1292 } while (size > max);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1293
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1294 fnvlist_remove_nvpair(errors, more_errors);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1295 fnvlist_add_int32(errors, ZPROP_N_MORE_ERRORS, n);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1296 ASSERT3U(fnvlist_size(errors), <=, max);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1297 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1298
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1299 return (0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1300 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1301
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1302 static int
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1303 put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1304 {
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1305 char *packed = NULL;
11807
73a3c0d27389 6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents: 11727
diff changeset
1306 int error = 0;
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1307 size_t size;
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1308
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1309 size = fnvlist_size(nvl);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1310
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1311 if (size > zc->zc_nvlist_dst_size) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1312 error = SET_ERROR(ENOMEM);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1313 } else {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1314 packed = fnvlist_pack(nvl, &size);
11807
73a3c0d27389 6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents: 11727
diff changeset
1315 if (ddi_copyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst,
73a3c0d27389 6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents: 11727
diff changeset
1316 size, zc->zc_iflags) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1317 error = SET_ERROR(EFAULT);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1318 fnvlist_pack_free(packed, size);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1319 }
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1320
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1321 zc->zc_nvlist_dst_size = size;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1322 zc->zc_nvlist_dst_filled = B_TRUE;
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1323 return (error);
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1324 }
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1325
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1326 static int
11185
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1327 getzfsvfs(const char *dsname, zfsvfs_t **zfvp)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1328 {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1329 objset_t *os;
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1330 int error;
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1331
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1332 error = dmu_objset_hold(dsname, FTAG, &os);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1333 if (error != 0)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1334 return (error);
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1335 if (dmu_objset_type(os) != DMU_OST_ZFS) {
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1336 dmu_objset_rele(os, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1337 return (SET_ERROR(EINVAL));
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1338 }
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1339
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1340 mutex_enter(&os->os_user_ptr_lock);
11185
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1341 *zfvp = dmu_objset_get_user(os);
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1342 if (*zfvp) {
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1343 VFS_HOLD((*zfvp)->z_vfs);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1344 } else {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1345 error = SET_ERROR(ESRCH);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1346 }
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1347 mutex_exit(&os->os_user_ptr_lock);
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1348 dmu_objset_rele(os, FTAG);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1349 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1350 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1351
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1352 /*
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1353 * Find a zfsvfs_t for a mounted filesystem, or create our own, in which
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1354 * case its z_vfs will be NULL, and it will be opened as the owner.
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1355 * If 'writer' is set, the z_teardown_lock will be held for RW_WRITER,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1356 * which prevents all vnode ops from running.
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1357 */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1358 static int
12620
12fcd99a642d 6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12527
diff changeset
1359 zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zfvp, boolean_t writer)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1360 {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1361 int error = 0;
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1362
11185
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1363 if (getzfsvfs(name, zfvp) != 0)
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1364 error = zfsvfs_create(name, zfvp);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1365 if (error == 0) {
12620
12fcd99a642d 6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12527
diff changeset
1366 rrw_enter(&(*zfvp)->z_teardown_lock, (writer) ? RW_WRITER :
12fcd99a642d 6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12527
diff changeset
1367 RW_READER, tag);
11185
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1368 if ((*zfvp)->z_unmounted) {
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1369 /*
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1370 * XXX we could probably try again, since the unmounting
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1371 * thread should be just about to disassociate the
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1372 * objset from the zfsvfs.
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1373 */
11185
f0c31008e395 6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents: 11181
diff changeset
1374 rrw_exit(&(*zfvp)->z_teardown_lock, tag);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1375 return (SET_ERROR(EBUSY));
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1376 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1377 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1378 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1379 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1380
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1381 static void
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1382 zfsvfs_rele(zfsvfs_t *zfsvfs, void *tag)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1383 {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1384 rrw_exit(&zfsvfs->z_teardown_lock, tag);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1385
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1386 if (zfsvfs->z_vfs) {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1387 VFS_RELE(zfsvfs->z_vfs);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1388 } else {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1389 dmu_objset_disown(zfsvfs->z_os, zfsvfs);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1390 zfsvfs_free(zfsvfs);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1391 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1392 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1393
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
1394 static int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1395 zfs_ioc_pool_create(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1396 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1397 int error;
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1398 nvlist_t *config, *props = NULL;
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1399 nvlist_t *rootprops = NULL;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1400 nvlist_t *zplprops = NULL;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1401
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1402 if (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1403 zc->zc_iflags, &config))
4988
db8abd9846d4 6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents: 4849
diff changeset
1404 return (error);
4715
e8d212dda064 6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents: 4670
diff changeset
1405
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1406 if (zc->zc_nvlist_src_size != 0 && (error =
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1407 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1408 zc->zc_iflags, &props))) {
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1409 nvlist_free(config);
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1410 return (error);
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1411 }
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1412
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1413 if (props) {
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1414 nvlist_t *nvl = NULL;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1415 uint64_t version = SPA_VERSION;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1416
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1417 (void) nvlist_lookup_uint64(props,
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1418 zpool_prop_to_name(ZPOOL_PROP_VERSION), &version);
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1419 if (!SPA_VERSION_IS_SUPPORTED(version)) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1420 error = SET_ERROR(EINVAL);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1421 goto pool_props_bad;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1422 }
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1423 (void) nvlist_lookup_nvlist(props, ZPOOL_ROOTFS_PROPS, &nvl);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1424 if (nvl) {
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1425 error = nvlist_dup(nvl, &rootprops, KM_SLEEP);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1426 if (error != 0) {
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1427 nvlist_free(config);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1428 nvlist_free(props);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1429 return (error);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1430 }
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1431 (void) nvlist_remove_all(props, ZPOOL_ROOTFS_PROPS);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1432 }
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1433 VERIFY(nvlist_alloc(&zplprops, NV_UNIQUE_NAME, KM_SLEEP) == 0);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1434 error = zfs_fill_zplprops_root(version, rootprops,
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1435 zplprops, NULL);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1436 if (error != 0)
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1437 goto pool_props_bad;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1438 }
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1439
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1440 error = spa_create(zc->zc_name, config, props, zplprops);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1441
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1442 /*
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1443 * Set the remaining root properties
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1444 */
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1445 if (!error && (error = zfs_set_prop_nvlist(zc->zc_name,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1446 ZPROP_SRC_LOCAL, rootprops, NULL)) != 0)
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1447 (void) spa_destroy(zc->zc_name);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1448
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1449 pool_props_bad:
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1450 nvlist_free(rootprops);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1451 nvlist_free(zplprops);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1452 nvlist_free(config);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
1453 nvlist_free(props);
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1454
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1455 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1456 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1457
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1458 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1459 zfs_ioc_pool_destroy(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1460 {
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1461 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1462 zfs_log_history(zc);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1463 error = spa_destroy(zc->zc_name);
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
1464 if (error == 0)
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
1465 zvol_remove_minors(zc->zc_name);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1466 return (error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1467 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1468
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1469 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1470 zfs_ioc_pool_import(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1471 {
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1472 nvlist_t *config, *props = NULL;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1473 uint64_t guid;
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
1474 int error;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1475
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1476 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1477 zc->zc_iflags, &config)) != 0)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1478 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1479
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1480 if (zc->zc_nvlist_src_size != 0 && (error =
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1481 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1482 zc->zc_iflags, &props))) {
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1483 nvlist_free(config);
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1484 return (error);
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1485 }
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1486
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1487 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) != 0 ||
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1488 guid != zc->zc_guid)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1489 error = SET_ERROR(EINVAL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1490 else
12961
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1491 error = spa_import(zc->zc_name, config, props, zc->zc_cookie);
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1492
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1493 if (zc->zc_nvlist_dst != 0) {
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1494 int err;
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1495
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1496 if ((err = put_nvlist(zc, config)) != 0)
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1497 error = err;
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
1498 }
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
1499
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1500 nvlist_free(config);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1501
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1502 if (props)
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1503 nvlist_free(props);
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1504
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1505 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1506 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1507
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1508 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1509 zfs_ioc_pool_export(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1510 {
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1511 int error;
7214
04c540040a32 6721908 A hot spare "in use" in an exported zpool, is stolen when a disk fails in an imported pool.
lling
parents: 7184
diff changeset
1512 boolean_t force = (boolean_t)zc->zc_cookie;
8211
32722be6ad3b 6775357 ZFS should have a way to export a pool without touching anything
George Wilson <George.Wilson@Sun.COM>
parents: 8080
diff changeset
1513 boolean_t hardforce = (boolean_t)zc->zc_guid;
7214
04c540040a32 6721908 A hot spare "in use" in an exported zpool, is stolen when a disk fails in an imported pool.
lling
parents: 7184
diff changeset
1514
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1515 zfs_log_history(zc);
8211
32722be6ad3b 6775357 ZFS should have a way to export a pool without touching anything
George Wilson <George.Wilson@Sun.COM>
parents: 8080
diff changeset
1516 error = spa_export(zc->zc_name, NULL, force, hardforce);
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
1517 if (error == 0)
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
1518 zvol_remove_minors(zc->zc_name);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
1519 return (error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1520 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1521
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1522 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1523 zfs_ioc_pool_configs(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1524 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1525 nvlist_t *configs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1526 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1527
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1528 if ((configs = spa_all_configs(&zc->zc_cookie)) == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1529 return (SET_ERROR(EEXIST));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1530
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1531 error = put_nvlist(zc, configs);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1532
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1533 nvlist_free(configs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1534
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1535 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1536 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1537
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1538 /*
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1539 * inputs:
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1540 * zc_name name of the pool
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1541 *
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1542 * outputs:
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1543 * zc_cookie real errno
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1544 * zc_nvlist_dst config nvlist
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1545 * zc_nvlist_dst_size size of config nvlist
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1546 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1547 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1548 zfs_ioc_pool_stats(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1549 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1550 nvlist_t *config;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1551 int error;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1552 int ret = 0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1553
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1554 error = spa_get_stats(zc->zc_name, &config, zc->zc_value,
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1555 sizeof (zc->zc_value));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1556
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1557 if (config != NULL) {
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1558 ret = put_nvlist(zc, config);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1559 nvlist_free(config);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1560
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1561 /*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1562 * The config may be present even if 'error' is non-zero.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1563 * In this case we return success, and preserve the real errno
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1564 * in 'zc_cookie'.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1565 */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1566 zc->zc_cookie = error;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1567 } else {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1568 ret = error;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1569 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1570
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1571 return (ret);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1572 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1573
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1574 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1575 * Try to import the given pool, returning pool stats as appropriate so that
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1576 * user land knows which devices are available and overall pool health.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1577 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1578 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1579 zfs_ioc_pool_tryimport(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1580 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1581 nvlist_t *tryconfig, *config;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1582 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1583
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1584 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1585 zc->zc_iflags, &tryconfig)) != 0)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1586 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1587
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1588 config = spa_tryimport(tryconfig);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1589
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1590 nvlist_free(tryconfig);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1591
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1592 if (config == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1593 return (SET_ERROR(EINVAL));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1594
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1595 error = put_nvlist(zc, config);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1596 nvlist_free(config);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1597
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1598 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1599 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1600
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1601 /*
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1602 * inputs:
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1603 * zc_name name of the pool
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1604 * zc_cookie scan func (pool_scan_func_t)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1605 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1606 static int
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1607 zfs_ioc_pool_scan(zfs_cmd_t *zc)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1608 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1609 spa_t *spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1610 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1611
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1612 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1613 return (error);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1614
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1615 if (zc->zc_cookie == POOL_SCAN_NONE)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1616 error = spa_scan_stop(spa);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1617 else
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1618 error = spa_scan(spa, zc->zc_cookie);
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1619
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1620 spa_close(spa, FTAG);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1621
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1622 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1623 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1624
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1625 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1626 zfs_ioc_pool_freeze(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1627 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1628 spa_t *spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1629 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1630
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1631 error = spa_open(zc->zc_name, &spa, FTAG);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1632 if (error == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1633 spa_freeze(spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1634 spa_close(spa, FTAG);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1635 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1636 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1637 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1638
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1639 static int
1760
e1ad2821c30d PSARC 2006/206 zpool upgrade
eschrock
parents: 1544
diff changeset
1640 zfs_ioc_pool_upgrade(zfs_cmd_t *zc)
e1ad2821c30d PSARC 2006/206 zpool upgrade
eschrock
parents: 1544
diff changeset
1641 {
e1ad2821c30d PSARC 2006/206 zpool upgrade
eschrock
parents: 1544
diff changeset
1642 spa_t *spa;
e1ad2821c30d PSARC 2006/206 zpool upgrade
eschrock
parents: 1544
diff changeset
1643 int error;
e1ad2821c30d PSARC 2006/206 zpool upgrade
eschrock
parents: 1544
diff changeset
1644
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1645 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1646 return (error);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1647
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1648 if (zc->zc_cookie < spa_version(spa) ||
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13686
diff changeset
1649 !SPA_VERSION_IS_SUPPORTED(zc->zc_cookie)) {
5118
c723b1aa9f79 6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents: 5094
diff changeset
1650 spa_close(spa, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1651 return (SET_ERROR(EINVAL));
5118
c723b1aa9f79 6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents: 5094
diff changeset
1652 }
c723b1aa9f79 6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents: 5094
diff changeset
1653
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1654 spa_upgrade(spa, zc->zc_cookie);
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1655 spa_close(spa, FTAG);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1656
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1657 return (error);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1658 }
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1659
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1660 static int
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1661 zfs_ioc_pool_get_history(zfs_cmd_t *zc)
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1662 {
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1663 spa_t *spa;
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1664 char *hist_buf;
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1665 uint64_t size;
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1666 int error;
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1667
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1668 if ((size = zc->zc_history_len) == 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1669 return (SET_ERROR(EINVAL));
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1670
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1671 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1672 return (error);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1673
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
1674 if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) {
3863
d56571426115 6529406 zpool history needs to bump the on-disk version
ek110237
parents: 3741
diff changeset
1675 spa_close(spa, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1676 return (SET_ERROR(ENOTSUP));
3863
d56571426115 6529406 zpool history needs to bump the on-disk version
ek110237
parents: 3741
diff changeset
1677 }
d56571426115 6529406 zpool history needs to bump the on-disk version
ek110237
parents: 3741
diff changeset
1678
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1679 hist_buf = kmem_alloc(size, KM_SLEEP);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1680 if ((error = spa_history_get(spa, &zc->zc_history_offset,
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1681 &zc->zc_history_len, hist_buf)) == 0) {
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1682 error = ddi_copyout(hist_buf,
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1683 (void *)(uintptr_t)zc->zc_history,
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1684 zc->zc_history_len, zc->zc_iflags);
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1685 }
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1686
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1687 spa_close(spa, FTAG);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1688 kmem_free(hist_buf, size);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1689 return (error);
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1690 }
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1691
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1692 static int
13514
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1693 zfs_ioc_pool_reguid(zfs_cmd_t *zc)
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1694 {
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1695 spa_t *spa;
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1696 int error;
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1697
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1698 error = spa_open(zc->zc_name, &spa, FTAG);
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1699 if (error == 0) {
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1700 error = spa_change_guid(spa);
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1701 spa_close(spa, FTAG);
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1702 }
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1703 return (error);
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1704 }
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1705
417c34452f03 1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents: 13512
diff changeset
1706 static int
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1707 zfs_ioc_dsobj_to_dsname(zfs_cmd_t *zc)
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1708 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
1709 return (dsl_dsobj_to_dsname(zc->zc_name, zc->zc_obj, zc->zc_value));
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1710 }
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1711
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1712 /*
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1713 * inputs:
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1714 * zc_name name of filesystem
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1715 * zc_obj object to find
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1716 *
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1717 * outputs:
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1718 * zc_value name of object
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1719 */
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1720 static int
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1721 zfs_ioc_obj_to_path(zfs_cmd_t *zc)
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1722 {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1723 objset_t *os;
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1724 int error;
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1725
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1726 /* XXX reading from objset not owned */
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1727 if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os)) != 0)
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1728 return (error);
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1729 if (dmu_objset_type(os) != DMU_OST_ZFS) {
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1730 dmu_objset_rele(os, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1731 return (SET_ERROR(EINVAL));
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1732 }
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1733 error = zfs_obj_to_path(os, zc->zc_obj, zc->zc_value,
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1734 sizeof (zc->zc_value));
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1735 dmu_objset_rele(os, FTAG);
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1736
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1737 return (error);
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1738 }
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1739
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1740 /*
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1741 * inputs:
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1742 * zc_name name of filesystem
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1743 * zc_obj object to find
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1744 *
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1745 * outputs:
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1746 * zc_stat stats on object
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1747 * zc_value path to object
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1748 */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1749 static int
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1750 zfs_ioc_obj_to_stats(zfs_cmd_t *zc)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1751 {
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1752 objset_t *os;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1753 int error;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1754
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1755 /* XXX reading from objset not owned */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1756 if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os)) != 0)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1757 return (error);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1758 if (dmu_objset_type(os) != DMU_OST_ZFS) {
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1759 dmu_objset_rele(os, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1760 return (SET_ERROR(EINVAL));
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1761 }
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1762 error = zfs_obj_to_stats(os, zc->zc_obj, &zc->zc_stat, zc->zc_value,
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1763 sizeof (zc->zc_value));
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1764 dmu_objset_rele(os, FTAG);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1765
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1766 return (error);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1767 }
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
1768
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3265
diff changeset
1769 static int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1770 zfs_ioc_vdev_add(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1771 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1772 spa_t *spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1773 int error;
6423
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1774 nvlist_t *config, **l2cache, **spares;
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1775 uint_t nl2cache = 0, nspares = 0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1776
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1777 error = spa_open(zc->zc_name, &spa, FTAG);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1778 if (error != 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1779 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1780
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
1781 error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1782 zc->zc_iflags, &config);
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
1783 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_L2CACHE,
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
1784 &l2cache, &nl2cache);
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
1785
6423
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1786 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_SPARES,
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1787 &spares, &nspares);
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1788
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
1789 /*
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
1790 * A root pool with concatenated devices is not supported.
6423
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1791 * Thus, can not add a device to a root pool.
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1792 *
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1793 * Intent log device can not be added to a rootpool because
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1794 * during mountroot, zil is replayed, a seperated log device
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1795 * can not be accessed during the mountroot time.
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1796 *
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
1797 * l2cache and spare devices are ok to be added to a rootpool.
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
1798 */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1799 if (spa_bootfs(spa) != 0 && nl2cache == 0 && nspares == 0) {
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1800 nvlist_free(config);
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
1801 spa_close(spa, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1802 return (SET_ERROR(EDOM));
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
1803 }
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
1804
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
1805 if (error == 0) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1806 error = spa_vdev_add(spa, config);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1807 nvlist_free(config);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1808 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1809 spa_close(spa, FTAG);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1810 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1811 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1812
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1813 /*
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1814 * inputs:
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1815 * zc_name name of the pool
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1816 * zc_nvlist_conf nvlist of devices to remove
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1817 * zc_cookie to stop the remove?
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 11935
diff changeset
1818 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1819 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1820 zfs_ioc_vdev_remove(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1821 {
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1822 spa_t *spa;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1823 int error;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1824
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1825 error = spa_open(zc->zc_name, &spa, FTAG);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1826 if (error != 0)
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1827 return (error);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1828 error = spa_vdev_remove(spa, zc->zc_guid, B_FALSE);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1829 spa_close(spa, FTAG);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
1830 return (error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1831 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1832
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1833 static int
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1834 zfs_ioc_vdev_set_state(zfs_cmd_t *zc)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1835 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1836 spa_t *spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1837 int error;
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1838 vdev_state_t newstate = VDEV_STATE_UNKNOWN;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1839
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1840 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1841 return (error);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1842 switch (zc->zc_cookie) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1843 case VDEV_STATE_ONLINE:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1844 error = vdev_online(spa, zc->zc_guid, zc->zc_obj, &newstate);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1845 break;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1846
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1847 case VDEV_STATE_OFFLINE:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1848 error = vdev_offline(spa, zc->zc_guid, zc->zc_obj);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1849 break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1850
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1851 case VDEV_STATE_FAULTED:
10817
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1852 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED &&
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1853 zc->zc_obj != VDEV_AUX_EXTERNAL)
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1854 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED;
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1855
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1856 error = vdev_fault(spa, zc->zc_guid, zc->zc_obj);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1857 break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1858
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1859 case VDEV_STATE_DEGRADED:
10817
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1860 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED &&
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1861 zc->zc_obj != VDEV_AUX_EXTERNAL)
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1862 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED;
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1863
7dfde45252f0 6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10693
diff changeset
1864 error = vdev_degrade(spa, zc->zc_guid, zc->zc_obj);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1865 break;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1866
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1867 default:
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
1868 error = SET_ERROR(EINVAL);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1869 }
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents: 4098
diff changeset
1870 zc->zc_cookie = newstate;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1871 spa_close(spa, FTAG);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1872 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1873 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1874
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1875 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1876 zfs_ioc_vdev_attach(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1877 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1878 spa_t *spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1879 int replacing = zc->zc_cookie;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1880 nvlist_t *config;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1881 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1882
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1883 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1884 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1885
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
1886 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
1887 zc->zc_iflags, &config)) == 0) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1888 error = spa_vdev_attach(spa, zc->zc_guid, config, replacing);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1889 nvlist_free(config);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1890 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1891
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1892 spa_close(spa, FTAG);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1893 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1894 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1895
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1896 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1897 zfs_ioc_vdev_detach(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1898 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1899 spa_t *spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1900 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1901
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1902 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1903 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1904
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8213
diff changeset
1905 error = spa_vdev_detach(spa, zc->zc_guid, 0, B_FALSE);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1906
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1907 spa_close(spa, FTAG);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1908 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1909 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1910
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1911 static int
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1912 zfs_ioc_vdev_split(zfs_cmd_t *zc)
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1913 {
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1914 spa_t *spa;
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1915 nvlist_t *config, *props = NULL;
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1916 int error;
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1917 boolean_t exp = !!(zc->zc_cookie & ZPOOL_EXPORT_AFTER_SPLIT);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1918
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1919 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1920 return (error);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1921
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1922 if (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1923 zc->zc_iflags, &config)) {
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1924 spa_close(spa, FTAG);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1925 return (error);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1926 }
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1927
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1928 if (zc->zc_nvlist_src_size != 0 && (error =
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1929 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1930 zc->zc_iflags, &props))) {
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1931 spa_close(spa, FTAG);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1932 nvlist_free(config);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1933 return (error);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1934 }
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1935
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1936 error = spa_vdev_split_mirror(spa, zc->zc_string, config, props, exp);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1937
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1938 spa_close(spa, FTAG);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1939
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1940 nvlist_free(config);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1941 nvlist_free(props);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1942
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1943 return (error);
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1944 }
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1945
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
1946 static int
1354
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1947 zfs_ioc_vdev_setpath(zfs_cmd_t *zc)
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1948 {
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1949 spa_t *spa;
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
1950 char *path = zc->zc_value;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
1951 uint64_t guid = zc->zc_guid;
1354
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1952 int error;
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1953
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1954 error = spa_open(zc->zc_name, &spa, FTAG);
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1955 if (error != 0)
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1956 return (error);
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1957
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1958 error = spa_vdev_setpath(spa, guid, path);
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1959 spa_close(spa, FTAG);
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1960 return (error);
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1961 }
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1962
9425
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1963 static int
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1964 zfs_ioc_vdev_setfru(zfs_cmd_t *zc)
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1965 {
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1966 spa_t *spa;
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1967 char *fru = zc->zc_value;
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1968 uint64_t guid = zc->zc_guid;
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1969 int error;
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1970
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1971 error = spa_open(zc->zc_name, &spa, FTAG);
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1972 if (error != 0)
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1973 return (error);
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1974
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1975 error = spa_vdev_setfru(spa, guid, fru);
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1976 spa_close(spa, FTAG);
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1977 return (error);
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1978 }
e7ffacaec3a8 6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 9396
diff changeset
1979
1354
81359ee1ee63 6362672 import gets confused about overlapping slices
eschrock
parents: 1133
diff changeset
1980 static int
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
1981 zfs_ioc_objset_stats_impl(zfs_cmd_t *zc, objset_t *os)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1982 {
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
1983 int error = 0;
1356
e021b5e4aa0e 6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents: 1354
diff changeset
1984 nvlist_t *nv;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1985
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1986 dmu_objset_fast_stat(os, &zc->zc_objset_stats);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1987
2856
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2717
diff changeset
1988 if (zc->zc_nvlist_dst != 0 &&
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
1989 (error = dsl_prop_get_all(os, &nv)) == 0) {
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1990 dmu_objset_stats(os, nv);
3087
62df4acfd5cb 6468748 assertion failure in dnode_sync
ahrens
parents: 2926
diff changeset
1991 /*
5147
5e950ccc9585 6596190 "zfs list" is slow due to version property
rm160521
parents: 5118
diff changeset
1992 * NB: zvol_get_stats() will read the objset contents,
3087
62df4acfd5cb 6468748 assertion failure in dnode_sync
ahrens
parents: 2926
diff changeset
1993 * which we aren't supposed to do with a
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
1994 * DS_MODE_USER hold, because it could be
3087
62df4acfd5cb 6468748 assertion failure in dnode_sync
ahrens
parents: 2926
diff changeset
1995 * inconsistent. So this is a bit of a workaround...
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
1996 * XXX reading with out owning
3087
62df4acfd5cb 6468748 assertion failure in dnode_sync
ahrens
parents: 2926
diff changeset
1997 */
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
1998 if (!zc->zc_objset_stats.dds_inconsistent &&
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
1999 dmu_objset_type(os) == DMU_OST_ZVOL) {
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
2000 error = zvol_get_stats(os, nv);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
2001 if (error == EIO)
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
2002 return (error);
13805
e3a9ae14a119 3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents: 13794
diff changeset
2003 VERIFY0(error);
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
2004 }
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2005 error = put_nvlist(zc, nv);
1356
e021b5e4aa0e 6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents: 1354
diff changeset
2006 nvlist_free(nv);
e021b5e4aa0e 6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents: 1354
diff changeset
2007 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2008
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2009 return (error);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2010 }
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2011
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2012 /*
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2013 * inputs:
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2014 * zc_name name of filesystem
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2015 * zc_nvlist_dst_size size of buffer for property nvlist
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2016 *
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2017 * outputs:
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2018 * zc_objset_stats stats
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2019 * zc_nvlist_dst property nvlist
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2020 * zc_nvlist_dst_size size of property nvlist
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2021 */
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2022 static int
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2023 zfs_ioc_objset_stats(zfs_cmd_t *zc)
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2024 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2025 objset_t *os;
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2026 int error;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2027
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2028 error = dmu_objset_hold(zc->zc_name, FTAG, &os);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2029 if (error == 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2030 error = zfs_ioc_objset_stats_impl(zc, os);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2031 dmu_objset_rele(os, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2032 }
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2033
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2034 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2035 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2036
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2037 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2038 * inputs:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2039 * zc_name name of filesystem
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2040 * zc_nvlist_dst_size size of buffer for property nvlist
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2041 *
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2042 * outputs:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2043 * zc_nvlist_dst received property nvlist
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2044 * zc_nvlist_dst_size size of received property nvlist
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2045 *
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2046 * Gets received properties (distinct from local properties on or after
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2047 * SPA_VERSION_RECVD_PROPS) for callers who want to differentiate received from
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2048 * local property values.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2049 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2050 static int
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2051 zfs_ioc_objset_recvd_props(zfs_cmd_t *zc)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2052 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2053 int error = 0;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2054 nvlist_t *nv;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2055
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2056 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2057 * Without this check, we would return local property values if the
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2058 * caller has not already received properties on or after
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2059 * SPA_VERSION_RECVD_PROPS.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2060 */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2061 if (!dsl_prop_get_hasrecvd(zc->zc_name))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2062 return (SET_ERROR(ENOTSUP));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2063
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2064 if (zc->zc_nvlist_dst != 0 &&
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2065 (error = dsl_prop_get_received(zc->zc_name, &nv)) == 0) {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2066 error = put_nvlist(zc, nv);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2067 nvlist_free(nv);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2068 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2069
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2070 return (error);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2071 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2072
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2073 static int
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2074 nvl_add_zplprop(objset_t *os, nvlist_t *props, zfs_prop_t prop)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2075 {
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2076 uint64_t value;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2077 int error;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2078
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2079 /*
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2080 * zfs_get_zplprop() will either find a value or give us
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2081 * the default value (if there is one).
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2082 */
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2083 if ((error = zfs_get_zplprop(os, prop, &value)) != 0)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2084 return (error);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2085 VERIFY(nvlist_add_uint64(props, zfs_prop_to_name(prop), value) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2086 return (0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2087 }
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2088
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2089 /*
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2090 * inputs:
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2091 * zc_name name of filesystem
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2092 * zc_nvlist_dst_size size of buffer for zpl property nvlist
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2093 *
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2094 * outputs:
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2095 * zc_nvlist_dst zpl property nvlist
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2096 * zc_nvlist_dst_size size of zpl property nvlist
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2097 */
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2098 static int
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2099 zfs_ioc_objset_zplprops(zfs_cmd_t *zc)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2100 {
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2101 objset_t *os;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2102 int err;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2103
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
2104 /* XXX reading without owning */
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
2105 if (err = dmu_objset_hold(zc->zc_name, FTAG, &os))
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2106 return (err);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2107
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2108 dmu_objset_fast_stat(os, &zc->zc_objset_stats);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2109
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2110 /*
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2111 * NB: nvl_add_zplprop() will read the objset contents,
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
2112 * which we aren't supposed to do with a DS_MODE_USER
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
2113 * hold, because it could be inconsistent.
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2114 */
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2115 if (zc->zc_nvlist_dst != NULL &&
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2116 !zc->zc_objset_stats.dds_inconsistent &&
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2117 dmu_objset_type(os) == DMU_OST_ZFS) {
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2118 nvlist_t *nv;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2119
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2120 VERIFY(nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2121 if ((err = nvl_add_zplprop(os, nv, ZFS_PROP_VERSION)) == 0 &&
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2122 (err = nvl_add_zplprop(os, nv, ZFS_PROP_NORMALIZE)) == 0 &&
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2123 (err = nvl_add_zplprop(os, nv, ZFS_PROP_UTF8ONLY)) == 0 &&
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2124 (err = nvl_add_zplprop(os, nv, ZFS_PROP_CASE)) == 0)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2125 err = put_nvlist(zc, nv);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2126 nvlist_free(nv);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2127 } else {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2128 err = SET_ERROR(ENOENT);
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2129 }
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
2130 dmu_objset_rele(os, FTAG);
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2131 return (err);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2132 }
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2133
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2134 static boolean_t
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2135 dataset_name_hidden(const char *name)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2136 {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2137 /*
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2138 * Skip over datasets that are not visible in this zone,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2139 * internal datasets (which have a $ in their name), and
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2140 * temporary datasets (which have a % in their name).
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2141 */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2142 if (strchr(name, '$') != NULL)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2143 return (B_TRUE);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2144 if (strchr(name, '%') != NULL)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2145 return (B_TRUE);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2146 if (!INGLOBALZONE(curproc) && !zone_dataset_visible(name, NULL))
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2147 return (B_TRUE);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2148 return (B_FALSE);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2149 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2150
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2151 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2152 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2153 * zc_name name of filesystem
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2154 * zc_cookie zap cursor
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2155 * zc_nvlist_dst_size size of buffer for property nvlist
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2156 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2157 * outputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2158 * zc_name name of next filesystem
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2159 * zc_cookie zap cursor
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2160 * zc_objset_stats stats
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2161 * zc_nvlist_dst property nvlist
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2162 * zc_nvlist_dst_size size of property nvlist
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2163 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2164 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2165 zfs_ioc_dataset_list_next(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2166 {
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2167 objset_t *os;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2168 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2169 char *p;
11546
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2170 size_t orig_len = strlen(zc->zc_name);
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2171
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2172 top:
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
2173 if (error = dmu_objset_hold(zc->zc_name, FTAG, &os)) {
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2174 if (error == ENOENT)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2175 error = SET_ERROR(ESRCH);
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2176 return (error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2177 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2178
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2179 p = strrchr(zc->zc_name, '/');
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2180 if (p == NULL || p[1] != '\0')
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2181 (void) strlcat(zc->zc_name, "/", sizeof (zc->zc_name));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2182 p = zc->zc_name + strlen(zc->zc_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2183
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2184 do {
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2185 error = dmu_dir_list_next(os,
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2186 sizeof (zc->zc_name) - (p - zc->zc_name), p,
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2187 NULL, &zc->zc_cookie);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2188 if (error == ENOENT)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2189 error = SET_ERROR(ESRCH);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
2190 } while (error == 0 && dataset_name_hidden(zc->zc_name));
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
2191 dmu_objset_rele(os, FTAG);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2192
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
2193 /*
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
2194 * If it's an internal dataset (ie. with a '$' in its name),
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
2195 * don't try to get stats for it, otherwise we'll return ENOENT.
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
2196 */
11546
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2197 if (error == 0 && strchr(zc->zc_name, '$') == NULL) {
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2198 error = zfs_ioc_objset_stats(zc); /* fill in the stats */
11546
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2199 if (error == ENOENT) {
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2200 /* We lost a race with destroy, get the next one. */
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2201 zc->zc_name[orig_len] = '\0';
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2202 goto top;
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2203 }
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2204 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2205 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2206 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2207
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2208 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2209 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2210 * zc_name name of filesystem
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2211 * zc_cookie zap cursor
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2212 * zc_nvlist_dst_size size of buffer for property nvlist
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2213 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2214 * outputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2215 * zc_name name of next snapshot
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2216 * zc_objset_stats stats
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2217 * zc_nvlist_dst property nvlist
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2218 * zc_nvlist_dst_size size of property nvlist
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2219 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2220 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2221 zfs_ioc_snapshot_list_next(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2222 {
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2223 objset_t *os;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2224 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2225
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
2226 error = dmu_objset_hold(zc->zc_name, FTAG, &os);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2227 if (error != 0) {
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
2228 return (error == ENOENT ? ESRCH : error);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2229 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2230
1003
ce99098d6a9b 6350417 long name will cause rename a dataset panic
lling
parents: 885
diff changeset
2231 /*
ce99098d6a9b 6350417 long name will cause rename a dataset panic
lling
parents: 885
diff changeset
2232 * A dataset name of maximum length cannot have any snapshots,
ce99098d6a9b 6350417 long name will cause rename a dataset panic
lling
parents: 885
diff changeset
2233 * so exit immediately.
ce99098d6a9b 6350417 long name will cause rename a dataset panic
lling
parents: 885
diff changeset
2234 */
ce99098d6a9b 6350417 long name will cause rename a dataset panic
lling
parents: 885
diff changeset
2235 if (strlcat(zc->zc_name, "@", sizeof (zc->zc_name)) >= MAXNAMELEN) {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
2236 dmu_objset_rele(os, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2237 return (SET_ERROR(ESRCH));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2238 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2239
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2240 error = dmu_snapshot_list_next(os,
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 849
diff changeset
2241 sizeof (zc->zc_name) - strlen(zc->zc_name),
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2242 zc->zc_name + strlen(zc->zc_name), &zc->zc_obj, &zc->zc_cookie,
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2243 NULL);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2244
11546
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2245 if (error == 0) {
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2246 dsl_dataset_t *ds;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2247 dsl_pool_t *dp = os->os_dsl_dataset->ds_dir->dd_pool;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2248
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2249 error = dsl_dataset_hold_obj(dp, zc->zc_obj, FTAG, &ds);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2250 if (error == 0) {
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2251 objset_t *ossnap;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2252
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2253 error = dmu_objset_from_ds(ds, &ossnap);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2254 if (error == 0)
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2255 error = zfs_ioc_objset_stats_impl(zc, ossnap);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2256 dsl_dataset_rele(ds, FTAG);
11546
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2257 }
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2258 } else if (error == ENOENT) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2259 error = SET_ERROR(ESRCH);
11546
42ea6be8961b 6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents: 11515
diff changeset
2260 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2261
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
2262 dmu_objset_rele(os, FTAG);
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2263 /* if we failed, undo the @ that we tacked on to zc_name */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2264 if (error != 0)
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2265 *strchr(zc->zc_name, '@') = '\0';
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2266 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2267 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2268
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2269 static int
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2270 zfs_prop_set_userquota(const char *dsname, nvpair_t *pair)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2271 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2272 const char *propname = nvpair_name(pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2273 uint64_t *valary;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2274 unsigned int vallen;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2275 const char *domain;
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2276 char *dash;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2277 zfs_userquota_prop_t type;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2278 uint64_t rid;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2279 uint64_t quota;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2280 zfsvfs_t *zfsvfs;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2281 int err;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2282
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2283 if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2284 nvlist_t *attrs;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2285 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2286 if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2287 &pair) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2288 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2289 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2290
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2291 /*
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2292 * A correctly constructed propname is encoded as
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2293 * userquota@<rid>-<domain>.
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2294 */
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2295 if ((dash = strchr(propname, '-')) == NULL ||
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2296 nvpair_value_uint64_array(pair, &valary, &vallen) != 0 ||
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2297 vallen != 3)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2298 return (SET_ERROR(EINVAL));
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2299
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2300 domain = dash + 1;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2301 type = valary[0];
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2302 rid = valary[1];
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2303 quota = valary[2];
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2304
12620
12fcd99a642d 6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12527
diff changeset
2305 err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_FALSE);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2306 if (err == 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2307 err = zfs_set_userquota(zfsvfs, type, domain, rid, quota);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2308 zfsvfs_rele(zfsvfs, FTAG);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2309 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2310
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2311 return (err);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2312 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2313
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2314 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2315 * If the named property is one that has a special function to set its value,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2316 * return 0 on success and a positive error code on failure; otherwise if it is
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2317 * not one of the special properties handled by this function, return -1.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2318 *
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2319 * XXX: It would be better for callers of the property interface if we handled
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2320 * these special cases in dsl_prop.c (in the dsl layer).
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2321 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2322 static int
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2323 zfs_prop_set_special(const char *dsname, zprop_source_t source,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2324 nvpair_t *pair)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2325 {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2326 const char *propname = nvpair_name(pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2327 zfs_prop_t prop = zfs_name_to_prop(propname);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2328 uint64_t intval;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2329 int err;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2330
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2331 if (prop == ZPROP_INVAL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2332 if (zfs_prop_userquota(propname))
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2333 return (zfs_prop_set_userquota(dsname, pair));
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2334 return (-1);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2335 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2336
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2337 if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2338 nvlist_t *attrs;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2339 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2340 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2341 &pair) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2342 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2343
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2344 if (zfs_prop_get_type(prop) == PROP_TYPE_STRING)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2345 return (-1);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2346
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2347 VERIFY(0 == nvpair_value_uint64(pair, &intval));
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2348
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2349 switch (prop) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2350 case ZFS_PROP_QUOTA:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2351 err = dsl_dir_set_quota(dsname, source, intval);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2352 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2353 case ZFS_PROP_REFQUOTA:
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2354 err = dsl_dataset_set_refquota(dsname, source, intval);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2355 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2356 case ZFS_PROP_RESERVATION:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2357 err = dsl_dir_set_reservation(dsname, source, intval);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2358 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2359 case ZFS_PROP_REFRESERVATION:
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2360 err = dsl_dataset_set_refreservation(dsname, source, intval);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2361 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2362 case ZFS_PROP_VOLSIZE:
13967
92bec6d87f59 3557 dumpvp_size is not updated correctly when a dump zvol's size is changed
George Wilson <george.wilson@delphix.com>
parents: 13952
diff changeset
2363 err = zvol_set_volsize(dsname, intval);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2364 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2365 case ZFS_PROP_VERSION:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2366 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2367 zfsvfs_t *zfsvfs;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2368
12620
12fcd99a642d 6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12527
diff changeset
2369 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0)
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2370 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2371
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2372 err = zfs_set_version(zfsvfs, intval);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2373 zfsvfs_rele(zfsvfs, FTAG);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2374
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2375 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) {
11147
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 11045
diff changeset
2376 zfs_cmd_t *zc;
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 11045
diff changeset
2377
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 11045
diff changeset
2378 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 11045
diff changeset
2379 (void) strcpy(zc->zc_name, dsname);
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 11045
diff changeset
2380 (void) zfs_ioc_userspace_upgrade(zc);
74e8c05021f1 6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents: 11045
diff changeset
2381 kmem_free(zc, sizeof (zfs_cmd_t));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2382 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2383 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2384 }
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2385 case ZFS_PROP_COMPRESSION:
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2386 {
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2387 if (intval == ZIO_COMPRESS_LZ4) {
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2388 zfeature_info_t *feature =
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2389 &spa_feature_table[SPA_FEATURE_LZ4_COMPRESS];
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2390 spa_t *spa;
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2391
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2392 if ((err = spa_open(dsname, &spa, FTAG)) != 0)
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2393 return (err);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2394
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2395 /*
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2396 * Setting the LZ4 compression algorithm activates
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2397 * the feature.
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2398 */
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2399 if (!spa_feature_is_active(spa, feature)) {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2400 if ((err = zfs_prop_activate_feature(spa,
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2401 feature)) != 0) {
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2402 spa_close(spa, FTAG);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2403 return (err);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2404 }
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2405 }
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2406
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2407 spa_close(spa, FTAG);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2408 }
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2409 /*
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2410 * We still want the default set action to be performed in the
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2411 * caller, we only performed zfeature settings here.
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2412 */
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2413 err = -1;
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2414 break;
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
2415 }
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2416
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2417 default:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2418 err = -1;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2419 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2420
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2421 return (err);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2422 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2423
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2424 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2425 * This function is best effort. If it fails to set any of the given properties,
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2426 * it continues to set as many as it can and returns the last error
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2427 * encountered. If the caller provides a non-NULL errlist, it will be filled in
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2428 * with the list of names of all the properties that failed along with the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2429 * corresponding error numbers.
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2430 *
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2431 * If every property is set successfully, zero is returned and errlist is not
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2432 * modified.
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2433 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2434 int
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2435 zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl,
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2436 nvlist_t *errlist)
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2437 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2438 nvpair_t *pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2439 nvpair_t *propval;
11045
0db6e4248051 6900437 uninitialized variable in zfs_set_prop_nvlist() panics 'zpool create' during installation of zfsroot
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11022
diff changeset
2440 int rv = 0;
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2441 uint64_t intval;
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2442 char *strval;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2443 nvlist_t *genericnvl = fnvlist_alloc();
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2444 nvlist_t *retrynvl = fnvlist_alloc();
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2445
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2446 retry:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2447 pair = NULL;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2448 while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2449 const char *propname = nvpair_name(pair);
4670
002728040e28 6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents: 4611
diff changeset
2450 zfs_prop_t prop = zfs_name_to_prop(propname);
11181
daeb45eeb9fb 6904147 spurious 'zfs receive' errors when receiving properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11147
diff changeset
2451 int err = 0;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2452
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2453 /* decode the property value */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2454 propval = pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2455 if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2456 nvlist_t *attrs;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2457 attrs = fnvpair_value_nvlist(pair);
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2458 if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2459 &propval) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2460 err = SET_ERROR(EINVAL);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2461 }
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2462
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2463 /* Validate value type */
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2464 if (err == 0 && prop == ZPROP_INVAL) {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2465 if (zfs_prop_user(propname)) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2466 if (nvpair_type(propval) != DATA_TYPE_STRING)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2467 err = SET_ERROR(EINVAL);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2468 } else if (zfs_prop_userquota(propname)) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2469 if (nvpair_type(propval) !=
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2470 DATA_TYPE_UINT64_ARRAY)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2471 err = SET_ERROR(EINVAL);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
2472 } else {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2473 err = SET_ERROR(EINVAL);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2474 }
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
2475 } else if (err == 0) {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2476 if (nvpair_type(propval) == DATA_TYPE_STRING) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2477 if (zfs_prop_get_type(prop) != PROP_TYPE_STRING)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2478 err = SET_ERROR(EINVAL);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2479 } else if (nvpair_type(propval) == DATA_TYPE_UINT64) {
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
2480 const char *unused;
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
2481
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2482 intval = fnvpair_value_uint64(propval);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2483
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2484 switch (zfs_prop_get_type(prop)) {
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2485 case PROP_TYPE_NUMBER:
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2486 break;
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2487 case PROP_TYPE_STRING:
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2488 err = SET_ERROR(EINVAL);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2489 break;
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2490 case PROP_TYPE_INDEX:
2717
ed589a32259d 6469385 zfs_set_prop_nvlist range checking is busted
eschrock
parents: 2676
diff changeset
2491 if (zfs_prop_index_to_string(prop,
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2492 intval, &unused) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2493 err = SET_ERROR(EINVAL);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2494 break;
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2495 default:
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
2496 cmn_err(CE_PANIC,
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
2497 "unknown property type");
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2498 }
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2499 } else {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2500 err = SET_ERROR(EINVAL);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2501 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2502 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2503
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2504 /* Validate permissions */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2505 if (err == 0)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2506 err = zfs_check_settable(dsname, pair, CRED());
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2507
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2508 if (err == 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2509 err = zfs_prop_set_special(dsname, source, pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2510 if (err == -1) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2511 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2512 * For better performance we build up a list of
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2513 * properties to set in a single transaction.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2514 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2515 err = nvlist_add_nvpair(genericnvl, pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2516 } else if (err != 0 && nvl != retrynvl) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2517 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2518 * This may be a spurious error caused by
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2519 * receiving quota and reservation out of order.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2520 * Try again in a second pass.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2521 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2522 err = nvlist_add_nvpair(retrynvl, pair);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2523 }
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2524 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2525
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2526 if (err != 0) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2527 if (errlist != NULL)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2528 fnvlist_add_int32(errlist, propname, err);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2529 rv = err;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2530 }
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2531 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2532
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2533 if (nvl != retrynvl && !nvlist_empty(retrynvl)) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2534 nvl = retrynvl;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2535 goto retry;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2536 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2537
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2538 if (!nvlist_empty(genericnvl) &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2539 dsl_props_set(dsname, source, genericnvl) != 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2540 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2541 * If this fails, we still want to set as many properties as we
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2542 * can, so try setting them individually.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2543 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2544 pair = NULL;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2545 while ((pair = nvlist_next_nvpair(genericnvl, pair)) != NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2546 const char *propname = nvpair_name(pair);
11181
daeb45eeb9fb 6904147 spurious 'zfs receive' errors when receiving properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11147
diff changeset
2547 int err = 0;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2548
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2549 propval = pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2550 if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2551 nvlist_t *attrs;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2552 attrs = fnvpair_value_nvlist(pair);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2553 propval = fnvlist_lookup_nvpair(attrs,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2554 ZPROP_VALUE);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2555 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2556
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2557 if (nvpair_type(propval) == DATA_TYPE_STRING) {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2558 strval = fnvpair_value_string(propval);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2559 err = dsl_prop_set_string(dsname, propname,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2560 source, strval);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2561 } else {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2562 intval = fnvpair_value_uint64(propval);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2563 err = dsl_prop_set_int(dsname, propname, source,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2564 intval);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2565 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2566
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2567 if (err != 0) {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2568 if (errlist != NULL) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2569 fnvlist_add_int32(errlist, propname,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2570 err);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2571 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2572 rv = err;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2573 }
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2574 }
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2575 }
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2576 nvlist_free(genericnvl);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2577 nvlist_free(retrynvl);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2578
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2579 return (rv);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2580 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2581
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2582 /*
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2583 * Check that all the properties are valid user properties.
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2584 */
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2585 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2586 zfs_check_userprops(const char *fsname, nvlist_t *nvl)
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2587 {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2588 nvpair_t *pair = NULL;
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2589 int error = 0;
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2590
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2591 while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2592 const char *propname = nvpair_name(pair);
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2593 char *valstr;
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2594
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2595 if (!zfs_prop_user(propname) ||
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2596 nvpair_type(pair) != DATA_TYPE_STRING)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2597 return (SET_ERROR(EINVAL));
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2598
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2599 if (error = zfs_secpolicy_write_perms(fsname,
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2600 ZFS_DELEG_PERM_USERPROP, CRED()))
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2601 return (error);
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2602
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2603 if (strlen(propname) >= ZAP_MAXNAMELEN)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2604 return (SET_ERROR(ENAMETOOLONG));
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2605
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2606 VERIFY(nvpair_value_string(pair, &valstr) == 0);
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2607 if (strlen(valstr) >= ZAP_MAXVALUELEN)
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2608 return (E2BIG);
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2609 }
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2610 return (0);
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2611 }
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2612
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2613 static void
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2614 props_skip(nvlist_t *props, nvlist_t *skipped, nvlist_t **newprops)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2615 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2616 nvpair_t *pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2617
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2618 VERIFY(nvlist_alloc(newprops, NV_UNIQUE_NAME, KM_SLEEP) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2619
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2620 pair = NULL;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2621 while ((pair = nvlist_next_nvpair(props, pair)) != NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2622 if (nvlist_exists(skipped, nvpair_name(pair)))
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2623 continue;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2624
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2625 VERIFY(nvlist_add_nvpair(*newprops, pair) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2626 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2627 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2628
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2629 static int
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2630 clear_received_props(const char *dsname, nvlist_t *props,
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2631 nvlist_t *skipped)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2632 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2633 int err = 0;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2634 nvlist_t *cleared_props = NULL;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2635 props_skip(props, skipped, &cleared_props);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2636 if (!nvlist_empty(cleared_props)) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2637 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2638 * Acts on local properties until the dataset has received
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2639 * properties at least once on or after SPA_VERSION_RECVD_PROPS.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2640 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2641 zprop_source_t flags = (ZPROP_SRC_NONE |
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2642 (dsl_prop_get_hasrecvd(dsname) ? ZPROP_SRC_RECEIVED : 0));
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2643 err = zfs_set_prop_nvlist(dsname, flags, cleared_props, NULL);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2644 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2645 nvlist_free(cleared_props);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2646 return (err);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2647 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2648
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
2649 /*
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2650 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2651 * zc_name name of filesystem
8697
e62d2612c14d 6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents: 8536
diff changeset
2652 * zc_value name of property to set
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2653 * zc_nvlist_src{_size} nvlist of properties to apply
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2654 * zc_cookie received properties flag
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2655 *
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2656 * outputs:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2657 * zc_nvlist_dst{_size} error for each unapplied received property
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2658 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2659 static int
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2660 zfs_ioc_set_prop(zfs_cmd_t *zc)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2661 {
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2662 nvlist_t *nvl;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2663 boolean_t received = zc->zc_cookie;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2664 zprop_source_t source = (received ? ZPROP_SRC_RECEIVED :
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2665 ZPROP_SRC_LOCAL);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2666 nvlist_t *errors;
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2667 int error;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2668
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
2669 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
2670 zc->zc_iflags, &nvl)) != 0)
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2671 return (error);
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2672
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2673 if (received) {
7265
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7214
diff changeset
2674 nvlist_t *origprops;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2675
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2676 if (dsl_prop_get_received(zc->zc_name, &origprops) == 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2677 (void) clear_received_props(zc->zc_name,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2678 origprops, nvl);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2679 nvlist_free(origprops);
7265
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7214
diff changeset
2680 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2681
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2682 error = dsl_prop_set_hasrecvd(zc->zc_name);
7265
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7214
diff changeset
2683 }
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7214
diff changeset
2684
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2685 errors = fnvlist_alloc();
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2686 if (error == 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2687 error = zfs_set_prop_nvlist(zc->zc_name, source, nvl, errors);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2688
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2689 if (zc->zc_nvlist_dst != NULL && errors != NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2690 (void) put_nvlist(zc, errors);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2691 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2692
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2693 nvlist_free(errors);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2694 nvlist_free(nvl);
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
2695 return (error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2696 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2697
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2698 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2699 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2700 * zc_name name of filesystem
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2701 * zc_value name of property to inherit
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2702 * zc_cookie revert to received value if TRUE
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2703 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2704 * outputs: none
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2705 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2706 static int
4849
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
2707 zfs_ioc_inherit_prop(zfs_cmd_t *zc)
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
2708 {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2709 const char *propname = zc->zc_value;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2710 zfs_prop_t prop = zfs_name_to_prop(propname);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2711 boolean_t received = zc->zc_cookie;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2712 zprop_source_t source = (received
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2713 ? ZPROP_SRC_NONE /* revert to received value, if any */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2714 : ZPROP_SRC_INHERITED); /* explicitly inherit */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2715
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2716 if (received) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2717 nvlist_t *dummy;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2718 nvpair_t *pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2719 zprop_type_t type;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2720 int err;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2721
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2722 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2723 * zfs_prop_set_special() expects properties in the form of an
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2724 * nvpair with type info.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2725 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2726 if (prop == ZPROP_INVAL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2727 if (!zfs_prop_user(propname))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2728 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2729
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2730 type = PROP_TYPE_STRING;
11515
a122949107d4 6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11454
diff changeset
2731 } else if (prop == ZFS_PROP_VOLSIZE ||
a122949107d4 6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11454
diff changeset
2732 prop == ZFS_PROP_VERSION) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2733 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2734 } else {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2735 type = zfs_prop_get_type(prop);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2736 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2737
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2738 VERIFY(nvlist_alloc(&dummy, NV_UNIQUE_NAME, KM_SLEEP) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2739
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2740 switch (type) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2741 case PROP_TYPE_STRING:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2742 VERIFY(0 == nvlist_add_string(dummy, propname, ""));
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2743 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2744 case PROP_TYPE_NUMBER:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2745 case PROP_TYPE_INDEX:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2746 VERIFY(0 == nvlist_add_uint64(dummy, propname, 0));
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2747 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2748 default:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2749 nvlist_free(dummy);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2750 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2751 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2752
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2753 pair = nvlist_next_nvpair(dummy, NULL);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2754 err = zfs_prop_set_special(zc->zc_name, source, pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2755 nvlist_free(dummy);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2756 if (err != -1)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2757 return (err); /* special property already handled */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2758 } else {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2759 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2760 * Only check this in the non-received case. We want to allow
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2761 * 'inherit -S' to revert non-inheritable properties like quota
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2762 * and reservation to the received or default values even though
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2763 * they are not considered inheritable.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2764 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2765 if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2766 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2767 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2768
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
2769 /* property name has been validated by zfs_secpolicy_inherit_prop() */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2770 return (dsl_prop_inherit(zc->zc_name, zc->zc_value, source));
4849
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
2771 }
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
2772
3a61e0a9a953 6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents: 4808
diff changeset
2773 static int
4098
0a182c2128e6 6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents: 4007
diff changeset
2774 zfs_ioc_pool_set_props(zfs_cmd_t *zc)
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2775 {
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
2776 nvlist_t *props;
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2777 spa_t *spa;
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
2778 int error;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2779 nvpair_t *pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2780
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2781 if (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2782 zc->zc_iflags, &props))
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2783 return (error);
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2784
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2785 /*
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2786 * If the only property is the configfile, then just do a spa_lookup()
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2787 * to handle the faulted case.
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2788 */
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2789 pair = nvlist_next_nvpair(props, NULL);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2790 if (pair != NULL && strcmp(nvpair_name(pair),
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2791 zpool_prop_to_name(ZPOOL_PROP_CACHEFILE)) == 0 &&
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
2792 nvlist_next_nvpair(props, pair) == NULL) {
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2793 mutex_enter(&spa_namespace_lock);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2794 if ((spa = spa_lookup(zc->zc_name)) != NULL) {
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2795 spa_configfile_set(spa, props, B_FALSE);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2796 spa_config_sync(spa, B_FALSE, B_TRUE);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2797 }
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2798 mutex_exit(&spa_namespace_lock);
10672
cee5a0f557db 6836743 zfs_ioc_pool_set_props() leaks nvlist if configfile is only property
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10588
diff changeset
2799 if (spa != NULL) {
cee5a0f557db 6836743 zfs_ioc_pool_set_props() leaks nvlist if configfile is only property
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10588
diff changeset
2800 nvlist_free(props);
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2801 return (0);
10672
cee5a0f557db 6836743 zfs_ioc_pool_set_props() leaks nvlist if configfile is only property
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 10588
diff changeset
2802 }
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2803 }
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2804
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2805 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) {
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
2806 nvlist_free(props);
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2807 return (error);
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2808 }
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2809
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
2810 error = spa_prop_set(spa, props);
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2811
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
2812 nvlist_free(props);
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2813 spa_close(spa, FTAG);
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2814
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2815 return (error);
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2816 }
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2817
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2818 static int
4098
0a182c2128e6 6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents: 4007
diff changeset
2819 zfs_ioc_pool_get_props(zfs_cmd_t *zc)
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2820 {
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2821 spa_t *spa;
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2822 int error;
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2823 nvlist_t *nvp = NULL;
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2824
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2825 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) {
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2826 /*
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2827 * If the pool is faulted, there may be properties we can still
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2828 * get (such as altroot and cachefile), so attempt to get them
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2829 * anyway.
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2830 */
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2831 mutex_enter(&spa_namespace_lock);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2832 if ((spa = spa_lookup(zc->zc_name)) != NULL)
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2833 error = spa_prop_get(spa, &nvp);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2834 mutex_exit(&spa_namespace_lock);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2835 } else {
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2836 error = spa_prop_get(spa, &nvp);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2837 spa_close(spa, FTAG);
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2838 }
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2839
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2840 if (error == 0 && zc->zc_nvlist_dst != NULL)
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2841 error = put_nvlist(zc, nvp);
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2842 else
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2843 error = SET_ERROR(EFAULT);
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2844
8525
e0e0e525d0f8 6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 8415
diff changeset
2845 nvlist_free(nvp);
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2846 return (error);
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2847 }
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3886
diff changeset
2848
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2849 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2850 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2851 * zc_name name of filesystem
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2852 * zc_nvlist_src{_size} nvlist of delegated permissions
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2853 * zc_perm_action allow/unallow flag
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2854 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2855 * outputs: none
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2856 */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2857 static int
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2858 zfs_ioc_set_fsacl(zfs_cmd_t *zc)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2859 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2860 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2861 nvlist_t *fsaclnv = NULL;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2862
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4988
diff changeset
2863 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
2864 zc->zc_iflags, &fsaclnv)) != 0)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2865 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2866
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2867 /*
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2868 * Verify nvlist is constructed correctly
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2869 */
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2870 if ((error = zfs_deleg_verify_nvlist(fsaclnv)) != 0) {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2871 nvlist_free(fsaclnv);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
2872 return (SET_ERROR(EINVAL));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2873 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2874
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2875 /*
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2876 * If we don't have PRIV_SYS_MOUNT, then validate
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2877 * that user is allowed to hand out each permission in
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2878 * the nvlist(s)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2879 */
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2880
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2881 error = secpolicy_zfs(CRED());
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
2882 if (error != 0) {
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2883 if (zc->zc_perm_action == B_FALSE) {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2884 error = dsl_deleg_can_allow(zc->zc_name,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2885 fsaclnv, CRED());
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2886 } else {
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2887 error = dsl_deleg_can_unallow(zc->zc_name,
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2888 fsaclnv, CRED());
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
2889 }
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2890 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2891
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2892 if (error == 0)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2893 error = dsl_deleg_set(zc->zc_name, fsaclnv, zc->zc_perm_action);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2894
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2895 nvlist_free(fsaclnv);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2896 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2897 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2898
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2899 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2900 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2901 * zc_name name of filesystem
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2902 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2903 * outputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2904 * zc_nvlist_src{_size} nvlist of delegated permissions
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2905 */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2906 static int
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2907 zfs_ioc_get_fsacl(zfs_cmd_t *zc)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2908 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2909 nvlist_t *nvp;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2910 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2911
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2912 if ((error = dsl_deleg_get(zc->zc_name, &nvp)) == 0) {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2913 error = put_nvlist(zc, nvp);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2914 nvlist_free(nvp);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2915 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2916
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2917 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2918 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2919
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
2920 /*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2921 * Search the vfs list for a specified resource. Returns a pointer to it
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2922 * or NULL if no suitable entry is found. The caller of this routine
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2923 * is responsible for releasing the returned vfs pointer.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2924 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2925 static vfs_t *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2926 zfs_get_vfs(const char *resource)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2927 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2928 struct vfs *vfsp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2929 struct vfs *vfs_found = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2930
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2931 vfs_list_read_lock();
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2932 vfsp = rootvfs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2933 do {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2934 if (strcmp(refstr_value(vfsp->vfs_resource), resource) == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2935 VFS_HOLD(vfsp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2936 vfs_found = vfsp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2937 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2938 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2939 vfsp = vfsp->vfs_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2940 } while (vfsp != rootvfs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2941 vfs_list_unlock();
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2942 return (vfs_found);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2943 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2944
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2945 /* ARGSUSED */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2946 static void
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
2947 zfs_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2948 {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2949 zfs_creat_t *zct = arg;
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2950
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2951 zfs_create_fs(os, cr, zct->zct_zplprops, tx);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2952 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2953
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2954 #define ZFS_PROP_UNDEFINED ((uint64_t)-1)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2955
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2956 /*
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2957 * inputs:
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
2958 * createprops list of properties requested by creator
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
2959 * default_zplver zpl version to use if unspecified in createprops
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
2960 * fuids_ok fuids allowed in this version of the spa?
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
2961 * os parent objset pointer (NULL if root fs)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2962 *
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2963 * outputs:
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2964 * zplprops values for the zplprops we attach to the master node object
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
2965 * is_ci true if requested file system will be purely case-insensitive
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2966 *
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2967 * Determine the settings for utf8only, normalization and
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2968 * casesensitivity. Specific values may have been requested by the
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2969 * creator and/or we can inherit values from the parent dataset. If
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2970 * the file system is of too early a vintage, a creator can not
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2971 * request settings for these properties, even if the requested
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2972 * setting is the default value. We don't actually want to create dsl
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2973 * properties for these, so remove them from the source nvlist after
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2974 * processing.
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2975 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2976 static int
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
2977 zfs_fill_zplprops_impl(objset_t *os, uint64_t zplver,
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
2978 boolean_t fuids_ok, boolean_t sa_ok, nvlist_t *createprops,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
2979 nvlist_t *zplprops, boolean_t *is_ci)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
2980 {
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2981 uint64_t sense = ZFS_PROP_UNDEFINED;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2982 uint64_t norm = ZFS_PROP_UNDEFINED;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2983 uint64_t u8 = ZFS_PROP_UNDEFINED;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2984
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2985 ASSERT(zplprops != NULL);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2986
5375
c682f8c5f5e3 6622822 can not create clone on old version pool
timh
parents: 5367
diff changeset
2987 /*
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2988 * Pull out creator prop choices, if any.
5375
c682f8c5f5e3 6622822 can not create clone on old version pool
timh
parents: 5367
diff changeset
2989 */
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2990 if (createprops) {
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2991 (void) nvlist_lookup_uint64(createprops,
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
2992 zfs_prop_to_name(ZFS_PROP_VERSION), &zplver);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
2993 (void) nvlist_lookup_uint64(createprops,
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2994 zfs_prop_to_name(ZFS_PROP_NORMALIZE), &norm);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2995 (void) nvlist_remove_all(createprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2996 zfs_prop_to_name(ZFS_PROP_NORMALIZE));
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2997 (void) nvlist_lookup_uint64(createprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2998 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), &u8);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
2999 (void) nvlist_remove_all(createprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3000 zfs_prop_to_name(ZFS_PROP_UTF8ONLY));
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3001 (void) nvlist_lookup_uint64(createprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3002 zfs_prop_to_name(ZFS_PROP_CASE), &sense);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3003 (void) nvlist_remove_all(createprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3004 zfs_prop_to_name(ZFS_PROP_CASE));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
3005 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
3006
5375
c682f8c5f5e3 6622822 can not create clone on old version pool
timh
parents: 5367
diff changeset
3007 /*
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3008 * If the zpl version requested is whacky or the file system
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3009 * or pool is version is too "young" to support normalization
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3010 * and the creator tried to set a value for one of the props,
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3011 * error out.
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3012 */
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3013 if ((zplver < ZPL_VERSION_INITIAL || zplver > ZPL_VERSION) ||
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3014 (zplver >= ZPL_VERSION_FUID && !fuids_ok) ||
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3015 (zplver >= ZPL_VERSION_SA && !sa_ok) ||
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3016 (zplver < ZPL_VERSION_NORMALIZATION &&
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3017 (norm != ZFS_PROP_UNDEFINED || u8 != ZFS_PROP_UNDEFINED ||
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3018 sense != ZFS_PROP_UNDEFINED)))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3019 return (SET_ERROR(ENOTSUP));
5498
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3020
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3021 /*
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3022 * Put the version in the zplprops
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3023 */
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3024 VERIFY(nvlist_add_uint64(zplprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3025 zfs_prop_to_name(ZFS_PROP_VERSION), zplver) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3026
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3027 if (norm == ZFS_PROP_UNDEFINED)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3028 VERIFY(zfs_get_zplprop(os, ZFS_PROP_NORMALIZE, &norm) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3029 VERIFY(nvlist_add_uint64(zplprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3030 zfs_prop_to_name(ZFS_PROP_NORMALIZE), norm) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3031
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3032 /*
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3033 * If we're normalizing, names must always be valid UTF-8 strings.
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3034 */
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3035 if (norm)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3036 u8 = 1;
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3037 if (u8 == ZFS_PROP_UNDEFINED)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3038 VERIFY(zfs_get_zplprop(os, ZFS_PROP_UTF8ONLY, &u8) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3039 VERIFY(nvlist_add_uint64(zplprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3040 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), u8) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3041
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3042 if (sense == ZFS_PROP_UNDEFINED)
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3043 VERIFY(zfs_get_zplprop(os, ZFS_PROP_CASE, &sense) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3044 VERIFY(nvlist_add_uint64(zplprops,
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3045 zfs_prop_to_name(ZFS_PROP_CASE), sense) == 0);
334b476844ca 6622831 normalization properties are not preserved by "zfs send"
timh
parents: 5450
diff changeset
3046
6492
903545192033 6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents: 6423
diff changeset
3047 if (is_ci)
903545192033 6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents: 6423
diff changeset
3048 *is_ci = (sense == ZFS_CASE_INSENSITIVE);
903545192033 6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents: 6423
diff changeset
3049
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3050 return (0);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3051 }
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3052
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3053 static int
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3054 zfs_fill_zplprops(const char *dataset, nvlist_t *createprops,
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3055 nvlist_t *zplprops, boolean_t *is_ci)
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3056 {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3057 boolean_t fuids_ok, sa_ok;
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3058 uint64_t zplver = ZPL_VERSION;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3059 objset_t *os = NULL;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3060 char parentname[MAXNAMELEN];
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3061 char *cp;
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3062 spa_t *spa;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3063 uint64_t spa_vers;
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3064 int error;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3065
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3066 (void) strlcpy(parentname, dataset, sizeof (parentname));
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3067 cp = strrchr(parentname, '/');
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3068 ASSERT(cp != NULL);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3069 cp[0] = '\0';
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3070
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3071 if ((error = spa_open(dataset, &spa, FTAG)) != 0)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3072 return (error);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3073
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3074 spa_vers = spa_version(spa);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3075 spa_close(spa, FTAG);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3076
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3077 zplver = zfs_zpl_version_map(spa_vers);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3078 fuids_ok = (zplver >= ZPL_VERSION_FUID);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3079 sa_ok = (zplver >= ZPL_VERSION_SA);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3080
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3081 /*
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3082 * Open parent object set so we can inherit zplprop values.
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3083 */
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
3084 if ((error = dmu_objset_hold(parentname, FTAG, &os)) != 0)
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3085 return (error);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3086
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3087 error = zfs_fill_zplprops_impl(os, zplver, fuids_ok, sa_ok, createprops,
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3088 zplprops, is_ci);
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
3089 dmu_objset_rele(os, FTAG);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3090 return (error);
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3091 }
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3092
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3093 static int
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3094 zfs_fill_zplprops_root(uint64_t spa_vers, nvlist_t *createprops,
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3095 nvlist_t *zplprops, boolean_t *is_ci)
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3096 {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3097 boolean_t fuids_ok;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3098 boolean_t sa_ok;
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3099 uint64_t zplver = ZPL_VERSION;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3100 int error;
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3101
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3102 zplver = zfs_zpl_version_map(spa_vers);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3103 fuids_ok = (zplver >= ZPL_VERSION_FUID);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3104 sa_ok = (zplver >= ZPL_VERSION_SA);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3105
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3106 error = zfs_fill_zplprops_impl(NULL, zplver, fuids_ok, sa_ok,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11933
diff changeset
3107 createprops, zplprops, is_ci);
7184
9508660f9c27 PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents: 7046
diff changeset
3108 return (error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3109 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3110
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3111 /*
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3112 * innvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3113 * "type" -> dmu_objset_type_t (int32)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3114 * (optional) "props" -> { prop -> value }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3115 * }
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3116 *
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3117 * outnvl: propname -> error code (int32)
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3118 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3119 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3120 zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3121 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3122 int error = 0;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3123 zfs_creat_t zct = { 0 };
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
3124 nvlist_t *nvprops = NULL;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
3125 void (*cbfunc)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3126 int32_t type32;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3127 dmu_objset_type_t type;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3128 boolean_t is_insensitive = B_FALSE;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3129
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3130 if (nvlist_lookup_int32(innvl, "type", &type32) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3131 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3132 type = type32;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3133 (void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3134
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3135 switch (type) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3136 case DMU_OST_ZFS:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3137 cbfunc = zfs_create_cb;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3138 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3139
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3140 case DMU_OST_ZVOL:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3141 cbfunc = zvol_create_cb;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3142 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3143
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3144 default:
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3145 cbfunc = NULL;
6423
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
3146 break;
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3147 }
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3148 if (strchr(fsname, '@') ||
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3149 strchr(fsname, '%'))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3150 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3151
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3152 zct.zct_props = nvprops;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3153
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3154 if (cbfunc == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3155 return (SET_ERROR(EINVAL));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3156
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3157 if (type == DMU_OST_ZVOL) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3158 uint64_t volsize, volblocksize;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3159
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3160 if (nvprops == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3161 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3162 if (nvlist_lookup_uint64(nvprops,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3163 zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3164 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3165
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3166 if ((error = nvlist_lookup_uint64(nvprops,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3167 zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3168 &volblocksize)) != 0 && error != ENOENT)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3169 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3170
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3171 if (error != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3172 volblocksize = zfs_prop_default_numeric(
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3173 ZFS_PROP_VOLBLOCKSIZE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3174
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3175 if ((error = zvol_check_volblocksize(
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3176 volblocksize)) != 0 ||
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3177 (error = zvol_check_volsize(volsize,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3178 volblocksize)) != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3179 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3180 } else if (type == DMU_OST_ZFS) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3181 int error;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3182
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3183 /*
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3184 * We have to have normalization and
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3185 * case-folding flags correct when we do the
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3186 * file system creation, so go figure them out
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3187 * now.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3188 */
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3189 VERIFY(nvlist_alloc(&zct.zct_zplprops,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3190 NV_UNIQUE_NAME, KM_SLEEP) == 0);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3191 error = zfs_fill_zplprops(fsname, nvprops,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3192 zct.zct_zplprops, &is_insensitive);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3193 if (error != 0) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3194 nvlist_free(zct.zct_zplprops);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
3195 return (error);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
3196 }
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3197 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3198
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3199 error = dmu_objset_create(fsname, type,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3200 is_insensitive ? DS_FLAG_CI_DATASET : 0, cbfunc, &zct);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3201 nvlist_free(zct.zct_zplprops);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3202
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3203 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3204 * It would be nice to do this atomically.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3205 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3206 if (error == 0) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3207 error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3208 nvprops, outnvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3209 if (error != 0)
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3210 (void) dsl_destroy_head(fsname);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3211 }
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3212 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3213 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3214
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3215 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3216 * innvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3217 * "origin" -> name of origin snapshot
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3218 * (optional) "props" -> { prop -> value }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3219 * }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3220 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3221 * outnvl: propname -> error code (int32)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3222 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3223 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3224 zfs_ioc_clone(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3225 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3226 int error = 0;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3227 nvlist_t *nvprops = NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3228 char *origin_name;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3229
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3230 if (nvlist_lookup_string(innvl, "origin", &origin_name) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3231 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3232 (void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3233
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3234 if (strchr(fsname, '@') ||
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3235 strchr(fsname, '%'))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3236 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3237
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3238 if (dataset_namecheck(origin_name, NULL, NULL) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3239 return (SET_ERROR(EINVAL));
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3240 error = dmu_objset_clone(fsname, origin_name);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3241 if (error != 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3242 return (error);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
3243
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
3244 /*
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
3245 * It would be nice to do this atomically.
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
3246 */
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
3247 if (error == 0) {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3248 error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3249 nvprops, outnvl);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3250 if (error != 0)
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3251 (void) dsl_destroy_head(fsname);
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
3252 }
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3253 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3254 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3255
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3256 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3257 * innvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3258 * "snaps" -> { snapshot1, snapshot2 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3259 * (optional) "props" -> { prop -> value (string) }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3260 * }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3261 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3262 * outnvl: snapshot -> error code (int32)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3263 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3264 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3265 zfs_ioc_snapshot(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3266 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3267 nvlist_t *snaps;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3268 nvlist_t *props = NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3269 int error, poollen;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3270 nvpair_t *pair;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3271
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3272 (void) nvlist_lookup_nvlist(innvl, "props", &props);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3273 if ((error = zfs_check_userprops(poolname, props)) != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3274 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3275
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3276 if (!nvlist_empty(props) &&
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3277 zfs_earlier_version(poolname, SPA_VERSION_SNAP_PROPS))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3278 return (SET_ERROR(ENOTSUP));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3279
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3280 if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3281 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3282 poollen = strlen(poolname);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3283 for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3284 pair = nvlist_next_nvpair(snaps, pair)) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3285 const char *name = nvpair_name(pair);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3286 const char *cp = strchr(name, '@');
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3287
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3288 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3289 * The snap name must contain an @, and the part after it must
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3290 * contain only valid characters.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3291 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3292 if (cp == NULL || snapshot_namecheck(cp + 1, NULL, NULL) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3293 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3294
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3295 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3296 * The snap must be in the specified pool.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3297 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3298 if (strncmp(name, poolname, poollen) != 0 ||
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3299 (name[poollen] != '/' && name[poollen] != '@'))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3300 return (SET_ERROR(EXDEV));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3301
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3302 /* This must be the only snap of this fs. */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3303 for (nvpair_t *pair2 = nvlist_next_nvpair(snaps, pair);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3304 pair2 != NULL; pair2 = nvlist_next_nvpair(snaps, pair2)) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3305 if (strncmp(name, nvpair_name(pair2), cp - name + 1)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3306 == 0) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3307 return (SET_ERROR(EXDEV));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3308 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3309 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3310 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3311
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3312 error = dsl_dataset_snapshot(snaps, props, outnvl);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3313 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3314 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3315
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3316 /*
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3317 * innvl: "message" -> string
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3318 */
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3319 /* ARGSUSED */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3320 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3321 zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3322 {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3323 char *message;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3324 spa_t *spa;
7265
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7214
diff changeset
3325 int error;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3326 char *poolname;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3327
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3328 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3329 * The poolname in the ioctl is not set, we get it from the TSD,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3330 * which was set at the end of the last successful ioctl that allows
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3331 * logging. The secpolicy func already checked that it is set.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3332 * Only one log ioctl is allowed after each successful ioctl, so
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3333 * we clear the TSD here.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3334 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3335 poolname = tsd_get(zfs_allow_log_key);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3336 (void) tsd_set(zfs_allow_log_key, NULL);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3337 error = spa_open(poolname, &spa, FTAG);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3338 strfree(poolname);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3339 if (error != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3340 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3341
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3342 if (nvlist_lookup_string(innvl, "message", &message) != 0) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3343 spa_close(spa, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3344 return (SET_ERROR(EINVAL));
7265
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7214
diff changeset
3345 }
9355
09928982c591 6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9234
diff changeset
3346
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3347 if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3348 spa_close(spa, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3349 return (SET_ERROR(ENOTSUP));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3350 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3351
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3352 error = spa_history_log(spa, message);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3353 spa_close(spa, FTAG);
7265
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7214
diff changeset
3354 return (error);
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3355 }
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3356
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3357 /*
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3358 * The dp_config_rwlock must not be held when calling this, because the
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3359 * unmount may need to write out data.
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3360 *
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3361 * This function is best-effort. Callers must deal gracefully if it
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3362 * remains mounted (or is remounted after this call).
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3363 */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3364 void
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3365 zfs_unmount_snap(const char *snapname)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3366 {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3367 vfs_t *vfsp;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3368 zfsvfs_t *zfsvfs;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3369
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3370 if (strchr(snapname, '@') == NULL)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3371 return;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3372
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3373 vfsp = zfs_get_vfs(snapname);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3374 if (vfsp == NULL)
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3375 return;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3376
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3377 zfsvfs = vfsp->vfs_data;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3378 ASSERT(!dsl_pool_config_held(dmu_objset_pool(zfsvfs->z_os)));
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3379
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3380 if (vn_vfswlock(vfsp->vfs_vnodecovered) != 0) {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3381 VFS_RELE(vfsp);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3382 return;
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3383 }
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3384 VFS_RELE(vfsp);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3385
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3386 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3387 * Always force the unmount for snapshots.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3388 */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3389 (void) dounmount(vfsp, MS_FORCE, kcred);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3390 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3391
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3392 /* ARGSUSED */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3393 static int
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3394 zfs_unmount_snap_cb(const char *snapname, void *arg)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3395 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3396 zfs_unmount_snap(snapname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3397 return (0);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3398 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3399
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3400 /*
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3401 * When a clone is destroyed, its origin may also need to be destroyed,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3402 * in which case it must be unmounted. This routine will do that unmount
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3403 * if necessary.
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3404 */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3405 void
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3406 zfs_destroy_unmount_origin(const char *fsname)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3407 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3408 int error;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3409 objset_t *os;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3410 dsl_dataset_t *ds;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3411
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3412 error = dmu_objset_hold(fsname, FTAG, &os);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3413 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3414 return;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3415 ds = dmu_objset_ds(os);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3416 if (dsl_dir_is_clone(ds->ds_dir) && DS_IS_DEFER_DESTROY(ds->ds_prev)) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3417 char originname[MAXNAMELEN];
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3418 dsl_dataset_name(ds->ds_prev, originname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3419 dmu_objset_rele(os, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3420 zfs_unmount_snap(originname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3421 } else {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3422 dmu_objset_rele(os, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3423 }
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3424 }
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3425
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3426 /*
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3427 * innvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3428 * "snaps" -> { snapshot1, snapshot2 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3429 * (optional boolean) "defer"
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3430 * }
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3431 *
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3432 * outnvl: snapshot -> error code (int32)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3433 *
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3434 */
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3435 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3436 zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3437 {
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3438 int poollen;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3439 nvlist_t *snaps;
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
3440 nvpair_t *pair;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3441 boolean_t defer;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3442
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3443 if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3444 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3445 defer = nvlist_exists(innvl, "defer");
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3446
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3447 poollen = strlen(poolname);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3448 for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3449 pair = nvlist_next_nvpair(snaps, pair)) {
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
3450 const char *name = nvpair_name(pair);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3451
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
3452 /*
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3453 * The snap must be in the specified pool.
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
3454 */
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3455 if (strncmp(name, poolname, poollen) != 0 ||
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3456 (name[poollen] != '/' && name[poollen] != '@'))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3457 return (SET_ERROR(EXDEV));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3458
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3459 zfs_unmount_snap(name);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
3460 }
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
3461
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3462 return (dsl_destroy_snapshots_nvl(snaps, defer, outnvl));
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3463 }
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3464
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3465 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3466 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3467 * zc_name name of dataset to destroy
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3468 * zc_objset_type type of objset
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
3469 * zc_defer_destroy mark for deferred destroy
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3470 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3471 * outputs: none
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3472 */
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3473 static int
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3474 zfs_ioc_destroy(zfs_cmd_t *zc)
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
3475 {
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
3476 int err;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3477 if (strchr(zc->zc_name, '@') && zc->zc_objset_type == DMU_OST_ZFS)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3478 zfs_unmount_snap(zc->zc_name);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3479
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3480 if (strchr(zc->zc_name, '@'))
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3481 err = dsl_destroy_snapshot(zc->zc_name, zc->zc_defer_destroy);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3482 else
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3483 err = dsl_destroy_head(zc->zc_name);
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
3484 if (zc->zc_objset_type == DMU_OST_ZVOL && err == 0)
10693
aaa91fcac595 6871683 ztest should exercise deferred destroy
Chris Kirby <chris.kirby@sun.com>
parents: 10685
diff changeset
3485 (void) zvol_remove_minor(zc->zc_name);
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
3486 return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3487 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3488
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3489 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3490 * inputs:
5446
51fbc14b301d 6421210 zfs rollback without unmounting
ahrens
parents: 5378
diff changeset
3491 * zc_name name of dataset to rollback (to most recent snapshot)
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3492 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3493 * outputs: none
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3494 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3495 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3496 zfs_ioc_rollback(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3497 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3498 zfsvfs_t *zfsvfs;
5446
51fbc14b301d 6421210 zfs rollback without unmounting
ahrens
parents: 5378
diff changeset
3499 int error;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3500
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
3501 if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
3502 error = zfs_suspend_fs(zfsvfs);
6083
23e77aa611b1 6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents: 5977
diff changeset
3503 if (error == 0) {
23e77aa611b1 6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents: 5977
diff changeset
3504 int resume_err;
23e77aa611b1 6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents: 5977
diff changeset
3505
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3506 error = dsl_dataset_rollback(zc->zc_name);
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
3507 resume_err = zfs_resume_fs(zfsvfs, zc->zc_name);
6083
23e77aa611b1 6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents: 5977
diff changeset
3508 error = error ? error : resume_err;
23e77aa611b1 6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents: 5977
diff changeset
3509 }
5446
51fbc14b301d 6421210 zfs rollback without unmounting
ahrens
parents: 5378
diff changeset
3510 VFS_RELE(zfsvfs->z_vfs);
51fbc14b301d 6421210 zfs rollback without unmounting
ahrens
parents: 5378
diff changeset
3511 } else {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3512 error = dsl_dataset_rollback(zc->zc_name);
5446
51fbc14b301d 6421210 zfs rollback without unmounting
ahrens
parents: 5378
diff changeset
3513 }
51fbc14b301d 6421210 zfs rollback without unmounting
ahrens
parents: 5378
diff changeset
3514 return (error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3515 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3516
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3517 static int
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3518 recursive_unmount(const char *fsname, void *arg)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3519 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3520 const char *snapname = arg;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3521 char fullname[MAXNAMELEN];
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3522
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3523 (void) snprintf(fullname, sizeof (fullname), "%s@%s", fsname, snapname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3524 zfs_unmount_snap(fullname);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3525 return (0);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3526 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3527
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3528 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3529 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3530 * zc_name old name of dataset
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3531 * zc_value new name of dataset
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3532 * zc_cookie recursive flag (only valid for snapshots)
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3533 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3534 * outputs: none
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3535 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3536 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3537 zfs_ioc_rename(zfs_cmd_t *zc)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3538 {
4490
abf035049f7f PSARC 2007/199 zfs {create,clone,rename} -p
vb160487
parents: 4451
diff changeset
3539 boolean_t recursive = zc->zc_cookie & 1;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3540 char *at;
4007
c6f5c6753018 PSARC 2007/142 zfs rename -r
mmusante
parents: 3912
diff changeset
3541
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
3542 zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
5326
6752aa2bd5bc 6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents: 5147
diff changeset
3543 if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
6752aa2bd5bc 6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents: 5147
diff changeset
3544 strchr(zc->zc_value, '%'))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3545 return (SET_ERROR(EINVAL));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3546
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3547 at = strchr(zc->zc_name, '@');
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3548 if (at != NULL) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3549 /* snaps must be in same fs */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3550 if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3551 return (SET_ERROR(EXDEV));
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3552 *at = '\0';
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3553 if (zc->zc_objset_type == DMU_OST_ZFS) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3554 int error = dmu_objset_find(zc->zc_name,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3555 recursive_unmount, at + 1,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3556 recursive ? DS_FIND_CHILDREN : 0);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3557 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3558 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3559 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3560 return (dsl_dataset_rename_snapshot(zc->zc_name,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3561 at + 1, strchr(zc->zc_value, '@') + 1, recursive));
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3562 } else {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3563 if (zc->zc_objset_type == DMU_OST_ZVOL)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3564 (void) zvol_remove_minor(zc->zc_name);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3565 return (dsl_dir_rename(zc->zc_name, zc->zc_value));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3566 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3567 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3568
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3569 static int
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3570 zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3571 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3572 const char *propname = nvpair_name(pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3573 boolean_t issnap = (strchr(dsname, '@') != NULL);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3574 zfs_prop_t prop = zfs_name_to_prop(propname);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3575 uint64_t intval;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3576 int err;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3577
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3578 if (prop == ZPROP_INVAL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3579 if (zfs_prop_user(propname)) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3580 if (err = zfs_secpolicy_write_perms(dsname,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3581 ZFS_DELEG_PERM_USERPROP, cr))
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3582 return (err);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3583 return (0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3584 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3585
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3586 if (!issnap && zfs_prop_userquota(propname)) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3587 const char *perm = NULL;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3588 const char *uq_prefix =
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3589 zfs_userquota_prop_prefixes[ZFS_PROP_USERQUOTA];
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3590 const char *gq_prefix =
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3591 zfs_userquota_prop_prefixes[ZFS_PROP_GROUPQUOTA];
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3592
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3593 if (strncmp(propname, uq_prefix,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3594 strlen(uq_prefix)) == 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3595 perm = ZFS_DELEG_PERM_USERQUOTA;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3596 } else if (strncmp(propname, gq_prefix,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3597 strlen(gq_prefix)) == 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3598 perm = ZFS_DELEG_PERM_GROUPQUOTA;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3599 } else {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3600 /* USERUSED and GROUPUSED are read-only */
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3601 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3602 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3603
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3604 if (err = zfs_secpolicy_write_perms(dsname, perm, cr))
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3605 return (err);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3606 return (0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3607 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3608
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3609 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3610 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3611
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3612 if (issnap)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3613 return (SET_ERROR(EINVAL));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3614
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3615 if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3616 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3617 * dsl_prop_get_all_impl() returns properties in this
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3618 * format.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3619 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3620 nvlist_t *attrs;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3621 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3622 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3623 &pair) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3624 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3625
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3626 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3627 * Check that this value is valid for this pool version
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3628 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3629 switch (prop) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3630 case ZFS_PROP_COMPRESSION:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3631 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3632 * If the user specified gzip compression, make sure
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3633 * the SPA supports it. We ignore any errors here since
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3634 * we'll catch them later.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3635 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3636 if (nvpair_type(pair) == DATA_TYPE_UINT64 &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3637 nvpair_value_uint64(pair, &intval) == 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3638 if (intval >= ZIO_COMPRESS_GZIP_1 &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3639 intval <= ZIO_COMPRESS_GZIP_9 &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3640 zfs_earlier_version(dsname,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3641 SPA_VERSION_GZIP_COMPRESSION)) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3642 return (SET_ERROR(ENOTSUP));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3643 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3644
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3645 if (intval == ZIO_COMPRESS_ZLE &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3646 zfs_earlier_version(dsname,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3647 SPA_VERSION_ZLE_COMPRESSION))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3648 return (SET_ERROR(ENOTSUP));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3649
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3650 if (intval == ZIO_COMPRESS_LZ4) {
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3651 zfeature_info_t *feature =
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3652 &spa_feature_table[
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3653 SPA_FEATURE_LZ4_COMPRESS];
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3654 spa_t *spa;
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3655
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3656 if ((err = spa_open(dsname, &spa, FTAG)) != 0)
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3657 return (err);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3658
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3659 if (!spa_feature_is_enabled(spa, feature)) {
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3660 spa_close(spa, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3661 return (SET_ERROR(ENOTSUP));
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3662 }
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3663 spa_close(spa, FTAG);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3664 }
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3665
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3666 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3667 * If this is a bootable dataset then
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3668 * verify that the compression algorithm
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3669 * is supported for booting. We must return
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3670 * something other than ENOTSUP since it
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3671 * implies a downrev pool version.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3672 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3673 if (zfs_is_bootfs(dsname) &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3674 !BOOTFS_COMPRESS_VALID(intval)) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3675 return (SET_ERROR(ERANGE));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3676 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3677 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3678 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3679
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3680 case ZFS_PROP_COPIES:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3681 if (zfs_earlier_version(dsname, SPA_VERSION_DITTO_BLOCKS))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3682 return (SET_ERROR(ENOTSUP));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3683 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3684
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3685 case ZFS_PROP_DEDUP:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3686 if (zfs_earlier_version(dsname, SPA_VERSION_DEDUP))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3687 return (SET_ERROR(ENOTSUP));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3688 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3689
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3690 case ZFS_PROP_SHARESMB:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3691 if (zpl_earlier_version(dsname, ZPL_VERSION_FUID))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3692 return (SET_ERROR(ENOTSUP));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3693 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3694
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3695 case ZFS_PROP_ACLINHERIT:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3696 if (nvpair_type(pair) == DATA_TYPE_UINT64 &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3697 nvpair_value_uint64(pair, &intval) == 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3698 if (intval == ZFS_ACL_PASSTHROUGH_X &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3699 zfs_earlier_version(dsname,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3700 SPA_VERSION_PASSTHROUGH_X))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3701 return (SET_ERROR(ENOTSUP));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3702 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3703 break;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3704 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3705
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3706 return (zfs_secpolicy_setprop(dsname, prop, pair, CRED()));
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3707 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3708
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3709 /*
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3710 * Checks for a race condition to make sure we don't increment a feature flag
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3711 * multiple times.
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3712 */
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3713 static int
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3714 zfs_prop_activate_feature_check(void *arg, dmu_tx_t *tx)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3715 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3716 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3717 zfeature_info_t *feature = arg;
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3718
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3719 if (!spa_feature_is_active(spa, feature))
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3720 return (0);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3721 else
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3722 return (SET_ERROR(EBUSY));
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3723 }
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3724
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3725 /*
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3726 * The callback invoked on feature activation in the sync task caused by
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3727 * zfs_prop_activate_feature.
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3728 */
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3729 static void
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3730 zfs_prop_activate_feature_sync(void *arg, dmu_tx_t *tx)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3731 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3732 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3733 zfeature_info_t *feature = arg;
13921
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3734
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3735 spa_feature_incr(spa, feature, tx);
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3736 }
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3737
9d721847e469 3035 LZ4 compression support in ZFS and GRUB
Sašo Kiselkov <skiselkov.ml@gmail.com>
parents: 13805
diff changeset
3738 /*
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3739 * Activates a feature on a pool in response to a property setting. This
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3740 * creates a new sync task which modifies the pool to reflect the feature
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3741 * as being active.
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3742 */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3743 static int
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3744 zfs_prop_activate_feature(spa_t *spa, zfeature_info_t *feature)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3745 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3746 int err;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3747
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3748 /* EBUSY here indicates that the feature is already active */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3749 err = dsl_sync_task(spa_name(spa),
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3750 zfs_prop_activate_feature_check, zfs_prop_activate_feature_sync,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3751 feature, 2);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3752
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3753 if (err != 0 && err != EBUSY)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3754 return (err);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3755 else
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3756 return (0);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3757 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3758
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3759 /*
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3760 * Removes properties from the given props list that fail permission checks
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3761 * needed to clear them and to restore them in case of a receive error. For each
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3762 * property, make sure we have both set and inherit permissions.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3763 *
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3764 * Returns the first error encountered if any permission checks fail. If the
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3765 * caller provides a non-NULL errlist, it also gives the complete list of names
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3766 * of all the properties that failed a permission check along with the
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3767 * corresponding error numbers. The caller is responsible for freeing the
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3768 * returned errlist.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3769 *
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3770 * If every property checks out successfully, zero is returned and the list
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3771 * pointed at by errlist is NULL.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3772 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3773 static int
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3774 zfs_check_clearable(char *dataset, nvlist_t *props, nvlist_t **errlist)
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3775 {
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3776 zfs_cmd_t *zc;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3777 nvpair_t *pair, *next_pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3778 nvlist_t *errors;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3779 int err, rv = 0;
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3780
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3781 if (props == NULL)
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3782 return (0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3783
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3784 VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3785
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3786 zc = kmem_alloc(sizeof (zfs_cmd_t), KM_SLEEP);
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3787 (void) strcpy(zc->zc_name, dataset);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3788 pair = nvlist_next_nvpair(props, NULL);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3789 while (pair != NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3790 next_pair = nvlist_next_nvpair(props, pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3791
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3792 (void) strcpy(zc->zc_value, nvpair_name(pair));
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3793 if ((err = zfs_check_settable(dataset, pair, CRED())) != 0 ||
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
3794 (err = zfs_secpolicy_inherit_prop(zc, NULL, CRED())) != 0) {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3795 VERIFY(nvlist_remove_nvpair(props, pair) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3796 VERIFY(nvlist_add_int32(errors,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3797 zc->zc_value, err) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3798 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3799 pair = next_pair;
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3800 }
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3801 kmem_free(zc, sizeof (zfs_cmd_t));
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3802
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3803 if ((pair = nvlist_next_nvpair(errors, NULL)) == NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3804 nvlist_free(errors);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3805 errors = NULL;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3806 } else {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3807 VERIFY(nvpair_value_int32(pair, &rv) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3808 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3809
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3810 if (errlist == NULL)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3811 nvlist_free(errors);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3812 else
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3813 *errlist = errors;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3814
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3815 return (rv);
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3816 }
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3817
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3818 static boolean_t
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3819 propval_equals(nvpair_t *p1, nvpair_t *p2)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3820 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3821 if (nvpair_type(p1) == DATA_TYPE_NVLIST) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3822 /* dsl_prop_get_all_impl() format */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3823 nvlist_t *attrs;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3824 VERIFY(nvpair_value_nvlist(p1, &attrs) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3825 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3826 &p1) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3827 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3828
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3829 if (nvpair_type(p2) == DATA_TYPE_NVLIST) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3830 nvlist_t *attrs;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3831 VERIFY(nvpair_value_nvlist(p2, &attrs) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3832 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3833 &p2) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3834 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3835
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3836 if (nvpair_type(p1) != nvpair_type(p2))
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3837 return (B_FALSE);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3838
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3839 if (nvpair_type(p1) == DATA_TYPE_STRING) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3840 char *valstr1, *valstr2;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3841
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3842 VERIFY(nvpair_value_string(p1, (char **)&valstr1) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3843 VERIFY(nvpair_value_string(p2, (char **)&valstr2) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3844 return (strcmp(valstr1, valstr2) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3845 } else {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3846 uint64_t intval1, intval2;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3847
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3848 VERIFY(nvpair_value_uint64(p1, &intval1) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3849 VERIFY(nvpair_value_uint64(p2, &intval2) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3850 return (intval1 == intval2);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3851 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3852 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3853
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3854 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3855 * Remove properties from props if they are not going to change (as determined
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3856 * by comparison with origprops). Remove them from origprops as well, since we
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3857 * do not need to clear or restore properties that won't change.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3858 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3859 static void
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3860 props_reduce(nvlist_t *props, nvlist_t *origprops)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3861 {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3862 nvpair_t *pair, *next_pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3863
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3864 if (origprops == NULL)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3865 return; /* all props need to be received */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3866
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3867 pair = nvlist_next_nvpair(props, NULL);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3868 while (pair != NULL) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3869 const char *propname = nvpair_name(pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3870 nvpair_t *match;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3871
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3872 next_pair = nvlist_next_nvpair(props, pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3873
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3874 if ((nvlist_lookup_nvpair(origprops, propname,
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3875 &match) != 0) || !propval_equals(pair, match))
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3876 goto next; /* need to set received value */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3877
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3878 /* don't clear the existing received value */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3879 (void) nvlist_remove_nvpair(origprops, match);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3880 /* don't bother receiving the property */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3881 (void) nvlist_remove_nvpair(props, pair);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3882 next:
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3883 pair = next_pair;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3884 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3885 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3886
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3887 #ifdef DEBUG
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3888 static boolean_t zfs_ioc_recv_inject_err;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3889 #endif
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3890
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3891 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3892 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3893 * zc_name name of containing filesystem
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3894 * zc_nvlist_src{_size} nvlist of properties to apply
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3895 * zc_value name of snapshot to create
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3896 * zc_string name of clone origin (if DRR_FLAG_CLONE)
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3897 * zc_cookie file descriptor to recv from
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3898 * zc_begin_record the BEGIN record of the stream (not byteswapped)
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3899 * zc_guid force flag
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
3900 * zc_cleanup_fd cleanup-on-exit file descriptor
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
3901 * zc_action_handle handle for this guid/ds mapping (or zero on first call)
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3902 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3903 * outputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3904 * zc_cookie number of bytes read
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3905 * zc_nvlist_dst{_size} error for each unapplied received property
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3906 * zc_obj zprop_errflags_t
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
3907 * zc_action_handle handle for this guid/ds mapping
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3908 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3909 static int
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3910 zfs_ioc_recv(zfs_cmd_t *zc)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3911 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3912 file_t *fp;
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3913 dmu_recv_cookie_t drc;
5326
6752aa2bd5bc 6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents: 5147
diff changeset
3914 boolean_t force = (boolean_t)zc->zc_guid;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3915 int fd;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3916 int error = 0;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3917 int props_error = 0;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3918 nvlist_t *errors;
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3919 offset_t off;
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3920 nvlist_t *props = NULL; /* sent properties */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3921 nvlist_t *origprops = NULL; /* existing properties */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3922 char *origin = NULL;
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3923 char *tosnap;
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3924 char tofs[ZFS_MAXNAMELEN];
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3925 boolean_t first_recvd_props = B_FALSE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3926
3265
967e0fca6143 6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents: 3087
diff changeset
3927 if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
5326
6752aa2bd5bc 6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents: 5147
diff changeset
3928 strchr(zc->zc_value, '@') == NULL ||
6752aa2bd5bc 6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents: 5147
diff changeset
3929 strchr(zc->zc_value, '%'))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3930 return (SET_ERROR(EINVAL));
3265
967e0fca6143 6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents: 3087
diff changeset
3931
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3932 (void) strcpy(tofs, zc->zc_value);
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3933 tosnap = strchr(tofs, '@');
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3934 *tosnap++ = '\0';
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3935
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3936 if (zc->zc_nvlist_src != NULL &&
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3937 (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
3938 zc->zc_iflags, &props)) != 0)
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3939 return (error);
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3940
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3941 fd = zc->zc_cookie;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3942 fp = getf(fd);
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3943 if (fp == NULL) {
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3944 nvlist_free(props);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
3945 return (SET_ERROR(EBADF));
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
3946 }
5326
6752aa2bd5bc 6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents: 5147
diff changeset
3947
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3948 VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3949
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3950 if (zc->zc_string[0])
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3951 origin = zc->zc_string;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3952
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3953 error = dmu_recv_begin(tofs, tosnap,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3954 &zc->zc_begin_record, force, origin, &drc);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3955 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3956 goto out;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3957
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3958 /*
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3959 * Set properties before we receive the stream so that they are applied
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3960 * to the new data. Note that we must call dmu_recv_stream() if
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3961 * dmu_recv_begin() succeeds.
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3962 */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3963 if (props != NULL && !drc.drc_newfs) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3964 if (spa_version(dsl_dataset_get_spa(drc.drc_ds)) >=
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3965 SPA_VERSION_RECVD_PROPS &&
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3966 !dsl_prop_get_hasrecvd(tofs))
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3967 first_recvd_props = B_TRUE;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3968
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3969 /*
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3970 * If new received properties are supplied, they are to
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3971 * completely replace the existing received properties, so stash
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3972 * away the existing ones.
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
3973 */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3974 if (dsl_prop_get_received(tofs, &origprops) == 0) {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3975 nvlist_t *errlist = NULL;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3976 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3977 * Don't bother writing a property if its value won't
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3978 * change (and avoid the unnecessary security checks).
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3979 *
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3980 * The first receive after SPA_VERSION_RECVD_PROPS is a
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3981 * special case where we blow away all local properties
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3982 * regardless.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3983 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3984 if (!first_recvd_props)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3985 props_reduce(props, origprops);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3986 if (zfs_check_clearable(tofs, origprops, &errlist) != 0)
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3987 (void) nvlist_merge(errors, errlist, 0);
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3988 nvlist_free(errlist);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3989
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3990 if (clear_received_props(tofs, origprops,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3991 first_recvd_props ? NULL : props) != 0)
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3992 zc->zc_obj |= ZPROP_ERR_NOCLEAR;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3993 } else {
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3994 zc->zc_obj |= ZPROP_ERR_NOCLEAR;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
3995 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3996 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3997
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3998 if (props != NULL) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
3999 props_error = dsl_prop_set_hasrecvd(tofs);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4000
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4001 if (props_error == 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4002 (void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_RECEIVED,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4003 props, errors);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4004 }
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4005 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4006
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4007 if (zc->zc_nvlist_dst_size != 0 &&
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4008 (nvlist_smush(errors, zc->zc_nvlist_dst_size) != 0 ||
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4009 put_nvlist(zc, errors) != 0)) {
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4010 /*
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4011 * Caller made zc->zc_nvlist_dst less than the minimum expected
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4012 * size or supplied an invalid address.
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4013 */
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4014 props_error = SET_ERROR(EINVAL);
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4015 }
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4016
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4017 off = fp->f_offset;
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
4018 error = dmu_recv_stream(&drc, fp->f_vnode, &off, zc->zc_cleanup_fd,
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
4019 &zc->zc_action_handle);
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4020
10204
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4021 if (error == 0) {
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4022 zfsvfs_t *zfsvfs = NULL;
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4023
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4024 if (getzfsvfs(tofs, &zfsvfs) == 0) {
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4025 /* online recv */
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4026 int end_err;
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4027
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4028 error = zfs_suspend_fs(zfsvfs);
10204
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4029 /*
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4030 * If the suspend fails, then the recv_end will
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4031 * likely also fail, and clean up after itself.
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4032 */
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4033 end_err = dmu_recv_end(&drc);
11812
453b88fd62f1 6891437 DEADCODE in zfs_ioc_recv after dmu_recv_end.
George Wilson <George.Wilson@Sun.COM>
parents: 11807
diff changeset
4034 if (error == 0)
453b88fd62f1 6891437 DEADCODE in zfs_ioc_recv after dmu_recv_end.
George Wilson <George.Wilson@Sun.COM>
parents: 11807
diff changeset
4035 error = zfs_resume_fs(zfsvfs, tofs);
10204
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4036 error = error ? error : end_err;
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4037 VFS_RELE(zfsvfs->z_vfs);
83c3a84aecef 6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9643
diff changeset
4038 } else {
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4039 error = dmu_recv_end(&drc);
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4040 }
6083
23e77aa611b1 6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents: 5977
diff changeset
4041 }
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4042
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4043 zc->zc_cookie = off - fp->f_offset;
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4044 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4045 fp->f_offset = off;
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
4046
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4047 #ifdef DEBUG
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4048 if (zfs_ioc_recv_inject_err) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4049 zfs_ioc_recv_inject_err = B_FALSE;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4050 error = 1;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4051 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4052 #endif
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4053 /*
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4054 * On error, restore the original props.
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4055 */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4056 if (error != 0 && props != NULL && !drc.drc_newfs) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4057 if (clear_received_props(tofs, props, NULL) != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4058 /*
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4059 * We failed to clear the received properties.
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4060 * Since we may have left a $recvd value on the
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4061 * system, we can't clear the $hasrecvd flag.
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4062 */
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4063 zc->zc_obj |= ZPROP_ERR_NORESTORE;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4064 } else if (first_recvd_props) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4065 dsl_prop_unset_hasrecvd(tofs);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4066 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4067
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4068 if (origprops == NULL && !drc.drc_newfs) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4069 /* We failed to stash the original properties. */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4070 zc->zc_obj |= ZPROP_ERR_NORESTORE;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4071 }
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4072
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4073 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4074 * dsl_props_set() will not convert RECEIVED to LOCAL on or
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4075 * after SPA_VERSION_RECVD_PROPS, so we need to specify LOCAL
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4076 * explictly if we're restoring local properties cleared in the
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4077 * first new-style receive.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4078 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4079 if (origprops != NULL &&
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4080 zfs_set_prop_nvlist(tofs, (first_recvd_props ?
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4081 ZPROP_SRC_LOCAL : ZPROP_SRC_RECEIVED),
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4082 origprops, NULL) != 0) {
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4083 /*
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4084 * We stashed the original properties but failed to
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4085 * restore them.
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4086 */
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4087 zc->zc_obj |= ZPROP_ERR_NORESTORE;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4088 }
6689
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4089 }
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4090 out:
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4091 nvlist_free(props);
47572a2f5e73 6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents: 6643
diff changeset
4092 nvlist_free(origprops);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4093 nvlist_free(errors);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4094 releasef(fd);
11022
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4095
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4096 if (error == 0)
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4097 error = props_error;
63ab26072e41 PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 11007
diff changeset
4098
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4099 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4100 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4101
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4102 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4103 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4104 * zc_name name of snapshot to send
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4105 * zc_cookie file descriptor to send stream to
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4106 * zc_obj fromorigin flag (mutually exclusive with zc_fromobj)
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4107 * zc_sendobj objsetid of snapshot to send
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4108 * zc_fromobj objsetid of incremental fromsnap (may be zero)
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4109 * zc_guid if set, estimate size of stream only. zc_cookie is ignored.
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4110 * output size in zc_objset_type.
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4111 *
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4112 * outputs: none
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4113 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4114 static int
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4115 zfs_ioc_send(zfs_cmd_t *zc)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4116 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4117 int error;
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4118 offset_t off;
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4119 boolean_t estimate = (zc->zc_guid != 0);
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4120
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4121 if (zc->zc_obj != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4122 dsl_pool_t *dp;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4123 dsl_dataset_t *tosnap;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4124
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4125 error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4126 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4127 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4128
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4129 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &tosnap);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4130 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4131 dsl_pool_rele(dp, FTAG);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4132 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4133 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4134
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4135 if (dsl_dir_is_clone(tosnap->ds_dir))
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4136 zc->zc_fromobj = tosnap->ds_dir->dd_phys->dd_origin_obj;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4137 dsl_dataset_rele(tosnap, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4138 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4139 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4140
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4141 if (estimate) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4142 dsl_pool_t *dp;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4143 dsl_dataset_t *tosnap;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4144 dsl_dataset_t *fromsnap = NULL;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4145
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4146 error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4147 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4148 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4149
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4150 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &tosnap);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4151 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4152 dsl_pool_rele(dp, FTAG);
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4153 return (error);
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4154 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4155
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4156 if (zc->zc_fromobj != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4157 error = dsl_dataset_hold_obj(dp, zc->zc_fromobj,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4158 FTAG, &fromsnap);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4159 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4160 dsl_dataset_rele(tosnap, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4161 dsl_pool_rele(dp, FTAG);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4162 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4163 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4164 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4165
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4166 error = dmu_send_estimate(tosnap, fromsnap,
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4167 &zc->zc_objset_type);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4168
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4169 if (fromsnap != NULL)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4170 dsl_dataset_rele(fromsnap, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4171 dsl_dataset_rele(tosnap, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4172 dsl_pool_rele(dp, FTAG);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4173 } else {
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4174 file_t *fp = getf(zc->zc_cookie);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4175 if (fp == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4176 return (SET_ERROR(EBADF));
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4177
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4178 off = fp->f_offset;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4179 error = dmu_send_obj(zc->zc_name, zc->zc_sendobj,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4180 zc->zc_fromobj, zc->zc_cookie, fp->f_vnode, &off);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4181
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4182 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4183 fp->f_offset = off;
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4184 releasef(zc->zc_cookie);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4185 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4186 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4187 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4188
13686
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4189 /*
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4190 * inputs:
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4191 * zc_name name of snapshot on which to report progress
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4192 * zc_cookie file descriptor of send stream
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4193 *
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4194 * outputs:
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4195 * zc_cookie number of bytes written in send stream thus far
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4196 */
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4197 static int
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4198 zfs_ioc_send_progress(zfs_cmd_t *zc)
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4199 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4200 dsl_pool_t *dp;
13686
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4201 dsl_dataset_t *ds;
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4202 dmu_sendarg_t *dsp = NULL;
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4203 int error;
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4204
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4205 error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4206 if (error != 0)
13686
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4207 return (error);
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4208
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4209 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &ds);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4210 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4211 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4212 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4213 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4214
13686
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4215 mutex_enter(&ds->ds_sendstream_lock);
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4216
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4217 /*
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4218 * Iterate over all the send streams currently active on this dataset.
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4219 * If there's one which matches the specified file descriptor _and_ the
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4220 * stream was started by the current process, return the progress of
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4221 * that stream.
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4222 */
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4223 for (dsp = list_head(&ds->ds_sendstreams); dsp != NULL;
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4224 dsp = list_next(&ds->ds_sendstreams, dsp)) {
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4225 if (dsp->dsa_outfd == zc->zc_cookie &&
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4226 dsp->dsa_proc == curproc)
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4227 break;
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4228 }
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4229
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4230 if (dsp != NULL)
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4231 zc->zc_cookie = *(dsp->dsa_off);
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4232 else
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4233 error = SET_ERROR(ENOENT);
13686
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4234
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4235 mutex_exit(&ds->ds_sendstream_lock);
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4236 dsl_dataset_rele(ds, FTAG);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4237 dsl_pool_rele(dp, FTAG);
13686
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4238 return (error);
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4239 }
4bc0783f6064 2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents: 13570
diff changeset
4240
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4241 static int
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4242 zfs_ioc_inject_fault(zfs_cmd_t *zc)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4243 {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4244 int id, error;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4245
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4246 error = zio_inject_fault(zc->zc_name, (int)zc->zc_guid, &id,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4247 &zc->zc_inject_record);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4248
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4249 if (error == 0)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4250 zc->zc_guid = (uint64_t)id;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4251
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4252 return (error);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4253 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4254
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4255 static int
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4256 zfs_ioc_clear_fault(zfs_cmd_t *zc)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4257 {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4258 return (zio_clear_fault((int)zc->zc_guid));
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4259 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4260
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4261 static int
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4262 zfs_ioc_inject_list_next(zfs_cmd_t *zc)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4263 {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4264 int id = (int)zc->zc_guid;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4265 int error;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4266
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4267 error = zio_inject_list_next(&id, zc->zc_name, sizeof (zc->zc_name),
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4268 &zc->zc_inject_record);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4269
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4270 zc->zc_guid = id;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4271
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4272 return (error);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4273 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4274
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4275 static int
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4276 zfs_ioc_error_log(zfs_cmd_t *zc)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4277 {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4278 spa_t *spa;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4279 int error;
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
4280 size_t count = (size_t)zc->zc_nvlist_dst_size;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4281
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4282 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4283 return (error);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4284
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
4285 error = spa_get_errlog(spa, (void *)(uintptr_t)zc->zc_nvlist_dst,
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4286 &count);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4287 if (error == 0)
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
4288 zc->zc_nvlist_dst_size = count;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4289 else
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
4290 zc->zc_nvlist_dst_size = spa_get_errlog_size(spa);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4291
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4292 spa_close(spa, FTAG);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4293
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4294 return (error);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4295 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4296
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4297 static int
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4298 zfs_ioc_clear(zfs_cmd_t *zc)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4299 {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4300 spa_t *spa;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4301 vdev_t *vd;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4302 int error;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4303
7294
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4304 /*
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4305 * On zpool clear we also fix up missing slogs
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4306 */
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4307 mutex_enter(&spa_namespace_lock);
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4308 spa = spa_lookup(zc->zc_name);
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4309 if (spa == NULL) {
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4310 mutex_exit(&spa_namespace_lock);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4311 return (SET_ERROR(EIO));
7294
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4312 }
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
4313 if (spa_get_log_state(spa) == SPA_LOG_MISSING) {
7294
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4314 /* we need to let spa_open/spa_load clear the chains */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
4315 spa_set_log_state(spa, SPA_LOG_CLEAR);
7294
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4316 }
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4317 spa->spa_last_open_failed = 0;
7294
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4318 mutex_exit(&spa_namespace_lock);
c9c31ef4c960 PSARC 2008/486 Intent log replay failure handling
perrin
parents: 7265
diff changeset
4319
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11546
diff changeset
4320 if (zc->zc_cookie & ZPOOL_NO_REWIND) {
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4321 error = spa_open(zc->zc_name, &spa, FTAG);
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4322 } else {
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4323 nvlist_t *policy;
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4324 nvlist_t *config = NULL;
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4325
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4326 if (zc->zc_nvlist_src == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4327 return (SET_ERROR(EINVAL));
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4328
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4329 if ((error = get_nvlist(zc->zc_nvlist_src,
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4330 zc->zc_nvlist_src_size, zc->zc_iflags, &policy)) == 0) {
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4331 error = spa_open_rewind(zc->zc_name, &spa, FTAG,
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4332 policy, &config);
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4333 if (config != NULL) {
12961
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
4334 int err;
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
4335
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
4336 if ((err = put_nvlist(zc, config)) != 0)
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12798
diff changeset
4337 error = err;
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4338 nvlist_free(config);
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4339 }
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4340 nvlist_free(policy);
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4341 }
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4342 }
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10850
diff changeset
4343
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4344 if (error != 0)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4345 return (error);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4346
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10672
diff changeset
4347 spa_vdev_state_enter(spa, SCL_NONE);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4348
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
4349 if (zc->zc_guid == 0) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4350 vd = NULL;
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6492
diff changeset
4351 } else {
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6492
diff changeset
4352 vd = spa_lookup_by_guid(spa, zc->zc_guid, B_TRUE);
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
4353 if (vd == NULL) {
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4354 (void) spa_vdev_state_exit(spa, NULL, ENODEV);
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
4355 spa_close(spa, FTAG);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4356 return (SET_ERROR(ENODEV));
5450
b25030891c44 PSARC 2007/618 ZFS L2ARC
brendan
parents: 5446
diff changeset
4357 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4358 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4359
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4360 vdev_clear(spa, vd);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4361
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4362 (void) spa_vdev_state_exit(spa, NULL, 0);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4363
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4364 /*
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4365 * Resume any suspended I/Os.
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7656
diff changeset
4366 */
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
4367 if (zio_resume(spa) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4368 error = SET_ERROR(EIO);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4369
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4370 spa_close(spa, FTAG);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4371
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
4372 return (error);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4373 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4374
13570
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4375 static int
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4376 zfs_ioc_pool_reopen(zfs_cmd_t *zc)
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4377 {
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4378 spa_t *spa;
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4379 int error;
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4380
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4381 error = spa_open(zc->zc_name, &spa, FTAG);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4382 if (error != 0)
13570
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4383 return (error);
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4384
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4385 spa_vdev_state_enter(spa, SCL_NONE);
13794
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4386
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4387 /*
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4388 * If a resilver is already in progress then set the
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4389 * spa_scrub_reopen flag to B_TRUE so that we don't restart
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4390 * the scan as a side effect of the reopen. Otherwise, let
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4391 * vdev_open() decided if a resilver is required.
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4392 */
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4393 spa->spa_scrub_reopen = dsl_scan_resilvering(spa->spa_dsl_pool);
13570
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4394 vdev_reopen(spa->spa_root_vdev);
13794
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4395 spa->spa_scrub_reopen = B_FALSE;
7c5e0e746b2c 3129 'zpool reopen' restarts resilvers
George Wilson <george.wilson@delphix.com>
parents: 13765
diff changeset
4396
13570
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4397 (void) spa_vdev_state_exit(spa, NULL, 0);
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4398 spa_close(spa, FTAG);
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4399 return (0);
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 13524
diff changeset
4400 }
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4401 /*
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4402 * inputs:
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4403 * zc_name name of filesystem
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4404 * zc_value name of origin snapshot
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4405 *
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
4406 * outputs:
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
4407 * zc_string name of conflicting snapshot, if there is one
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
4408 */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
4409 static int
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
4410 zfs_ioc_promote(zfs_cmd_t *zc)
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
4411 {
2417
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4412 char *cp;
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4413
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4414 /*
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4415 * We don't need to unmount *all* the origin fs's snapshots, but
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4416 * it's easier.
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4417 */
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
4418 cp = strchr(zc->zc_value, '@');
2417
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4419 if (cp)
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2199
diff changeset
4420 *cp = '\0';
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 2665
diff changeset
4421 (void) dmu_objset_find(zc->zc_value,
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4422 zfs_unmount_snap_cb, NULL, DS_FIND_SNAPSHOTS);
10588
dc03f981ea18 6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 10474
diff changeset
4423 return (dsl_dataset_promote(zc->zc_name, zc->zc_string));
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
4424 }
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1775
diff changeset
4425
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4426 /*
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4427 * Retrieve a single {user|group}{used|quota}@... property.
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4428 *
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4429 * inputs:
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4430 * zc_name name of filesystem
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4431 * zc_objset_type zfs_userquota_prop_t
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4432 * zc_value domain name (eg. "S-1-234-567-89")
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4433 * zc_guid RID/UID/GID
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4434 *
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4435 * outputs:
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4436 * zc_cookie property value
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4437 */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4438 static int
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4439 zfs_ioc_userspace_one(zfs_cmd_t *zc)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4440 {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4441 zfsvfs_t *zfsvfs;
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4442 int error;
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4443
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4444 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4445 return (SET_ERROR(EINVAL));
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4446
12620
12fcd99a642d 6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12527
diff changeset
4447 error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4448 if (error != 0)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4449 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4450
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4451 error = zfs_userspace_one(zfsvfs,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4452 zc->zc_objset_type, zc->zc_value, zc->zc_guid, &zc->zc_cookie);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4453 zfsvfs_rele(zfsvfs, FTAG);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4454
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4455 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4456 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4457
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4458 /*
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4459 * inputs:
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4460 * zc_name name of filesystem
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4461 * zc_cookie zap cursor
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4462 * zc_objset_type zfs_userquota_prop_t
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4463 * zc_nvlist_dst[_size] buffer to fill (not really an nvlist)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4464 *
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4465 * outputs:
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4466 * zc_nvlist_dst[_size] data buffer (array of zfs_useracct_t)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4467 * zc_cookie zap cursor
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4468 */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4469 static int
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4470 zfs_ioc_userspace_many(zfs_cmd_t *zc)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4471 {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4472 zfsvfs_t *zfsvfs;
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
4473 int bufsize = zc->zc_nvlist_dst_size;
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
4474
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
4475 if (bufsize <= 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4476 return (SET_ERROR(ENOMEM));
11933
76670fc4178f 6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents: 11889
diff changeset
4477
12620
12fcd99a642d 6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12527
diff changeset
4478 int error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4479 if (error != 0)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4480 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4481
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4482 void *buf = kmem_alloc(bufsize, KM_SLEEP);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4483
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4484 error = zfs_userspace_many(zfsvfs, zc->zc_objset_type, &zc->zc_cookie,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4485 buf, &zc->zc_nvlist_dst_size);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4486
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4487 if (error == 0) {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4488 error = xcopyout(buf,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4489 (void *)(uintptr_t)zc->zc_nvlist_dst,
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4490 zc->zc_nvlist_dst_size);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4491 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4492 kmem_free(buf, bufsize);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4493 zfsvfs_rele(zfsvfs, FTAG);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4494
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4495 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4496 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4497
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4498 /*
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4499 * inputs:
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4500 * zc_name name of filesystem
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4501 *
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4502 * outputs:
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4503 * none
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4504 */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4505 static int
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4506 zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4507 {
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4508 objset_t *os;
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
4509 int error = 0;
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4510 zfsvfs_t *zfsvfs;
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4511
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4512 if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4513 if (!dmu_objset_userused_enabled(zfsvfs->z_os)) {
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4514 /*
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4515 * If userused is not enabled, it may be because the
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4516 * objset needs to be closed & reopened (to grow the
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4517 * objset_phys_t). Suspend/resume the fs will do that.
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4518 */
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4519 error = zfs_suspend_fs(zfsvfs);
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4520 if (error == 0)
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4521 error = zfs_resume_fs(zfsvfs, zc->zc_name);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4522 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4523 if (error == 0)
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4524 error = dmu_objset_userspace_upgrade(zfsvfs->z_os);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4525 VFS_RELE(zfsvfs->z_vfs);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4526 } else {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4527 /* XXX kind of reading contents without owning */
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4528 error = dmu_objset_hold(zc->zc_name, FTAG, &os);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4529 if (error != 0)
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4530 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4531
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4532 error = dmu_objset_userspace_upgrade(os);
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10272
diff changeset
4533 dmu_objset_rele(os, FTAG);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4534 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4535
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4536 return (error);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4537 }
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4538
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
4539 /*
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4540 * We don't want to have a hard dependency
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4541 * against some special symbols in sharefs
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4542 * nfs, and smbsrv. Determine them if needed when
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4543 * the first file system is shared.
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4544 * Neither sharefs, nfs or smbsrv are unloadable modules.
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4545 */
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4546 int (*znfsexport_fs)(void *arg);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4547 int (*zshare_fs)(enum sharefs_sys_op, share_t *, uint32_t);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4548 int (*zsmbexport_fs)(void *arg, boolean_t add_share);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4549
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4550 int zfs_nfsshare_inited;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4551 int zfs_smbshare_inited;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4552
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4553 ddi_modhandle_t nfs_mod;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4554 ddi_modhandle_t sharefs_mod;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4555 ddi_modhandle_t smbsrv_mod;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4556 kmutex_t zfs_share_lock;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4557
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4558 static int
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4559 zfs_init_sharefs()
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4560 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4561 int error;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4562
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4563 ASSERT(MUTEX_HELD(&zfs_share_lock));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4564 /* Both NFS and SMB shares also require sharetab support. */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4565 if (sharefs_mod == NULL && ((sharefs_mod =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4566 ddi_modopen("fs/sharefs",
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4567 KRTLD_MODE_FIRST, &error)) == NULL)) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4568 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4569 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4570 if (zshare_fs == NULL && ((zshare_fs =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4571 (int (*)(enum sharefs_sys_op, share_t *, uint32_t))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4572 ddi_modsym(sharefs_mod, "sharefs_impl", &error)) == NULL)) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4573 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4574 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4575 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4576 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4577
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4578 static int
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4579 zfs_ioc_share(zfs_cmd_t *zc)
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4580 {
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4581 int error;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4582 int opcode;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4583
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4584 switch (zc->zc_share.z_sharetype) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4585 case ZFS_SHARE_NFS:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4586 case ZFS_UNSHARE_NFS:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4587 if (zfs_nfsshare_inited == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4588 mutex_enter(&zfs_share_lock);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4589 if (nfs_mod == NULL && ((nfs_mod = ddi_modopen("fs/nfs",
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4590 KRTLD_MODE_FIRST, &error)) == NULL)) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4591 mutex_exit(&zfs_share_lock);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4592 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4593 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4594 if (znfsexport_fs == NULL &&
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4595 ((znfsexport_fs = (int (*)(void *))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4596 ddi_modsym(nfs_mod,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4597 "nfs_export", &error)) == NULL)) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4598 mutex_exit(&zfs_share_lock);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4599 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4600 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4601 error = zfs_init_sharefs();
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4602 if (error != 0) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4603 mutex_exit(&zfs_share_lock);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4604 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4605 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4606 zfs_nfsshare_inited = 1;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4607 mutex_exit(&zfs_share_lock);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4608 }
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4609 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4610 case ZFS_SHARE_SMB:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4611 case ZFS_UNSHARE_SMB:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4612 if (zfs_smbshare_inited == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4613 mutex_enter(&zfs_share_lock);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4614 if (smbsrv_mod == NULL && ((smbsrv_mod =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4615 ddi_modopen("drv/smbsrv",
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4616 KRTLD_MODE_FIRST, &error)) == NULL)) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4617 mutex_exit(&zfs_share_lock);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4618 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4619 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4620 if (zsmbexport_fs == NULL && ((zsmbexport_fs =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4621 (int (*)(void *, boolean_t))ddi_modsym(smbsrv_mod,
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 6083
diff changeset
4622 "smb_server_share", &error)) == NULL)) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4623 mutex_exit(&zfs_share_lock);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4624 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4625 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4626 error = zfs_init_sharefs();
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4627 if (error != 0) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4628 mutex_exit(&zfs_share_lock);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4629 return (SET_ERROR(ENOSYS));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4630 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4631 zfs_smbshare_inited = 1;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4632 mutex_exit(&zfs_share_lock);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4633 }
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4634 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4635 default:
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4636 return (SET_ERROR(EINVAL));
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4637 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4638
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4639 switch (zc->zc_share.z_sharetype) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4640 case ZFS_SHARE_NFS:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4641 case ZFS_UNSHARE_NFS:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4642 if (error =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4643 znfsexport_fs((void *)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4644 (uintptr_t)zc->zc_share.z_exportdata))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4645 return (error);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4646 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4647 case ZFS_SHARE_SMB:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4648 case ZFS_UNSHARE_SMB:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4649 if (error = zsmbexport_fs((void *)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4650 (uintptr_t)zc->zc_share.z_exportdata,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4651 zc->zc_share.z_sharetype == ZFS_SHARE_SMB ?
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4652 B_TRUE: B_FALSE)) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4653 return (error);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4654 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4655 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4656 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4657
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4658 opcode = (zc->zc_share.z_sharetype == ZFS_SHARE_NFS ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4659 zc->zc_share.z_sharetype == ZFS_SHARE_SMB) ?
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4660 SHAREFS_ADD : SHAREFS_REMOVE;
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4661
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4662 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4663 * Add or remove share from sharetab
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
4664 */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4665 error = zshare_fs(opcode,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4666 (void *)(uintptr_t)zc->zc_share.z_sharedata,
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4667 zc->zc_share.z_sharemax);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4668
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4669 return (error);
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4670
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4671 }
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4672
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4673 ace_t full_access[] = {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4674 {(uid_t)-1, ACE_ALL_PERMS, ACE_EVERYONE, 0}
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4675 };
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4676
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4677 /*
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4678 * inputs:
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4679 * zc_name name of containing filesystem
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4680 * zc_obj object # beyond which we want next in-use object #
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4681 *
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4682 * outputs:
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4683 * zc_obj next in-use object #
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4684 */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4685 static int
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4686 zfs_ioc_next_obj(zfs_cmd_t *zc)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4687 {
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4688 objset_t *os = NULL;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4689 int error;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4690
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4691 error = dmu_objset_hold(zc->zc_name, FTAG, &os);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4692 if (error != 0)
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4693 return (error);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4694
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4695 error = dmu_object_next(os, &zc->zc_obj, B_FALSE,
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4696 os->os_dsl_dataset->ds_phys->ds_prev_snap_txg);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4697
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4698 dmu_objset_rele(os, FTAG);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4699 return (error);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4700 }
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4701
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4702 /*
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4703 * inputs:
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4704 * zc_name name of filesystem
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4705 * zc_value prefix name for snapshot
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4706 * zc_cleanup_fd cleanup-on-exit file descriptor for calling process
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4707 *
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4708 * outputs:
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
4709 * zc_value short name of new snapshot
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4710 */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4711 static int
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4712 zfs_ioc_tmp_snapshot(zfs_cmd_t *zc)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4713 {
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4714 char *snap_name;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4715 char *hold_name;
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4716 int error;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4717 minor_t minor;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4718
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4719 error = zfs_onexit_fd_hold(zc->zc_cleanup_fd, &minor);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4720 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4721 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4722
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4723 snap_name = kmem_asprintf("%s-%016llx", zc->zc_value,
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4724 (u_longlong_t)ddi_get_lbolt64());
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4725 hold_name = kmem_asprintf("%%%s", zc->zc_value);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4726
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4727 error = dsl_dataset_snapshot_tmp(zc->zc_name, snap_name, minor,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4728 hold_name);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4729 if (error == 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4730 (void) strcpy(zc->zc_value, snap_name);
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4731 strfree(snap_name);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4732 strfree(hold_name);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4733 zfs_onexit_fd_rele(zc->zc_cleanup_fd);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4734 return (error);
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4735 }
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4736
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4737 /*
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4738 * inputs:
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4739 * zc_name name of "to" snapshot
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4740 * zc_value name of "from" snapshot
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4741 * zc_cookie file descriptor to write diff data on
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4742 *
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4743 * outputs:
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4744 * dmu_diff_record_t's to the file descriptor
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4745 */
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4746 static int
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4747 zfs_ioc_diff(zfs_cmd_t *zc)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4748 {
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4749 file_t *fp;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4750 offset_t off;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4751 int error;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4752
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4753 fp = getf(zc->zc_cookie);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4754 if (fp == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4755 return (SET_ERROR(EBADF));
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4756
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4757 off = fp->f_offset;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4758
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4759 error = dmu_diff(zc->zc_name, zc->zc_value, fp->f_vnode, &off);
13055
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4760
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4761 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4762 fp->f_offset = off;
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4763 releasef(zc->zc_cookie);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4764
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4765 return (error);
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4766 }
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4767
8c712bbb18ea PSARC 2010/105 zfs diff
Tim Haley <Tim.Haley@Sun.COM>
parents: 12961
diff changeset
4768 /*
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4769 * Remove all ACL files in shares dir
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4770 */
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4771 static int
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4772 zfs_smb_acl_purge(znode_t *dzp)
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4773 {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4774 zap_cursor_t zc;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4775 zap_attribute_t zap;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4776 zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4777 int error;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4778
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4779 for (zap_cursor_init(&zc, zfsvfs->z_os, dzp->z_id);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4780 (error = zap_cursor_retrieve(&zc, &zap)) == 0;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4781 zap_cursor_advance(&zc)) {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4782 if ((error = VOP_REMOVE(ZTOV(dzp), zap.za_name, kcred,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4783 NULL, 0)) != 0)
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4784 break;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4785 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4786 zap_cursor_fini(&zc);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4787 return (error);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4788 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4789
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4790 static int
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4791 zfs_ioc_smb_acl(zfs_cmd_t *zc)
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4792 {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4793 vnode_t *vp;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4794 znode_t *dzp;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4795 vnode_t *resourcevp = NULL;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4796 znode_t *sharedir;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4797 zfsvfs_t *zfsvfs;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4798 nvlist_t *nvlist;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4799 char *src, *target;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4800 vattr_t vattr;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4801 vsecattr_t vsec;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4802 int error = 0;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4803
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4804 if ((error = lookupname(zc->zc_value, UIO_SYSSPACE,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4805 NO_FOLLOW, NULL, &vp)) != 0)
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4806 return (error);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4807
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4808 /* Now make sure mntpnt and dataset are ZFS */
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4809
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4810 if (vp->v_vfsp->vfs_fstype != zfsfstype ||
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4811 (strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4812 zc->zc_name) != 0)) {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4813 VN_RELE(vp);
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4814 return (SET_ERROR(EINVAL));
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4815 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4816
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4817 dzp = VTOZ(vp);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4818 zfsvfs = dzp->z_zfsvfs;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4819 ZFS_ENTER(zfsvfs);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4820
9030
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4821 /*
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4822 * Create share dir if its missing.
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4823 */
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4824 mutex_enter(&zfsvfs->z_lock);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4825 if (zfsvfs->z_shares_dir == 0) {
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4826 dmu_tx_t *tx;
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4827
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4828 tx = dmu_tx_create(zfsvfs->z_os);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4829 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, TRUE,
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4830 ZFS_SHARES_DIR);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4831 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4832 error = dmu_tx_assign(tx, TXG_WAIT);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4833 if (error != 0) {
9030
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4834 dmu_tx_abort(tx);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4835 } else {
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4836 error = zfs_create_share_dir(zfsvfs, tx);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4837 dmu_tx_commit(tx);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4838 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4839 if (error != 0) {
9030
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4840 mutex_exit(&zfsvfs->z_lock);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4841 VN_RELE(vp);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4842 ZFS_EXIT(zfsvfs);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4843 return (error);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4844 }
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4845 }
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4846 mutex_exit(&zfsvfs->z_lock);
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4847
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4848 ASSERT(zfsvfs->z_shares_dir);
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4849 if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &sharedir)) != 0) {
9030
243fd360d81f 6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8845
diff changeset
4850 VN_RELE(vp);
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4851 ZFS_EXIT(zfsvfs);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4852 return (error);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4853 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4854
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4855 switch (zc->zc_cookie) {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4856 case ZFS_SMB_ACL_ADD:
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4857 vattr.va_mask = AT_MODE|AT_UID|AT_GID|AT_TYPE;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4858 vattr.va_type = VREG;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4859 vattr.va_mode = S_IFREG|0777;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4860 vattr.va_uid = 0;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4861 vattr.va_gid = 0;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4862
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4863 vsec.vsa_mask = VSA_ACE;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4864 vsec.vsa_aclentp = &full_access;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4865 vsec.vsa_aclentsz = sizeof (full_access);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4866 vsec.vsa_aclcnt = 1;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4867
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4868 error = VOP_CREATE(ZTOV(sharedir), zc->zc_string,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4869 &vattr, EXCL, 0, &resourcevp, kcred, 0, NULL, &vsec);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4870 if (resourcevp)
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4871 VN_RELE(resourcevp);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4872 break;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4873
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4874 case ZFS_SMB_ACL_REMOVE:
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4875 error = VOP_REMOVE(ZTOV(sharedir), zc->zc_string, kcred,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4876 NULL, 0);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4877 break;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4878
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4879 case ZFS_SMB_ACL_RENAME:
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4880 if ((error = get_nvlist(zc->zc_nvlist_src,
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
4881 zc->zc_nvlist_src_size, zc->zc_iflags, &nvlist)) != 0) {
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4882 VN_RELE(vp);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4883 ZFS_EXIT(zfsvfs);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4884 return (error);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4885 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4886 if (nvlist_lookup_string(nvlist, ZFS_SMB_ACL_SRC, &src) ||
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4887 nvlist_lookup_string(nvlist, ZFS_SMB_ACL_TARGET,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4888 &target)) {
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4889 VN_RELE(vp);
9179
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 9030
diff changeset
4890 VN_RELE(ZTOV(sharedir));
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4891 ZFS_EXIT(zfsvfs);
11422
42768837421d PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11314
diff changeset
4892 nvlist_free(nvlist);
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4893 return (error);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4894 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4895 error = VOP_RENAME(ZTOV(sharedir), src, ZTOV(sharedir), target,
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4896 kcred, NULL, 0);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4897 nvlist_free(nvlist);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4898 break;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4899
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4900 case ZFS_SMB_ACL_PURGE:
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4901 error = zfs_smb_acl_purge(sharedir);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4902 break;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4903
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4904 default:
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4905 error = SET_ERROR(EINVAL);
8845
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4906 break;
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4907 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4908
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4909 VN_RELE(vp);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4910 VN_RELE(ZTOV(sharedir));
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4911
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4912 ZFS_EXIT(zfsvfs);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4913
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4914 return (error);
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4915 }
91af0d9c0790 6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents: 8724
diff changeset
4916
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
4917 /*
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4918 * innvl: {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4919 * "holds" -> { snapname -> holdname (string), ... }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4920 * (optional) "cleanup_fd" -> fd (int32)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4921 * }
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4922 *
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4923 * outnvl: {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4924 * snapname -> error value (int32)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4925 * ...
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4926 * }
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4927 */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4928 /* ARGSUSED */
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4929 static int
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4930 zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4931 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4932 nvlist_t *holds;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4933 int cleanup_fd = -1;
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4934 int error;
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4935 minor_t minor = 0;
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4936
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4937 error = nvlist_lookup_nvlist(args, "holds", &holds);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4938 if (error != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
4939 return (SET_ERROR(EINVAL));
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4940
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4941 if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4942 error = zfs_onexit_fd_hold(cleanup_fd, &minor);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4943 if (error != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4944 return (error);
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4945 }
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4946
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4947 error = dsl_dataset_user_hold(holds, minor, errlist);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4948 if (minor != 0)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4949 zfs_onexit_fd_rele(cleanup_fd);
12798
f6c8601080b4 6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12620
diff changeset
4950 return (error);
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4951 }
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4952
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4953 /*
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4954 * innvl is not used.
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4955 *
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4956 * outnvl: {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4957 * holdname -> time added (uint64 seconds since epoch)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4958 * ...
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4959 * }
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4960 */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4961 /* ARGSUSED */
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4962 static int
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4963 zfs_ioc_get_holds(const char *snapname, nvlist_t *args, nvlist_t *outnvl)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4964 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4965 return (dsl_dataset_get_holds(snapname, outnvl));
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4966 }
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4967
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4968 /*
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4969 * innvl: {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4970 * snapname -> { holdname, ... }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4971 * ...
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4972 * }
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4973 *
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4974 * outnvl: {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4975 * snapname -> error value (int32)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4976 * ...
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4977 * }
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4978 */
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4979 /* ARGSUSED */
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4980 static int
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4981 zfs_ioc_release(const char *pool, nvlist_t *holds, nvlist_t *errlist)
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4982 {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4983 nvpair_t *pair;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4984
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4985 /*
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4986 * The release may cause the snapshot to be destroyed; make sure it
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4987 * is not mounted.
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4988 */
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4989 for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4990 pair = nvlist_next_nvpair(holds, pair))
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4991 zfs_unmount_snap(nvpair_name(pair));
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4992
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
4993 return (dsl_dataset_user_release(holds, errlist));
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4994 }
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4995
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 10233
diff changeset
4996 /*
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4997 * inputs:
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4998 * zc_name name of new filesystem or snapshot
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
4999 * zc_value full name of old snapshot
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5000 *
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5001 * outputs:
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5002 * zc_cookie space in bytes
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5003 * zc_objset_type compressed space in bytes
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5004 * zc_perm_action uncompressed space in bytes
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5005 */
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5006 static int
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5007 zfs_ioc_space_written(zfs_cmd_t *zc)
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5008 {
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5009 int error;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5010 dsl_pool_t *dp;
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5011 dsl_dataset_t *new, *old;
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5012
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5013 error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5014 if (error != 0)
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5015 return (error);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5016 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &new);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5017 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5018 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5019 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5020 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5021 error = dsl_dataset_hold(dp, zc->zc_value, FTAG, &old);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5022 if (error != 0) {
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5023 dsl_dataset_rele(new, FTAG);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5024 dsl_pool_rele(dp, FTAG);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5025 return (error);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5026 }
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5027
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5028 error = dsl_dataset_space_written(old, new, &zc->zc_cookie,
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5029 &zc->zc_objset_type, &zc->zc_perm_action);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5030 dsl_dataset_rele(old, FTAG);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5031 dsl_dataset_rele(new, FTAG);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5032 dsl_pool_rele(dp, FTAG);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5033 return (error);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5034 }
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5035
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5036 /*
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5037 * innvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5038 * "firstsnap" -> snapshot name
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5039 * }
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5040 *
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5041 * outnvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5042 * "used" -> space in bytes
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5043 * "compressed" -> compressed space in bytes
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5044 * "uncompressed" -> uncompressed space in bytes
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5045 * }
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5046 */
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5047 static int
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5048 zfs_ioc_space_snaps(const char *lastsnap, nvlist_t *innvl, nvlist_t *outnvl)
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5049 {
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5050 int error;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5051 dsl_pool_t *dp;
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5052 dsl_dataset_t *new, *old;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5053 char *firstsnap;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5054 uint64_t used, comp, uncomp;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5055
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5056 if (nvlist_lookup_string(innvl, "firstsnap", &firstsnap) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5057 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5058
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5059 error = dsl_pool_hold(lastsnap, FTAG, &dp);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5060 if (error != 0)
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5061 return (error);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5062
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5063 error = dsl_dataset_hold(dp, lastsnap, FTAG, &new);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5064 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5065 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5066 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5067 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5068 error = dsl_dataset_hold(dp, firstsnap, FTAG, &old);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5069 if (error != 0) {
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5070 dsl_dataset_rele(new, FTAG);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5071 dsl_pool_rele(dp, FTAG);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5072 return (error);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5073 }
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5074
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5075 error = dsl_dataset_space_wouldfree(old, new, &used, &comp, &uncomp);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5076 dsl_dataset_rele(old, FTAG);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5077 dsl_dataset_rele(new, FTAG);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5078 dsl_pool_rele(dp, FTAG);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5079 fnvlist_add_uint64(outnvl, "used", used);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5080 fnvlist_add_uint64(outnvl, "compressed", comp);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5081 fnvlist_add_uint64(outnvl, "uncompressed", uncomp);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5082 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5083 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5084
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5085 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5086 * innvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5087 * "fd" -> file descriptor to write stream to (int32)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5088 * (optional) "fromsnap" -> full snap name to send an incremental from
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5089 * }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5090 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5091 * outnvl is unused
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5092 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5093 /* ARGSUSED */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5094 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5095 zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5096 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5097 int error;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5098 offset_t off;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5099 char *fromname = NULL;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5100 int fd;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5101
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5102 error = nvlist_lookup_int32(innvl, "fd", &fd);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5103 if (error != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5104 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5105
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5106 (void) nvlist_lookup_string(innvl, "fromsnap", &fromname);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5107
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5108 file_t *fp = getf(fd);
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5109 if (fp == NULL)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5110 return (SET_ERROR(EBADF));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5111
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5112 off = fp->f_offset;
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5113 error = dmu_send(snapname, fromname, fd, fp->f_vnode, &off);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5114
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5115 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5116 fp->f_offset = off;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5117 releasef(fd);
13524
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5118 return (error);
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5119 }
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5120
f0e12b33f77c 1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents: 13514
diff changeset
5121 /*
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5122 * Determine approximately how large a zfs send stream will be -- the number
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5123 * of bytes that will be written to the fd supplied to zfs_ioc_send_new().
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5124 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5125 * innvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5126 * (optional) "fromsnap" -> full snap name to send an incremental from
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5127 * }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5128 *
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5129 * outnvl: {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5130 * "space" -> bytes of space (uint64)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5131 * }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5132 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5133 static int
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5134 zfs_ioc_send_space(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5135 {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5136 dsl_pool_t *dp;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5137 dsl_dataset_t *fromsnap = NULL;
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5138 dsl_dataset_t *tosnap;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5139 int error;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5140 char *fromname;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5141 uint64_t space;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5142
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5143 error = dsl_pool_hold(snapname, FTAG, &dp);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5144 if (error != 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5145 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5146
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5147 error = dsl_dataset_hold(dp, snapname, FTAG, &tosnap);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5148 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5149 dsl_pool_rele(dp, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5150 return (error);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5151 }
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5152
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5153 error = nvlist_lookup_string(innvl, "fromsnap", &fromname);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5154 if (error == 0) {
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5155 error = dsl_dataset_hold(dp, fromname, FTAG, &fromsnap);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5156 if (error != 0) {
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5157 dsl_dataset_rele(tosnap, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5158 dsl_pool_rele(dp, FTAG);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5159 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5160 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5161 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5162
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5163 error = dmu_send_estimate(tosnap, fromsnap, &space);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5164 fnvlist_add_uint64(outnvl, "space", space);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5165
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5166 if (fromsnap != NULL)
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5167 dsl_dataset_rele(fromsnap, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5168 dsl_dataset_rele(tosnap, FTAG);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5169 dsl_pool_rele(dp, FTAG);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5170 return (error);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5171 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5172
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5173
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5174 static zfs_ioc_vec_t zfs_ioc_vec[ZFS_IOC_LAST - ZFS_IOC_FIRST];
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5175
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5176 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5177 zfs_ioctl_register_legacy(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5178 zfs_secpolicy_func_t *secpolicy, zfs_ioc_namecheck_t namecheck,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5179 boolean_t log_history, zfs_ioc_poolcheck_t pool_check)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5180 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5181 zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST];
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5182
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5183 ASSERT3U(ioc, >=, ZFS_IOC_FIRST);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5184 ASSERT3U(ioc, <, ZFS_IOC_LAST);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5185 ASSERT3P(vec->zvec_legacy_func, ==, NULL);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5186 ASSERT3P(vec->zvec_func, ==, NULL);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5187
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5188 vec->zvec_legacy_func = func;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5189 vec->zvec_secpolicy = secpolicy;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5190 vec->zvec_namecheck = namecheck;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5191 vec->zvec_allow_log = log_history;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5192 vec->zvec_pool_check = pool_check;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5193 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5194
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5195 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5196 * See the block comment at the beginning of this file for details on
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5197 * each argument to this function.
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
5198 */
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5199 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5200 zfs_ioctl_register(const char *name, zfs_ioc_t ioc, zfs_ioc_func_t *func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5201 zfs_secpolicy_func_t *secpolicy, zfs_ioc_namecheck_t namecheck,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5202 zfs_ioc_poolcheck_t pool_check, boolean_t smush_outnvlist,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5203 boolean_t allow_log)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5204 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5205 zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST];
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5206
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5207 ASSERT3U(ioc, >=, ZFS_IOC_FIRST);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5208 ASSERT3U(ioc, <, ZFS_IOC_LAST);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5209 ASSERT3P(vec->zvec_legacy_func, ==, NULL);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5210 ASSERT3P(vec->zvec_func, ==, NULL);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5211
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5212 /* if we are logging, the name must be valid */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5213 ASSERT(!allow_log || namecheck != NO_NAME);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5214
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5215 vec->zvec_name = name;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5216 vec->zvec_func = func;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5217 vec->zvec_secpolicy = secpolicy;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5218 vec->zvec_namecheck = namecheck;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5219 vec->zvec_pool_check = pool_check;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5220 vec->zvec_smush_outnvlist = smush_outnvlist;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5221 vec->zvec_allow_log = allow_log;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5222 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5223
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5224 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5225 zfs_ioctl_register_pool(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5226 zfs_secpolicy_func_t *secpolicy, boolean_t log_history,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5227 zfs_ioc_poolcheck_t pool_check)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5228 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5229 zfs_ioctl_register_legacy(ioc, func, secpolicy,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5230 POOL_NAME, log_history, pool_check);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5231 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5232
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5233 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5234 zfs_ioctl_register_dataset_nolog(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5235 zfs_secpolicy_func_t *secpolicy, zfs_ioc_poolcheck_t pool_check)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5236 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5237 zfs_ioctl_register_legacy(ioc, func, secpolicy,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5238 DATASET_NAME, B_FALSE, pool_check);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5239 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5240
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5241 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5242 zfs_ioctl_register_pool_modify(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5243 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5244 zfs_ioctl_register_legacy(ioc, func, zfs_secpolicy_config,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5245 POOL_NAME, B_TRUE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5246 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5247
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5248 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5249 zfs_ioctl_register_pool_meta(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5250 zfs_secpolicy_func_t *secpolicy)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5251 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5252 zfs_ioctl_register_legacy(ioc, func, secpolicy,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5253 NO_NAME, B_FALSE, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5254 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5255
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5256 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5257 zfs_ioctl_register_dataset_read_secpolicy(zfs_ioc_t ioc,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5258 zfs_ioc_legacy_func_t *func, zfs_secpolicy_func_t *secpolicy)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5259 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5260 zfs_ioctl_register_legacy(ioc, func, secpolicy,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5261 DATASET_NAME, B_FALSE, POOL_CHECK_SUSPENDED);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5262 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5263
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5264 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5265 zfs_ioctl_register_dataset_read(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5266 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5267 zfs_ioctl_register_dataset_read_secpolicy(ioc, func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5268 zfs_secpolicy_read);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5269 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5270
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5271 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5272 zfs_ioctl_register_dataset_modify(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5273 zfs_secpolicy_func_t *secpolicy)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5274 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5275 zfs_ioctl_register_legacy(ioc, func, secpolicy,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5276 DATASET_NAME, B_TRUE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5277 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5278
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5279 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5280 zfs_ioctl_init(void)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5281 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5282 zfs_ioctl_register("snapshot", ZFS_IOC_SNAPSHOT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5283 zfs_ioc_snapshot, zfs_secpolicy_snapshot, POOL_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5284 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5285
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5286 zfs_ioctl_register("log_history", ZFS_IOC_LOG_HISTORY,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5287 zfs_ioc_log_history, zfs_secpolicy_log_history, NO_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5288 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_FALSE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5289
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5290 zfs_ioctl_register("space_snaps", ZFS_IOC_SPACE_SNAPS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5291 zfs_ioc_space_snaps, zfs_secpolicy_read, DATASET_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5292 POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5293
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5294 zfs_ioctl_register("send", ZFS_IOC_SEND_NEW,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5295 zfs_ioc_send_new, zfs_secpolicy_send_new, DATASET_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5296 POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5297
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5298 zfs_ioctl_register("send_space", ZFS_IOC_SEND_SPACE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5299 zfs_ioc_send_space, zfs_secpolicy_read, DATASET_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5300 POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5301
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5302 zfs_ioctl_register("create", ZFS_IOC_CREATE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5303 zfs_ioc_create, zfs_secpolicy_create_clone, DATASET_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5304 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5305
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5306 zfs_ioctl_register("clone", ZFS_IOC_CLONE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5307 zfs_ioc_clone, zfs_secpolicy_create_clone, DATASET_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5308 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5309
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5310 zfs_ioctl_register("destroy_snaps", ZFS_IOC_DESTROY_SNAPS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5311 zfs_ioc_destroy_snaps, zfs_secpolicy_destroy_snaps, POOL_NAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5312 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5313
13973
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5314 zfs_ioctl_register("hold", ZFS_IOC_HOLD,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5315 zfs_ioc_hold, zfs_secpolicy_hold, POOL_NAME,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5316 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5317 zfs_ioctl_register("release", ZFS_IOC_RELEASE,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5318 zfs_ioc_release, zfs_secpolicy_release, POOL_NAME,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5319 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5320
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5321 zfs_ioctl_register("get_holds", ZFS_IOC_GET_HOLDS,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5322 zfs_ioc_get_holds, zfs_secpolicy_read, DATASET_NAME,
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5323 POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
4972ab336f54 3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents: 13967
diff changeset
5324
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5325 /* IOCTLS that use the legacy function signature */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5326
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5327 zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5328 zfs_secpolicy_config, NO_NAME, B_FALSE, POOL_CHECK_READONLY);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5329
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5330 zfs_ioctl_register_pool(ZFS_IOC_POOL_CREATE, zfs_ioc_pool_create,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5331 zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5332 zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_SCAN,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5333 zfs_ioc_pool_scan);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5334 zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_UPGRADE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5335 zfs_ioc_pool_upgrade);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5336 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_ADD,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5337 zfs_ioc_vdev_add);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5338 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_REMOVE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5339 zfs_ioc_vdev_remove);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5340 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SET_STATE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5341 zfs_ioc_vdev_set_state);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5342 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_ATTACH,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5343 zfs_ioc_vdev_attach);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5344 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_DETACH,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5345 zfs_ioc_vdev_detach);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5346 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SETPATH,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5347 zfs_ioc_vdev_setpath);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5348 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SETFRU,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5349 zfs_ioc_vdev_setfru);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5350 zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_SET_PROPS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5351 zfs_ioc_pool_set_props);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5352 zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SPLIT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5353 zfs_ioc_vdev_split);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5354 zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_REGUID,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5355 zfs_ioc_pool_reguid);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5356
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5357 zfs_ioctl_register_pool_meta(ZFS_IOC_POOL_CONFIGS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5358 zfs_ioc_pool_configs, zfs_secpolicy_none);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5359 zfs_ioctl_register_pool_meta(ZFS_IOC_POOL_TRYIMPORT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5360 zfs_ioc_pool_tryimport, zfs_secpolicy_config);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5361 zfs_ioctl_register_pool_meta(ZFS_IOC_INJECT_FAULT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5362 zfs_ioc_inject_fault, zfs_secpolicy_inject);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5363 zfs_ioctl_register_pool_meta(ZFS_IOC_CLEAR_FAULT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5364 zfs_ioc_clear_fault, zfs_secpolicy_inject);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5365 zfs_ioctl_register_pool_meta(ZFS_IOC_INJECT_LIST_NEXT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5366 zfs_ioc_inject_list_next, zfs_secpolicy_inject);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5367
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5368 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5369 * pool destroy, and export don't log the history as part of
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5370 * zfsdev_ioctl, but rather zfs_ioc_pool_export
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5371 * does the logging of those commands.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5372 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5373 zfs_ioctl_register_pool(ZFS_IOC_POOL_DESTROY, zfs_ioc_pool_destroy,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5374 zfs_secpolicy_config, B_FALSE, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5375 zfs_ioctl_register_pool(ZFS_IOC_POOL_EXPORT, zfs_ioc_pool_export,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5376 zfs_secpolicy_config, B_FALSE, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5377
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5378 zfs_ioctl_register_pool(ZFS_IOC_POOL_STATS, zfs_ioc_pool_stats,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5379 zfs_secpolicy_read, B_FALSE, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5380 zfs_ioctl_register_pool(ZFS_IOC_POOL_GET_PROPS, zfs_ioc_pool_get_props,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5381 zfs_secpolicy_read, B_FALSE, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5382
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5383 zfs_ioctl_register_pool(ZFS_IOC_ERROR_LOG, zfs_ioc_error_log,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5384 zfs_secpolicy_inject, B_FALSE, POOL_CHECK_SUSPENDED);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5385 zfs_ioctl_register_pool(ZFS_IOC_DSOBJ_TO_DSNAME,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5386 zfs_ioc_dsobj_to_dsname,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5387 zfs_secpolicy_diff, B_FALSE, POOL_CHECK_SUSPENDED);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5388 zfs_ioctl_register_pool(ZFS_IOC_POOL_GET_HISTORY,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5389 zfs_ioc_pool_get_history,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5390 zfs_secpolicy_config, B_FALSE, POOL_CHECK_SUSPENDED);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5391
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5392 zfs_ioctl_register_pool(ZFS_IOC_POOL_IMPORT, zfs_ioc_pool_import,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5393 zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5394
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5395 zfs_ioctl_register_pool(ZFS_IOC_CLEAR, zfs_ioc_clear,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5396 zfs_secpolicy_config, B_TRUE, POOL_CHECK_SUSPENDED);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5397 zfs_ioctl_register_pool(ZFS_IOC_POOL_REOPEN, zfs_ioc_pool_reopen,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5398 zfs_secpolicy_config, B_TRUE, POOL_CHECK_SUSPENDED);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5399
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5400 zfs_ioctl_register_dataset_read(ZFS_IOC_SPACE_WRITTEN,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5401 zfs_ioc_space_written);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5402 zfs_ioctl_register_dataset_read(ZFS_IOC_OBJSET_RECVD_PROPS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5403 zfs_ioc_objset_recvd_props);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5404 zfs_ioctl_register_dataset_read(ZFS_IOC_NEXT_OBJ,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5405 zfs_ioc_next_obj);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5406 zfs_ioctl_register_dataset_read(ZFS_IOC_GET_FSACL,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5407 zfs_ioc_get_fsacl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5408 zfs_ioctl_register_dataset_read(ZFS_IOC_OBJSET_STATS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5409 zfs_ioc_objset_stats);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5410 zfs_ioctl_register_dataset_read(ZFS_IOC_OBJSET_ZPLPROPS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5411 zfs_ioc_objset_zplprops);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5412 zfs_ioctl_register_dataset_read(ZFS_IOC_DATASET_LIST_NEXT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5413 zfs_ioc_dataset_list_next);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5414 zfs_ioctl_register_dataset_read(ZFS_IOC_SNAPSHOT_LIST_NEXT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5415 zfs_ioc_snapshot_list_next);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5416 zfs_ioctl_register_dataset_read(ZFS_IOC_SEND_PROGRESS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5417 zfs_ioc_send_progress);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5418
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5419 zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_DIFF,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5420 zfs_ioc_diff, zfs_secpolicy_diff);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5421 zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_OBJ_TO_STATS,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5422 zfs_ioc_obj_to_stats, zfs_secpolicy_diff);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5423 zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_OBJ_TO_PATH,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5424 zfs_ioc_obj_to_path, zfs_secpolicy_diff);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5425 zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_USERSPACE_ONE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5426 zfs_ioc_userspace_one, zfs_secpolicy_userspace_one);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5427 zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_USERSPACE_MANY,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5428 zfs_ioc_userspace_many, zfs_secpolicy_userspace_many);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5429 zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_SEND,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5430 zfs_ioc_send, zfs_secpolicy_send);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5431
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5432 zfs_ioctl_register_dataset_modify(ZFS_IOC_SET_PROP, zfs_ioc_set_prop,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5433 zfs_secpolicy_none);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5434 zfs_ioctl_register_dataset_modify(ZFS_IOC_DESTROY, zfs_ioc_destroy,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5435 zfs_secpolicy_destroy);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5436 zfs_ioctl_register_dataset_modify(ZFS_IOC_ROLLBACK, zfs_ioc_rollback,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5437 zfs_secpolicy_rollback);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5438 zfs_ioctl_register_dataset_modify(ZFS_IOC_RENAME, zfs_ioc_rename,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5439 zfs_secpolicy_rename);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5440 zfs_ioctl_register_dataset_modify(ZFS_IOC_RECV, zfs_ioc_recv,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5441 zfs_secpolicy_recv);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5442 zfs_ioctl_register_dataset_modify(ZFS_IOC_PROMOTE, zfs_ioc_promote,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5443 zfs_secpolicy_promote);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5444 zfs_ioctl_register_dataset_modify(ZFS_IOC_INHERIT_PROP,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5445 zfs_ioc_inherit_prop, zfs_secpolicy_inherit_prop);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5446 zfs_ioctl_register_dataset_modify(ZFS_IOC_SET_FSACL, zfs_ioc_set_fsacl,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5447 zfs_secpolicy_set_fsacl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5448
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5449 zfs_ioctl_register_dataset_nolog(ZFS_IOC_SHARE, zfs_ioc_share,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5450 zfs_secpolicy_share, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5451 zfs_ioctl_register_dataset_nolog(ZFS_IOC_SMB_ACL, zfs_ioc_smb_acl,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5452 zfs_secpolicy_smb_acl, POOL_CHECK_NONE);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5453 zfs_ioctl_register_dataset_nolog(ZFS_IOC_USERSPACE_UPGRADE,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5454 zfs_ioc_userspace_upgrade, zfs_secpolicy_userspace_upgrade,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5455 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5456 zfs_ioctl_register_dataset_nolog(ZFS_IOC_TMP_SNAPSHOT,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5457 zfs_ioc_tmp_snapshot, zfs_secpolicy_tmp_snapshot,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5458 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5459 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5460
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5461 int
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5462 pool_status_check(const char *name, zfs_ioc_namecheck_t type,
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5463 zfs_ioc_poolcheck_t check)
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5464 {
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5465 spa_t *spa;
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5466 int error;
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5467
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5468 ASSERT(type == POOL_NAME || type == DATASET_NAME);
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5469
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5470 if (check & POOL_CHECK_NONE)
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5471 return (0);
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5472
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9355
diff changeset
5473 error = spa_open(name, &spa, FTAG);
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5474 if (error == 0) {
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5475 if ((check & POOL_CHECK_SUSPENDED) && spa_suspended(spa))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5476 error = SET_ERROR(EAGAIN);
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5477 else if ((check & POOL_CHECK_READONLY) && !spa_writeable(spa))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5478 error = SET_ERROR(EROFS);
9234
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5479 spa_close(spa, FTAG);
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5480 }
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5481 return (error);
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5482 }
bffdc4fc05c4 6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents: 9179
diff changeset
5483
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5484 /*
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5485 * Find a free minor number.
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5486 */
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5487 minor_t
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5488 zfsdev_minor_alloc(void)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5489 {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5490 static minor_t last_minor;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5491 minor_t m;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5492
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5493 ASSERT(MUTEX_HELD(&zfsdev_state_lock));
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5494
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5495 for (m = last_minor + 1; m != last_minor; m++) {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5496 if (m > ZFSDEV_MAX_MINOR)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5497 m = 1;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5498 if (ddi_get_soft_state(zfsdev_state, m) == NULL) {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5499 last_minor = m;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5500 return (m);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5501 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5502 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5503
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5504 return (0);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5505 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5506
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5507 static int
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5508 zfs_ctldev_init(dev_t *devp)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5509 {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5510 minor_t minor;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5511 zfs_soft_state_t *zs;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5512
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5513 ASSERT(MUTEX_HELD(&zfsdev_state_lock));
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5514 ASSERT(getminor(*devp) == 0);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5515
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5516 minor = zfsdev_minor_alloc();
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5517 if (minor == 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5518 return (SET_ERROR(ENXIO));
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5519
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5520 if (ddi_soft_state_zalloc(zfsdev_state, minor) != DDI_SUCCESS)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5521 return (SET_ERROR(EAGAIN));
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5522
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5523 *devp = makedevice(getemajor(*devp), minor);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5524
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5525 zs = ddi_get_soft_state(zfsdev_state, minor);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5526 zs->zss_type = ZSST_CTLDEV;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5527 zfs_onexit_init((zfs_onexit_t **)&zs->zss_data);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5528
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5529 return (0);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5530 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5531
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5532 static void
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5533 zfs_ctldev_destroy(zfs_onexit_t *zo, minor_t minor)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5534 {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5535 ASSERT(MUTEX_HELD(&zfsdev_state_lock));
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5536
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5537 zfs_onexit_destroy(zo);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5538 ddi_soft_state_free(zfsdev_state, minor);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5539 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5540
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5541 void *
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5542 zfsdev_get_soft_state(minor_t minor, enum zfs_soft_state_type which)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5543 {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5544 zfs_soft_state_t *zp;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5545
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5546 zp = ddi_get_soft_state(zfsdev_state, minor);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5547 if (zp == NULL || zp->zss_type != which)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5548 return (NULL);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5549
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5550 return (zp->zss_data);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5551 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5552
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5553 static int
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5554 zfsdev_open(dev_t *devp, int flag, int otyp, cred_t *cr)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5555 {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5556 int error = 0;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5557
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5558 if (getminor(*devp) != 0)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5559 return (zvol_open(devp, flag, otyp, cr));
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5560
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5561 /* This is the control device. Allocate a new minor if requested. */
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5562 if (flag & FEXCL) {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5563 mutex_enter(&zfsdev_state_lock);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5564 error = zfs_ctldev_init(devp);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5565 mutex_exit(&zfsdev_state_lock);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5566 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5567
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5568 return (error);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5569 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5570
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5571 static int
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5572 zfsdev_close(dev_t dev, int flag, int otyp, cred_t *cr)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5573 {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5574 zfs_onexit_t *zo;
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5575 minor_t minor = getminor(dev);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5576
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5577 if (minor == 0)
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5578 return (0);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5579
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5580 mutex_enter(&zfsdev_state_lock);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5581 zo = zfsdev_get_soft_state(minor, ZSST_CTLDEV);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5582 if (zo == NULL) {
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5583 mutex_exit(&zfsdev_state_lock);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5584 return (zvol_close(dev, flag, otyp, cr));
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5585 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5586 zfs_ctldev_destroy(zo, minor);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5587 mutex_exit(&zfsdev_state_lock);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5588
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5589 return (0);
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5590 }
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5591
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5592 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5593 zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5594 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5595 zfs_cmd_t *zc;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5596 uint_t vecnum;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5597 int error, rc, len;
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5598 minor_t minor = getminor(dev);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5599 const zfs_ioc_vec_t *vec;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5600 char *saved_poolname = NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5601 nvlist_t *innvl = NULL;
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5602
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5603 if (minor != 0 &&
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5604 zfsdev_get_soft_state(minor, ZSST_CTLDEV) == NULL)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5605 return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5606
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5607 vecnum = cmd - ZFS_IOC_FIRST;
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4720
diff changeset
5608 ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5609
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5610 if (vecnum >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5611 return (SET_ERROR(EINVAL));
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5612 vec = &zfs_ioc_vec[vecnum];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5613
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5614 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5615
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
5616 error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5617 if (error != 0) {
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5618 error = SET_ERROR(EFAULT);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5619 goto out;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5620 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5621
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5622 zc->zc_iflags = flag & FKIOCTL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5623 if (zc->zc_nvlist_src_size != 0) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5624 error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5625 zc->zc_iflags, &innvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5626 if (error != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5627 goto out;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5628 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5629
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5630 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5631 * Ensure that all pool/dataset names are valid before we pass down to
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5632 * the lower layers.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5633 */
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5634 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0';
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5635 switch (vec->zvec_namecheck) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5636 case POOL_NAME:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5637 if (pool_namecheck(zc->zc_name, NULL, NULL) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5638 error = SET_ERROR(EINVAL);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5639 else
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5640 error = pool_status_check(zc->zc_name,
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5641 vec->zvec_namecheck, vec->zvec_pool_check);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5642 break;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5643
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5644 case DATASET_NAME:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5645 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5646 error = SET_ERROR(EINVAL);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5647 else
13061
bda0decf867b PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents: 13055
diff changeset
5648 error = pool_status_check(zc->zc_name,
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5649 vec->zvec_namecheck, vec->zvec_pool_check);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5650 break;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5651
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5652 case NO_NAME:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5653 break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5654 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5655
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5656
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5657 if (error == 0 && !(flag & FKIOCTL))
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5658 error = vec->zvec_secpolicy(zc, innvl, cr);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5659
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5660 if (error != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5661 goto out;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5662
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5663 /* legacy ioctls can modify zc_name */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5664 len = strcspn(zc->zc_name, "/@") + 1;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5665 saved_poolname = kmem_alloc(len, KM_SLEEP);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5666 (void) strlcpy(saved_poolname, zc->zc_name, len);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5667
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5668 if (vec->zvec_func != NULL) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5669 nvlist_t *outnvl;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5670 int puterror = 0;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5671 spa_t *spa;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5672 nvlist_t *lognv = NULL;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5673
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5674 ASSERT(vec->zvec_legacy_func == NULL);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5675
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5676 /*
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5677 * Add the innvl to the lognv before calling the func,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5678 * in case the func changes the innvl.
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5679 */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5680 if (vec->zvec_allow_log) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5681 lognv = fnvlist_alloc();
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5682 fnvlist_add_string(lognv, ZPOOL_HIST_IOCTL,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5683 vec->zvec_name);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5684 if (!nvlist_empty(innvl)) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5685 fnvlist_add_nvlist(lognv, ZPOOL_HIST_INPUT_NVL,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5686 innvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5687 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5688 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5689
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5690 outnvl = fnvlist_alloc();
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5691 error = vec->zvec_func(zc->zc_name, innvl, outnvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5692
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5693 if (error == 0 && vec->zvec_allow_log &&
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5694 spa_open(zc->zc_name, &spa, FTAG) == 0) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5695 if (!nvlist_empty(outnvl)) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5696 fnvlist_add_nvlist(lognv, ZPOOL_HIST_OUTPUT_NVL,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5697 outnvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5698 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5699 (void) spa_history_log_nvl(spa, lognv);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5700 spa_close(spa, FTAG);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5701 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5702 fnvlist_free(lognv);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5703
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5704 if (!nvlist_empty(outnvl) || zc->zc_nvlist_dst_size != 0) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5705 int smusherror = 0;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5706 if (vec->zvec_smush_outnvlist) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5707 smusherror = nvlist_smush(outnvl,
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5708 zc->zc_nvlist_dst_size);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5709 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5710 if (smusherror == 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5711 puterror = put_nvlist(zc, outnvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5712 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5713
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5714 if (puterror != 0)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5715 error = puterror;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5716
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5717 nvlist_free(outnvl);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5718 } else {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5719 error = vec->zvec_legacy_func(zc);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5720 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5721
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5722 out:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5723 nvlist_free(innvl);
9643
ffd8e7765f02 6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 9425
diff changeset
5724 rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5725 if (error == 0 && rc != 0)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5726 error = SET_ERROR(EFAULT);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5727 if (error == 0 && vec->zvec_allow_log) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5728 char *s = tsd_get(zfs_allow_log_key);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5729 if (s != NULL)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5730 strfree(s);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5731 (void) tsd_set(zfs_allow_log_key, saved_poolname);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5732 } else {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5733 if (saved_poolname != NULL)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5734 strfree(saved_poolname);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
5735 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5736
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5737 kmem_free(zc, sizeof (zfs_cmd_t));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5738 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5739 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5740
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5741 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5742 zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5743 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5744 if (cmd != DDI_ATTACH)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5745 return (DDI_FAILURE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5746
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5747 if (ddi_create_minor_node(dip, "zfs", S_IFCHR, 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5748 DDI_PSEUDO, 0) == DDI_FAILURE)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5749 return (DDI_FAILURE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5750
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5751 zfs_dip = dip;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5752
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5753 ddi_report_dev(dip);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5754
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5755 return (DDI_SUCCESS);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5756 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5757
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5758 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5759 zfs_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5760 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5761 if (spa_busy() || zfs_busy() || zvol_busy())
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5762 return (DDI_FAILURE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5763
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5764 if (cmd != DDI_DETACH)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5765 return (DDI_FAILURE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5766
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5767 zfs_dip = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5768
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5769 ddi_prop_remove_all(dip);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5770 ddi_remove_minor_node(dip, NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5771
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5772 return (DDI_SUCCESS);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5773 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5774
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5775 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5776 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5777 zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5778 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5779 switch (infocmd) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5780 case DDI_INFO_DEVT2DEVINFO:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5781 *result = zfs_dip;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5782 return (DDI_SUCCESS);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5783
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5784 case DDI_INFO_DEVT2INSTANCE:
849
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5785 *result = (void *)0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5786 return (DDI_SUCCESS);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5787 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5788
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5789 return (DDI_FAILURE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5790 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5791
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5792 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5793 * OK, so this is a little weird.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5794 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5795 * /dev/zfs is the control node, i.e. minor 0.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5796 * /dev/zvol/[r]dsk/pool/dataset are the zvols, minor > 0.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5797 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5798 * /dev/zfs has basically nothing to do except serve up ioctls,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5799 * so most of the standard driver entry points are in zvol.c.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5800 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5801 static struct cb_ops zfs_cb_ops = {
12527
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5802 zfsdev_open, /* open */
693dd2cad55f 6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents: 12296
diff changeset
5803 zfsdev_close, /* close */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5804 zvol_strategy, /* strategy */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5805 nodev, /* print */
6423
437422a29d3a PSARC 2006/370 ZFS Boot Support
gw25295
parents: 6139
diff changeset
5806 zvol_dump, /* dump */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5807 zvol_read, /* read */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5808 zvol_write, /* write */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5809 zfsdev_ioctl, /* ioctl */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5810 nodev, /* devmap */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5811 nodev, /* mmap */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5812 nodev, /* segmap */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5813 nochpoll, /* poll */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5814 ddi_prop_op, /* prop_op */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5815 NULL, /* streamtab */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5816 D_NEW | D_MP | D_64BIT, /* Driver compatibility flag */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5817 CB_REV, /* version */
3638
6b28ebc717aa 6496357 spec_fsync() is useless on devices that do write caching
billm
parents: 3444
diff changeset
5818 nodev, /* async read */
6b28ebc717aa 6496357 spec_fsync() is useless on devices that do write caching
billm
parents: 3444
diff changeset
5819 nodev, /* async write */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5820 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5821
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5822 static struct dev_ops zfs_dev_ops = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5823 DEVO_REV, /* version */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5824 0, /* refcnt */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5825 zfs_info, /* info */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5826 nulldev, /* identify */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5827 nulldev, /* probe */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5828 zfs_attach, /* attach */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5829 zfs_detach, /* detach */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5830 nodev, /* reset */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5831 &zfs_cb_ops, /* driver operations */
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7294
diff changeset
5832 NULL, /* no bus operations */
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7294
diff changeset
5833 NULL, /* power */
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7294
diff changeset
5834 ddi_quiesce_not_needed, /* quiesce */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5835 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5836
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5837 static struct modldrv zfs_modldrv = {
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7294
diff changeset
5838 &mod_driverops,
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7294
diff changeset
5839 "ZFS storage pool",
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7294
diff changeset
5840 &zfs_dev_ops
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5841 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5842
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5843 static struct modlinkage modlinkage = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5844 MODREV_1,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5845 (void *)&zfs_modlfs,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5846 (void *)&zfs_modldrv,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5847 NULL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5848 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5849
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5850 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5851 zfs_allow_log_destroy(void *arg)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5852 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5853 char *poolname = arg;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5854 strfree(poolname);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5855 }
4720
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4715
diff changeset
5856
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5857 int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5858 _init(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5859 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5860 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5861
849
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5862 spa_init(FREAD | FWRITE);
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5863 zfs_init();
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5864 zvol_init();
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5865 zfs_ioctl_init();
849
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5866
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5867 if ((error = mod_install(&modlinkage)) != 0) {
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5868 zvol_fini();
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5869 zfs_fini();
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5870 spa_fini();
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5871 return (error);
849
8d799fd81a9b 6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents: 789
diff changeset
5872 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5873
4720
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4715
diff changeset
5874 tsd_create(&zfs_fsyncer_key, NULL);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5875 tsd_create(&rrw_tsd_key, rrw_tsd_destroy);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
5876 tsd_create(&zfs_allow_log_key, zfs_allow_log_destroy);
4720
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4715
diff changeset
5877
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5878 error = ldi_ident_from_mod(&modlinkage, &zfs_li);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5879 ASSERT(error == 0);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
5880 mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5881
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5882 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5883 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5884
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5885 int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5886 _fini(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5887 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5888 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5889
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1485
diff changeset
5890 if (spa_busy() || zfs_busy() || zvol_busy() || zio_injection_enabled)
13980
d7059eb1884c 3598 want to dtrace when errors are generated in zfs
Matthew Ahrens <mahrens@delphix.com>
parents: 13973
diff changeset
5891 return (SET_ERROR(EBUSY));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5892
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5893 if ((error = mod_remove(&modlinkage)) != 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5894 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5895
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5896 zvol_fini();
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5897 zfs_fini();
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5898 spa_fini();
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
5899 if (zfs_nfsshare_inited)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
5900 (void) ddi_modclose(nfs_mod);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
5901 if (zfs_smbshare_inited)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
5902 (void) ddi_modclose(smbsrv_mod);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
5903 if (zfs_nfsshare_inited || zfs_smbshare_inited)
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
5904 (void) ddi_modclose(sharefs_mod);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5905
4720
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4715
diff changeset
5906 tsd_destroy(&zfs_fsyncer_key);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5907 ldi_ident_release(zfs_li);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5908 zfs_li = NULL;
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4490
diff changeset
5909 mutex_destroy(&zfs_share_lock);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5910
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5911 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5912 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5913
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5914 int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5915 _info(struct modinfo *modinfop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5916 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5917 return (mod_info(&modlinkage, modinfop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
5918 }