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