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