Mercurial > illumos > illumos-gate
annotate usr/src/uts/common/fs/zfs/zfs_ioctl.c @ 11727:497d03ab2824
6900971 zdb rewind behavior needs to be revisited
author | Victor Latushkin <Victor.Latushkin@Sun.COM> |
---|---|
date | Sat, 20 Feb 2010 06:04:43 +0300 |
parents | 42ea6be8961b |
children | 73a3c0d27389 |
rev | line source |
---|---|
789 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
4 * The contents of this file are subject to the terms of the | |
1485 | 5 * Common Development and Distribution License (the "License"). |
6 * You may not use this file except in compliance with the License. | |
789 | 7 * |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 * or http://www.opensolaris.org/os/licensing. | |
10 * See the License for the specific language governing permissions | |
11 * and limitations under the License. | |
12 * | |
13 * When distributing Covered Code, include this CDDL HEADER in each | |
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 * If applicable, add the following below this CDDL HEADER, with the | |
16 * fields enclosed by brackets "[]" replaced with your own identifying | |
17 * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 * | |
19 * CDDL HEADER END | |
20 */ | |
21 /* | |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
789 | 23 * Use is subject to license terms. |
24 */ | |
25 | |
26 #include <sys/types.h> | |
27 #include <sys/param.h> | |
28 #include <sys/errno.h> | |
29 #include <sys/uio.h> | |
30 #include <sys/buf.h> | |
31 #include <sys/modctl.h> | |
32 #include <sys/open.h> | |
33 #include <sys/file.h> | |
34 #include <sys/kmem.h> | |
35 #include <sys/conf.h> | |
36 #include <sys/cmn_err.h> | |
37 #include <sys/stat.h> | |
38 #include <sys/zfs_ioctl.h> | |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
39 #include <sys/zfs_vfsops.h> |
5331 | 40 #include <sys/zfs_znode.h> |
789 | 41 #include <sys/zap.h> |
42 #include <sys/spa.h> | |
3912 | 43 #include <sys/spa_impl.h> |
789 | 44 #include <sys/vdev.h> |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
45 #include <sys/priv_impl.h> |
789 | 46 #include <sys/dmu.h> |
47 #include <sys/dsl_dir.h> | |
48 #include <sys/dsl_dataset.h> | |
49 #include <sys/dsl_prop.h> | |
4543 | 50 #include <sys/dsl_deleg.h> |
51 #include <sys/dmu_objset.h> | |
789 | 52 #include <sys/ddi.h> |
53 #include <sys/sunddi.h> | |
54 #include <sys/sunldi.h> | |
55 #include <sys/policy.h> | |
56 #include <sys/zone.h> | |
57 #include <sys/nvpair.h> | |
58 #include <sys/pathname.h> | |
59 #include <sys/mount.h> | |
60 #include <sys/sdt.h> | |
61 #include <sys/fs/zfs.h> | |
62 #include <sys/zfs_ctldir.h> | |
5331 | 63 #include <sys/zfs_dir.h> |
2885 | 64 #include <sys/zvol.h> |
4543 | 65 #include <sharefs/share.h> |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
66 #include <sys/dmu_objset.h> |
789 | 67 |
68 #include "zfs_namecheck.h" | |
2676 | 69 #include "zfs_prop.h" |
4543 | 70 #include "zfs_deleg.h" |
789 | 71 |
72 extern struct modlfs zfs_modlfs; | |
73 | |
74 extern void zfs_init(void); | |
75 extern void zfs_fini(void); | |
76 | |
77 ldi_ident_t zfs_li = NULL; | |
78 dev_info_t *zfs_dip; | |
79 | |
80 typedef int zfs_ioc_func_t(zfs_cmd_t *); | |
4543 | 81 typedef int zfs_secpolicy_func_t(zfs_cmd_t *, cred_t *); |
789 | 82 |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
83 typedef enum { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
84 NO_NAME, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
85 POOL_NAME, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
86 DATASET_NAME |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
87 } zfs_ioc_namecheck_t; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
88 |
789 | 89 typedef struct zfs_ioc_vec { |
90 zfs_ioc_func_t *zvec_func; | |
91 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
|
92 zfs_ioc_namecheck_t zvec_namecheck; |
4543 | 93 boolean_t zvec_his_log; |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
94 boolean_t zvec_pool_check; |
789 | 95 } zfs_ioc_vec_t; |
96 | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
97 /* 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
|
98 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
|
99 ZFS_DELEG_PERM_USERUSED, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
100 ZFS_DELEG_PERM_USERQUOTA, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
101 ZFS_DELEG_PERM_GROUPUSED, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
102 ZFS_DELEG_PERM_GROUPQUOTA, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
103 }; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
104 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
105 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
|
106 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
|
107 cred_t *cr); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
108 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
|
109 nvlist_t **errors); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
110 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
|
111 boolean_t *); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
112 int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t **); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
113 |
789 | 114 /* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */ |
115 void | |
116 __dprintf(const char *file, const char *func, int line, const char *fmt, ...) | |
117 { | |
118 const char *newfile; | |
119 char buf[256]; | |
120 va_list adx; | |
121 | |
122 /* | |
123 * Get rid of annoying "../common/" prefix to filename. | |
124 */ | |
125 newfile = strrchr(file, '/'); | |
126 if (newfile != NULL) { | |
127 newfile = newfile + 1; /* Get rid of leading / */ | |
128 } else { | |
129 newfile = file; | |
130 } | |
131 | |
132 va_start(adx, fmt); | |
133 (void) vsnprintf(buf, sizeof (buf), fmt, adx); | |
134 va_end(adx); | |
135 | |
136 /* | |
137 * To get this data, use the zfs-dprintf probe as so: | |
138 * dtrace -q -n 'zfs-dprintf \ | |
139 * /stringof(arg0) == "dbuf.c"/ \ | |
140 * {printf("%s: %s", stringof(arg1), stringof(arg3))}' | |
141 * arg0 = file name | |
142 * arg1 = function name | |
143 * arg2 = line number | |
144 * arg3 = message | |
145 */ | |
146 DTRACE_PROBE4(zfs__dprintf, | |
147 char *, newfile, char *, func, int, line, char *, buf); | |
148 } | |
149 | |
4543 | 150 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
|
151 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
|
152 { |
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
|
153 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
|
154 } |
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
|
155 |
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
|
156 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
|
157 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
|
158 { |
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
|
159 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
|
160 |
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
|
161 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
|
162 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
|
163 |
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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 } |
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
|
170 |
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
|
171 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
|
172 |
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
|
173 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
|
174 } |
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
|
175 |
5375 | 176 /* |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
177 * 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
|
178 */ |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
179 static boolean_t |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
180 zfs_is_bootfs(const char *name) |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
181 { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
182 objset_t *os; |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
183 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
184 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
|
185 boolean_t ret; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
186 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
|
187 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
|
188 return (ret); |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
189 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
190 return (B_FALSE); |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
191 } |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
192 |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
193 /* |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
194 * zfs_earlier_version |
5375 | 195 * |
196 * Return non-zero if the spa version is less than requested version. | |
197 */ | |
5331 | 198 static int |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
199 zfs_earlier_version(const char *name, int version) |
5331 | 200 { |
201 spa_t *spa; | |
202 | |
203 if (spa_open(name, &spa, FTAG) == 0) { | |
204 if (spa_version(spa) < version) { | |
205 spa_close(spa, FTAG); | |
206 return (1); | |
207 } | |
208 spa_close(spa, FTAG); | |
209 } | |
210 return (0); | |
211 } | |
212 | |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
213 /* |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
214 * zpl_earlier_version |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
215 * |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
216 * 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
|
217 */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
218 static boolean_t |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
219 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
|
220 { |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
221 objset_t *os; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
222 boolean_t rc = B_TRUE; |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
223 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
224 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
|
225 uint64_t zplversion; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
226 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
227 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
|
228 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
|
229 return (B_TRUE); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
230 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
231 /* 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
|
232 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
|
233 rc = zplversion < version; |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
234 dmu_objset_rele(os, FTAG); |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
235 } |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
236 return (rc); |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
237 } |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
238 |
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
|
239 static void |
4543 | 240 zfs_log_history(zfs_cmd_t *zc) |
241 { | |
242 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
|
243 char *buf; |
4543 | 244 |
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
|
245 if ((buf = history_str_get(zc)) == NULL) |
4577 | 246 return; |
247 | |
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
|
248 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
|
249 if (spa_version(spa) >= SPA_VERSION_ZPOOL_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
|
250 (void) spa_history_log(spa, buf, LOG_CMD_NORMAL); |
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
|
251 spa_close(spa, FTAG); |
4543 | 252 } |
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
|
253 history_str_free(buf); |
4543 | 254 } |
255 | |
789 | 256 /* |
257 * Policy for top-level read operations (list pools). Requires no privileges, | |
258 * and can be used in the local zone, as there is no associated dataset. | |
259 */ | |
260 /* ARGSUSED */ | |
261 static int | |
4543 | 262 zfs_secpolicy_none(zfs_cmd_t *zc, cred_t *cr) |
789 | 263 { |
264 return (0); | |
265 } | |
266 | |
267 /* | |
268 * Policy for dataset read operations (list children, get statistics). Requires | |
269 * no privileges, but must be visible in the local zone. | |
270 */ | |
271 /* ARGSUSED */ | |
272 static int | |
4543 | 273 zfs_secpolicy_read(zfs_cmd_t *zc, cred_t *cr) |
789 | 274 { |
275 if (INGLOBALZONE(curproc) || | |
4543 | 276 zone_dataset_visible(zc->zc_name, NULL)) |
789 | 277 return (0); |
278 | |
279 return (ENOENT); | |
280 } | |
281 | |
282 static int | |
283 zfs_dozonecheck(const char *dataset, cred_t *cr) | |
284 { | |
285 uint64_t zoned; | |
286 int writable = 1; | |
287 | |
288 /* | |
289 * The dataset must be visible by this zone -- check this first | |
290 * so they don't see EPERM on something they shouldn't know about. | |
291 */ | |
292 if (!INGLOBALZONE(curproc) && | |
293 !zone_dataset_visible(dataset, &writable)) | |
294 return (ENOENT); | |
295 | |
296 if (dsl_prop_get_integer(dataset, "zoned", &zoned, NULL)) | |
297 return (ENOENT); | |
298 | |
299 if (INGLOBALZONE(curproc)) { | |
300 /* | |
301 * If the fs is zoned, only root can access it from the | |
302 * global zone. | |
303 */ | |
304 if (secpolicy_zfs(cr) && zoned) | |
305 return (EPERM); | |
306 } else { | |
307 /* | |
308 * If we are in a local zone, the 'zoned' property must be set. | |
309 */ | |
310 if (!zoned) | |
311 return (EPERM); | |
312 | |
313 /* must be writable by this zone */ | |
314 if (!writable) | |
315 return (EPERM); | |
316 } | |
317 return (0); | |
318 } | |
319 | |
320 int | |
4543 | 321 zfs_secpolicy_write_perms(const char *name, const char *perm, cred_t *cr) |
789 | 322 { |
323 int error; | |
324 | |
4543 | 325 error = zfs_dozonecheck(name, cr); |
326 if (error == 0) { | |
327 error = secpolicy_zfs(cr); | |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
328 if (error) |
4543 | 329 error = dsl_deleg_access(name, perm, cr); |
330 } | |
331 return (error); | |
332 } | |
333 | |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
334 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
335 * 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
|
336 * |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
337 * 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
|
338 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
339 static int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
340 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
|
341 { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
342 char ds_hexsl[MAXNAMELEN]; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
343 bslabel_t ds_sl, new_sl; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
344 boolean_t new_default = FALSE; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
345 uint64_t zoned; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
346 int needed_priv = -1; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
347 int error; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
348 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
349 /* First get the existing dataset label. */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
350 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
|
351 1, sizeof (ds_hexsl), &ds_hexsl, NULL); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
352 if (error) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
353 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
354 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
355 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
|
356 new_default = TRUE; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
357 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
358 /* The label must be translatable */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
359 if (!new_default && (hexstr_to_label(strval, &new_sl) != 0)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
360 return (EINVAL); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
361 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
362 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
363 * 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
|
364 * 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
|
365 * are needed. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
366 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
367 if (!INGLOBALZONE(curproc)) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
368 if (new_default || !blequal(&new_sl, CR_SL(CRED()))) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
369 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
370 return (0); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
371 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
372 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
373 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
374 * 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
|
375 * "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
|
376 * global zone. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
377 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
378 if (dsl_prop_get_integer(name, |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
379 zfs_prop_to_name(ZFS_PROP_ZONED), &zoned, NULL)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
380 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
381 if (!zoned) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
382 if (zfs_check_global_label(name, strval) != 0) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
383 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
384 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
385 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
386 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
387 * 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
|
388 * 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
|
389 * 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
|
390 * 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
|
391 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
392 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
|
393 objset_t *os; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
394 static char *setsl_tag = "setsl_tag"; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
395 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
396 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
397 * 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
|
398 * (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
|
399 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
400 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
|
401 setsl_tag, &os); |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
402 if (error) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
403 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
404 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
405 dmu_objset_disown(os, setsl_tag); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
406 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
407 if (new_default) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
408 needed_priv = PRIV_FILE_DOWNGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
409 goto out_check; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
410 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
411 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
412 if (hexstr_to_label(strval, &new_sl) != 0) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
413 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
414 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
415 if (blstrictdom(&ds_sl, &new_sl)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
416 needed_priv = PRIV_FILE_DOWNGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
417 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
|
418 needed_priv = PRIV_FILE_UPGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
419 } else { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
420 /* dataset currently has a default label */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
421 if (!new_default) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
422 needed_priv = PRIV_FILE_UPGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
423 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
424 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
425 out_check: |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
426 if (needed_priv != -1) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
427 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
|
428 return (0); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
429 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
430 |
4543 | 431 static int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
432 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
|
433 cred_t *cr) |
4543 | 434 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
435 char *strval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
436 |
4543 | 437 /* |
438 * Check permissions for special properties. | |
439 */ | |
440 switch (prop) { | |
441 case ZFS_PROP_ZONED: | |
442 /* | |
443 * Disallow setting of 'zoned' from within a local zone. | |
444 */ | |
445 if (!INGLOBALZONE(curproc)) | |
446 return (EPERM); | |
447 break; | |
789 | 448 |
4543 | 449 case ZFS_PROP_QUOTA: |
450 if (!INGLOBALZONE(curproc)) { | |
451 uint64_t zoned; | |
452 char setpoint[MAXNAMELEN]; | |
453 /* | |
454 * Unprivileged users are allowed to modify the | |
455 * quota on things *under* (ie. contained by) | |
456 * the thing they own. | |
457 */ | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
458 if (dsl_prop_get_integer(dsname, "zoned", &zoned, |
4543 | 459 setpoint)) |
460 return (EPERM); | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
461 if (!zoned || strlen(dsname) <= strlen(setpoint)) |
4543 | 462 return (EPERM); |
463 } | |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
464 break; |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
465 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
466 case ZFS_PROP_MLSLABEL: |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
467 if (!is_system_labeled()) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
468 return (EPERM); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
469 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
470 if (nvpair_value_string(propval, &strval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
471 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
472 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
473 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
|
474 if (err != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
475 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
476 } |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
477 break; |
4543 | 478 } |
479 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
480 return (zfs_secpolicy_write_perms(dsname, zfs_prop_to_name(prop), cr)); |
789 | 481 } |
482 | |
4543 | 483 int |
484 zfs_secpolicy_fsacl(zfs_cmd_t *zc, cred_t *cr) | |
485 { | |
486 int error; | |
487 | |
488 error = zfs_dozonecheck(zc->zc_name, cr); | |
489 if (error) | |
490 return (error); | |
491 | |
492 /* | |
493 * permission to set permissions will be evaluated later in | |
494 * dsl_deleg_can_allow() | |
495 */ | |
496 return (0); | |
497 } | |
498 | |
499 int | |
500 zfs_secpolicy_rollback(zfs_cmd_t *zc, cred_t *cr) | |
501 { | |
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
|
502 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
|
503 ZFS_DELEG_PERM_ROLLBACK, cr)); |
4543 | 504 } |
505 | |
506 int | |
507 zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr) | |
508 { | |
509 return (zfs_secpolicy_write_perms(zc->zc_name, | |
510 ZFS_DELEG_PERM_SEND, cr)); | |
511 } | |
512 | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
513 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
514 zfs_secpolicy_deleg_share(zfs_cmd_t *zc, cred_t *cr) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
515 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
516 vnode_t *vp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
517 int error; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
518 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
519 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
|
520 NO_FOLLOW, NULL, &vp)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
521 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
522 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
523 /* 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
|
524 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
525 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
|
526 (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
|
527 zc->zc_name) != 0)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
528 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
529 return (EPERM); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
530 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
531 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
532 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
533 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
|
534 ZFS_DELEG_PERM_SHARE, cr)); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
535 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
536 |
4543 | 537 int |
538 zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr) | |
539 { | |
540 if (!INGLOBALZONE(curproc)) | |
541 return (EPERM); | |
542 | |
5367 | 543 if (secpolicy_nfs(cr) == 0) { |
4543 | 544 return (0); |
545 } else { | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
546 return (zfs_secpolicy_deleg_share(zc, cr)); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
547 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
548 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
549 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
550 int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
551 zfs_secpolicy_smb_acl(zfs_cmd_t *zc, cred_t *cr) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
552 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
553 if (!INGLOBALZONE(curproc)) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
554 return (EPERM); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
555 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
556 if (secpolicy_smb(cr) == 0) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
557 return (0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
558 } else { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
559 return (zfs_secpolicy_deleg_share(zc, cr)); |
4543 | 560 } |
561 } | |
562 | |
789 | 563 static int |
4543 | 564 zfs_get_parent(const char *datasetname, char *parent, int parentsize) |
789 | 565 { |
566 char *cp; | |
567 | |
568 /* | |
569 * Remove the @bla or /bla from the end of the name to get the parent. | |
570 */ | |
4543 | 571 (void) strncpy(parent, datasetname, parentsize); |
572 cp = strrchr(parent, '@'); | |
789 | 573 if (cp != NULL) { |
574 cp[0] = '\0'; | |
575 } else { | |
4543 | 576 cp = strrchr(parent, '/'); |
789 | 577 if (cp == NULL) |
578 return (ENOENT); | |
579 cp[0] = '\0'; | |
580 } | |
581 | |
4543 | 582 return (0); |
583 } | |
584 | |
585 int | |
586 zfs_secpolicy_destroy_perms(const char *name, cred_t *cr) | |
587 { | |
588 int error; | |
589 | |
590 if ((error = zfs_secpolicy_write_perms(name, | |
591 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
592 return (error); | |
593 | |
594 return (zfs_secpolicy_write_perms(name, ZFS_DELEG_PERM_DESTROY, cr)); | |
595 } | |
596 | |
597 static int | |
598 zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr) | |
599 { | |
600 return (zfs_secpolicy_destroy_perms(zc->zc_name, cr)); | |
601 } | |
602 | |
603 /* | |
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
|
604 * Destroying snapshots with delegated permissions requires |
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
|
605 * descendent mount and destroy permissions. |
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
|
606 * Reassemble the full filesystem@snap name so dsl_deleg_access() |
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
|
607 * can do the correct permission check. |
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
|
608 * |
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
|
609 * Since this routine is used when doing a recursive destroy of snapshots |
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
|
610 * and destroying snapshots requires descendent permissions, a successfull |
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
|
611 * check of the top level snapshot applies to snapshots of all descendent |
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
|
612 * datasets as well. |
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
|
613 */ |
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
|
614 static int |
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
|
615 zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, cred_t *cr) |
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
|
616 { |
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
|
617 int 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
|
618 char *dsname; |
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
|
619 |
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
|
620 dsname = kmem_asprintf("%s@%s", zc->zc_name, zc->zc_value); |
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
|
621 |
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
|
622 error = zfs_secpolicy_destroy_perms(dsname, cr); |
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
|
623 |
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
|
624 strfree(dsname); |
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
|
625 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
|
626 } |
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
|
627 |
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
|
628 /* |
4543 | 629 * Must have sys_config privilege to check the iscsi permission |
630 */ | |
631 /* ARGSUSED */ | |
632 static int | |
633 zfs_secpolicy_iscsi(zfs_cmd_t *zc, cred_t *cr) | |
634 { | |
635 return (secpolicy_zfs(cr)); | |
636 } | |
637 | |
638 int | |
639 zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr) | |
640 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
641 char parentname[MAXNAMELEN]; |
4543 | 642 int error; |
643 | |
644 if ((error = zfs_secpolicy_write_perms(from, | |
645 ZFS_DELEG_PERM_RENAME, cr)) != 0) | |
646 return (error); | |
647 | |
648 if ((error = zfs_secpolicy_write_perms(from, | |
649 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
650 return (error); | |
651 | |
652 if ((error = zfs_get_parent(to, parentname, | |
653 sizeof (parentname))) != 0) | |
654 return (error); | |
655 | |
656 if ((error = zfs_secpolicy_write_perms(parentname, | |
657 ZFS_DELEG_PERM_CREATE, cr)) != 0) | |
658 return (error); | |
659 | |
660 if ((error = zfs_secpolicy_write_perms(parentname, | |
661 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
662 return (error); | |
663 | |
664 return (error); | |
665 } | |
666 | |
667 static int | |
668 zfs_secpolicy_rename(zfs_cmd_t *zc, cred_t *cr) | |
669 { | |
670 return (zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr)); | |
671 } | |
672 | |
673 static int | |
674 zfs_secpolicy_promote(zfs_cmd_t *zc, cred_t *cr) | |
675 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
676 char parentname[MAXNAMELEN]; |
4543 | 677 objset_t *clone; |
678 int error; | |
679 | |
680 error = zfs_secpolicy_write_perms(zc->zc_name, | |
681 ZFS_DELEG_PERM_PROMOTE, cr); | |
682 if (error) | |
683 return (error); | |
684 | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
685 error = dmu_objset_hold(zc->zc_name, FTAG, &clone); |
4543 | 686 |
687 if (error == 0) { | |
688 dsl_dataset_t *pclone = NULL; | |
689 dsl_dir_t *dd; | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
690 dd = clone->os_dsl_dataset->ds_dir; |
4543 | 691 |
692 rw_enter(&dd->dd_pool->dp_config_rwlock, RW_READER); | |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
693 error = dsl_dataset_hold_obj(dd->dd_pool, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
694 dd->dd_phys->dd_origin_obj, FTAG, &pclone); |
4543 | 695 rw_exit(&dd->dd_pool->dp_config_rwlock); |
696 if (error) { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
697 dmu_objset_rele(clone, FTAG); |
4543 | 698 return (error); |
699 } | |
700 | |
701 error = zfs_secpolicy_write_perms(zc->zc_name, | |
702 ZFS_DELEG_PERM_MOUNT, cr); | |
703 | |
704 dsl_dataset_name(pclone, parentname); | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
705 dmu_objset_rele(clone, FTAG); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
706 dsl_dataset_rele(pclone, FTAG); |
4543 | 707 if (error == 0) |
708 error = zfs_secpolicy_write_perms(parentname, | |
709 ZFS_DELEG_PERM_PROMOTE, cr); | |
710 } | |
711 return (error); | |
712 } | |
713 | |
714 static int | |
715 zfs_secpolicy_receive(zfs_cmd_t *zc, cred_t *cr) | |
716 { | |
717 int error; | |
718 | |
719 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
720 ZFS_DELEG_PERM_RECEIVE, cr)) != 0) | |
721 return (error); | |
722 | |
723 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
724 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
725 return (error); | |
726 | |
727 return (zfs_secpolicy_write_perms(zc->zc_name, | |
728 ZFS_DELEG_PERM_CREATE, cr)); | |
729 } | |
730 | |
731 int | |
732 zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr) | |
733 { | |
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
|
734 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
|
735 ZFS_DELEG_PERM_SNAPSHOT, cr)); |
4543 | 736 } |
737 | |
738 static int | |
739 zfs_secpolicy_snapshot(zfs_cmd_t *zc, cred_t *cr) | |
740 { | |
741 | |
742 return (zfs_secpolicy_snapshot_perms(zc->zc_name, cr)); | |
743 } | |
744 | |
745 static int | |
746 zfs_secpolicy_create(zfs_cmd_t *zc, cred_t *cr) | |
747 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
748 char parentname[MAXNAMELEN]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
749 int error; |
4543 | 750 |
751 if ((error = zfs_get_parent(zc->zc_name, parentname, | |
752 sizeof (parentname))) != 0) | |
753 return (error); | |
754 | |
755 if (zc->zc_value[0] != '\0') { | |
756 if ((error = zfs_secpolicy_write_perms(zc->zc_value, | |
757 ZFS_DELEG_PERM_CLONE, cr)) != 0) | |
758 return (error); | |
759 } | |
760 | |
761 if ((error = zfs_secpolicy_write_perms(parentname, | |
762 ZFS_DELEG_PERM_CREATE, cr)) != 0) | |
763 return (error); | |
764 | |
765 error = zfs_secpolicy_write_perms(parentname, | |
766 ZFS_DELEG_PERM_MOUNT, cr); | |
767 | |
768 return (error); | |
769 } | |
770 | |
771 static int | |
772 zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr) | |
773 { | |
774 int error; | |
775 | |
776 error = secpolicy_fs_unmount(cr, NULL); | |
777 if (error) { | |
778 error = dsl_deleg_access(zc->zc_name, ZFS_DELEG_PERM_MOUNT, cr); | |
779 } | |
780 return (error); | |
789 | 781 } |
782 | |
783 /* | |
784 * Policy for pool operations - create/destroy pools, add vdevs, etc. Requires | |
785 * SYS_CONFIG privilege, which is not available in a local zone. | |
786 */ | |
787 /* ARGSUSED */ | |
788 static int | |
4543 | 789 zfs_secpolicy_config(zfs_cmd_t *zc, cred_t *cr) |
789 | 790 { |
791 if (secpolicy_sys_config(cr, B_FALSE) != 0) | |
792 return (EPERM); | |
793 | |
794 return (0); | |
795 } | |
796 | |
797 /* | |
1544 | 798 * Policy for fault injection. Requires all privileges. |
799 */ | |
800 /* ARGSUSED */ | |
801 static int | |
4543 | 802 zfs_secpolicy_inject(zfs_cmd_t *zc, cred_t *cr) |
1544 | 803 { |
804 return (secpolicy_zinject(cr)); | |
805 } | |
806 | |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
807 static int |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
808 zfs_secpolicy_inherit(zfs_cmd_t *zc, cred_t *cr) |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
809 { |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
810 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
|
811 |
5094 | 812 if (prop == ZPROP_INVAL) { |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
813 if (!zfs_prop_user(zc->zc_value)) |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
814 return (EINVAL); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
815 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
|
816 ZFS_DELEG_PERM_USERPROP, cr)); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
817 } else { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
818 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
|
819 NULL, cr)); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
820 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
821 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
822 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
823 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
824 zfs_secpolicy_userspace_one(zfs_cmd_t *zc, cred_t *cr) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
825 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
826 int err = zfs_secpolicy_read(zc, cr); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
827 if (err) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
828 return (err); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
829 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
830 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
831 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
832 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
833 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
|
834 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
835 * 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
|
836 * themself, allow it. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
837 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
838 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
|
839 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
|
840 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
|
841 return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
842 } else { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
843 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
|
844 return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
845 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
846 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
847 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
848 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
|
849 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
|
850 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
851 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
852 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
853 zfs_secpolicy_userspace_many(zfs_cmd_t *zc, cred_t *cr) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
854 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
855 int err = zfs_secpolicy_read(zc, cr); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
856 if (err) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
857 return (err); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
858 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
859 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
860 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
861 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
862 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
|
863 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
|
864 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
865 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
866 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
867 zfs_secpolicy_userspace_upgrade(zfs_cmd_t *zc, cred_t *cr) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
868 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
869 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
|
870 NULL, cr)); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
871 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
872 |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
873 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
874 zfs_secpolicy_hold(zfs_cmd_t *zc, cred_t *cr) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
875 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
876 return (zfs_secpolicy_write_perms(zc->zc_name, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
877 ZFS_DELEG_PERM_HOLD, cr)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
878 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
879 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
880 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
881 zfs_secpolicy_release(zfs_cmd_t *zc, cred_t *cr) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
882 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
883 return (zfs_secpolicy_write_perms(zc->zc_name, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
884 ZFS_DELEG_PERM_RELEASE, cr)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
885 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
886 |
1544 | 887 /* |
789 | 888 * Returns the nvlist as specified by the user in the zfs_cmd_t. |
889 */ | |
890 static int | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
891 get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp) |
789 | 892 { |
893 char *packed; | |
894 int error; | |
5094 | 895 nvlist_t *list = NULL; |
789 | 896 |
897 /* | |
2676 | 898 * Read in and unpack the user-supplied nvlist. |
789 | 899 */ |
5094 | 900 if (size == 0) |
789 | 901 return (EINVAL); |
902 | |
903 packed = kmem_alloc(size, KM_SLEEP); | |
904 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
905 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
|
906 iflag)) != 0) { |
789 | 907 kmem_free(packed, size); |
908 return (error); | |
909 } | |
910 | |
5094 | 911 if ((error = nvlist_unpack(packed, size, &list, 0)) != 0) { |
789 | 912 kmem_free(packed, size); |
913 return (error); | |
914 } | |
915 | |
916 kmem_free(packed, size); | |
917 | |
5094 | 918 *nvp = list; |
789 | 919 return (0); |
920 } | |
921 | |
922 static int | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
923 fit_error_list(zfs_cmd_t *zc, nvlist_t **errors) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
924 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
925 size_t size; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
926 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
927 VERIFY(nvlist_size(*errors, &size, NV_ENCODE_NATIVE) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
928 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
929 if (size > zc->zc_nvlist_dst_size) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
930 nvpair_t *more_errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
931 int n = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
932 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
933 if (zc->zc_nvlist_dst_size < 1024) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
934 return (ENOMEM); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
935 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
936 VERIFY(nvlist_add_int32(*errors, ZPROP_N_MORE_ERRORS, 0) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
937 more_errors = nvlist_prev_nvpair(*errors, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
938 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
939 do { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
940 nvpair_t *pair = nvlist_prev_nvpair(*errors, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
941 more_errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
942 VERIFY(nvlist_remove_nvpair(*errors, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
943 n++; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
944 VERIFY(nvlist_size(*errors, &size, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
945 NV_ENCODE_NATIVE) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
946 } while (size > zc->zc_nvlist_dst_size); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
947 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
948 VERIFY(nvlist_remove_nvpair(*errors, more_errors) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
949 VERIFY(nvlist_add_int32(*errors, ZPROP_N_MORE_ERRORS, n) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
950 ASSERT(nvlist_size(*errors, &size, NV_ENCODE_NATIVE) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
951 ASSERT(size <= zc->zc_nvlist_dst_size); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
952 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
953 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
954 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
955 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
956 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
957 static int |
2676 | 958 put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl) |
959 { | |
960 char *packed = NULL; | |
961 size_t size; | |
962 int error; | |
963 | |
964 VERIFY(nvlist_size(nvl, &size, NV_ENCODE_NATIVE) == 0); | |
965 | |
966 if (size > zc->zc_nvlist_dst_size) { | |
967 error = ENOMEM; | |
968 } else { | |
4611 | 969 packed = kmem_alloc(size, KM_SLEEP); |
2676 | 970 VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE, |
971 KM_SLEEP) == 0); | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
972 error = ddi_copyout(packed, |
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
973 (void *)(uintptr_t)zc->zc_nvlist_dst, size, zc->zc_iflags); |
2676 | 974 kmem_free(packed, size); |
975 } | |
976 | |
977 zc->zc_nvlist_dst_size = size; | |
978 return (error); | |
979 } | |
980 | |
981 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
|
982 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
|
983 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
984 objset_t *os; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
985 int error; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
986 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
987 error = dmu_objset_hold(dsname, FTAG, &os); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
988 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
989 return (error); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
990 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
|
991 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
|
992 return (EINVAL); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
993 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
994 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
995 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
|
996 *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
|
997 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
|
998 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
|
999 } else { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1000 error = ESRCH; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1001 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1002 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
|
1003 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
|
1004 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1005 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1006 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1007 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1008 * 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
|
1009 * case its z_vfs will be NULL, and it will be opened as the owner. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1010 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1011 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
|
1012 zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zfvp) |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1013 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1014 int error = 0; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1015 |
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
|
1016 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
|
1017 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
|
1018 if (error == 0) { |
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
|
1019 rrw_enter(&(*zfvp)->z_teardown_lock, RW_READER, tag); |
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
|
1020 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
|
1021 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1022 * 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
|
1023 * 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
|
1024 * objset from the zfsvfs. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1025 */ |
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
|
1026 rrw_exit(&(*zfvp)->z_teardown_lock, tag); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1027 return (EBUSY); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1028 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1029 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1030 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1031 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1032 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1033 static void |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1034 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
|
1035 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1036 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
|
1037 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1038 if (zfsvfs->z_vfs) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1039 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
|
1040 } else { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1041 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
|
1042 zfsvfs_free(zfsvfs); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1043 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1044 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1045 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1046 static int |
789 | 1047 zfs_ioc_pool_create(zfs_cmd_t *zc) |
1048 { | |
1049 int error; | |
5094 | 1050 nvlist_t *config, *props = NULL; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1051 nvlist_t *rootprops = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1052 nvlist_t *zplprops = NULL; |
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
|
1053 char *buf; |
789 | 1054 |
5094 | 1055 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
|
1056 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
|
1057 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
|
1058 |
5094 | 1059 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
|
1060 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
|
1061 zc->zc_iflags, &props))) { |
5094 | 1062 nvlist_free(config); |
1063 return (error); | |
1064 } | |
1065 | |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1066 if (props) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1067 nvlist_t *nvl = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1068 uint64_t version = SPA_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1069 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1070 (void) nvlist_lookup_uint64(props, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1071 zpool_prop_to_name(ZPOOL_PROP_VERSION), &version); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1072 if (version < SPA_VERSION_INITIAL || version > SPA_VERSION) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1073 error = EINVAL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1074 goto pool_props_bad; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1075 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1076 (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
|
1077 if (nvl) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1078 error = nvlist_dup(nvl, &rootprops, KM_SLEEP); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1079 if (error != 0) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1080 nvlist_free(config); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1081 nvlist_free(props); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1082 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1083 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1084 (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
|
1085 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1086 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
|
1087 error = zfs_fill_zplprops_root(version, rootprops, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1088 zplprops, NULL); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1089 if (error) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1090 goto pool_props_bad; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1091 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1092 |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1093 buf = history_str_get(zc); |
789 | 1094 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1095 error = spa_create(zc->zc_name, config, props, buf, zplprops); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1096 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1097 /* |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1098 * Set the remaining root properties |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1099 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1100 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
|
1101 ZPROP_SRC_LOCAL, rootprops, NULL)) != 0) |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1102 (void) spa_destroy(zc->zc_name); |
789 | 1103 |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1104 if (buf != NULL) |
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1105 history_str_free(buf); |
5094 | 1106 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1107 pool_props_bad: |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1108 nvlist_free(rootprops); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1109 nvlist_free(zplprops); |
789 | 1110 nvlist_free(config); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1111 nvlist_free(props); |
5094 | 1112 |
789 | 1113 return (error); |
1114 } | |
1115 | |
1116 static int | |
1117 zfs_ioc_pool_destroy(zfs_cmd_t *zc) | |
1118 { | |
4543 | 1119 int error; |
1120 zfs_log_history(zc); | |
1121 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
|
1122 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
|
1123 zvol_remove_minors(zc->zc_name); |
4543 | 1124 return (error); |
789 | 1125 } |
1126 | |
1127 static int | |
1128 zfs_ioc_pool_import(zfs_cmd_t *zc) | |
1129 { | |
5094 | 1130 nvlist_t *config, *props = NULL; |
789 | 1131 uint64_t guid; |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1132 int error; |
789 | 1133 |
5094 | 1134 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
|
1135 zc->zc_iflags, &config)) != 0) |
789 | 1136 return (error); |
1137 | |
5094 | 1138 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
|
1139 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
|
1140 zc->zc_iflags, &props))) { |
5094 | 1141 nvlist_free(config); |
1142 return (error); | |
1143 } | |
1144 | |
789 | 1145 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) != 0 || |
1544 | 1146 guid != zc->zc_guid) |
789 | 1147 error = EINVAL; |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6492
diff
changeset
|
1148 else if (zc->zc_cookie) |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1149 error = spa_import_verbatim(zc->zc_name, config, props); |
789 | 1150 else |
5094 | 1151 error = spa_import(zc->zc_name, config, props); |
789 | 1152 |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1153 if (zc->zc_nvlist_dst != 0) |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1154 (void) put_nvlist(zc, config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1155 |
789 | 1156 nvlist_free(config); |
1157 | |
5094 | 1158 if (props) |
1159 nvlist_free(props); | |
1160 | |
789 | 1161 return (error); |
1162 } | |
1163 | |
1164 static int | |
1165 zfs_ioc_pool_export(zfs_cmd_t *zc) | |
1166 { | |
4543 | 1167 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
|
1168 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
|
1169 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
|
1170 |
4543 | 1171 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
|
1172 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
|
1173 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
|
1174 zvol_remove_minors(zc->zc_name); |
4543 | 1175 return (error); |
789 | 1176 } |
1177 | |
1178 static int | |
1179 zfs_ioc_pool_configs(zfs_cmd_t *zc) | |
1180 { | |
1181 nvlist_t *configs; | |
1182 int error; | |
1183 | |
1184 if ((configs = spa_all_configs(&zc->zc_cookie)) == NULL) | |
1185 return (EEXIST); | |
1186 | |
2676 | 1187 error = put_nvlist(zc, configs); |
789 | 1188 |
1189 nvlist_free(configs); | |
1190 | |
1191 return (error); | |
1192 } | |
1193 | |
1194 static int | |
1195 zfs_ioc_pool_stats(zfs_cmd_t *zc) | |
1196 { | |
1197 nvlist_t *config; | |
1198 int error; | |
1544 | 1199 int ret = 0; |
789 | 1200 |
2676 | 1201 error = spa_get_stats(zc->zc_name, &config, zc->zc_value, |
1202 sizeof (zc->zc_value)); | |
789 | 1203 |
1204 if (config != NULL) { | |
2676 | 1205 ret = put_nvlist(zc, config); |
789 | 1206 nvlist_free(config); |
1544 | 1207 |
1208 /* | |
1209 * The config may be present even if 'error' is non-zero. | |
1210 * In this case we return success, and preserve the real errno | |
1211 * in 'zc_cookie'. | |
1212 */ | |
1213 zc->zc_cookie = error; | |
789 | 1214 } else { |
1544 | 1215 ret = error; |
789 | 1216 } |
1217 | |
1544 | 1218 return (ret); |
789 | 1219 } |
1220 | |
1221 /* | |
1222 * Try to import the given pool, returning pool stats as appropriate so that | |
1223 * user land knows which devices are available and overall pool health. | |
1224 */ | |
1225 static int | |
1226 zfs_ioc_pool_tryimport(zfs_cmd_t *zc) | |
1227 { | |
1228 nvlist_t *tryconfig, *config; | |
1229 int error; | |
1230 | |
5094 | 1231 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
|
1232 zc->zc_iflags, &tryconfig)) != 0) |
789 | 1233 return (error); |
1234 | |
1235 config = spa_tryimport(tryconfig); | |
1236 | |
1237 nvlist_free(tryconfig); | |
1238 | |
1239 if (config == NULL) | |
1240 return (EINVAL); | |
1241 | |
2676 | 1242 error = put_nvlist(zc, config); |
789 | 1243 nvlist_free(config); |
1244 | |
1245 return (error); | |
1246 } | |
1247 | |
1248 static int | |
1249 zfs_ioc_pool_scrub(zfs_cmd_t *zc) | |
1250 { | |
1251 spa_t *spa; | |
1252 int error; | |
1253 | |
2926 | 1254 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
1255 return (error); | |
1256 | |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
7042
diff
changeset
|
1257 error = spa_scrub(spa, zc->zc_cookie); |
2926 | 1258 |
1259 spa_close(spa, FTAG); | |
1260 | |
789 | 1261 return (error); |
1262 } | |
1263 | |
1264 static int | |
1265 zfs_ioc_pool_freeze(zfs_cmd_t *zc) | |
1266 { | |
1267 spa_t *spa; | |
1268 int error; | |
1269 | |
1270 error = spa_open(zc->zc_name, &spa, FTAG); | |
1271 if (error == 0) { | |
1272 spa_freeze(spa); | |
1273 spa_close(spa, FTAG); | |
1274 } | |
1275 return (error); | |
1276 } | |
1277 | |
1278 static int | |
1760 | 1279 zfs_ioc_pool_upgrade(zfs_cmd_t *zc) |
1280 { | |
1281 spa_t *spa; | |
1282 int error; | |
1283 | |
2926 | 1284 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
1285 return (error); | |
1286 | |
5118
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1287 if (zc->zc_cookie < spa_version(spa) || zc->zc_cookie > SPA_VERSION) { |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1288 spa_close(spa, FTAG); |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1289 return (EINVAL); |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1290 } |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1291 |
5094 | 1292 spa_upgrade(spa, zc->zc_cookie); |
2926 | 1293 spa_close(spa, FTAG); |
1294 | |
1295 return (error); | |
1296 } | |
1297 | |
1298 static int | |
1299 zfs_ioc_pool_get_history(zfs_cmd_t *zc) | |
1300 { | |
1301 spa_t *spa; | |
1302 char *hist_buf; | |
1303 uint64_t size; | |
1304 int error; | |
1305 | |
1306 if ((size = zc->zc_history_len) == 0) | |
1307 return (EINVAL); | |
1308 | |
1309 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) | |
1310 return (error); | |
1311 | |
4577 | 1312 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
|
1313 spa_close(spa, FTAG); |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1314 return (ENOTSUP); |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1315 } |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1316 |
2926 | 1317 hist_buf = kmem_alloc(size, KM_SLEEP); |
1318 if ((error = spa_history_get(spa, &zc->zc_history_offset, | |
1319 &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
|
1320 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
|
1321 (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
|
1322 zc->zc_history_len, zc->zc_iflags); |
2926 | 1323 } |
1324 | |
1325 spa_close(spa, FTAG); | |
1326 kmem_free(hist_buf, size); | |
1327 return (error); | |
1328 } | |
1329 | |
1330 static int | |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1331 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
|
1332 { |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1333 int error; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1334 |
3912 | 1335 if (error = 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
|
1336 return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1337 |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1338 return (0); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1339 } |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1340 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1341 /* |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1342 * inputs: |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1343 * 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
|
1344 * 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
|
1345 * |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1346 * outputs: |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1347 * 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
|
1348 */ |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1349 static int |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1350 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
|
1351 { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1352 objset_t *os; |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1353 int error; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1354 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1355 /* 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
|
1356 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
|
1357 return (error); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1358 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
|
1359 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
|
1360 return (EINVAL); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1361 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1362 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
|
1363 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
|
1364 dmu_objset_rele(os, FTAG); |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1365 |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1366 return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1367 } |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1368 |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1369 static int |
789 | 1370 zfs_ioc_vdev_add(zfs_cmd_t *zc) |
1371 { | |
1372 spa_t *spa; | |
1373 int error; | |
6423 | 1374 nvlist_t *config, **l2cache, **spares; |
1375 uint_t nl2cache = 0, nspares = 0; | |
789 | 1376 |
1377 error = spa_open(zc->zc_name, &spa, FTAG); | |
1378 if (error != 0) | |
1379 return (error); | |
1380 | |
5450 | 1381 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
|
1382 zc->zc_iflags, &config); |
5450 | 1383 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_L2CACHE, |
1384 &l2cache, &nl2cache); | |
1385 | |
6423 | 1386 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_SPARES, |
1387 &spares, &nspares); | |
1388 | |
3912 | 1389 /* |
1390 * A root pool with concatenated devices is not supported. | |
6423 | 1391 * Thus, can not add a device to a root pool. |
1392 * | |
1393 * Intent log device can not be added to a rootpool because | |
1394 * during mountroot, zil is replayed, a seperated log device | |
1395 * can not be accessed during the mountroot time. | |
1396 * | |
1397 * l2cache and spare devices are ok to be added to a rootpool. | |
3912 | 1398 */ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1399 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
|
1400 nvlist_free(config); |
3912 | 1401 spa_close(spa, FTAG); |
1402 return (EDOM); | |
1403 } | |
1404 | |
5450 | 1405 if (error == 0) { |
789 | 1406 error = spa_vdev_add(spa, config); |
1407 nvlist_free(config); | |
1408 } | |
1409 spa_close(spa, FTAG); | |
1410 return (error); | |
1411 } | |
1412 | |
1413 static int | |
1414 zfs_ioc_vdev_remove(zfs_cmd_t *zc) | |
1415 { | |
2082 | 1416 spa_t *spa; |
1417 int error; | |
1418 | |
1419 error = spa_open(zc->zc_name, &spa, FTAG); | |
1420 if (error != 0) | |
1421 return (error); | |
1422 error = spa_vdev_remove(spa, zc->zc_guid, B_FALSE); | |
1423 spa_close(spa, FTAG); | |
1424 return (error); | |
789 | 1425 } |
1426 | |
1427 static int | |
4451 | 1428 zfs_ioc_vdev_set_state(zfs_cmd_t *zc) |
789 | 1429 { |
1430 spa_t *spa; | |
1431 int error; | |
4451 | 1432 vdev_state_t newstate = VDEV_STATE_UNKNOWN; |
789 | 1433 |
2926 | 1434 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1435 return (error); |
4451 | 1436 switch (zc->zc_cookie) { |
1437 case VDEV_STATE_ONLINE: | |
1438 error = vdev_online(spa, zc->zc_guid, zc->zc_obj, &newstate); | |
1439 break; | |
1440 | |
1441 case VDEV_STATE_OFFLINE: | |
1442 error = vdev_offline(spa, zc->zc_guid, zc->zc_obj); | |
1443 break; | |
789 | 1444 |
4451 | 1445 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
|
1446 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
|
1447 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
|
1448 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
|
1449 |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1450 error = vdev_fault(spa, zc->zc_guid, zc->zc_obj); |
4451 | 1451 break; |
789 | 1452 |
4451 | 1453 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
|
1454 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
|
1455 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
|
1456 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
|
1457 |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1458 error = vdev_degrade(spa, zc->zc_guid, zc->zc_obj); |
4451 | 1459 break; |
1460 | |
1461 default: | |
1462 error = EINVAL; | |
1463 } | |
1464 zc->zc_cookie = newstate; | |
789 | 1465 spa_close(spa, FTAG); |
1466 return (error); | |
1467 } | |
1468 | |
1469 static int | |
1470 zfs_ioc_vdev_attach(zfs_cmd_t *zc) | |
1471 { | |
1472 spa_t *spa; | |
1473 int replacing = zc->zc_cookie; | |
1474 nvlist_t *config; | |
1475 int error; | |
1476 | |
2926 | 1477 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1478 return (error); |
1479 | |
5094 | 1480 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
|
1481 zc->zc_iflags, &config)) == 0) { |
1544 | 1482 error = spa_vdev_attach(spa, zc->zc_guid, config, replacing); |
789 | 1483 nvlist_free(config); |
1484 } | |
1485 | |
1486 spa_close(spa, FTAG); | |
1487 return (error); | |
1488 } | |
1489 | |
1490 static int | |
1491 zfs_ioc_vdev_detach(zfs_cmd_t *zc) | |
1492 { | |
1493 spa_t *spa; | |
1494 int error; | |
1495 | |
2926 | 1496 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1497 return (error); |
1498 | |
8241
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
8213
diff
changeset
|
1499 error = spa_vdev_detach(spa, zc->zc_guid, 0, B_FALSE); |
789 | 1500 |
1501 spa_close(spa, FTAG); | |
1502 return (error); | |
1503 } | |
1504 | |
1505 static int | |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1506 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
|
1507 { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1508 spa_t *spa; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1509 nvlist_t *config, *props = NULL; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1510 int error; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1511 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
|
1512 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1513 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
|
1514 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1515 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1516 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
|
1517 zc->zc_iflags, &config)) { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1518 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1519 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1520 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1521 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1522 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
|
1523 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
|
1524 zc->zc_iflags, &props))) { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1525 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1526 nvlist_free(config); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1527 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1528 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1529 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1530 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
|
1531 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1532 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1533 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1534 nvlist_free(config); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1535 nvlist_free(props); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1536 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1537 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1538 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1539 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1540 static int |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1541 zfs_ioc_vdev_setpath(zfs_cmd_t *zc) |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1542 { |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1543 spa_t *spa; |
2676 | 1544 char *path = zc->zc_value; |
1544 | 1545 uint64_t guid = zc->zc_guid; |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1546 int error; |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1547 |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1548 error = spa_open(zc->zc_name, &spa, FTAG); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1549 if (error != 0) |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1550 return (error); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1551 |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1552 error = spa_vdev_setpath(spa, guid, path); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1553 spa_close(spa, FTAG); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1554 return (error); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1555 } |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1556 |
9425
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1557 static int |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1558 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
|
1559 { |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1560 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
|
1561 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
|
1562 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
|
1563 int error; |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1564 |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1565 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
|
1566 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
|
1567 return (error); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1568 |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1569 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
|
1570 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
|
1571 return (error); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1572 } |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1573 |
5367 | 1574 /* |
1575 * inputs: | |
1576 * zc_name name of filesystem | |
1577 * zc_nvlist_dst_size size of buffer for property nvlist | |
1578 * | |
1579 * outputs: | |
1580 * zc_objset_stats stats | |
1581 * zc_nvlist_dst property nvlist | |
1582 * zc_nvlist_dst_size size of property nvlist | |
1583 */ | |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1584 static int |
789 | 1585 zfs_ioc_objset_stats(zfs_cmd_t *zc) |
1586 { | |
1587 objset_t *os = NULL; | |
1588 int error; | |
1356
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1589 nvlist_t *nv; |
789 | 1590 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1591 if (error = dmu_objset_hold(zc->zc_name, FTAG, &os)) |
789 | 1592 return (error); |
1593 | |
2885 | 1594 dmu_objset_fast_stat(os, &zc->zc_objset_stats); |
789 | 1595 |
2856 | 1596 if (zc->zc_nvlist_dst != 0 && |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1597 (error = dsl_prop_get_all(os, &nv)) == 0) { |
2885 | 1598 dmu_objset_stats(os, nv); |
3087 | 1599 /* |
5147
5e950ccc9585
6596190 "zfs list" is slow due to version property
rm160521
parents:
5118
diff
changeset
|
1600 * NB: zvol_get_stats() will read the objset contents, |
3087 | 1601 * 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
|
1602 * DS_MODE_USER hold, because it could be |
3087 | 1603 * 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
|
1604 * XXX reading with out owning |
3087 | 1605 */ |
4577 | 1606 if (!zc->zc_objset_stats.dds_inconsistent) { |
1607 if (dmu_objset_type(os) == DMU_OST_ZVOL) | |
1608 VERIFY(zvol_get_stats(os, nv) == 0); | |
1609 } | |
2676 | 1610 error = put_nvlist(zc, nv); |
1356
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1611 nvlist_free(nv); |
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1612 } |
789 | 1613 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1614 dmu_objset_rele(os, FTAG); |
789 | 1615 return (error); |
1616 } | |
1617 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1618 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1619 * inputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1620 * zc_name name of filesystem |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1621 * 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
|
1622 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1623 * outputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1624 * zc_nvlist_dst received property nvlist |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1625 * 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
|
1626 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1627 * 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
|
1628 * 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
|
1629 * local property values. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1630 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1631 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1632 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
|
1633 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1634 objset_t *os = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1635 int error; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1636 nvlist_t *nv; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1637 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1638 if (error = dmu_objset_hold(zc->zc_name, FTAG, &os)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1639 return (error); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1640 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1641 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1642 * 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
|
1643 * 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
|
1644 * SPA_VERSION_RECVD_PROPS. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1645 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1646 if (!dsl_prop_get_hasrecvd(os)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1647 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1648 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1649 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1650 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1651 if (zc->zc_nvlist_dst != 0 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1652 (error = dsl_prop_get_received(os, &nv)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1653 error = put_nvlist(zc, nv); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1654 nvlist_free(nv); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1655 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1656 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1657 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1658 return (error); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1659 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1660 |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1661 static int |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1662 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
|
1663 { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1664 uint64_t value; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1665 int error; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1666 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1667 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1668 * 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
|
1669 * the default value (if there is one). |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1670 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1671 if ((error = zfs_get_zplprop(os, prop, &value)) != 0) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1672 return (error); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1673 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
|
1674 return (0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1675 } |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1676 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1677 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1678 * inputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1679 * zc_name name of filesystem |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1680 * 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
|
1681 * |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1682 * outputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1683 * zc_nvlist_dst zpl property nvlist |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1684 * zc_nvlist_dst_size size of zpl property nvlist |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1685 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1686 static int |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1687 zfs_ioc_objset_zplprops(zfs_cmd_t *zc) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1688 { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1689 objset_t *os; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1690 int err; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1691 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1692 /* XXX reading without owning */ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1693 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
|
1694 return (err); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1695 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1696 dmu_objset_fast_stat(os, &zc->zc_objset_stats); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1697 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1698 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1699 * 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
|
1700 * 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
|
1701 * hold, because it could be inconsistent. |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1702 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1703 if (zc->zc_nvlist_dst != NULL && |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1704 !zc->zc_objset_stats.dds_inconsistent && |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1705 dmu_objset_type(os) == DMU_OST_ZFS) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1706 nvlist_t *nv; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1707 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1708 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
|
1709 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
|
1710 (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
|
1711 (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
|
1712 (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
|
1713 err = put_nvlist(zc, nv); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1714 nvlist_free(nv); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1715 } else { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1716 err = ENOENT; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1717 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1718 dmu_objset_rele(os, FTAG); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1719 return (err); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1720 } |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1721 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1722 static boolean_t |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1723 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
|
1724 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1725 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1726 * 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
|
1727 * 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
|
1728 * 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
|
1729 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1730 if (strchr(name, '$') != NULL) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1731 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1732 if (strchr(name, '%') != NULL) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1733 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1734 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
|
1735 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1736 return (B_FALSE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1737 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1738 |
5367 | 1739 /* |
1740 * inputs: | |
1741 * zc_name name of filesystem | |
1742 * zc_cookie zap cursor | |
1743 * zc_nvlist_dst_size size of buffer for property nvlist | |
1744 * | |
1745 * outputs: | |
1746 * 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
|
1747 * zc_cookie zap cursor |
5367 | 1748 * zc_objset_stats stats |
1749 * zc_nvlist_dst property nvlist | |
1750 * zc_nvlist_dst_size size of property nvlist | |
1751 */ | |
789 | 1752 static int |
1753 zfs_ioc_dataset_list_next(zfs_cmd_t *zc) | |
1754 { | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1755 objset_t *os; |
789 | 1756 int error; |
1757 char *p; | |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1758 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
|
1759 |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1760 top: |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1761 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
|
1762 if (error == ENOENT) |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1763 error = ESRCH; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1764 return (error); |
789 | 1765 } |
1766 | |
1767 p = strrchr(zc->zc_name, '/'); | |
1768 if (p == NULL || p[1] != '\0') | |
1769 (void) strlcat(zc->zc_name, "/", sizeof (zc->zc_name)); | |
1770 p = zc->zc_name + strlen(zc->zc_name); | |
1771 | |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1772 /* |
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1773 * Pre-fetch the datasets. dmu_objset_prefetch() always returns 0 |
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1774 * but is not declared void because its called by dmu_objset_find(). |
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1775 */ |
8415
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1776 if (zc->zc_cookie == 0) { |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1777 uint64_t cookie = 0; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1778 int len = sizeof (zc->zc_name) - (p - zc->zc_name); |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1779 |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1780 while (dmu_dir_list_next(os, len, p, NULL, &cookie) == 0) |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1781 (void) dmu_objset_prefetch(p, NULL); |
8415
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1782 } |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1783 |
789 | 1784 do { |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1785 error = dmu_dir_list_next(os, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1786 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
|
1787 NULL, &zc->zc_cookie); |
789 | 1788 if (error == ENOENT) |
1789 error = ESRCH; | |
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
|
1790 } while (error == 0 && dataset_name_hidden(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
|
1791 !(zc->zc_iflags & FKIOCTL)); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1792 dmu_objset_rele(os, FTAG); |
789 | 1793 |
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
|
1794 /* |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1795 * 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
|
1796 * 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
|
1797 */ |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1798 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
|
1799 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
|
1800 if (error == ENOENT) { |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1801 /* 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
|
1802 zc->zc_name[orig_len] = '\0'; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1803 goto top; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1804 } |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1805 } |
789 | 1806 return (error); |
1807 } | |
1808 | |
5367 | 1809 /* |
1810 * inputs: | |
1811 * zc_name name of filesystem | |
1812 * zc_cookie zap cursor | |
1813 * zc_nvlist_dst_size size of buffer for property nvlist | |
1814 * | |
1815 * outputs: | |
1816 * zc_name name of next snapshot | |
1817 * zc_objset_stats stats | |
1818 * zc_nvlist_dst property nvlist | |
1819 * zc_nvlist_dst_size size of property nvlist | |
1820 */ | |
789 | 1821 static int |
1822 zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) | |
1823 { | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1824 objset_t *os; |
789 | 1825 int error; |
1826 | |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1827 top: |
10474
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
1828 if (zc->zc_cookie == 0) |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
1829 (void) dmu_objset_find(zc->zc_name, dmu_objset_prefetch, |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
1830 NULL, DS_FIND_SNAPSHOTS); |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
1831 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1832 error = dmu_objset_hold(zc->zc_name, FTAG, &os); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1833 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1834 return (error == ENOENT ? ESRCH : error); |
789 | 1835 |
1003 | 1836 /* |
1837 * A dataset name of maximum length cannot have any snapshots, | |
1838 * so exit immediately. | |
1839 */ | |
1840 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
|
1841 dmu_objset_rele(os, FTAG); |
1003 | 1842 return (ESRCH); |
789 | 1843 } |
1844 | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1845 error = dmu_snapshot_list_next(os, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1846 sizeof (zc->zc_name) - strlen(zc->zc_name), |
5663
029cc4273b57
6627223 gfs needs to support extended dirent flags
ck153898
parents:
5498
diff
changeset
|
1847 zc->zc_name + strlen(zc->zc_name), NULL, &zc->zc_cookie, NULL); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1848 dmu_objset_rele(os, FTAG); |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1849 if (error == 0) { |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1850 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
|
1851 if (error == ENOENT) { |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1852 /* 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
|
1853 *strchr(zc->zc_name, '@') = '\0'; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1854 goto top; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1855 } |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1856 } else if (error == ENOENT) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1857 error = ESRCH; |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1858 } |
789 | 1859 |
5367 | 1860 /* if we failed, undo the @ that we tacked on to zc_name */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1861 if (error) |
5367 | 1862 *strchr(zc->zc_name, '@') = '\0'; |
789 | 1863 return (error); |
1864 } | |
1865 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1866 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1867 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
|
1868 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1869 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1870 uint64_t *valary; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1871 unsigned int vallen; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1872 const char *domain; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1873 zfs_userquota_prop_t type; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1874 uint64_t rid; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1875 uint64_t quota; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1876 zfsvfs_t *zfsvfs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1877 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1878 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1879 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1880 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1881 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1882 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1883 &pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1884 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1885 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1886 VERIFY(nvpair_value_uint64_array(pair, &valary, &vallen) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1887 VERIFY(vallen == 3); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1888 type = valary[0]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1889 rid = valary[1]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1890 quota = valary[2]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1891 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1892 * The propname is encoded as |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1893 * userquota@<rid>-<domain>. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1894 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1895 domain = strchr(propname, '-') + 1; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1896 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1897 err = zfsvfs_hold(dsname, FTAG, &zfsvfs); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1898 if (err == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1899 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
|
1900 zfsvfs_rele(zfsvfs, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1901 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1902 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1903 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1904 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1905 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1906 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1907 * 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
|
1908 * 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
|
1909 * 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
|
1910 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1911 * XXX: It would be better for callers of the properety interface if we handled |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1912 * 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
|
1913 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1914 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1915 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
|
1916 nvpair_t *pair) |
789 | 1917 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1918 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1919 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
|
1920 uint64_t intval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1921 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1922 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1923 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1924 if (zfs_prop_userquota(propname)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1925 return (zfs_prop_set_userquota(dsname, pair)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1926 return (-1); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1927 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1928 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1929 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1930 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1931 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1932 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1933 &pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1934 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1935 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1936 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
|
1937 return (-1); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1938 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1939 VERIFY(0 == nvpair_value_uint64(pair, &intval)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1940 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1941 switch (prop) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1942 case ZFS_PROP_QUOTA: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1943 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
|
1944 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1945 case ZFS_PROP_REFQUOTA: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1946 err = dsl_dataset_set_quota(dsname, source, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1947 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1948 case ZFS_PROP_RESERVATION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1949 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
|
1950 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1951 case ZFS_PROP_REFRESERVATION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1952 err = dsl_dataset_set_reservation(dsname, source, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1953 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1954 case ZFS_PROP_VOLSIZE: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1955 err = zvol_set_volsize(dsname, ddi_driver_major(zfs_dip), |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1956 intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1957 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1958 case ZFS_PROP_VERSION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1959 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1960 zfsvfs_t *zfsvfs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1961 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1962 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs)) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1963 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1964 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1965 err = zfs_set_version(zfsvfs, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1966 zfsvfs_rele(zfsvfs, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1967 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1968 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) { |
11147
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
1969 zfs_cmd_t *zc; |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
1970 |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
1971 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
|
1972 (void) strcpy(zc->zc_name, dsname); |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
1973 (void) zfs_ioc_userspace_upgrade(zc); |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
1974 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
|
1975 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1976 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1977 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1978 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1979 default: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1980 err = -1; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1981 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1982 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1983 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1984 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1985 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1986 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1987 * This function is best effort. If it fails to set any of the given properties, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1988 * it continues to set as many as it can and returns the first error |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1989 * encountered. If the caller provides a non-NULL errlist, it also gives the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1990 * complete list of names of all the properties it failed to set along with the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1991 * 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
|
1992 * returned errlist. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1993 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1994 * If every property is set successfully, zero is returned and the list pointed |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1995 * at by errlist is NULL. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1996 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1997 int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1998 zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1999 nvlist_t **errlist) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2000 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2001 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2002 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
|
2003 int rv = 0; |
2676 | 2004 uint64_t intval; |
2005 char *strval; | |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2006 nvlist_t *genericnvl; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2007 nvlist_t *errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2008 nvlist_t *retrynvl; |
4543 | 2009 |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2010 VERIFY(nvlist_alloc(&genericnvl, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2011 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
|
2012 VERIFY(nvlist_alloc(&retrynvl, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2013 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2014 retry: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2015 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2016 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
|
2017 const char *propname = nvpair_name(pair); |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
2018 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
|
2019 int err = 0; |
4543 | 2020 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2021 /* decode the property value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2022 propval = pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2023 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2024 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2025 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2026 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2027 &propval) == 0); |
4543 | 2028 } |
2676 | 2029 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2030 /* Validate value type */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2031 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2032 if (zfs_prop_user(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2033 if (nvpair_type(propval) != DATA_TYPE_STRING) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2034 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2035 } else if (zfs_prop_userquota(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2036 if (nvpair_type(propval) != |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2037 DATA_TYPE_UINT64_ARRAY) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2038 err = EINVAL; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2039 } |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2040 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2041 if (nvpair_type(propval) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2042 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
|
2043 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2044 } else if (nvpair_type(propval) == DATA_TYPE_UINT64) { |
2885 | 2045 const char *unused; |
2046 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2047 VERIFY(nvpair_value_uint64(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2048 &intval) == 0); |
2676 | 2049 |
2050 switch (zfs_prop_get_type(prop)) { | |
4787 | 2051 case PROP_TYPE_NUMBER: |
2676 | 2052 break; |
4787 | 2053 case PROP_TYPE_STRING: |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2054 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2055 break; |
4787 | 2056 case PROP_TYPE_INDEX: |
2717
ed589a32259d
6469385 zfs_set_prop_nvlist range checking is busted
eschrock
parents:
2676
diff
changeset
|
2057 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
|
2058 intval, &unused) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2059 err = EINVAL; |
2676 | 2060 break; |
2061 default: | |
4577 | 2062 cmn_err(CE_PANIC, |
2063 "unknown property type"); | |
2676 | 2064 } |
2065 } else { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2066 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2067 } |
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 /* Validate permissions */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2071 if (err == 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2072 err = zfs_check_settable(dsname, pair, CRED()); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2073 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2074 if (err == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2075 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
|
2076 if (err == -1) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2077 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2078 * 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
|
2079 * properties to set in a single transaction. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2080 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2081 err = nvlist_add_nvpair(genericnvl, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2082 } else if (err != 0 && nvl != retrynvl) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2083 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2084 * 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
|
2085 * receiving quota and reservation out of order. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2086 * Try again in a second pass. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2087 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2088 err = nvlist_add_nvpair(retrynvl, pair); |
2676 | 2089 } |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2090 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2091 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2092 if (err != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2093 VERIFY(nvlist_add_int32(errors, propname, err) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2094 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2095 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2096 if (nvl != retrynvl && !nvlist_empty(retrynvl)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2097 nvl = retrynvl; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2098 goto retry; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2099 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2100 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2101 if (!nvlist_empty(genericnvl) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2102 dsl_props_set(dsname, source, genericnvl) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2103 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2104 * 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
|
2105 * can, so try setting them individually. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2106 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2107 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2108 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
|
2109 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
|
2110 int err = 0; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2111 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2112 propval = pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2113 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2114 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2115 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2116 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2117 &propval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2118 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2119 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2120 if (nvpair_type(propval) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2121 VERIFY(nvpair_value_string(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2122 &strval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2123 err = dsl_prop_set(dsname, propname, source, 1, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2124 strlen(strval) + 1, strval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2125 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2126 VERIFY(nvpair_value_uint64(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2127 &intval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2128 err = dsl_prop_set(dsname, propname, source, 8, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2129 1, &intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2130 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2131 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2132 if (err != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2133 VERIFY(nvlist_add_int32(errors, propname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2134 err) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2135 } |
2676 | 2136 } |
2137 } | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2138 nvlist_free(genericnvl); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2139 nvlist_free(retrynvl); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2140 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2141 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
|
2142 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2143 errors = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2144 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2145 VERIFY(nvpair_value_int32(pair, &rv) == 0); |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2146 } |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2147 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2148 if (errlist == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2149 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2150 else |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2151 *errlist = errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2152 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2153 return (rv); |
789 | 2154 } |
2155 | |
5367 | 2156 /* |
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
|
2157 * 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
|
2158 */ |
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
|
2159 static int |
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
|
2160 zfs_check_userprops(char *fsname, nvlist_t *nvl) |
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
|
2161 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2162 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
|
2163 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
|
2164 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2165 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
|
2166 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
|
2167 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
|
2168 |
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
|
2169 if (!zfs_prop_user(propname) || |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2170 nvpair_type(pair) != DATA_TYPE_STRING) |
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
|
2171 return (EINVAL); |
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
|
2172 |
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
|
2173 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
|
2174 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
|
2175 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
|
2176 |
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
|
2177 if (strlen(propname) >= ZAP_MAXNAMELEN) |
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
|
2178 return (ENAMETOOLONG); |
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
|
2179 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2180 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
|
2181 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
|
2182 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
|
2183 } |
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
|
2184 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
|
2185 } |
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
|
2186 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2187 static void |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2188 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
|
2189 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2190 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2191 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2192 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
|
2193 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2194 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2195 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
|
2196 if (nvlist_exists(skipped, nvpair_name(pair))) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2197 continue; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2198 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2199 VERIFY(nvlist_add_nvpair(*newprops, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2200 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2201 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2202 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2203 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2204 clear_received_props(objset_t *os, const char *fs, nvlist_t *props, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2205 nvlist_t *skipped) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2206 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2207 int err = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2208 nvlist_t *cleared_props = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2209 props_skip(props, skipped, &cleared_props); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2210 if (!nvlist_empty(cleared_props)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2211 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2212 * 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
|
2213 * 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
|
2214 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2215 zprop_source_t flags = (ZPROP_SRC_NONE | |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2216 (dsl_prop_get_hasrecvd(os) ? ZPROP_SRC_RECEIVED : 0)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2217 err = zfs_set_prop_nvlist(fs, flags, cleared_props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2218 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2219 nvlist_free(cleared_props); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2220 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2221 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2222 |
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
|
2223 /* |
5367 | 2224 * inputs: |
2225 * 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
|
2226 * zc_value name of property to set |
5367 | 2227 * 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
|
2228 * zc_cookie received properties flag |
5367 | 2229 * |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2230 * outputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2231 * zc_nvlist_dst{_size} error for each unapplied received property |
5367 | 2232 */ |
789 | 2233 static int |
2676 | 2234 zfs_ioc_set_prop(zfs_cmd_t *zc) |
789 | 2235 { |
2676 | 2236 nvlist_t *nvl; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2237 boolean_t received = zc->zc_cookie; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2238 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
|
2239 ZPROP_SRC_LOCAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2240 nvlist_t *errors = NULL; |
2676 | 2241 int error; |
789 | 2242 |
5094 | 2243 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
|
2244 zc->zc_iflags, &nvl)) != 0) |
2676 | 2245 return (error); |
2246 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2247 if (received) { |
7265 | 2248 nvlist_t *origprops; |
2249 objset_t *os; | |
2250 | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2251 if (dmu_objset_hold(zc->zc_name, FTAG, &os) == 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2252 if (dsl_prop_get_received(os, &origprops) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2253 (void) clear_received_props(os, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2254 zc->zc_name, origprops, nvl); |
7265 | 2255 nvlist_free(origprops); |
2256 } | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2257 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2258 dsl_prop_set_hasrecvd(os); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2259 dmu_objset_rele(os, FTAG); |
7265 | 2260 } |
2261 } | |
2262 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2263 error = zfs_set_prop_nvlist(zc->zc_name, source, nvl, &errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2264 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2265 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
|
2266 (void) put_nvlist(zc, errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2267 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2268 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2269 nvlist_free(errors); |
2676 | 2270 nvlist_free(nvl); |
2271 return (error); | |
789 | 2272 } |
2273 | |
5367 | 2274 /* |
2275 * inputs: | |
2276 * zc_name name of filesystem | |
2277 * 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
|
2278 * zc_cookie revert to received value if TRUE |
5367 | 2279 * |
2280 * outputs: none | |
2281 */ | |
789 | 2282 static int |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2283 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
|
2284 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2285 const char *propname = zc->zc_value; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2286 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
|
2287 boolean_t received = zc->zc_cookie; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2288 zprop_source_t source = (received |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2289 ? 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
|
2290 : ZPROP_SRC_INHERITED); /* explicitly inherit */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2291 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2292 if (received) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2293 nvlist_t *dummy; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2294 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2295 zprop_type_t type; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2296 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2297 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2298 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2299 * 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
|
2300 * nvpair with type info. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2301 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2302 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2303 if (!zfs_prop_user(propname)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2304 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2305 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2306 type = PROP_TYPE_STRING; |
11515
a122949107d4
6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11454
diff
changeset
|
2307 } 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
|
2308 prop == ZFS_PROP_VERSION) { |
a122949107d4
6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11454
diff
changeset
|
2309 return (EINVAL); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2310 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2311 type = zfs_prop_get_type(prop); |
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 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
|
2315 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2316 switch (type) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2317 case PROP_TYPE_STRING: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2318 VERIFY(0 == nvlist_add_string(dummy, propname, "")); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2319 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2320 case PROP_TYPE_NUMBER: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2321 case PROP_TYPE_INDEX: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2322 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
|
2323 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2324 default: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2325 nvlist_free(dummy); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2326 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2327 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2328 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2329 pair = nvlist_next_nvpair(dummy, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2330 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
|
2331 nvlist_free(dummy); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2332 if (err != -1) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2333 return (err); /* special property already handled */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2334 } else { |
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 * 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
|
2337 * '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
|
2338 * 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
|
2339 * they are not considered inheritable. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2340 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2341 if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2342 return (EINVAL); |
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 |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2345 /* the property name has been validated by zfs_secpolicy_inherit() */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2346 return (dsl_prop_set(zc->zc_name, zc->zc_value, source, 0, 0, NULL)); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2347 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2348 |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2349 static int |
4098
0a182c2128e6
6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents:
4007
diff
changeset
|
2350 zfs_ioc_pool_set_props(zfs_cmd_t *zc) |
3912 | 2351 { |
5094 | 2352 nvlist_t *props; |
3912 | 2353 spa_t *spa; |
5094 | 2354 int error; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2355 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2356 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2357 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
|
2358 zc->zc_iflags, &props)) |
3912 | 2359 return (error); |
2360 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2361 /* |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2362 * 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
|
2363 * 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
|
2364 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2365 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2366 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
|
2367 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
|
2368 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
|
2369 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
|
2370 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
|
2371 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
|
2372 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
|
2373 } |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2374 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
|
2375 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
|
2376 nvlist_free(props); |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2377 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
|
2378 } |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2379 } |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2380 |
3912 | 2381 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) { |
5094 | 2382 nvlist_free(props); |
3912 | 2383 return (error); |
2384 } | |
2385 | |
5094 | 2386 error = spa_prop_set(spa, props); |
3912 | 2387 |
5094 | 2388 nvlist_free(props); |
3912 | 2389 spa_close(spa, FTAG); |
2390 | |
2391 return (error); | |
2392 } | |
2393 | |
2394 static int | |
4098
0a182c2128e6
6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents:
4007
diff
changeset
|
2395 zfs_ioc_pool_get_props(zfs_cmd_t *zc) |
3912 | 2396 { |
2397 spa_t *spa; | |
2398 int error; | |
2399 nvlist_t *nvp = NULL; | |
2400 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2401 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
|
2402 /* |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2403 * 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
|
2404 * 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
|
2405 * anyway. |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2406 */ |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2407 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
|
2408 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
|
2409 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
|
2410 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
|
2411 } else { |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2412 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
|
2413 spa_close(spa, FTAG); |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2414 } |
3912 | 2415 |
2416 if (error == 0 && zc->zc_nvlist_dst != NULL) | |
2417 error = put_nvlist(zc, nvp); | |
2418 else | |
2419 error = EFAULT; | |
2420 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2421 nvlist_free(nvp); |
3912 | 2422 return (error); |
2423 } | |
2424 | |
2425 static int | |
4543 | 2426 zfs_ioc_iscsi_perm_check(zfs_cmd_t *zc) |
2427 { | |
2428 nvlist_t *nvp; | |
2429 int error; | |
2430 uint32_t uid; | |
2431 uint32_t gid; | |
2432 uint32_t *groups; | |
2433 uint_t group_cnt; | |
2434 cred_t *usercred; | |
2435 | |
5094 | 2436 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
|
2437 zc->zc_iflags, &nvp)) != 0) { |
4543 | 2438 return (error); |
2439 } | |
2440 | |
2441 if ((error = nvlist_lookup_uint32(nvp, | |
2442 ZFS_DELEG_PERM_UID, &uid)) != 0) { | |
2443 nvlist_free(nvp); | |
2444 return (EPERM); | |
2445 } | |
2446 | |
2447 if ((error = nvlist_lookup_uint32(nvp, | |
2448 ZFS_DELEG_PERM_GID, &gid)) != 0) { | |
2449 nvlist_free(nvp); | |
2450 return (EPERM); | |
2451 } | |
2452 | |
2453 if ((error = nvlist_lookup_uint32_array(nvp, ZFS_DELEG_PERM_GROUPS, | |
2454 &groups, &group_cnt)) != 0) { | |
2455 nvlist_free(nvp); | |
2456 return (EPERM); | |
2457 } | |
2458 usercred = cralloc(); | |
2459 if ((crsetugid(usercred, uid, gid) != 0) || | |
2460 (crsetgroups(usercred, group_cnt, (gid_t *)groups) != 0)) { | |
2461 nvlist_free(nvp); | |
2462 crfree(usercred); | |
2463 return (EPERM); | |
2464 } | |
2465 nvlist_free(nvp); | |
2466 error = dsl_deleg_access(zc->zc_name, | |
4787 | 2467 zfs_prop_to_name(ZFS_PROP_SHAREISCSI), usercred); |
4543 | 2468 crfree(usercred); |
2469 return (error); | |
2470 } | |
2471 | |
5367 | 2472 /* |
2473 * inputs: | |
2474 * zc_name name of filesystem | |
2475 * zc_nvlist_src{_size} nvlist of delegated permissions | |
2476 * zc_perm_action allow/unallow flag | |
2477 * | |
2478 * outputs: none | |
2479 */ | |
4543 | 2480 static int |
2481 zfs_ioc_set_fsacl(zfs_cmd_t *zc) | |
2482 { | |
2483 int error; | |
2484 nvlist_t *fsaclnv = NULL; | |
2485 | |
5094 | 2486 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
|
2487 zc->zc_iflags, &fsaclnv)) != 0) |
4543 | 2488 return (error); |
2489 | |
2490 /* | |
2491 * Verify nvlist is constructed correctly | |
2492 */ | |
2493 if ((error = zfs_deleg_verify_nvlist(fsaclnv)) != 0) { | |
2494 nvlist_free(fsaclnv); | |
2495 return (EINVAL); | |
2496 } | |
2497 | |
2498 /* | |
2499 * If we don't have PRIV_SYS_MOUNT, then validate | |
2500 * that user is allowed to hand out each permission in | |
2501 * the nvlist(s) | |
2502 */ | |
2503 | |
4787 | 2504 error = secpolicy_zfs(CRED()); |
4543 | 2505 if (error) { |
4787 | 2506 if (zc->zc_perm_action == B_FALSE) { |
2507 error = dsl_deleg_can_allow(zc->zc_name, | |
2508 fsaclnv, CRED()); | |
2509 } else { | |
2510 error = dsl_deleg_can_unallow(zc->zc_name, | |
2511 fsaclnv, CRED()); | |
2512 } | |
4543 | 2513 } |
2514 | |
2515 if (error == 0) | |
2516 error = dsl_deleg_set(zc->zc_name, fsaclnv, zc->zc_perm_action); | |
2517 | |
2518 nvlist_free(fsaclnv); | |
2519 return (error); | |
2520 } | |
2521 | |
5367 | 2522 /* |
2523 * inputs: | |
2524 * zc_name name of filesystem | |
2525 * | |
2526 * outputs: | |
2527 * zc_nvlist_src{_size} nvlist of delegated permissions | |
2528 */ | |
4543 | 2529 static int |
2530 zfs_ioc_get_fsacl(zfs_cmd_t *zc) | |
2531 { | |
2532 nvlist_t *nvp; | |
2533 int error; | |
2534 | |
2535 if ((error = dsl_deleg_get(zc->zc_name, &nvp)) == 0) { | |
2536 error = put_nvlist(zc, nvp); | |
2537 nvlist_free(nvp); | |
2538 } | |
2539 | |
2540 return (error); | |
2541 } | |
2542 | |
5367 | 2543 /* |
789 | 2544 * Search the vfs list for a specified resource. Returns a pointer to it |
2545 * or NULL if no suitable entry is found. The caller of this routine | |
2546 * is responsible for releasing the returned vfs pointer. | |
2547 */ | |
2548 static vfs_t * | |
2549 zfs_get_vfs(const char *resource) | |
2550 { | |
2551 struct vfs *vfsp; | |
2552 struct vfs *vfs_found = NULL; | |
2553 | |
2554 vfs_list_read_lock(); | |
2555 vfsp = rootvfs; | |
2556 do { | |
2557 if (strcmp(refstr_value(vfsp->vfs_resource), resource) == 0) { | |
2558 VFS_HOLD(vfsp); | |
2559 vfs_found = vfsp; | |
2560 break; | |
2561 } | |
2562 vfsp = vfsp->vfs_next; | |
2563 } while (vfsp != rootvfs); | |
2564 vfs_list_unlock(); | |
2565 return (vfs_found); | |
2566 } | |
2567 | |
4543 | 2568 /* ARGSUSED */ |
789 | 2569 static void |
4543 | 2570 zfs_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx) |
789 | 2571 { |
5331 | 2572 zfs_creat_t *zct = arg; |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2573 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2574 zfs_create_fs(os, cr, zct->zct_zplprops, tx); |
5331 | 2575 } |
2576 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2577 #define ZFS_PROP_UNDEFINED ((uint64_t)-1) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2578 |
5331 | 2579 /* |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2580 * inputs: |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2581 * createprops list of properties requested by creator |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2582 * 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
|
2583 * 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
|
2584 * os parent objset pointer (NULL if root fs) |
5331 | 2585 * |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2586 * outputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2587 * 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
|
2588 * is_ci true if requested file system will be purely case-insensitive |
5331 | 2589 * |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2590 * Determine the settings for utf8only, normalization and |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2591 * casesensitivity. Specific values may have been requested by the |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2592 * 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
|
2593 * 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
|
2594 * request settings for these properties, even if the requested |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2595 * 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
|
2596 * 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
|
2597 * processing. |
5331 | 2598 */ |
2599 static int | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2600 zfs_fill_zplprops_impl(objset_t *os, uint64_t zplver, |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2601 boolean_t fuids_ok, nvlist_t *createprops, nvlist_t *zplprops, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2602 boolean_t *is_ci) |
5331 | 2603 { |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2604 uint64_t sense = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2605 uint64_t norm = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2606 uint64_t u8 = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2607 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2608 ASSERT(zplprops != NULL); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2609 |
5375 | 2610 /* |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2611 * Pull out creator prop choices, if any. |
5375 | 2612 */ |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2613 if (createprops) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2614 (void) nvlist_lookup_uint64(createprops, |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2615 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
|
2616 (void) nvlist_lookup_uint64(createprops, |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2617 zfs_prop_to_name(ZFS_PROP_NORMALIZE), &norm); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2618 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2619 zfs_prop_to_name(ZFS_PROP_NORMALIZE)); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2620 (void) nvlist_lookup_uint64(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2621 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), &u8); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2622 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2623 zfs_prop_to_name(ZFS_PROP_UTF8ONLY)); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2624 (void) nvlist_lookup_uint64(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2625 zfs_prop_to_name(ZFS_PROP_CASE), &sense); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2626 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2627 zfs_prop_to_name(ZFS_PROP_CASE)); |
5331 | 2628 } |
2629 | |
5375 | 2630 /* |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2631 * 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
|
2632 * 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
|
2633 * 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
|
2634 * error out. |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2635 */ |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2636 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
|
2637 (zplver >= ZPL_VERSION_FUID && !fuids_ok) || |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2638 (zplver < ZPL_VERSION_NORMALIZATION && |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2639 (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
|
2640 sense != ZFS_PROP_UNDEFINED))) |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2641 return (ENOTSUP); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2642 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2643 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2644 * Put the version in the zplprops |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2645 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2646 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2647 zfs_prop_to_name(ZFS_PROP_VERSION), zplver) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2648 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2649 if (norm == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2650 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
|
2651 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2652 zfs_prop_to_name(ZFS_PROP_NORMALIZE), norm) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2653 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2654 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2655 * 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
|
2656 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2657 if (norm) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2658 u8 = 1; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2659 if (u8 == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2660 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
|
2661 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2662 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), u8) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2663 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2664 if (sense == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2665 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
|
2666 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2667 zfs_prop_to_name(ZFS_PROP_CASE), sense) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2668 |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2669 if (is_ci) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2670 *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
|
2671 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2672 return (0); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2673 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2674 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2675 static int |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2676 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
|
2677 nvlist_t *zplprops, boolean_t *is_ci) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2678 { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2679 boolean_t fuids_ok = B_TRUE; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2680 uint64_t zplver = ZPL_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2681 objset_t *os = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2682 char parentname[MAXNAMELEN]; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2683 char *cp; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2684 int error; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2685 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2686 (void) strlcpy(parentname, dataset, sizeof (parentname)); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2687 cp = strrchr(parentname, '/'); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2688 ASSERT(cp != NULL); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2689 cp[0] = '\0'; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2690 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2691 if (zfs_earlier_version(dataset, SPA_VERSION_USERSPACE)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2692 zplver = ZPL_VERSION_USERSPACE - 1; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2693 if (zfs_earlier_version(dataset, SPA_VERSION_FUID)) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2694 zplver = ZPL_VERSION_FUID - 1; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2695 fuids_ok = B_FALSE; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2696 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2697 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2698 /* |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2699 * 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
|
2700 */ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2701 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
|
2702 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2703 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2704 error = zfs_fill_zplprops_impl(os, zplver, fuids_ok, createprops, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2705 zplprops, is_ci); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2706 dmu_objset_rele(os, FTAG); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2707 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2708 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2709 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2710 static int |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2711 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
|
2712 nvlist_t *zplprops, boolean_t *is_ci) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2713 { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2714 boolean_t fuids_ok = B_TRUE; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2715 uint64_t zplver = ZPL_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2716 int error; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2717 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2718 if (spa_vers < SPA_VERSION_FUID) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2719 zplver = ZPL_VERSION_FUID - 1; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2720 fuids_ok = B_FALSE; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2721 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2722 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2723 error = zfs_fill_zplprops_impl(NULL, zplver, fuids_ok, createprops, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2724 zplprops, is_ci); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2725 return (error); |
789 | 2726 } |
2727 | |
5367 | 2728 /* |
2729 * inputs: | |
2730 * zc_objset_type type of objset to create (fs vs zvol) | |
2731 * zc_name name of new objset | |
2732 * zc_value name of snapshot to clone from (may be empty) | |
2733 * zc_nvlist_src{_size} nvlist of properties to apply | |
2734 * | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2735 * outputs: none |
5367 | 2736 */ |
789 | 2737 static int |
2738 zfs_ioc_create(zfs_cmd_t *zc) | |
2739 { | |
2740 objset_t *clone; | |
2741 int error = 0; | |
5331 | 2742 zfs_creat_t zct; |
4543 | 2743 nvlist_t *nvprops = NULL; |
2744 void (*cbfunc)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx); | |
789 | 2745 dmu_objset_type_t type = zc->zc_objset_type; |
2746 | |
2747 switch (type) { | |
2748 | |
2749 case DMU_OST_ZFS: | |
2750 cbfunc = zfs_create_cb; | |
2751 break; | |
2752 | |
2753 case DMU_OST_ZVOL: | |
2754 cbfunc = zvol_create_cb; | |
2755 break; | |
2756 | |
2757 default: | |
2199 | 2758 cbfunc = NULL; |
6423 | 2759 break; |
2199 | 2760 } |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
2761 if (strchr(zc->zc_name, '@') || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
2762 strchr(zc->zc_name, '%')) |
789 | 2763 return (EINVAL); |
2764 | |
2676 | 2765 if (zc->zc_nvlist_src != NULL && |
5094 | 2766 (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
|
2767 zc->zc_iflags, &nvprops)) != 0) |
2676 | 2768 return (error); |
2769 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2770 zct.zct_zplprops = NULL; |
5331 | 2771 zct.zct_props = nvprops; |
2772 | |
2676 | 2773 if (zc->zc_value[0] != '\0') { |
789 | 2774 /* |
2775 * We're creating a clone of an existing snapshot. | |
2776 */ | |
2676 | 2777 zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; |
2778 if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0) { | |
4543 | 2779 nvlist_free(nvprops); |
789 | 2780 return (EINVAL); |
2676 | 2781 } |
789 | 2782 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2783 error = dmu_objset_hold(zc->zc_value, FTAG, &clone); |
2676 | 2784 if (error) { |
4543 | 2785 nvlist_free(nvprops); |
789 | 2786 return (error); |
2676 | 2787 } |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2788 |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
2789 error = dmu_objset_clone(zc->zc_name, dmu_objset_ds(clone), 0); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2790 dmu_objset_rele(clone, FTAG); |
5331 | 2791 if (error) { |
2792 nvlist_free(nvprops); | |
2793 return (error); | |
2794 } | |
789 | 2795 } else { |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2796 boolean_t is_insensitive = B_FALSE; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2797 |
2676 | 2798 if (cbfunc == NULL) { |
4543 | 2799 nvlist_free(nvprops); |
2199 | 2800 return (EINVAL); |
2676 | 2801 } |
2802 | |
789 | 2803 if (type == DMU_OST_ZVOL) { |
2676 | 2804 uint64_t volsize, volblocksize; |
2805 | |
4543 | 2806 if (nvprops == NULL || |
2807 nvlist_lookup_uint64(nvprops, | |
2676 | 2808 zfs_prop_to_name(ZFS_PROP_VOLSIZE), |
2809 &volsize) != 0) { | |
4543 | 2810 nvlist_free(nvprops); |
2676 | 2811 return (EINVAL); |
2812 } | |
2813 | |
4543 | 2814 if ((error = nvlist_lookup_uint64(nvprops, |
2676 | 2815 zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), |
2816 &volblocksize)) != 0 && error != ENOENT) { | |
4543 | 2817 nvlist_free(nvprops); |
2676 | 2818 return (EINVAL); |
2819 } | |
1133
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
1003
diff
changeset
|
2820 |
2676 | 2821 if (error != 0) |
2822 volblocksize = zfs_prop_default_numeric( | |
2823 ZFS_PROP_VOLBLOCKSIZE); | |
2824 | |
2825 if ((error = zvol_check_volblocksize( | |
2826 volblocksize)) != 0 || | |
2827 (error = zvol_check_volsize(volsize, | |
2828 volblocksize)) != 0) { | |
4543 | 2829 nvlist_free(nvprops); |
789 | 2830 return (error); |
2676 | 2831 } |
4577 | 2832 } else if (type == DMU_OST_ZFS) { |
5331 | 2833 int error; |
2834 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2835 /* |
5331 | 2836 * We have to have normalization and |
2837 * case-folding flags correct when we do the | |
2838 * file system creation, so go figure them out | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2839 * now. |
5331 | 2840 */ |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2841 VERIFY(nvlist_alloc(&zct.zct_zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2842 NV_UNIQUE_NAME, KM_SLEEP) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2843 error = zfs_fill_zplprops(zc->zc_name, nvprops, |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2844 zct.zct_zplprops, &is_insensitive); |
5331 | 2845 if (error != 0) { |
2846 nvlist_free(nvprops); | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2847 nvlist_free(zct.zct_zplprops); |
5331 | 2848 return (error); |
4577 | 2849 } |
2676 | 2850 } |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
2851 error = dmu_objset_create(zc->zc_name, type, |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2852 is_insensitive ? DS_FLAG_CI_DATASET : 0, cbfunc, &zct); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2853 nvlist_free(zct.zct_zplprops); |
789 | 2854 } |
2676 | 2855 |
2856 /* | |
2857 * It would be nice to do this atomically. | |
2858 */ | |
2859 if (error == 0) { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2860 error = zfs_set_prop_nvlist(zc->zc_name, ZPROP_SRC_LOCAL, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2861 nvprops, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2862 if (error != 0) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
2863 (void) dmu_objset_destroy(zc->zc_name, B_FALSE); |
2676 | 2864 } |
4543 | 2865 nvlist_free(nvprops); |
789 | 2866 return (error); |
2867 } | |
2868 | |
5367 | 2869 /* |
2870 * inputs: | |
2871 * zc_name name of filesystem | |
2872 * zc_value short name of snapshot | |
2873 * zc_cookie recursive flag | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2874 * zc_nvlist_src[_size] property list |
5367 | 2875 * |
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
|
2876 * 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
|
2877 * zc_value short snapname (i.e. part after the '@') |
5367 | 2878 */ |
789 | 2879 static int |
2199 | 2880 zfs_ioc_snapshot(zfs_cmd_t *zc) |
2881 { | |
7265 | 2882 nvlist_t *nvprops = NULL; |
2883 int error; | |
2884 boolean_t recursive = zc->zc_cookie; | |
2885 | |
2676 | 2886 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
2199 | 2887 return (EINVAL); |
7265 | 2888 |
2889 if (zc->zc_nvlist_src != NULL && | |
2890 (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
|
2891 zc->zc_iflags, &nvprops)) != 0) |
7265 | 2892 return (error); |
2893 | |
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
|
2894 error = zfs_check_userprops(zc->zc_name, nvprops); |
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
|
2895 if (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
|
2896 goto out; |
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
|
2897 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2898 if (!nvlist_empty(nvprops) && |
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
|
2899 zfs_earlier_version(zc->zc_name, SPA_VERSION_SNAP_PROPS)) { |
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
|
2900 error = ENOTSUP; |
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
|
2901 goto out; |
7265 | 2902 } |
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
|
2903 |
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
|
2904 error = dmu_objset_snapshot(zc->zc_name, zc->zc_value, |
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
|
2905 nvprops, recursive); |
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
|
2906 |
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
|
2907 out: |
7265 | 2908 nvlist_free(nvprops); |
2909 return (error); | |
2199 | 2910 } |
2911 | |
4007 | 2912 int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
2913 zfs_unmount_snap(const char *name, void *arg) |
789 | 2914 { |
2417 | 2915 vfs_t *vfsp = NULL; |
2199 | 2916 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2917 if (arg) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2918 char *snapname = arg; |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
2919 char *fullname = kmem_asprintf("%s@%s", name, snapname); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
2920 vfsp = zfs_get_vfs(fullname); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
2921 strfree(fullname); |
2417 | 2922 } else if (strchr(name, '@')) { |
2199 | 2923 vfsp = zfs_get_vfs(name); |
2924 } | |
2925 | |
2926 if (vfsp) { | |
2927 /* | |
2928 * Always force the unmount for snapshots. | |
2929 */ | |
2930 int flag = MS_FORCE; | |
789 | 2931 int err; |
2932 | |
2199 | 2933 if ((err = vn_vfswlock(vfsp->vfs_vnodecovered)) != 0) { |
2934 VFS_RELE(vfsp); | |
2935 return (err); | |
2936 } | |
2937 VFS_RELE(vfsp); | |
2938 if ((err = dounmount(vfsp, flag, kcred)) != 0) | |
2939 return (err); | |
2940 } | |
2941 return (0); | |
2942 } | |
2943 | |
5367 | 2944 /* |
2945 * inputs: | |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
2946 * zc_name name of filesystem |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
2947 * zc_value short name of snapshot |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
2948 * zc_defer_destroy mark for deferred destroy |
5367 | 2949 * |
2950 * outputs: none | |
2951 */ | |
2199 | 2952 static int |
2953 zfs_ioc_destroy_snaps(zfs_cmd_t *zc) | |
2954 { | |
2955 int err; | |
789 | 2956 |
2676 | 2957 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
2199 | 2958 return (EINVAL); |
2959 err = dmu_objset_find(zc->zc_name, | |
2676 | 2960 zfs_unmount_snap, zc->zc_value, DS_FIND_CHILDREN); |
2199 | 2961 if (err) |
2962 return (err); | |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
2963 return (dmu_snapshots_destroy(zc->zc_name, zc->zc_value, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
2964 zc->zc_defer_destroy)); |
2199 | 2965 } |
2966 | |
5367 | 2967 /* |
2968 * inputs: | |
2969 * zc_name name of dataset to destroy | |
2970 * zc_objset_type type of objset | |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
2971 * zc_defer_destroy mark for deferred destroy |
5367 | 2972 * |
2973 * outputs: none | |
2974 */ | |
2199 | 2975 static int |
2976 zfs_ioc_destroy(zfs_cmd_t *zc) | |
2977 { | |
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
|
2978 int err; |
2199 | 2979 if (strchr(zc->zc_name, '@') && zc->zc_objset_type == DMU_OST_ZFS) { |
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
|
2980 err = zfs_unmount_snap(zc->zc_name, NULL); |
2199 | 2981 if (err) |
2982 return (err); | |
789 | 2983 } |
2984 | |
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
|
2985 err = dmu_objset_destroy(zc->zc_name, zc->zc_defer_destroy); |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
2986 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
|
2987 (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
|
2988 return (err); |
789 | 2989 } |
2990 | |
5367 | 2991 /* |
2992 * inputs: | |
5446 | 2993 * zc_name name of dataset to rollback (to most recent snapshot) |
5367 | 2994 * |
2995 * outputs: none | |
2996 */ | |
789 | 2997 static int |
2998 zfs_ioc_rollback(zfs_cmd_t *zc) | |
2999 { | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3000 dsl_dataset_t *ds, *clone; |
5446 | 3001 int error; |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3002 zfsvfs_t *zfsvfs; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3003 char *clone_name; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3004 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3005 error = dsl_dataset_hold(zc->zc_name, FTAG, &ds); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3006 if (error) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3007 return (error); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3008 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3009 /* must not be a snapshot */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3010 if (dsl_dataset_is_snapshot(ds)) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3011 dsl_dataset_rele(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3012 return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3013 } |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3014 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3015 /* must have a most recent snapshot */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3016 if (ds->ds_phys->ds_prev_snap_txg < TXG_INITIAL) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3017 dsl_dataset_rele(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3018 return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3019 } |
5446 | 3020 |
3021 /* | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3022 * Create clone of most recent snapshot. |
5446 | 3023 */ |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3024 clone_name = kmem_asprintf("%s/%%rollback", zc->zc_name); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3025 error = dmu_objset_clone(clone_name, ds->ds_prev, DS_FLAG_INCONSISTENT); |
5446 | 3026 if (error) |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3027 goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3028 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3029 error = dsl_dataset_own(clone_name, B_TRUE, FTAG, &clone); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3030 if (error) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3031 goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3032 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3033 /* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3034 * Do clone swap. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3035 */ |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3036 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
|
3037 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
|
3038 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
|
3039 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
|
3040 |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3041 if (dsl_dataset_tryown(ds, B_FALSE, FTAG)) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3042 error = dsl_dataset_clone_swap(clone, ds, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3043 B_TRUE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3044 dsl_dataset_disown(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3045 ds = NULL; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3046 } else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3047 error = EBUSY; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3048 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3049 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
|
3050 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
|
3051 } |
5446 | 3052 VFS_RELE(zfsvfs->z_vfs); |
3053 } else { | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3054 if (dsl_dataset_tryown(ds, B_FALSE, FTAG)) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3055 error = dsl_dataset_clone_swap(clone, ds, B_TRUE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3056 dsl_dataset_disown(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3057 ds = NULL; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3058 } else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3059 error = EBUSY; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3060 } |
5446 | 3061 } |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3062 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3063 /* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3064 * Destroy clone (which also closes it). |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3065 */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3066 (void) dsl_dataset_destroy(clone, FTAG, B_FALSE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3067 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3068 out: |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3069 strfree(clone_name); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3070 if (ds) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3071 dsl_dataset_rele(ds, FTAG); |
5446 | 3072 return (error); |
789 | 3073 } |
3074 | |
5367 | 3075 /* |
3076 * inputs: | |
3077 * zc_name old name of dataset | |
3078 * zc_value new name of dataset | |
3079 * zc_cookie recursive flag (only valid for snapshots) | |
3080 * | |
3081 * outputs: none | |
3082 */ | |
789 | 3083 static int |
3084 zfs_ioc_rename(zfs_cmd_t *zc) | |
3085 { | |
4490 | 3086 boolean_t recursive = zc->zc_cookie & 1; |
4007 | 3087 |
2676 | 3088 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
|
3089 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
|
3090 strchr(zc->zc_value, '%')) |
789 | 3091 return (EINVAL); |
3092 | |
4007 | 3093 /* |
3094 * Unmount snapshot unless we're doing a recursive rename, | |
3095 * in which case the dataset code figures out which snapshots | |
3096 * to unmount. | |
3097 */ | |
3098 if (!recursive && strchr(zc->zc_name, '@') != NULL && | |
789 | 3099 zc->zc_objset_type == DMU_OST_ZFS) { |
2199 | 3100 int err = zfs_unmount_snap(zc->zc_name, NULL); |
3101 if (err) | |
3102 return (err); | |
789 | 3103 } |
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
|
3104 if (zc->zc_objset_type == DMU_OST_ZVOL) |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3105 (void) zvol_remove_minor(zc->zc_name); |
4007 | 3106 return (dmu_objset_rename(zc->zc_name, zc->zc_value, recursive)); |
789 | 3107 } |
3108 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3109 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3110 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
|
3111 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3112 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3113 boolean_t issnap = (strchr(dsname, '@') != NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3114 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
|
3115 uint64_t intval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3116 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3117 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3118 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3119 if (zfs_prop_user(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3120 if (err = zfs_secpolicy_write_perms(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3121 ZFS_DELEG_PERM_USERPROP, cr)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3122 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3123 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3124 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3125 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3126 if (!issnap && zfs_prop_userquota(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3127 const char *perm = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3128 const char *uq_prefix = |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3129 zfs_userquota_prop_prefixes[ZFS_PROP_USERQUOTA]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3130 const char *gq_prefix = |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3131 zfs_userquota_prop_prefixes[ZFS_PROP_GROUPQUOTA]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3132 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3133 if (strncmp(propname, uq_prefix, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3134 strlen(uq_prefix)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3135 perm = ZFS_DELEG_PERM_USERQUOTA; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3136 } else if (strncmp(propname, gq_prefix, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3137 strlen(gq_prefix)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3138 perm = ZFS_DELEG_PERM_GROUPQUOTA; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3139 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3140 /* USERUSED and GROUPUSED are read-only */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3141 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3142 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3143 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3144 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
|
3145 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3146 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3147 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3148 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3149 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3150 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3151 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3152 if (issnap) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3153 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3154 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3155 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3156 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3157 * 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
|
3158 * format. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3159 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3160 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3161 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3162 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3163 &pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3164 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3165 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3166 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3167 * 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
|
3168 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3169 switch (prop) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3170 case ZFS_PROP_COMPRESSION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3171 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3172 * 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
|
3173 * 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
|
3174 * we'll catch them later. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3175 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3176 if (nvpair_type(pair) == DATA_TYPE_UINT64 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3177 nvpair_value_uint64(pair, &intval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3178 if (intval >= ZIO_COMPRESS_GZIP_1 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3179 intval <= ZIO_COMPRESS_GZIP_9 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3180 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3181 SPA_VERSION_GZIP_COMPRESSION)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3182 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3183 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3184 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3185 if (intval == ZIO_COMPRESS_ZLE && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3186 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3187 SPA_VERSION_ZLE_COMPRESSION)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3188 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3189 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3190 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3191 * If this is a bootable dataset then |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3192 * verify that the compression algorithm |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3193 * is supported for booting. We must return |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3194 * something other than ENOTSUP since it |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3195 * implies a downrev pool version. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3196 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3197 if (zfs_is_bootfs(dsname) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3198 !BOOTFS_COMPRESS_VALID(intval)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3199 return (ERANGE); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3200 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3201 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3202 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3203 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3204 case ZFS_PROP_COPIES: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3205 if (zfs_earlier_version(dsname, SPA_VERSION_DITTO_BLOCKS)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3206 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3207 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3208 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3209 case ZFS_PROP_DEDUP: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3210 if (zfs_earlier_version(dsname, SPA_VERSION_DEDUP)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3211 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3212 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3213 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3214 case ZFS_PROP_SHARESMB: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3215 if (zpl_earlier_version(dsname, ZPL_VERSION_FUID)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3216 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3217 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3218 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3219 case ZFS_PROP_ACLINHERIT: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3220 if (nvpair_type(pair) == DATA_TYPE_UINT64 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3221 nvpair_value_uint64(pair, &intval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3222 if (intval == ZFS_ACL_PASSTHROUGH_X && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3223 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3224 SPA_VERSION_PASSTHROUGH_X)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3225 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3226 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3227 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3228 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3229 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3230 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
|
3231 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3232 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3233 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3234 * 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
|
3235 * 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
|
3236 * 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
|
3237 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3238 * 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
|
3239 * 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
|
3240 * 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
|
3241 * 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
|
3242 * returned errlist. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3243 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3244 * 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
|
3245 * pointed at by errlist is NULL. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3246 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3247 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3248 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
|
3249 { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3250 zfs_cmd_t *zc; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3251 nvpair_t *pair, *next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3252 nvlist_t *errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3253 int err, rv = 0; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3254 |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3255 if (props == NULL) |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3256 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3257 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3258 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
|
3259 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3260 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
|
3261 (void) strcpy(zc->zc_name, dataset); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3262 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3263 while (pair != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3264 next_pair = nvlist_next_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3265 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3266 (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
|
3267 if ((err = zfs_check_settable(dataset, pair, CRED())) != 0 || |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3268 (err = zfs_secpolicy_inherit(zc, CRED())) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3269 VERIFY(nvlist_remove_nvpair(props, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3270 VERIFY(nvlist_add_int32(errors, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3271 zc->zc_value, err) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3272 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3273 pair = next_pair; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3274 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3275 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
|
3276 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3277 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
|
3278 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3279 errors = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3280 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3281 VERIFY(nvpair_value_int32(pair, &rv) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3282 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3283 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3284 if (errlist == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3285 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3286 else |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3287 *errlist = errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3288 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3289 return (rv); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3290 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3291 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3292 static boolean_t |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3293 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
|
3294 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3295 if (nvpair_type(p1) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3296 /* dsl_prop_get_all_impl() format */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3297 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3298 VERIFY(nvpair_value_nvlist(p1, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3299 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3300 &p1) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3301 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3302 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3303 if (nvpair_type(p2) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3304 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3305 VERIFY(nvpair_value_nvlist(p2, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3306 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3307 &p2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3308 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3309 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3310 if (nvpair_type(p1) != nvpair_type(p2)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3311 return (B_FALSE); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3312 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3313 if (nvpair_type(p1) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3314 char *valstr1, *valstr2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3315 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3316 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
|
3317 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
|
3318 return (strcmp(valstr1, valstr2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3319 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3320 uint64_t intval1, intval2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3321 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3322 VERIFY(nvpair_value_uint64(p1, &intval1) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3323 VERIFY(nvpair_value_uint64(p2, &intval2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3324 return (intval1 == intval2); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3325 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3326 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3327 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3328 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3329 * 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
|
3330 * 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
|
3331 * 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
|
3332 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3333 static void |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3334 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
|
3335 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3336 nvpair_t *pair, *next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3337 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3338 if (origprops == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3339 return; /* all props need to be received */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3340 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3341 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3342 while (pair != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3343 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3344 nvpair_t *match; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3345 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3346 next_pair = nvlist_next_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3347 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3348 if ((nvlist_lookup_nvpair(origprops, propname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3349 &match) != 0) || !propval_equals(pair, match)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3350 goto next; /* need to set received value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3351 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3352 /* don't clear the existing received value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3353 (void) nvlist_remove_nvpair(origprops, match); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3354 /* don't bother receiving the property */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3355 (void) nvlist_remove_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3356 next: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3357 pair = next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3358 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3359 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3360 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3361 #ifdef DEBUG |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3362 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
|
3363 #endif |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3364 |
5367 | 3365 /* |
3366 * inputs: | |
3367 * zc_name name of containing filesystem | |
3368 * zc_nvlist_src{_size} nvlist of properties to apply | |
3369 * zc_value name of snapshot to create | |
3370 * zc_string name of clone origin (if DRR_FLAG_CLONE) | |
3371 * zc_cookie file descriptor to recv from | |
3372 * zc_begin_record the BEGIN record of the stream (not byteswapped) | |
3373 * zc_guid force flag | |
3374 * | |
3375 * outputs: | |
3376 * zc_cookie number of bytes read | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3377 * 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
|
3378 * zc_obj zprop_errflags_t |
5367 | 3379 */ |
789 | 3380 static int |
5367 | 3381 zfs_ioc_recv(zfs_cmd_t *zc) |
789 | 3382 { |
3383 file_t *fp; | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3384 objset_t *os; |
5367 | 3385 dmu_recv_cookie_t drc; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3386 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
|
3387 int fd; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3388 int error = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3389 int props_error = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3390 nvlist_t *errors; |
5367 | 3391 offset_t off; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3392 nvlist_t *props = NULL; /* sent properties */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3393 nvlist_t *origprops = NULL; /* existing properties */ |
5367 | 3394 objset_t *origin = NULL; |
3395 char *tosnap; | |
3396 char tofs[ZFS_MAXNAMELEN]; | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3397 boolean_t first_recvd_props = B_FALSE; |
789 | 3398 |
3265
967e0fca6143
6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents:
3087
diff
changeset
|
3399 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
|
3400 strchr(zc->zc_value, '@') == NULL || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3401 strchr(zc->zc_value, '%')) |
3265
967e0fca6143
6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents:
3087
diff
changeset
|
3402 return (EINVAL); |
967e0fca6143
6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents:
3087
diff
changeset
|
3403 |
5367 | 3404 (void) strcpy(tofs, zc->zc_value); |
3405 tosnap = strchr(tofs, '@'); | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3406 *tosnap++ = '\0'; |
5367 | 3407 |
3408 if (zc->zc_nvlist_src != NULL && | |
3409 (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
|
3410 zc->zc_iflags, &props)) != 0) |
5367 | 3411 return (error); |
3412 | |
789 | 3413 fd = zc->zc_cookie; |
3414 fp = getf(fd); | |
5367 | 3415 if (fp == NULL) { |
3416 nvlist_free(props); | |
789 | 3417 return (EBADF); |
5367 | 3418 } |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3419 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3420 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
|
3421 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3422 if (props && dmu_objset_hold(tofs, FTAG, &os) == 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3423 if ((spa_version(os->os_spa) >= SPA_VERSION_RECVD_PROPS) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3424 !dsl_prop_get_hasrecvd(os)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3425 first_recvd_props = B_TRUE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3426 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3427 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3428 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3429 * 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
|
3430 * 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
|
3431 * away the existing ones. |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3432 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3433 if (dsl_prop_get_received(os, &origprops) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3434 nvlist_t *errlist = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3435 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3436 * 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
|
3437 * change (and avoid the unnecessary security checks). |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3438 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3439 * 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
|
3440 * 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
|
3441 * regardless. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3442 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3443 if (!first_recvd_props) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3444 props_reduce(props, origprops); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3445 if (zfs_check_clearable(tofs, origprops, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3446 &errlist) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3447 (void) nvlist_merge(errors, errlist, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3448 nvlist_free(errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3449 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3450 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3451 dmu_objset_rele(os, FTAG); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3452 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3453 |
5367 | 3454 if (zc->zc_string[0]) { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3455 error = dmu_objset_hold(zc->zc_string, FTAG, &origin); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3456 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3457 goto out; |
5367 | 3458 } |
3459 | |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10972
diff
changeset
|
3460 error = dmu_recv_begin(tofs, tosnap, zc->zc_top_ds, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10972
diff
changeset
|
3461 &zc->zc_begin_record, force, origin, &drc); |
5367 | 3462 if (origin) |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3463 dmu_objset_rele(origin, FTAG); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3464 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3465 goto out; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3466 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3467 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3468 * Set properties before we receive the stream so that they are applied |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3469 * to the new data. Note that we must call dmu_recv_stream() if |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3470 * dmu_recv_begin() succeeds. |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3471 */ |
5367 | 3472 if (props) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3473 nvlist_t *errlist; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3474 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3475 if (dmu_objset_from_ds(drc.drc_logical_ds, &os) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3476 if (drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3477 if (spa_version(os->os_spa) >= |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3478 SPA_VERSION_RECVD_PROPS) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3479 first_recvd_props = B_TRUE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3480 } else if (origprops != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3481 if (clear_received_props(os, tofs, origprops, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3482 first_recvd_props ? NULL : props) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3483 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3484 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3485 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3486 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3487 dsl_prop_set_hasrecvd(os); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3488 } else if (!drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3489 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3490 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3491 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3492 (void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_RECEIVED, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3493 props, &errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3494 (void) nvlist_merge(errors, errlist, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3495 nvlist_free(errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3496 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3497 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3498 if (fit_error_list(zc, &errors) != 0 || put_nvlist(zc, errors) != 0) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3499 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3500 * 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
|
3501 * 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
|
3502 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3503 props_error = EINVAL; |
5367 | 3504 } |
3505 | |
3506 off = fp->f_offset; | |
3507 error = dmu_recv_stream(&drc, fp->f_vnode, &off); | |
3508 | |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3509 if (error == 0) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3510 zfsvfs_t *zfsvfs = NULL; |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3511 |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3512 if (getzfsvfs(tofs, &zfsvfs) == 0) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3513 /* online recv */ |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3514 int end_err; |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3515 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3516 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
|
3517 /* |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3518 * 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
|
3519 * 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
|
3520 */ |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3521 end_err = dmu_recv_end(&drc); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3522 if (error == 0) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3523 int resume_err = |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3524 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
|
3525 error = error ? error : resume_err; |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3526 } |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3527 error = error ? error : end_err; |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3528 VFS_RELE(zfsvfs->z_vfs); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3529 } else { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3530 error = dmu_recv_end(&drc); |
5367 | 3531 } |
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
|
3532 } |
5367 | 3533 |
3534 zc->zc_cookie = off - fp->f_offset; | |
3535 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) | |
3536 fp->f_offset = off; | |
2885 | 3537 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3538 #ifdef DEBUG |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3539 if (zfs_ioc_recv_inject_err) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3540 zfs_ioc_recv_inject_err = B_FALSE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3541 error = 1; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3542 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3543 #endif |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3544 /* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3545 * On error, restore the original props. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3546 */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3547 if (error && props) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3548 if (dmu_objset_hold(tofs, FTAG, &os) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3549 if (clear_received_props(os, tofs, props, NULL) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3550 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3551 * We failed to clear the received properties. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3552 * Since we may have left a $recvd value on the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3553 * system, we can't clear the $hasrecvd flag. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3554 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3555 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3556 } else if (first_recvd_props) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3557 dsl_prop_unset_hasrecvd(os); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3558 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3559 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3560 } else if (!drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3561 /* We failed to clear the received properties. */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3562 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3563 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3564 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3565 if (origprops == NULL && !drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3566 /* We failed to stash the original properties. */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3567 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3568 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3569 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3570 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3571 * 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
|
3572 * 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
|
3573 * 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
|
3574 * first new-style receive. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3575 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3576 if (origprops != NULL && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3577 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
|
3578 ZPROP_SRC_LOCAL : ZPROP_SRC_RECEIVED), |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3579 origprops, NULL) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3580 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3581 * 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
|
3582 * restore them. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3583 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3584 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3585 } |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3586 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3587 out: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3588 nvlist_free(props); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3589 nvlist_free(origprops); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3590 nvlist_free(errors); |
789 | 3591 releasef(fd); |
11022
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 (error == 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3594 error = props_error; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3595 |
789 | 3596 return (error); |
3597 } | |
3598 | |
5367 | 3599 /* |
3600 * inputs: | |
3601 * zc_name name of snapshot to send | |
3602 * zc_value short name of incremental fromsnap (may be empty) | |
3603 * zc_cookie file descriptor to send stream to | |
3604 * zc_obj fromorigin flag (mutually exclusive with zc_value) | |
3605 * | |
3606 * outputs: none | |
3607 */ | |
789 | 3608 static int |
5367 | 3609 zfs_ioc_send(zfs_cmd_t *zc) |
789 | 3610 { |
3611 objset_t *fromsnap = NULL; | |
3612 objset_t *tosnap; | |
3613 file_t *fp; | |
3614 int error; | |
5367 | 3615 offset_t off; |
789 | 3616 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3617 error = dmu_objset_hold(zc->zc_name, FTAG, &tosnap); |
789 | 3618 if (error) |
3619 return (error); | |
3620 | |
2676 | 3621 if (zc->zc_value[0] != '\0') { |
8012
8ea30813950f
6765626 zfs send takes up too much stack space
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
3622 char *buf; |
2885 | 3623 char *cp; |
3624 | |
8012
8ea30813950f
6765626 zfs send takes up too much stack space
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
3625 buf = kmem_alloc(MAXPATHLEN, KM_SLEEP); |
8ea30813950f
6765626 zfs send takes up too much stack space
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
3626 (void) strncpy(buf, zc->zc_name, MAXPATHLEN); |
2885 | 3627 cp = strchr(buf, '@'); |
3628 if (cp) | |
3629 *(cp+1) = 0; | |
8012
8ea30813950f
6765626 zfs send takes up too much stack space
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
3630 (void) strncat(buf, zc->zc_value, MAXPATHLEN); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3631 error = dmu_objset_hold(buf, FTAG, &fromsnap); |
8012
8ea30813950f
6765626 zfs send takes up too much stack space
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
3632 kmem_free(buf, MAXPATHLEN); |
789 | 3633 if (error) { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3634 dmu_objset_rele(tosnap, FTAG); |
789 | 3635 return (error); |
3636 } | |
3637 } | |
3638 | |
3639 fp = getf(zc->zc_cookie); | |
3640 if (fp == NULL) { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3641 dmu_objset_rele(tosnap, FTAG); |
789 | 3642 if (fromsnap) |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3643 dmu_objset_rele(fromsnap, FTAG); |
789 | 3644 return (EBADF); |
3645 } | |
3646 | |
5367 | 3647 off = fp->f_offset; |
3648 error = dmu_sendbackup(tosnap, fromsnap, zc->zc_obj, fp->f_vnode, &off); | |
3649 | |
3650 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) | |
3651 fp->f_offset = off; | |
789 | 3652 releasef(zc->zc_cookie); |
3653 if (fromsnap) | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3654 dmu_objset_rele(fromsnap, FTAG); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3655 dmu_objset_rele(tosnap, FTAG); |
789 | 3656 return (error); |
3657 } | |
3658 | |
1544 | 3659 static int |
3660 zfs_ioc_inject_fault(zfs_cmd_t *zc) | |
3661 { | |
3662 int id, error; | |
3663 | |
3664 error = zio_inject_fault(zc->zc_name, (int)zc->zc_guid, &id, | |
3665 &zc->zc_inject_record); | |
3666 | |
3667 if (error == 0) | |
3668 zc->zc_guid = (uint64_t)id; | |
3669 | |
3670 return (error); | |
3671 } | |
3672 | |
3673 static int | |
3674 zfs_ioc_clear_fault(zfs_cmd_t *zc) | |
3675 { | |
3676 return (zio_clear_fault((int)zc->zc_guid)); | |
3677 } | |
3678 | |
3679 static int | |
3680 zfs_ioc_inject_list_next(zfs_cmd_t *zc) | |
3681 { | |
3682 int id = (int)zc->zc_guid; | |
3683 int error; | |
3684 | |
3685 error = zio_inject_list_next(&id, zc->zc_name, sizeof (zc->zc_name), | |
3686 &zc->zc_inject_record); | |
3687 | |
3688 zc->zc_guid = id; | |
3689 | |
3690 return (error); | |
3691 } | |
3692 | |
3693 static int | |
3694 zfs_ioc_error_log(zfs_cmd_t *zc) | |
3695 { | |
3696 spa_t *spa; | |
3697 int error; | |
2676 | 3698 size_t count = (size_t)zc->zc_nvlist_dst_size; |
1544 | 3699 |
3700 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) | |
3701 return (error); | |
3702 | |
2676 | 3703 error = spa_get_errlog(spa, (void *)(uintptr_t)zc->zc_nvlist_dst, |
1544 | 3704 &count); |
3705 if (error == 0) | |
2676 | 3706 zc->zc_nvlist_dst_size = count; |
1544 | 3707 else |
2676 | 3708 zc->zc_nvlist_dst_size = spa_get_errlog_size(spa); |
1544 | 3709 |
3710 spa_close(spa, FTAG); | |
3711 | |
3712 return (error); | |
3713 } | |
3714 | |
3715 static int | |
3716 zfs_ioc_clear(zfs_cmd_t *zc) | |
3717 { | |
3718 spa_t *spa; | |
3719 vdev_t *vd; | |
3720 int error; | |
3721 | |
7294 | 3722 /* |
3723 * On zpool clear we also fix up missing slogs | |
3724 */ | |
3725 mutex_enter(&spa_namespace_lock); | |
3726 spa = spa_lookup(zc->zc_name); | |
3727 if (spa == NULL) { | |
3728 mutex_exit(&spa_namespace_lock); | |
3729 return (EIO); | |
3730 } | |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
3731 if (spa_get_log_state(spa) == SPA_LOG_MISSING) { |
7294 | 3732 /* 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
|
3733 spa_set_log_state(spa, SPA_LOG_CLEAR); |
7294 | 3734 } |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3735 spa->spa_last_open_failed = 0; |
7294 | 3736 mutex_exit(&spa_namespace_lock); |
3737 | |
11727
497d03ab2824
6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11546
diff
changeset
|
3738 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
|
3739 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
|
3740 } else { |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3741 nvlist_t *policy; |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3742 nvlist_t *config = NULL; |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3743 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3744 if (zc->zc_nvlist_src == NULL) |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3745 return (EINVAL); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3746 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3747 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
|
3748 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
|
3749 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
|
3750 policy, &config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3751 if (config != NULL) { |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3752 (void) put_nvlist(zc, config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3753 nvlist_free(config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3754 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3755 nvlist_free(policy); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3756 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3757 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3758 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3759 if (error) |
1544 | 3760 return (error); |
3761 | |
10685
931790026ac6
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents:
10672
diff
changeset
|
3762 spa_vdev_state_enter(spa, SCL_NONE); |
1544 | 3763 |
2676 | 3764 if (zc->zc_guid == 0) { |
1544 | 3765 vd = NULL; |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6492
diff
changeset
|
3766 } else { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6492
diff
changeset
|
3767 vd = spa_lookup_by_guid(spa, zc->zc_guid, B_TRUE); |
5450 | 3768 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
|
3769 (void) spa_vdev_state_exit(spa, NULL, ENODEV); |
5450 | 3770 spa_close(spa, FTAG); |
3771 return (ENODEV); | |
3772 } | |
1544 | 3773 } |
3774 | |
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
|
3775 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
|
3776 |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
3777 (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
|
3778 |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
3779 /* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
3780 * 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
|
3781 */ |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
3782 if (zio_resume(spa) != 0) |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
3783 error = EIO; |
1544 | 3784 |
3785 spa_close(spa, FTAG); | |
3786 | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
3787 return (error); |
1544 | 3788 } |
3789 | |
5367 | 3790 /* |
3791 * inputs: | |
3792 * zc_name name of filesystem | |
3793 * zc_value name of origin snapshot | |
3794 * | |
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
|
3795 * 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
|
3796 * zc_string name of conflicting snapshot, if there is one |
5367 | 3797 */ |
1544 | 3798 static int |
2082 | 3799 zfs_ioc_promote(zfs_cmd_t *zc) |
3800 { | |
2417 | 3801 char *cp; |
3802 | |
3803 /* | |
3804 * We don't need to unmount *all* the origin fs's snapshots, but | |
3805 * it's easier. | |
3806 */ | |
2676 | 3807 cp = strchr(zc->zc_value, '@'); |
2417 | 3808 if (cp) |
3809 *cp = '\0'; | |
2676 | 3810 (void) dmu_objset_find(zc->zc_value, |
2417 | 3811 zfs_unmount_snap, 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
|
3812 return (dsl_dataset_promote(zc->zc_name, zc->zc_string)); |
2082 | 3813 } |
3814 | |
4543 | 3815 /* |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3816 * 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
|
3817 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3818 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3819 * 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
|
3820 * 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
|
3821 * 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
|
3822 * 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
|
3823 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3824 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3825 * zc_cookie property value |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3826 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3827 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3828 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
|
3829 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3830 zfsvfs_t *zfsvfs; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3831 int error; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3832 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3833 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3834 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3835 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3836 error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3837 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3838 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3839 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3840 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
|
3841 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
|
3842 zfsvfs_rele(zfsvfs, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3843 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3844 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3845 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3846 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3847 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3848 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3849 * 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
|
3850 * zc_cookie zap cursor |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3851 * 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
|
3852 * 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
|
3853 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3854 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3855 * 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
|
3856 * zc_cookie zap cursor |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3857 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3858 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3859 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
|
3860 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3861 zfsvfs_t *zfsvfs; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3862 int error; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3863 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3864 error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3865 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3866 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3867 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3868 int bufsize = 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
|
3869 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
|
3870 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3871 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
|
3872 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
|
3873 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3874 if (error == 0) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3875 error = xcopyout(buf, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3876 (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
|
3877 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
|
3878 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3879 kmem_free(buf, bufsize); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3880 zfsvfs_rele(zfsvfs, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3881 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3882 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3883 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3884 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3885 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3886 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3887 * 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
|
3888 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3889 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3890 * none |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3891 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3892 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3893 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
|
3894 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3895 objset_t *os; |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
3896 int error = 0; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3897 zfsvfs_t *zfsvfs; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3898 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3899 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
|
3900 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
|
3901 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3902 * 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
|
3903 * 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
|
3904 * 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
|
3905 */ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3906 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
|
3907 if (error == 0) |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3908 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
|
3909 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3910 if (error == 0) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3911 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
|
3912 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
|
3913 } else { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3914 /* 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
|
3915 error = dmu_objset_hold(zc->zc_name, FTAG, &os); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3916 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3917 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3918 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3919 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
|
3920 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
|
3921 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3922 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3923 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3924 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3925 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3926 /* |
4543 | 3927 * We don't want to have a hard dependency |
3928 * against some special symbols in sharefs | |
5331 | 3929 * nfs, and smbsrv. Determine them if needed when |
4543 | 3930 * the first file system is shared. |
5331 | 3931 * Neither sharefs, nfs or smbsrv are unloadable modules. |
4543 | 3932 */ |
5331 | 3933 int (*znfsexport_fs)(void *arg); |
4543 | 3934 int (*zshare_fs)(enum sharefs_sys_op, share_t *, uint32_t); |
5331 | 3935 int (*zsmbexport_fs)(void *arg, boolean_t add_share); |
3936 | |
3937 int zfs_nfsshare_inited; | |
3938 int zfs_smbshare_inited; | |
3939 | |
4543 | 3940 ddi_modhandle_t nfs_mod; |
3941 ddi_modhandle_t sharefs_mod; | |
5331 | 3942 ddi_modhandle_t smbsrv_mod; |
4543 | 3943 kmutex_t zfs_share_lock; |
3944 | |
3945 static int | |
5331 | 3946 zfs_init_sharefs() |
3947 { | |
3948 int error; | |
3949 | |
3950 ASSERT(MUTEX_HELD(&zfs_share_lock)); | |
3951 /* Both NFS and SMB shares also require sharetab support. */ | |
3952 if (sharefs_mod == NULL && ((sharefs_mod = | |
3953 ddi_modopen("fs/sharefs", | |
3954 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
3955 return (ENOSYS); | |
3956 } | |
3957 if (zshare_fs == NULL && ((zshare_fs = | |
3958 (int (*)(enum sharefs_sys_op, share_t *, uint32_t)) | |
3959 ddi_modsym(sharefs_mod, "sharefs_impl", &error)) == NULL)) { | |
3960 return (ENOSYS); | |
3961 } | |
3962 return (0); | |
3963 } | |
3964 | |
3965 static int | |
4543 | 3966 zfs_ioc_share(zfs_cmd_t *zc) |
3967 { | |
3968 int error; | |
3969 int opcode; | |
3970 | |
5331 | 3971 switch (zc->zc_share.z_sharetype) { |
3972 case ZFS_SHARE_NFS: | |
3973 case ZFS_UNSHARE_NFS: | |
3974 if (zfs_nfsshare_inited == 0) { | |
3975 mutex_enter(&zfs_share_lock); | |
3976 if (nfs_mod == NULL && ((nfs_mod = ddi_modopen("fs/nfs", | |
3977 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
3978 mutex_exit(&zfs_share_lock); | |
3979 return (ENOSYS); | |
3980 } | |
3981 if (znfsexport_fs == NULL && | |
3982 ((znfsexport_fs = (int (*)(void *)) | |
3983 ddi_modsym(nfs_mod, | |
3984 "nfs_export", &error)) == NULL)) { | |
3985 mutex_exit(&zfs_share_lock); | |
3986 return (ENOSYS); | |
3987 } | |
3988 error = zfs_init_sharefs(); | |
3989 if (error) { | |
3990 mutex_exit(&zfs_share_lock); | |
3991 return (ENOSYS); | |
3992 } | |
3993 zfs_nfsshare_inited = 1; | |
4543 | 3994 mutex_exit(&zfs_share_lock); |
3995 } | |
5331 | 3996 break; |
3997 case ZFS_SHARE_SMB: | |
3998 case ZFS_UNSHARE_SMB: | |
3999 if (zfs_smbshare_inited == 0) { | |
4000 mutex_enter(&zfs_share_lock); | |
4001 if (smbsrv_mod == NULL && ((smbsrv_mod = | |
4002 ddi_modopen("drv/smbsrv", | |
4003 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
4004 mutex_exit(&zfs_share_lock); | |
4005 return (ENOSYS); | |
4006 } | |
4007 if (zsmbexport_fs == NULL && ((zsmbexport_fs = | |
4008 (int (*)(void *, boolean_t))ddi_modsym(smbsrv_mod, | |
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6083
diff
changeset
|
4009 "smb_server_share", &error)) == NULL)) { |
5331 | 4010 mutex_exit(&zfs_share_lock); |
4011 return (ENOSYS); | |
4012 } | |
4013 error = zfs_init_sharefs(); | |
4014 if (error) { | |
4015 mutex_exit(&zfs_share_lock); | |
4016 return (ENOSYS); | |
4017 } | |
4018 zfs_smbshare_inited = 1; | |
4543 | 4019 mutex_exit(&zfs_share_lock); |
4020 } | |
5331 | 4021 break; |
4022 default: | |
4023 return (EINVAL); | |
4543 | 4024 } |
4025 | |
5331 | 4026 switch (zc->zc_share.z_sharetype) { |
4027 case ZFS_SHARE_NFS: | |
4028 case ZFS_UNSHARE_NFS: | |
4029 if (error = | |
4030 znfsexport_fs((void *) | |
4031 (uintptr_t)zc->zc_share.z_exportdata)) | |
4032 return (error); | |
4033 break; | |
4034 case ZFS_SHARE_SMB: | |
4035 case ZFS_UNSHARE_SMB: | |
4036 if (error = zsmbexport_fs((void *) | |
4037 (uintptr_t)zc->zc_share.z_exportdata, | |
4038 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
|
4039 B_TRUE: B_FALSE)) { |
5331 | 4040 return (error); |
4041 } | |
4042 break; | |
4043 } | |
4044 | |
4045 opcode = (zc->zc_share.z_sharetype == ZFS_SHARE_NFS || | |
4046 zc->zc_share.z_sharetype == ZFS_SHARE_SMB) ? | |
4543 | 4047 SHAREFS_ADD : SHAREFS_REMOVE; |
4048 | |
5331 | 4049 /* |
4050 * Add or remove share from sharetab | |
4051 */ | |
4543 | 4052 error = zshare_fs(opcode, |
4053 (void *)(uintptr_t)zc->zc_share.z_sharedata, | |
4054 zc->zc_share.z_sharemax); | |
4055 | |
4056 return (error); | |
4057 | |
4058 } | |
4059 | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4060 ace_t full_access[] = { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4061 {(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
|
4062 }; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4063 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4064 /* |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4065 * 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
|
4066 */ |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4067 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4068 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
|
4069 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4070 zap_cursor_t zc; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4071 zap_attribute_t zap; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4072 zfsvfs_t *zfsvfs = dzp->z_zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4073 int error; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4074 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4075 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
|
4076 (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
|
4077 zap_cursor_advance(&zc)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4078 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
|
4079 NULL, 0)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4080 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4081 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4082 zap_cursor_fini(&zc); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4083 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4084 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4085 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4086 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4087 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
|
4088 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4089 vnode_t *vp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4090 znode_t *dzp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4091 vnode_t *resourcevp = NULL; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4092 znode_t *sharedir; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4093 zfsvfs_t *zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4094 nvlist_t *nvlist; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4095 char *src, *target; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4096 vattr_t vattr; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4097 vsecattr_t vsec; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4098 int error = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4099 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4100 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
|
4101 NO_FOLLOW, NULL, &vp)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4102 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4103 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4104 /* 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
|
4105 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4106 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
|
4107 (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
|
4108 zc->zc_name) != 0)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4109 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4110 return (EINVAL); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4111 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4112 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4113 dzp = VTOZ(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4114 zfsvfs = dzp->z_zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4115 ZFS_ENTER(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4116 |
9030
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4117 /* |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4118 * 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
|
4119 */ |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4120 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
|
4121 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
|
4122 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
|
4123 |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4124 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
|
4125 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
|
4126 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
|
4127 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
|
4128 error = dmu_tx_assign(tx, TXG_WAIT); |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4129 if (error) { |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4130 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
|
4131 } else { |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4132 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
|
4133 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
|
4134 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4135 if (error) { |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4136 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
|
4137 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
|
4138 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
|
4139 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
|
4140 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4141 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4142 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
|
4143 |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4144 ASSERT(zfsvfs->z_shares_dir); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4145 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
|
4146 VN_RELE(vp); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4147 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4148 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4149 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4150 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4151 switch (zc->zc_cookie) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4152 case ZFS_SMB_ACL_ADD: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4153 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
|
4154 vattr.va_type = VREG; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4155 vattr.va_mode = S_IFREG|0777; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4156 vattr.va_uid = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4157 vattr.va_gid = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4158 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4159 vsec.vsa_mask = VSA_ACE; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4160 vsec.vsa_aclentp = &full_access; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4161 vsec.vsa_aclentsz = sizeof (full_access); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4162 vsec.vsa_aclcnt = 1; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4163 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4164 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
|
4165 &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
|
4166 if (resourcevp) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4167 VN_RELE(resourcevp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4168 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4169 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4170 case ZFS_SMB_ACL_REMOVE: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4171 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
|
4172 NULL, 0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4173 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4174 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4175 case ZFS_SMB_ACL_RENAME: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4176 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
|
4177 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
|
4178 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4179 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4180 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4181 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4182 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
|
4183 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
|
4184 &target)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4185 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
|
4186 VN_RELE(ZTOV(sharedir)); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4187 ZFS_EXIT(zfsvfs); |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4188 nvlist_free(nvlist); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4189 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4190 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4191 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
|
4192 kcred, NULL, 0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4193 nvlist_free(nvlist); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4194 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4195 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4196 case ZFS_SMB_ACL_PURGE: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4197 error = zfs_smb_acl_purge(sharedir); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4198 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4199 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4200 default: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4201 error = EINVAL; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4202 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4203 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4204 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4205 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4206 VN_RELE(ZTOV(sharedir)); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4207 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4208 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4209 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4210 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4211 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4212 |
4543 | 4213 /* |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4214 * inputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4215 * zc_name name of filesystem |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4216 * zc_value short name of snap |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4217 * zc_string user-supplied tag for this reference |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4218 * zc_cookie recursive flag |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4219 * zc_temphold set if hold is temporary |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4220 * |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4221 * outputs: none |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4222 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4223 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4224 zfs_ioc_hold(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4225 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4226 boolean_t recursive = zc->zc_cookie; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4227 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4228 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4229 return (EINVAL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4230 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4231 return (dsl_dataset_user_hold(zc->zc_name, zc->zc_value, |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4232 zc->zc_string, recursive, zc->zc_temphold)); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4233 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4234 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4235 /* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4236 * inputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4237 * zc_name name of dataset from which we're releasing a user reference |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4238 * zc_value short name of snap |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4239 * zc_string user-supplied tag for this reference |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4240 * zc_cookie recursive flag |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4241 * |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4242 * outputs: none |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4243 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4244 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4245 zfs_ioc_release(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4246 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4247 boolean_t recursive = zc->zc_cookie; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4248 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4249 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4250 return (EINVAL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4251 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4252 return (dsl_dataset_user_release(zc->zc_name, zc->zc_value, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4253 zc->zc_string, recursive)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4254 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4255 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4256 /* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4257 * inputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4258 * zc_name name of filesystem |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4259 * |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4260 * outputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4261 * zc_nvlist_src{_size} nvlist of snapshot holds |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4262 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4263 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4264 zfs_ioc_get_holds(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4265 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4266 nvlist_t *nvp; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4267 int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4268 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4269 if ((error = dsl_dataset_get_holds(zc->zc_name, &nvp)) == 0) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4270 error = put_nvlist(zc, nvp); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4271 nvlist_free(nvp); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4272 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4273 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4274 return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4275 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4276 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4277 /* |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
4278 * pool create, destroy, and export don't log the history as part of |
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
4279 * zfsdev_ioctl, but rather zfs_ioc_pool_create, and zfs_ioc_pool_export |
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
4280 * do the logging of those commands. |
4543 | 4281 */ |
789 | 4282 static zfs_ioc_vec_t zfs_ioc_vec[] = { |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4283 { zfs_ioc_pool_create, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4284 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4285 { zfs_ioc_pool_destroy, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4286 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4287 { zfs_ioc_pool_import, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4288 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4289 { zfs_ioc_pool_export, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4290 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4291 { zfs_ioc_pool_configs, zfs_secpolicy_none, NO_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4292 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4293 { zfs_ioc_pool_stats, zfs_secpolicy_read, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4294 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4295 { zfs_ioc_pool_tryimport, zfs_secpolicy_config, NO_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4296 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4297 { zfs_ioc_pool_scrub, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4298 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4299 { zfs_ioc_pool_freeze, zfs_secpolicy_config, NO_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4300 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4301 { zfs_ioc_pool_upgrade, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4302 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4303 { zfs_ioc_pool_get_history, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4304 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4305 { zfs_ioc_vdev_add, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4306 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4307 { zfs_ioc_vdev_remove, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4308 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4309 { zfs_ioc_vdev_set_state, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4310 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4311 { zfs_ioc_vdev_attach, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4312 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4313 { zfs_ioc_vdev_detach, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4314 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4315 { zfs_ioc_vdev_setpath, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4316 B_TRUE }, |
9425
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
4317 { zfs_ioc_vdev_setfru, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
4318 B_TRUE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4319 { zfs_ioc_objset_stats, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
11454
6e69bacc1a5a
6898245 suspended zpool should not cause rest of the zfs/zpool commands to hang
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
11422
diff
changeset
|
4320 B_TRUE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4321 { zfs_ioc_objset_zplprops, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4322 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4323 { zfs_ioc_dataset_list_next, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
11454
6e69bacc1a5a
6898245 suspended zpool should not cause rest of the zfs/zpool commands to hang
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
11422
diff
changeset
|
4324 B_TRUE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4325 { zfs_ioc_snapshot_list_next, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
11454
6e69bacc1a5a
6898245 suspended zpool should not cause rest of the zfs/zpool commands to hang
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
11422
diff
changeset
|
4326 B_TRUE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4327 { zfs_ioc_set_prop, zfs_secpolicy_none, DATASET_NAME, B_TRUE, B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4328 { zfs_ioc_create, zfs_secpolicy_create, DATASET_NAME, B_TRUE, B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4329 { zfs_ioc_destroy, zfs_secpolicy_destroy, DATASET_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4330 B_TRUE}, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4331 { zfs_ioc_rollback, zfs_secpolicy_rollback, DATASET_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4332 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4333 { zfs_ioc_rename, zfs_secpolicy_rename, DATASET_NAME, B_TRUE, B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4334 { zfs_ioc_recv, zfs_secpolicy_receive, DATASET_NAME, B_TRUE, B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4335 { zfs_ioc_send, zfs_secpolicy_send, DATASET_NAME, B_TRUE, B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4336 { zfs_ioc_inject_fault, zfs_secpolicy_inject, NO_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4337 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4338 { zfs_ioc_clear_fault, zfs_secpolicy_inject, NO_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4339 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4340 { zfs_ioc_inject_list_next, zfs_secpolicy_inject, NO_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4341 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4342 { zfs_ioc_error_log, zfs_secpolicy_inject, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4343 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4344 { zfs_ioc_clear, zfs_secpolicy_config, POOL_NAME, B_TRUE, B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4345 { zfs_ioc_promote, zfs_secpolicy_promote, DATASET_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4346 B_TRUE }, |
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
|
4347 { zfs_ioc_destroy_snaps, zfs_secpolicy_destroy_snaps, DATASET_NAME, |
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
|
4348 B_TRUE, B_TRUE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4349 { zfs_ioc_snapshot, zfs_secpolicy_snapshot, DATASET_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4350 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4351 { zfs_ioc_dsobj_to_dsname, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4352 B_FALSE }, |
10233
620468fcb233
6843474 zpool status -v hangs when all disks are unavailable
George Wilson <George.Wilson@Sun.COM>
parents:
10204
diff
changeset
|
4353 { zfs_ioc_obj_to_path, zfs_secpolicy_config, DATASET_NAME, B_FALSE, |
620468fcb233
6843474 zpool status -v hangs when all disks are unavailable
George Wilson <George.Wilson@Sun.COM>
parents:
10204
diff
changeset
|
4354 B_TRUE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4355 { zfs_ioc_pool_set_props, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4356 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4357 { zfs_ioc_pool_get_props, zfs_secpolicy_read, POOL_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4358 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4359 { zfs_ioc_set_fsacl, zfs_secpolicy_fsacl, DATASET_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4360 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4361 { zfs_ioc_get_fsacl, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4362 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4363 { zfs_ioc_iscsi_perm_check, zfs_secpolicy_iscsi, DATASET_NAME, B_FALSE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4364 B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4365 { zfs_ioc_share, zfs_secpolicy_share, DATASET_NAME, B_FALSE, B_FALSE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4366 { zfs_ioc_inherit_prop, zfs_secpolicy_inherit, DATASET_NAME, B_TRUE, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4367 B_TRUE }, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4368 { zfs_ioc_smb_acl, zfs_secpolicy_smb_acl, DATASET_NAME, B_FALSE, |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4369 B_FALSE }, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4370 { zfs_ioc_userspace_one, zfs_secpolicy_userspace_one, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4371 DATASET_NAME, B_FALSE, B_FALSE }, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4372 { zfs_ioc_userspace_many, zfs_secpolicy_userspace_many, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4373 DATASET_NAME, B_FALSE, B_FALSE }, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4374 { zfs_ioc_userspace_upgrade, zfs_secpolicy_userspace_upgrade, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4375 DATASET_NAME, B_FALSE, B_TRUE }, |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4376 { zfs_ioc_hold, zfs_secpolicy_hold, DATASET_NAME, B_TRUE, B_TRUE }, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4377 { zfs_ioc_release, zfs_secpolicy_release, DATASET_NAME, B_TRUE, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4378 B_TRUE }, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4379 { zfs_ioc_get_holds, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
4380 B_TRUE }, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
4381 { zfs_ioc_objset_recvd_props, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4382 B_FALSE }, |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4383 { zfs_ioc_vdev_split, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4384 B_TRUE } |
789 | 4385 }; |
4386 | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4387 int |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4388 pool_status_check(const char *name, zfs_ioc_namecheck_t type) |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4389 { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4390 spa_t *spa; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4391 int error; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4392 |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4393 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
|
4394 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4395 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
|
4396 if (error == 0) { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4397 if (spa_suspended(spa)) |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4398 error = EAGAIN; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4399 spa_close(spa, FTAG); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4400 } |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4401 return (error); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4402 } |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4403 |
789 | 4404 static int |
4405 zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) | |
4406 { | |
4407 zfs_cmd_t *zc; | |
4408 uint_t vec; | |
2199 | 4409 int error, rc; |
789 | 4410 |
4411 if (getminor(dev) != 0) | |
4412 return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp)); | |
4413 | |
4414 vec = cmd - ZFS_IOC; | |
4787 | 4415 ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip)); |
789 | 4416 |
4417 if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0])) | |
4418 return (EINVAL); | |
4419 | |
4420 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); | |
4421 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
4422 error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag); |
789 | 4423 |
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
|
4424 if ((error == 0) && !(flag & FKIOCTL)) |
4543 | 4425 error = zfs_ioc_vec[vec].zvec_secpolicy(zc, cr); |
789 | 4426 |
4427 /* | |
4428 * Ensure that all pool/dataset names are valid before we pass down to | |
4429 * the lower layers. | |
4430 */ | |
4431 if (error == 0) { | |
4432 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
4433 zc->zc_iflags = flag & FKIOCTL; |
789 | 4434 switch (zfs_ioc_vec[vec].zvec_namecheck) { |
4577 | 4435 case POOL_NAME: |
789 | 4436 if (pool_namecheck(zc->zc_name, NULL, NULL) != 0) |
4437 error = EINVAL; | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4438 if (zfs_ioc_vec[vec].zvec_pool_check) |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4439 error = pool_status_check(zc->zc_name, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4440 zfs_ioc_vec[vec].zvec_namecheck); |
789 | 4441 break; |
4442 | |
4577 | 4443 case DATASET_NAME: |
789 | 4444 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0) |
4445 error = EINVAL; | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4446 if (zfs_ioc_vec[vec].zvec_pool_check) |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4447 error = pool_status_check(zc->zc_name, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4448 zfs_ioc_vec[vec].zvec_namecheck); |
789 | 4449 break; |
2856 | 4450 |
4577 | 4451 case NO_NAME: |
2856 | 4452 break; |
789 | 4453 } |
4454 } | |
4455 | |
4456 if (error == 0) | |
4457 error = zfs_ioc_vec[vec].zvec_func(zc); | |
4458 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
4459 rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag); |
4543 | 4460 if (error == 0) { |
2199 | 4461 error = rc; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4462 if (zfs_ioc_vec[vec].zvec_his_log) |
4543 | 4463 zfs_log_history(zc); |
4464 } | |
789 | 4465 |
4466 kmem_free(zc, sizeof (zfs_cmd_t)); | |
4467 return (error); | |
4468 } | |
4469 | |
4470 static int | |
4471 zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) | |
4472 { | |
4473 if (cmd != DDI_ATTACH) | |
4474 return (DDI_FAILURE); | |
4475 | |
4476 if (ddi_create_minor_node(dip, "zfs", S_IFCHR, 0, | |
4477 DDI_PSEUDO, 0) == DDI_FAILURE) | |
4478 return (DDI_FAILURE); | |
4479 | |
4480 zfs_dip = dip; | |
4481 | |
4482 ddi_report_dev(dip); | |
4483 | |
4484 return (DDI_SUCCESS); | |
4485 } | |
4486 | |
4487 static int | |
4488 zfs_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) | |
4489 { | |
4490 if (spa_busy() || zfs_busy() || zvol_busy()) | |
4491 return (DDI_FAILURE); | |
4492 | |
4493 if (cmd != DDI_DETACH) | |
4494 return (DDI_FAILURE); | |
4495 | |
4496 zfs_dip = NULL; | |
4497 | |
4498 ddi_prop_remove_all(dip); | |
4499 ddi_remove_minor_node(dip, NULL); | |
4500 | |
4501 return (DDI_SUCCESS); | |
4502 } | |
4503 | |
4504 /*ARGSUSED*/ | |
4505 static int | |
4506 zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) | |
4507 { | |
4508 switch (infocmd) { | |
4509 case DDI_INFO_DEVT2DEVINFO: | |
4510 *result = zfs_dip; | |
4511 return (DDI_SUCCESS); | |
4512 | |
4513 case DDI_INFO_DEVT2INSTANCE: | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4514 *result = (void *)0; |
789 | 4515 return (DDI_SUCCESS); |
4516 } | |
4517 | |
4518 return (DDI_FAILURE); | |
4519 } | |
4520 | |
4521 /* | |
4522 * OK, so this is a little weird. | |
4523 * | |
4524 * /dev/zfs is the control node, i.e. minor 0. | |
4525 * /dev/zvol/[r]dsk/pool/dataset are the zvols, minor > 0. | |
4526 * | |
4527 * /dev/zfs has basically nothing to do except serve up ioctls, | |
4528 * so most of the standard driver entry points are in zvol.c. | |
4529 */ | |
4530 static struct cb_ops zfs_cb_ops = { | |
4531 zvol_open, /* open */ | |
4532 zvol_close, /* close */ | |
4533 zvol_strategy, /* strategy */ | |
4534 nodev, /* print */ | |
6423 | 4535 zvol_dump, /* dump */ |
789 | 4536 zvol_read, /* read */ |
4537 zvol_write, /* write */ | |
4538 zfsdev_ioctl, /* ioctl */ | |
4539 nodev, /* devmap */ | |
4540 nodev, /* mmap */ | |
4541 nodev, /* segmap */ | |
4542 nochpoll, /* poll */ | |
4543 ddi_prop_op, /* prop_op */ | |
4544 NULL, /* streamtab */ | |
4545 D_NEW | D_MP | D_64BIT, /* Driver compatibility flag */ | |
4546 CB_REV, /* version */ | |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3444
diff
changeset
|
4547 nodev, /* async read */ |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3444
diff
changeset
|
4548 nodev, /* async write */ |
789 | 4549 }; |
4550 | |
4551 static struct dev_ops zfs_dev_ops = { | |
4552 DEVO_REV, /* version */ | |
4553 0, /* refcnt */ | |
4554 zfs_info, /* info */ | |
4555 nulldev, /* identify */ | |
4556 nulldev, /* probe */ | |
4557 zfs_attach, /* attach */ | |
4558 zfs_detach, /* detach */ | |
4559 nodev, /* reset */ | |
4560 &zfs_cb_ops, /* driver operations */ | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
4561 NULL, /* no bus operations */ |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
4562 NULL, /* power */ |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
4563 ddi_quiesce_not_needed, /* quiesce */ |
789 | 4564 }; |
4565 | |
4566 static struct modldrv zfs_modldrv = { | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
4567 &mod_driverops, |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
4568 "ZFS storage pool", |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
4569 &zfs_dev_ops |
789 | 4570 }; |
4571 | |
4572 static struct modlinkage modlinkage = { | |
4573 MODREV_1, | |
4574 (void *)&zfs_modlfs, | |
4575 (void *)&zfs_modldrv, | |
4576 NULL | |
4577 }; | |
4578 | |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
4579 |
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
4580 uint_t zfs_fsyncer_key; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
4581 extern uint_t rrw_tsd_key; |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
4582 |
789 | 4583 int |
4584 _init(void) | |
4585 { | |
4586 int error; | |
4587 | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4588 spa_init(FREAD | FWRITE); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4589 zfs_init(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4590 zvol_init(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4591 |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4592 if ((error = mod_install(&modlinkage)) != 0) { |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4593 zvol_fini(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4594 zfs_fini(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4595 spa_fini(); |
789 | 4596 return (error); |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4597 } |
789 | 4598 |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
4599 tsd_create(&zfs_fsyncer_key, NULL); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
4600 tsd_create(&rrw_tsd_key, NULL); |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
4601 |
789 | 4602 error = ldi_ident_from_mod(&modlinkage, &zfs_li); |
4603 ASSERT(error == 0); | |
4543 | 4604 mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL); |
789 | 4605 |
4606 return (0); | |
4607 } | |
4608 | |
4609 int | |
4610 _fini(void) | |
4611 { | |
4612 int error; | |
4613 | |
1544 | 4614 if (spa_busy() || zfs_busy() || zvol_busy() || zio_injection_enabled) |
789 | 4615 return (EBUSY); |
4616 | |
4617 if ((error = mod_remove(&modlinkage)) != 0) | |
4618 return (error); | |
4619 | |
4620 zvol_fini(); | |
4621 zfs_fini(); | |
4622 spa_fini(); | |
5331 | 4623 if (zfs_nfsshare_inited) |
4543 | 4624 (void) ddi_modclose(nfs_mod); |
5331 | 4625 if (zfs_smbshare_inited) |
4626 (void) ddi_modclose(smbsrv_mod); | |
4627 if (zfs_nfsshare_inited || zfs_smbshare_inited) | |
4543 | 4628 (void) ddi_modclose(sharefs_mod); |
789 | 4629 |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
4630 tsd_destroy(&zfs_fsyncer_key); |
789 | 4631 ldi_ident_release(zfs_li); |
4632 zfs_li = NULL; | |
4543 | 4633 mutex_destroy(&zfs_share_lock); |
789 | 4634 |
4635 return (error); | |
4636 } | |
4637 | |
4638 int | |
4639 _info(struct modinfo *modinfop) | |
4640 { | |
4641 return (mod_info(&modlinkage, modinfop)); | |
4642 } |