Mercurial > illumos > illumos-gate
annotate usr/src/uts/common/fs/zfs/zfs_ioctl.c @ 13512:060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
author | Richard Lowe <richlowe@richlowe.net> |
---|---|
date | Tue, 08 Nov 2011 17:01:06 -0500 |
parents | 04570f5cbeca |
children | 417c34452f03 |
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 /* | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
13492
83d135508f56
1346 zfs incremental receive may leave behind temporary clones
Martin Matuska <mm@FreeBSD.org>
parents:
13061
diff
changeset
|
23 * Portions Copyright 2011 Martin Matuska |
789 | 24 */ |
25 | |
26 #include <sys/types.h> | |
27 #include <sys/param.h> | |
28 #include <sys/errno.h> | |
29 #include <sys/uio.h> | |
30 #include <sys/buf.h> | |
31 #include <sys/modctl.h> | |
32 #include <sys/open.h> | |
33 #include <sys/file.h> | |
34 #include <sys/kmem.h> | |
35 #include <sys/conf.h> | |
36 #include <sys/cmn_err.h> | |
37 #include <sys/stat.h> | |
38 #include <sys/zfs_ioctl.h> | |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
39 #include <sys/zfs_vfsops.h> |
5331 | 40 #include <sys/zfs_znode.h> |
789 | 41 #include <sys/zap.h> |
42 #include <sys/spa.h> | |
3912 | 43 #include <sys/spa_impl.h> |
789 | 44 #include <sys/vdev.h> |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
45 #include <sys/priv_impl.h> |
789 | 46 #include <sys/dmu.h> |
47 #include <sys/dsl_dir.h> | |
48 #include <sys/dsl_dataset.h> | |
49 #include <sys/dsl_prop.h> | |
4543 | 50 #include <sys/dsl_deleg.h> |
51 #include <sys/dmu_objset.h> | |
789 | 52 #include <sys/ddi.h> |
53 #include <sys/sunddi.h> | |
54 #include <sys/sunldi.h> | |
55 #include <sys/policy.h> | |
56 #include <sys/zone.h> | |
57 #include <sys/nvpair.h> | |
58 #include <sys/pathname.h> | |
59 #include <sys/mount.h> | |
60 #include <sys/sdt.h> | |
61 #include <sys/fs/zfs.h> | |
62 #include <sys/zfs_ctldir.h> | |
5331 | 63 #include <sys/zfs_dir.h> |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
64 #include <sys/zfs_onexit.h> |
2885 | 65 #include <sys/zvol.h> |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
66 #include <sys/dsl_scan.h> |
4543 | 67 #include <sharefs/share.h> |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
68 #include <sys/dmu_objset.h> |
789 | 69 |
70 #include "zfs_namecheck.h" | |
2676 | 71 #include "zfs_prop.h" |
4543 | 72 #include "zfs_deleg.h" |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
73 #include "zfs_comutil.h" |
789 | 74 |
75 extern struct modlfs zfs_modlfs; | |
76 | |
77 extern void zfs_init(void); | |
78 extern void zfs_fini(void); | |
79 | |
80 ldi_ident_t zfs_li = NULL; | |
81 dev_info_t *zfs_dip; | |
82 | |
83 typedef int zfs_ioc_func_t(zfs_cmd_t *); | |
4543 | 84 typedef int zfs_secpolicy_func_t(zfs_cmd_t *, cred_t *); |
789 | 85 |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
86 typedef enum { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
87 NO_NAME, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
88 POOL_NAME, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
89 DATASET_NAME |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
90 } zfs_ioc_namecheck_t; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
91 |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
92 typedef enum { |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
93 POOL_CHECK_NONE = 1 << 0, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
94 POOL_CHECK_SUSPENDED = 1 << 1, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
95 POOL_CHECK_READONLY = 1 << 2 |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
96 } zfs_ioc_poolcheck_t; |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
97 |
789 | 98 typedef struct zfs_ioc_vec { |
99 zfs_ioc_func_t *zvec_func; | |
100 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
|
101 zfs_ioc_namecheck_t zvec_namecheck; |
4543 | 102 boolean_t zvec_his_log; |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
103 zfs_ioc_poolcheck_t zvec_pool_check; |
789 | 104 } zfs_ioc_vec_t; |
105 | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
106 /* This array is indexed by zfs_userquota_prop_t */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
107 static const char *userquota_perms[] = { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
108 ZFS_DELEG_PERM_USERUSED, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
109 ZFS_DELEG_PERM_USERQUOTA, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
110 ZFS_DELEG_PERM_GROUPUSED, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
111 ZFS_DELEG_PERM_GROUPQUOTA, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
112 }; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
113 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
114 static int zfs_ioc_userspace_upgrade(zfs_cmd_t *zc); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
115 static int zfs_check_settable(const char *name, nvpair_t *property, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
116 cred_t *cr); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
117 static int zfs_check_clearable(char *dataset, nvlist_t *props, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
118 nvlist_t **errors); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
119 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
|
120 boolean_t *); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
121 int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t **); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
122 |
789 | 123 /* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */ |
124 void | |
125 __dprintf(const char *file, const char *func, int line, const char *fmt, ...) | |
126 { | |
127 const char *newfile; | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
128 char buf[512]; |
789 | 129 va_list adx; |
130 | |
131 /* | |
132 * Get rid of annoying "../common/" prefix to filename. | |
133 */ | |
134 newfile = strrchr(file, '/'); | |
135 if (newfile != NULL) { | |
136 newfile = newfile + 1; /* Get rid of leading / */ | |
137 } else { | |
138 newfile = file; | |
139 } | |
140 | |
141 va_start(adx, fmt); | |
142 (void) vsnprintf(buf, sizeof (buf), fmt, adx); | |
143 va_end(adx); | |
144 | |
145 /* | |
146 * To get this data, use the zfs-dprintf probe as so: | |
147 * dtrace -q -n 'zfs-dprintf \ | |
148 * /stringof(arg0) == "dbuf.c"/ \ | |
149 * {printf("%s: %s", stringof(arg1), stringof(arg3))}' | |
150 * arg0 = file name | |
151 * arg1 = function name | |
152 * arg2 = line number | |
153 * arg3 = message | |
154 */ | |
155 DTRACE_PROBE4(zfs__dprintf, | |
156 char *, newfile, char *, func, int, line, char *, buf); | |
157 } | |
158 | |
4543 | 159 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
|
160 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
|
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 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
|
163 } |
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4670
diff
changeset
|
164 |
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4670
diff
changeset
|
165 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
|
166 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
|
167 { |
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4670
diff
changeset
|
168 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
|
169 |
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4670
diff
changeset
|
170 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
|
171 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
|
172 |
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4670
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 } |
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
|
179 |
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
|
180 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
|
181 |
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
|
182 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
|
183 } |
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
|
184 |
5375 | 185 /* |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
186 * 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
|
187 */ |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
188 static boolean_t |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
189 zfs_is_bootfs(const char *name) |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
190 { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
191 objset_t *os; |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
192 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
193 if (dmu_objset_hold(name, FTAG, &os) == 0) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
194 boolean_t ret; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
195 ret = (dmu_objset_id(os) == spa_bootfs(dmu_objset_spa(os))); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
196 dmu_objset_rele(os, FTAG); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
197 return (ret); |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
198 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
199 return (B_FALSE); |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
200 } |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
201 |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
202 /* |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
203 * zfs_earlier_version |
5375 | 204 * |
205 * Return non-zero if the spa version is less than requested version. | |
206 */ | |
5331 | 207 static int |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
208 zfs_earlier_version(const char *name, int version) |
5331 | 209 { |
210 spa_t *spa; | |
211 | |
212 if (spa_open(name, &spa, FTAG) == 0) { | |
213 if (spa_version(spa) < version) { | |
214 spa_close(spa, FTAG); | |
215 return (1); | |
216 } | |
217 spa_close(spa, FTAG); | |
218 } | |
219 return (0); | |
220 } | |
221 | |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
222 /* |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
223 * zpl_earlier_version |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
224 * |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
225 * 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
|
226 */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
227 static boolean_t |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
228 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
|
229 { |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
230 objset_t *os; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
231 boolean_t rc = B_TRUE; |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
232 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
233 if (dmu_objset_hold(name, FTAG, &os) == 0) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
234 uint64_t zplversion; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
235 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
236 if (dmu_objset_type(os) != DMU_OST_ZFS) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
237 dmu_objset_rele(os, FTAG); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
238 return (B_TRUE); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
239 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
240 /* XXX reading from non-owned objset */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
241 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
|
242 rc = zplversion < version; |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
243 dmu_objset_rele(os, FTAG); |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
244 } |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
245 return (rc); |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
246 } |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
247 |
4715
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4670
diff
changeset
|
248 static void |
4543 | 249 zfs_log_history(zfs_cmd_t *zc) |
250 { | |
251 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
|
252 char *buf; |
4543 | 253 |
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
|
254 if ((buf = history_str_get(zc)) == NULL) |
4577 | 255 return; |
256 | |
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
|
257 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
|
258 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
|
259 (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
|
260 spa_close(spa, FTAG); |
4543 | 261 } |
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
|
262 history_str_free(buf); |
4543 | 263 } |
264 | |
789 | 265 /* |
266 * Policy for top-level read operations (list pools). Requires no privileges, | |
267 * and can be used in the local zone, as there is no associated dataset. | |
268 */ | |
269 /* ARGSUSED */ | |
270 static int | |
4543 | 271 zfs_secpolicy_none(zfs_cmd_t *zc, cred_t *cr) |
789 | 272 { |
273 return (0); | |
274 } | |
275 | |
276 /* | |
277 * Policy for dataset read operations (list children, get statistics). Requires | |
278 * no privileges, but must be visible in the local zone. | |
279 */ | |
280 /* ARGSUSED */ | |
281 static int | |
4543 | 282 zfs_secpolicy_read(zfs_cmd_t *zc, cred_t *cr) |
789 | 283 { |
284 if (INGLOBALZONE(curproc) || | |
4543 | 285 zone_dataset_visible(zc->zc_name, NULL)) |
789 | 286 return (0); |
287 | |
288 return (ENOENT); | |
289 } | |
290 | |
291 static int | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
292 zfs_dozonecheck_impl(const char *dataset, uint64_t zoned, cred_t *cr) |
789 | 293 { |
294 int writable = 1; | |
295 | |
296 /* | |
297 * The dataset must be visible by this zone -- check this first | |
298 * so they don't see EPERM on something they shouldn't know about. | |
299 */ | |
300 if (!INGLOBALZONE(curproc) && | |
301 !zone_dataset_visible(dataset, &writable)) | |
302 return (ENOENT); | |
303 | |
304 if (INGLOBALZONE(curproc)) { | |
305 /* | |
306 * If the fs is zoned, only root can access it from the | |
307 * global zone. | |
308 */ | |
309 if (secpolicy_zfs(cr) && zoned) | |
310 return (EPERM); | |
311 } else { | |
312 /* | |
313 * If we are in a local zone, the 'zoned' property must be set. | |
314 */ | |
315 if (!zoned) | |
316 return (EPERM); | |
317 | |
318 /* must be writable by this zone */ | |
319 if (!writable) | |
320 return (EPERM); | |
321 } | |
322 return (0); | |
323 } | |
324 | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
325 static int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
326 zfs_dozonecheck(const char *dataset, cred_t *cr) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
327 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
328 uint64_t zoned; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
329 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
330 if (dsl_prop_get_integer(dataset, "zoned", &zoned, NULL)) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
331 return (ENOENT); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
332 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
333 return (zfs_dozonecheck_impl(dataset, zoned, cr)); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
334 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
335 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
336 static int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
337 zfs_dozonecheck_ds(const char *dataset, dsl_dataset_t *ds, cred_t *cr) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
338 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
339 uint64_t zoned; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
340 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
341 rw_enter(&ds->ds_dir->dd_pool->dp_config_rwlock, RW_READER); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
342 if (dsl_prop_get_ds(ds, "zoned", 8, 1, &zoned, NULL)) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
343 rw_exit(&ds->ds_dir->dd_pool->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
344 return (ENOENT); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
345 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
346 rw_exit(&ds->ds_dir->dd_pool->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
347 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
348 return (zfs_dozonecheck_impl(dataset, zoned, cr)); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
349 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
350 |
789 | 351 int |
4543 | 352 zfs_secpolicy_write_perms(const char *name, const char *perm, cred_t *cr) |
789 | 353 { |
354 int error; | |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
355 |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
356 error = zfs_dozonecheck(name, cr); |
4543 | 357 if (error == 0) { |
358 error = secpolicy_zfs(cr); | |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
359 if (error) |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
360 error = dsl_deleg_access(name, perm, cr); |
4543 | 361 } |
362 return (error); | |
363 } | |
364 | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
365 int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
366 zfs_secpolicy_write_perms_ds(const char *name, dsl_dataset_t *ds, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
367 const char *perm, cred_t *cr) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
368 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
369 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
370 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
371 error = zfs_dozonecheck_ds(name, ds, cr); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
372 if (error == 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
373 error = secpolicy_zfs(cr); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
374 if (error) |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
375 error = dsl_deleg_access_impl(ds, perm, cr); |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
376 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
377 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
378 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
379 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
380 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
381 * Policy for setting the security label property. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
382 * |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
383 * Returns 0 for success, non-zero for access and other errors. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
384 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
385 static int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
386 zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr) |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
387 { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
388 char ds_hexsl[MAXNAMELEN]; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
389 bslabel_t ds_sl, new_sl; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
390 boolean_t new_default = FALSE; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
391 uint64_t zoned; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
392 int needed_priv = -1; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
393 int error; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
394 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
395 /* First get the existing dataset label. */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
396 error = dsl_prop_get(name, zfs_prop_to_name(ZFS_PROP_MLSLABEL), |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
397 1, sizeof (ds_hexsl), &ds_hexsl, NULL); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
398 if (error) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
399 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
400 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
401 if (strcasecmp(strval, ZFS_MLSLABEL_DEFAULT) == 0) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
402 new_default = TRUE; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
403 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
404 /* The label must be translatable */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
405 if (!new_default && (hexstr_to_label(strval, &new_sl) != 0)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
406 return (EINVAL); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
407 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
408 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
409 * In a non-global zone, disallow attempts to set a label that |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
410 * doesn't match that of the zone; otherwise no other checks |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
411 * are needed. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
412 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
413 if (!INGLOBALZONE(curproc)) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
414 if (new_default || !blequal(&new_sl, CR_SL(CRED()))) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
415 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
416 return (0); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
417 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
418 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
419 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
420 * For global-zone datasets (i.e., those whose zoned property is |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
421 * "off", verify that the specified new label is valid for the |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
422 * global zone. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
423 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
424 if (dsl_prop_get_integer(name, |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
425 zfs_prop_to_name(ZFS_PROP_ZONED), &zoned, NULL)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
426 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
427 if (!zoned) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
428 if (zfs_check_global_label(name, strval) != 0) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
429 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
430 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
431 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
432 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
433 * If the existing dataset label is nondefault, check if the |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
434 * dataset is mounted (label cannot be changed while mounted). |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
435 * Get the zfsvfs; if there isn't one, then the dataset isn't |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
436 * mounted (or isn't a dataset, doesn't exist, ...). |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
437 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
438 if (strcasecmp(ds_hexsl, ZFS_MLSLABEL_DEFAULT) != 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
439 objset_t *os; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
440 static char *setsl_tag = "setsl_tag"; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
441 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
442 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
443 * Try to own the dataset; abort if there is any error, |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
444 * (e.g., already mounted, in use, or other error). |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
445 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
446 error = dmu_objset_own(name, DMU_OST_ZFS, B_TRUE, |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
447 setsl_tag, &os); |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
448 if (error) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
449 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
450 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
451 dmu_objset_disown(os, setsl_tag); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
452 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
453 if (new_default) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
454 needed_priv = PRIV_FILE_DOWNGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
455 goto out_check; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
456 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
457 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
458 if (hexstr_to_label(strval, &new_sl) != 0) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
459 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
460 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
461 if (blstrictdom(&ds_sl, &new_sl)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
462 needed_priv = PRIV_FILE_DOWNGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
463 else if (blstrictdom(&new_sl, &ds_sl)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
464 needed_priv = PRIV_FILE_UPGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
465 } else { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
466 /* dataset currently has a default label */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
467 if (!new_default) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
468 needed_priv = PRIV_FILE_UPGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
469 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
470 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
471 out_check: |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
472 if (needed_priv != -1) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
473 return (PRIV_POLICY(cr, needed_priv, B_FALSE, EPERM, NULL)); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
474 return (0); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
475 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
476 |
4543 | 477 static int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
478 zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
479 cred_t *cr) |
4543 | 480 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
481 char *strval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
482 |
4543 | 483 /* |
484 * Check permissions for special properties. | |
485 */ | |
486 switch (prop) { | |
487 case ZFS_PROP_ZONED: | |
488 /* | |
489 * Disallow setting of 'zoned' from within a local zone. | |
490 */ | |
491 if (!INGLOBALZONE(curproc)) | |
492 return (EPERM); | |
493 break; | |
789 | 494 |
4543 | 495 case ZFS_PROP_QUOTA: |
496 if (!INGLOBALZONE(curproc)) { | |
497 uint64_t zoned; | |
498 char setpoint[MAXNAMELEN]; | |
499 /* | |
500 * Unprivileged users are allowed to modify the | |
501 * quota on things *under* (ie. contained by) | |
502 * the thing they own. | |
503 */ | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
504 if (dsl_prop_get_integer(dsname, "zoned", &zoned, |
4543 | 505 setpoint)) |
506 return (EPERM); | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
507 if (!zoned || strlen(dsname) <= strlen(setpoint)) |
4543 | 508 return (EPERM); |
509 } | |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
510 break; |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
511 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
512 case ZFS_PROP_MLSLABEL: |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
513 if (!is_system_labeled()) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
514 return (EPERM); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
515 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
516 if (nvpair_value_string(propval, &strval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
517 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
518 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
519 err = zfs_set_slabel_policy(dsname, strval, CRED()); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
520 if (err != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
521 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
522 } |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
523 break; |
4543 | 524 } |
525 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
526 return (zfs_secpolicy_write_perms(dsname, zfs_prop_to_name(prop), cr)); |
789 | 527 } |
528 | |
4543 | 529 int |
530 zfs_secpolicy_fsacl(zfs_cmd_t *zc, cred_t *cr) | |
531 { | |
532 int error; | |
533 | |
534 error = zfs_dozonecheck(zc->zc_name, cr); | |
535 if (error) | |
536 return (error); | |
537 | |
538 /* | |
539 * permission to set permissions will be evaluated later in | |
540 * dsl_deleg_can_allow() | |
541 */ | |
542 return (0); | |
543 } | |
544 | |
545 int | |
546 zfs_secpolicy_rollback(zfs_cmd_t *zc, cred_t *cr) | |
547 { | |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
548 return (zfs_secpolicy_write_perms(zc->zc_name, |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
549 ZFS_DELEG_PERM_ROLLBACK, cr)); |
4543 | 550 } |
551 | |
552 int | |
553 zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr) | |
554 { | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
555 spa_t *spa; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
556 dsl_pool_t *dp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
557 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
558 char *cp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
559 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
560 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
561 /* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
562 * Generate the current snapshot name from the given objsetid, then |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
563 * use that name for the secpolicy/zone checks. |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
564 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
565 cp = strchr(zc->zc_name, '@'); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
566 if (cp == NULL) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
567 return (EINVAL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
568 error = spa_open(zc->zc_name, &spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
569 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
570 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
571 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
572 dp = spa_get_dsl(spa); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
573 rw_enter(&dp->dp_config_rwlock, RW_READER); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
574 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &ds); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
575 rw_exit(&dp->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
576 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
577 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
578 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
579 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
580 dsl_dataset_name(ds, zc->zc_name); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
581 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
582 error = zfs_secpolicy_write_perms_ds(zc->zc_name, ds, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
583 ZFS_DELEG_PERM_SEND, cr); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
584 dsl_dataset_rele(ds, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
585 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
586 return (error); |
4543 | 587 } |
588 | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
589 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
590 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
|
591 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
592 vnode_t *vp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
593 int error; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
594 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
595 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
|
596 NO_FOLLOW, NULL, &vp)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
597 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
598 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
599 /* 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
|
600 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
601 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
|
602 (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
|
603 zc->zc_name) != 0)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
604 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
605 return (EPERM); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
606 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
607 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
608 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
609 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
|
610 ZFS_DELEG_PERM_SHARE, cr)); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
611 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
612 |
4543 | 613 int |
614 zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr) | |
615 { | |
616 if (!INGLOBALZONE(curproc)) | |
617 return (EPERM); | |
618 | |
5367 | 619 if (secpolicy_nfs(cr) == 0) { |
4543 | 620 return (0); |
621 } else { | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
622 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
|
623 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
624 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
625 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
626 int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
627 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
|
628 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
629 if (!INGLOBALZONE(curproc)) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
630 return (EPERM); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
631 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
632 if (secpolicy_smb(cr) == 0) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
633 return (0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
634 } else { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
635 return (zfs_secpolicy_deleg_share(zc, cr)); |
4543 | 636 } |
637 } | |
638 | |
789 | 639 static int |
4543 | 640 zfs_get_parent(const char *datasetname, char *parent, int parentsize) |
789 | 641 { |
642 char *cp; | |
643 | |
644 /* | |
645 * Remove the @bla or /bla from the end of the name to get the parent. | |
646 */ | |
4543 | 647 (void) strncpy(parent, datasetname, parentsize); |
648 cp = strrchr(parent, '@'); | |
789 | 649 if (cp != NULL) { |
650 cp[0] = '\0'; | |
651 } else { | |
4543 | 652 cp = strrchr(parent, '/'); |
789 | 653 if (cp == NULL) |
654 return (ENOENT); | |
655 cp[0] = '\0'; | |
656 } | |
657 | |
4543 | 658 return (0); |
659 } | |
660 | |
661 int | |
662 zfs_secpolicy_destroy_perms(const char *name, cred_t *cr) | |
663 { | |
664 int error; | |
665 | |
666 if ((error = zfs_secpolicy_write_perms(name, | |
667 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
668 return (error); | |
669 | |
670 return (zfs_secpolicy_write_perms(name, ZFS_DELEG_PERM_DESTROY, cr)); | |
671 } | |
672 | |
673 static int | |
674 zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr) | |
675 { | |
676 return (zfs_secpolicy_destroy_perms(zc->zc_name, cr)); | |
677 } | |
678 | |
679 /* | |
11314
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
680 * Destroying snapshots with delegated permissions requires |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
681 * descendent mount and destroy permissions. |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
682 * Reassemble the full filesystem@snap name so dsl_deleg_access() |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
683 * can do the correct permission check. |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
684 * |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
685 * Since this routine is used when doing a recursive destroy of snapshots |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
686 * and destroying snapshots requires descendent permissions, a successfull |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
687 * check of the top level snapshot applies to snapshots of all descendent |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
688 * datasets as well. |
11314
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
689 */ |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
690 static int |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
691 zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, cred_t *cr) |
11314
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
692 { |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
693 int error; |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
694 char *dsname; |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
695 |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
696 dsname = kmem_asprintf("%s@%s", zc->zc_name, zc->zc_value); |
11314
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
697 |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
698 error = zfs_secpolicy_destroy_perms(dsname, cr); |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
699 |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
700 strfree(dsname); |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
701 return (error); |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
702 } |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
703 |
4543 | 704 int |
705 zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr) | |
706 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
707 char parentname[MAXNAMELEN]; |
4543 | 708 int error; |
709 | |
710 if ((error = zfs_secpolicy_write_perms(from, | |
711 ZFS_DELEG_PERM_RENAME, cr)) != 0) | |
712 return (error); | |
713 | |
714 if ((error = zfs_secpolicy_write_perms(from, | |
715 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
716 return (error); | |
717 | |
718 if ((error = zfs_get_parent(to, parentname, | |
719 sizeof (parentname))) != 0) | |
720 return (error); | |
721 | |
722 if ((error = zfs_secpolicy_write_perms(parentname, | |
723 ZFS_DELEG_PERM_CREATE, cr)) != 0) | |
724 return (error); | |
725 | |
726 if ((error = zfs_secpolicy_write_perms(parentname, | |
727 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
728 return (error); | |
729 | |
730 return (error); | |
731 } | |
732 | |
733 static int | |
734 zfs_secpolicy_rename(zfs_cmd_t *zc, cred_t *cr) | |
735 { | |
736 return (zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr)); | |
737 } | |
738 | |
739 static int | |
740 zfs_secpolicy_promote(zfs_cmd_t *zc, cred_t *cr) | |
741 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
742 char parentname[MAXNAMELEN]; |
4543 | 743 objset_t *clone; |
744 int error; | |
745 | |
746 error = zfs_secpolicy_write_perms(zc->zc_name, | |
747 ZFS_DELEG_PERM_PROMOTE, cr); | |
748 if (error) | |
749 return (error); | |
750 | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
751 error = dmu_objset_hold(zc->zc_name, FTAG, &clone); |
4543 | 752 |
753 if (error == 0) { | |
754 dsl_dataset_t *pclone = NULL; | |
755 dsl_dir_t *dd; | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
756 dd = clone->os_dsl_dataset->ds_dir; |
4543 | 757 |
758 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
|
759 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
|
760 dd->dd_phys->dd_origin_obj, FTAG, &pclone); |
4543 | 761 rw_exit(&dd->dd_pool->dp_config_rwlock); |
762 if (error) { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
763 dmu_objset_rele(clone, FTAG); |
4543 | 764 return (error); |
765 } | |
766 | |
767 error = zfs_secpolicy_write_perms(zc->zc_name, | |
768 ZFS_DELEG_PERM_MOUNT, cr); | |
769 | |
770 dsl_dataset_name(pclone, parentname); | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
771 dmu_objset_rele(clone, FTAG); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
772 dsl_dataset_rele(pclone, FTAG); |
4543 | 773 if (error == 0) |
774 error = zfs_secpolicy_write_perms(parentname, | |
775 ZFS_DELEG_PERM_PROMOTE, cr); | |
776 } | |
777 return (error); | |
778 } | |
779 | |
780 static int | |
781 zfs_secpolicy_receive(zfs_cmd_t *zc, cred_t *cr) | |
782 { | |
783 int error; | |
784 | |
785 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
786 ZFS_DELEG_PERM_RECEIVE, cr)) != 0) | |
787 return (error); | |
788 | |
789 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
790 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
791 return (error); | |
792 | |
793 return (zfs_secpolicy_write_perms(zc->zc_name, | |
794 ZFS_DELEG_PERM_CREATE, cr)); | |
795 } | |
796 | |
797 int | |
798 zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr) | |
799 { | |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
800 return (zfs_secpolicy_write_perms(name, |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
801 ZFS_DELEG_PERM_SNAPSHOT, cr)); |
4543 | 802 } |
803 | |
804 static int | |
805 zfs_secpolicy_snapshot(zfs_cmd_t *zc, cred_t *cr) | |
806 { | |
807 | |
808 return (zfs_secpolicy_snapshot_perms(zc->zc_name, cr)); | |
809 } | |
810 | |
811 static int | |
812 zfs_secpolicy_create(zfs_cmd_t *zc, cred_t *cr) | |
813 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
814 char parentname[MAXNAMELEN]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
815 int error; |
4543 | 816 |
817 if ((error = zfs_get_parent(zc->zc_name, parentname, | |
818 sizeof (parentname))) != 0) | |
819 return (error); | |
820 | |
821 if (zc->zc_value[0] != '\0') { | |
822 if ((error = zfs_secpolicy_write_perms(zc->zc_value, | |
823 ZFS_DELEG_PERM_CLONE, cr)) != 0) | |
824 return (error); | |
825 } | |
826 | |
827 if ((error = zfs_secpolicy_write_perms(parentname, | |
828 ZFS_DELEG_PERM_CREATE, cr)) != 0) | |
829 return (error); | |
830 | |
831 error = zfs_secpolicy_write_perms(parentname, | |
832 ZFS_DELEG_PERM_MOUNT, cr); | |
833 | |
834 return (error); | |
835 } | |
836 | |
837 static int | |
838 zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr) | |
839 { | |
840 int error; | |
841 | |
842 error = secpolicy_fs_unmount(cr, NULL); | |
843 if (error) { | |
844 error = dsl_deleg_access(zc->zc_name, ZFS_DELEG_PERM_MOUNT, cr); | |
845 } | |
846 return (error); | |
789 | 847 } |
848 | |
849 /* | |
850 * Policy for pool operations - create/destroy pools, add vdevs, etc. Requires | |
851 * SYS_CONFIG privilege, which is not available in a local zone. | |
852 */ | |
853 /* ARGSUSED */ | |
854 static int | |
4543 | 855 zfs_secpolicy_config(zfs_cmd_t *zc, cred_t *cr) |
789 | 856 { |
857 if (secpolicy_sys_config(cr, B_FALSE) != 0) | |
858 return (EPERM); | |
859 | |
860 return (0); | |
861 } | |
862 | |
863 /* | |
13055 | 864 * Policy for object to name lookups. |
865 */ | |
866 /* ARGSUSED */ | |
867 static int | |
868 zfs_secpolicy_diff(zfs_cmd_t *zc, cred_t *cr) | |
869 { | |
870 int error; | |
871 | |
872 if ((error = secpolicy_sys_config(cr, B_FALSE)) == 0) | |
873 return (0); | |
874 | |
875 error = zfs_secpolicy_write_perms(zc->zc_name, ZFS_DELEG_PERM_DIFF, cr); | |
876 return (error); | |
877 } | |
878 | |
879 /* | |
1544 | 880 * Policy for fault injection. Requires all privileges. |
881 */ | |
882 /* ARGSUSED */ | |
883 static int | |
4543 | 884 zfs_secpolicy_inject(zfs_cmd_t *zc, cred_t *cr) |
1544 | 885 { |
886 return (secpolicy_zinject(cr)); | |
887 } | |
888 | |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
889 static int |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
890 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
|
891 { |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
892 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
|
893 |
5094 | 894 if (prop == ZPROP_INVAL) { |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
895 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
|
896 return (EINVAL); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
897 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
|
898 ZFS_DELEG_PERM_USERPROP, cr)); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
899 } else { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
900 return (zfs_secpolicy_setprop(zc->zc_name, prop, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
901 NULL, cr)); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
902 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
903 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
904 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
905 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
906 zfs_secpolicy_userspace_one(zfs_cmd_t *zc, cred_t *cr) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
907 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
908 int err = zfs_secpolicy_read(zc, cr); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
909 if (err) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
910 return (err); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
911 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
912 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
913 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
914 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
915 if (zc->zc_value[0] == 0) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
916 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
917 * They are asking about a posix uid/gid. If it's |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
918 * themself, allow it. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
919 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
920 if (zc->zc_objset_type == ZFS_PROP_USERUSED || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
921 zc->zc_objset_type == ZFS_PROP_USERQUOTA) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
922 if (zc->zc_guid == crgetuid(cr)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
923 return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
924 } else { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
925 if (groupmember(zc->zc_guid, cr)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
926 return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
927 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
928 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
929 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
930 return (zfs_secpolicy_write_perms(zc->zc_name, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
931 userquota_perms[zc->zc_objset_type], cr)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
932 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
933 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
934 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
935 zfs_secpolicy_userspace_many(zfs_cmd_t *zc, cred_t *cr) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
936 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
937 int err = zfs_secpolicy_read(zc, cr); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
938 if (err) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
939 return (err); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
940 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
941 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
942 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
943 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
944 return (zfs_secpolicy_write_perms(zc->zc_name, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
945 userquota_perms[zc->zc_objset_type], cr)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
946 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
947 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
948 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
949 zfs_secpolicy_userspace_upgrade(zfs_cmd_t *zc, cred_t *cr) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
950 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
951 return (zfs_secpolicy_setprop(zc->zc_name, ZFS_PROP_VERSION, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
952 NULL, cr)); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
953 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
954 |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
955 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
956 zfs_secpolicy_hold(zfs_cmd_t *zc, cred_t *cr) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
957 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
958 return (zfs_secpolicy_write_perms(zc->zc_name, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
959 ZFS_DELEG_PERM_HOLD, cr)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
960 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
961 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
962 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
963 zfs_secpolicy_release(zfs_cmd_t *zc, cred_t *cr) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
964 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
965 return (zfs_secpolicy_write_perms(zc->zc_name, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
966 ZFS_DELEG_PERM_RELEASE, cr)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
967 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
968 |
1544 | 969 /* |
13055 | 970 * Policy for allowing temporary snapshots to be taken or released |
971 */ | |
972 static int | |
973 zfs_secpolicy_tmp_snapshot(zfs_cmd_t *zc, cred_t *cr) | |
974 { | |
975 /* | |
976 * A temporary snapshot is the same as a snapshot, | |
977 * hold, destroy and release all rolled into one. | |
978 * Delegated diff alone is sufficient that we allow this. | |
979 */ | |
980 int error; | |
981 | |
982 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
983 ZFS_DELEG_PERM_DIFF, cr)) == 0) | |
984 return (0); | |
985 | |
986 error = zfs_secpolicy_snapshot(zc, cr); | |
987 if (!error) | |
988 error = zfs_secpolicy_hold(zc, cr); | |
989 if (!error) | |
990 error = zfs_secpolicy_release(zc, cr); | |
991 if (!error) | |
992 error = zfs_secpolicy_destroy(zc, cr); | |
993 return (error); | |
994 } | |
995 | |
996 /* | |
789 | 997 * Returns the nvlist as specified by the user in the zfs_cmd_t. |
998 */ | |
999 static int | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1000 get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp) |
789 | 1001 { |
1002 char *packed; | |
1003 int error; | |
5094 | 1004 nvlist_t *list = NULL; |
789 | 1005 |
1006 /* | |
2676 | 1007 * Read in and unpack the user-supplied nvlist. |
789 | 1008 */ |
5094 | 1009 if (size == 0) |
789 | 1010 return (EINVAL); |
1011 | |
1012 packed = kmem_alloc(size, KM_SLEEP); | |
1013 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1014 if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size, |
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1015 iflag)) != 0) { |
789 | 1016 kmem_free(packed, size); |
1017 return (error); | |
1018 } | |
1019 | |
5094 | 1020 if ((error = nvlist_unpack(packed, size, &list, 0)) != 0) { |
789 | 1021 kmem_free(packed, size); |
1022 return (error); | |
1023 } | |
1024 | |
1025 kmem_free(packed, size); | |
1026 | |
5094 | 1027 *nvp = list; |
789 | 1028 return (0); |
1029 } | |
1030 | |
1031 static int | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1032 fit_error_list(zfs_cmd_t *zc, nvlist_t **errors) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1033 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1034 size_t size; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1035 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1036 VERIFY(nvlist_size(*errors, &size, NV_ENCODE_NATIVE) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1037 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1038 if (size > zc->zc_nvlist_dst_size) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1039 nvpair_t *more_errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1040 int n = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1041 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1042 if (zc->zc_nvlist_dst_size < 1024) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1043 return (ENOMEM); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1044 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1045 VERIFY(nvlist_add_int32(*errors, ZPROP_N_MORE_ERRORS, 0) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1046 more_errors = nvlist_prev_nvpair(*errors, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1047 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1048 do { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1049 nvpair_t *pair = nvlist_prev_nvpair(*errors, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1050 more_errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1051 VERIFY(nvlist_remove_nvpair(*errors, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1052 n++; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1053 VERIFY(nvlist_size(*errors, &size, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1054 NV_ENCODE_NATIVE) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1055 } while (size > zc->zc_nvlist_dst_size); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1056 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1057 VERIFY(nvlist_remove_nvpair(*errors, more_errors) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1058 VERIFY(nvlist_add_int32(*errors, ZPROP_N_MORE_ERRORS, n) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1059 ASSERT(nvlist_size(*errors, &size, NV_ENCODE_NATIVE) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1060 ASSERT(size <= zc->zc_nvlist_dst_size); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1061 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1062 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1063 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1064 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1065 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1066 static int |
2676 | 1067 put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl) |
1068 { | |
1069 char *packed = NULL; | |
11807
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
1070 int error = 0; |
2676 | 1071 size_t size; |
1072 | |
1073 VERIFY(nvlist_size(nvl, &size, NV_ENCODE_NATIVE) == 0); | |
1074 | |
1075 if (size > zc->zc_nvlist_dst_size) { | |
1076 error = ENOMEM; | |
1077 } else { | |
4611 | 1078 packed = kmem_alloc(size, KM_SLEEP); |
2676 | 1079 VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE, |
1080 KM_SLEEP) == 0); | |
11807
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
1081 if (ddi_copyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst, |
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
1082 size, zc->zc_iflags) != 0) |
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
1083 error = EFAULT; |
2676 | 1084 kmem_free(packed, size); |
1085 } | |
1086 | |
1087 zc->zc_nvlist_dst_size = size; | |
1088 return (error); | |
1089 } | |
1090 | |
1091 static int | |
11185
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1092 getzfsvfs(const char *dsname, zfsvfs_t **zfvp) |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1093 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1094 objset_t *os; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1095 int error; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1096 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1097 error = dmu_objset_hold(dsname, FTAG, &os); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1098 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1099 return (error); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1100 if (dmu_objset_type(os) != DMU_OST_ZFS) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1101 dmu_objset_rele(os, FTAG); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1102 return (EINVAL); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1103 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1104 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1105 mutex_enter(&os->os_user_ptr_lock); |
11185
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1106 *zfvp = dmu_objset_get_user(os); |
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1107 if (*zfvp) { |
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1108 VFS_HOLD((*zfvp)->z_vfs); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1109 } else { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1110 error = ESRCH; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1111 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1112 mutex_exit(&os->os_user_ptr_lock); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1113 dmu_objset_rele(os, FTAG); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1114 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1115 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1116 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1117 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1118 * Find a zfsvfs_t for a mounted filesystem, or create our own, in which |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1119 * case its z_vfs will be NULL, and it will be opened as the owner. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1120 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1121 static int |
12620
12fcd99a642d
6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents:
12527
diff
changeset
|
1122 zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zfvp, boolean_t writer) |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1123 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1124 int error = 0; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1125 |
11185
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1126 if (getzfsvfs(name, zfvp) != 0) |
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1127 error = zfsvfs_create(name, zfvp); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1128 if (error == 0) { |
12620
12fcd99a642d
6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents:
12527
diff
changeset
|
1129 rrw_enter(&(*zfvp)->z_teardown_lock, (writer) ? RW_WRITER : |
12fcd99a642d
6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents:
12527
diff
changeset
|
1130 RW_READER, tag); |
11185
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1131 if ((*zfvp)->z_unmounted) { |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1132 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1133 * XXX we could probably try again, since the unmounting |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1134 * thread should be just about to disassociate the |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1135 * objset from the zfsvfs. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1136 */ |
11185
f0c31008e395
6887924 PP_ISKAS needs to be defined in terms of VN_ISKAS for vnodes
Sean McEnroe <Sean.McEnroe@Sun.COM>
parents:
11181
diff
changeset
|
1137 rrw_exit(&(*zfvp)->z_teardown_lock, tag); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1138 return (EBUSY); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1139 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1140 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1141 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1142 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1143 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1144 static void |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1145 zfsvfs_rele(zfsvfs_t *zfsvfs, void *tag) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1146 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1147 rrw_exit(&zfsvfs->z_teardown_lock, tag); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1148 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1149 if (zfsvfs->z_vfs) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1150 VFS_RELE(zfsvfs->z_vfs); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1151 } else { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1152 dmu_objset_disown(zfsvfs->z_os, zfsvfs); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1153 zfsvfs_free(zfsvfs); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1154 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1155 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1156 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1157 static int |
789 | 1158 zfs_ioc_pool_create(zfs_cmd_t *zc) |
1159 { | |
1160 int error; | |
5094 | 1161 nvlist_t *config, *props = NULL; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1162 nvlist_t *rootprops = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1163 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
|
1164 char *buf; |
789 | 1165 |
5094 | 1166 if (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1167 zc->zc_iflags, &config)) |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1168 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
|
1169 |
5094 | 1170 if (zc->zc_nvlist_src_size != 0 && (error = |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1171 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1172 zc->zc_iflags, &props))) { |
5094 | 1173 nvlist_free(config); |
1174 return (error); | |
1175 } | |
1176 | |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1177 if (props) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1178 nvlist_t *nvl = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1179 uint64_t version = SPA_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1180 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1181 (void) nvlist_lookup_uint64(props, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1182 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
|
1183 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
|
1184 error = EINVAL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1185 goto pool_props_bad; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1186 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1187 (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
|
1188 if (nvl) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1189 error = nvlist_dup(nvl, &rootprops, KM_SLEEP); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1190 if (error != 0) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1191 nvlist_free(config); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1192 nvlist_free(props); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1193 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1194 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1195 (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
|
1196 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1197 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
|
1198 error = zfs_fill_zplprops_root(version, rootprops, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1199 zplprops, NULL); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1200 if (error) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1201 goto pool_props_bad; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1202 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1203 |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1204 buf = history_str_get(zc); |
789 | 1205 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1206 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
|
1207 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1208 /* |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1209 * Set the remaining root properties |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1210 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1211 if (!error && (error = zfs_set_prop_nvlist(zc->zc_name, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1212 ZPROP_SRC_LOCAL, rootprops, NULL)) != 0) |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1213 (void) spa_destroy(zc->zc_name); |
789 | 1214 |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1215 if (buf != NULL) |
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1216 history_str_free(buf); |
5094 | 1217 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1218 pool_props_bad: |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1219 nvlist_free(rootprops); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1220 nvlist_free(zplprops); |
789 | 1221 nvlist_free(config); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1222 nvlist_free(props); |
5094 | 1223 |
789 | 1224 return (error); |
1225 } | |
1226 | |
1227 static int | |
1228 zfs_ioc_pool_destroy(zfs_cmd_t *zc) | |
1229 { | |
4543 | 1230 int error; |
1231 zfs_log_history(zc); | |
1232 error = spa_destroy(zc->zc_name); | |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1233 if (error == 0) |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1234 zvol_remove_minors(zc->zc_name); |
4543 | 1235 return (error); |
789 | 1236 } |
1237 | |
1238 static int | |
1239 zfs_ioc_pool_import(zfs_cmd_t *zc) | |
1240 { | |
5094 | 1241 nvlist_t *config, *props = NULL; |
789 | 1242 uint64_t guid; |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1243 int error; |
789 | 1244 |
5094 | 1245 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1246 zc->zc_iflags, &config)) != 0) |
789 | 1247 return (error); |
1248 | |
5094 | 1249 if (zc->zc_nvlist_src_size != 0 && (error = |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1250 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1251 zc->zc_iflags, &props))) { |
5094 | 1252 nvlist_free(config); |
1253 return (error); | |
1254 } | |
1255 | |
789 | 1256 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) != 0 || |
1544 | 1257 guid != zc->zc_guid) |
789 | 1258 error = EINVAL; |
1259 else | |
12961
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1260 error = spa_import(zc->zc_name, config, props, zc->zc_cookie); |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1261 |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1262 if (zc->zc_nvlist_dst != 0) { |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1263 int err; |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1264 |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1265 if ((err = put_nvlist(zc, config)) != 0) |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1266 error = err; |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1267 } |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1268 |
789 | 1269 nvlist_free(config); |
1270 | |
5094 | 1271 if (props) |
1272 nvlist_free(props); | |
1273 | |
789 | 1274 return (error); |
1275 } | |
1276 | |
1277 static int | |
1278 zfs_ioc_pool_export(zfs_cmd_t *zc) | |
1279 { | |
4543 | 1280 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
|
1281 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
|
1282 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
|
1283 |
4543 | 1284 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
|
1285 error = spa_export(zc->zc_name, NULL, force, hardforce); |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1286 if (error == 0) |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1287 zvol_remove_minors(zc->zc_name); |
4543 | 1288 return (error); |
789 | 1289 } |
1290 | |
1291 static int | |
1292 zfs_ioc_pool_configs(zfs_cmd_t *zc) | |
1293 { | |
1294 nvlist_t *configs; | |
1295 int error; | |
1296 | |
1297 if ((configs = spa_all_configs(&zc->zc_cookie)) == NULL) | |
1298 return (EEXIST); | |
1299 | |
2676 | 1300 error = put_nvlist(zc, configs); |
789 | 1301 |
1302 nvlist_free(configs); | |
1303 | |
1304 return (error); | |
1305 } | |
1306 | |
1307 static int | |
1308 zfs_ioc_pool_stats(zfs_cmd_t *zc) | |
1309 { | |
1310 nvlist_t *config; | |
1311 int error; | |
1544 | 1312 int ret = 0; |
789 | 1313 |
2676 | 1314 error = spa_get_stats(zc->zc_name, &config, zc->zc_value, |
1315 sizeof (zc->zc_value)); | |
789 | 1316 |
1317 if (config != NULL) { | |
2676 | 1318 ret = put_nvlist(zc, config); |
789 | 1319 nvlist_free(config); |
1544 | 1320 |
1321 /* | |
1322 * The config may be present even if 'error' is non-zero. | |
1323 * In this case we return success, and preserve the real errno | |
1324 * in 'zc_cookie'. | |
1325 */ | |
1326 zc->zc_cookie = error; | |
789 | 1327 } else { |
1544 | 1328 ret = error; |
789 | 1329 } |
1330 | |
1544 | 1331 return (ret); |
789 | 1332 } |
1333 | |
1334 /* | |
1335 * Try to import the given pool, returning pool stats as appropriate so that | |
1336 * user land knows which devices are available and overall pool health. | |
1337 */ | |
1338 static int | |
1339 zfs_ioc_pool_tryimport(zfs_cmd_t *zc) | |
1340 { | |
1341 nvlist_t *tryconfig, *config; | |
1342 int error; | |
1343 | |
5094 | 1344 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1345 zc->zc_iflags, &tryconfig)) != 0) |
789 | 1346 return (error); |
1347 | |
1348 config = spa_tryimport(tryconfig); | |
1349 | |
1350 nvlist_free(tryconfig); | |
1351 | |
1352 if (config == NULL) | |
1353 return (EINVAL); | |
1354 | |
2676 | 1355 error = put_nvlist(zc, config); |
789 | 1356 nvlist_free(config); |
1357 | |
1358 return (error); | |
1359 } | |
1360 | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1361 /* |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1362 * inputs: |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1363 * zc_name name of the pool |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1364 * zc_cookie scan func (pool_scan_func_t) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1365 */ |
789 | 1366 static int |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1367 zfs_ioc_pool_scan(zfs_cmd_t *zc) |
789 | 1368 { |
1369 spa_t *spa; | |
1370 int error; | |
1371 | |
2926 | 1372 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
1373 return (error); | |
1374 | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1375 if (zc->zc_cookie == POOL_SCAN_NONE) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1376 error = spa_scan_stop(spa); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1377 else |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1378 error = spa_scan(spa, zc->zc_cookie); |
2926 | 1379 |
1380 spa_close(spa, FTAG); | |
1381 | |
789 | 1382 return (error); |
1383 } | |
1384 | |
1385 static int | |
1386 zfs_ioc_pool_freeze(zfs_cmd_t *zc) | |
1387 { | |
1388 spa_t *spa; | |
1389 int error; | |
1390 | |
1391 error = spa_open(zc->zc_name, &spa, FTAG); | |
1392 if (error == 0) { | |
1393 spa_freeze(spa); | |
1394 spa_close(spa, FTAG); | |
1395 } | |
1396 return (error); | |
1397 } | |
1398 | |
1399 static int | |
1760 | 1400 zfs_ioc_pool_upgrade(zfs_cmd_t *zc) |
1401 { | |
1402 spa_t *spa; | |
1403 int error; | |
1404 | |
2926 | 1405 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
1406 return (error); | |
1407 | |
5118
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1408 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
|
1409 spa_close(spa, FTAG); |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1410 return (EINVAL); |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1411 } |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1412 |
5094 | 1413 spa_upgrade(spa, zc->zc_cookie); |
2926 | 1414 spa_close(spa, FTAG); |
1415 | |
1416 return (error); | |
1417 } | |
1418 | |
1419 static int | |
1420 zfs_ioc_pool_get_history(zfs_cmd_t *zc) | |
1421 { | |
1422 spa_t *spa; | |
1423 char *hist_buf; | |
1424 uint64_t size; | |
1425 int error; | |
1426 | |
1427 if ((size = zc->zc_history_len) == 0) | |
1428 return (EINVAL); | |
1429 | |
1430 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) | |
1431 return (error); | |
1432 | |
4577 | 1433 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
|
1434 spa_close(spa, FTAG); |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1435 return (ENOTSUP); |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1436 } |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1437 |
2926 | 1438 hist_buf = kmem_alloc(size, KM_SLEEP); |
1439 if ((error = spa_history_get(spa, &zc->zc_history_offset, | |
1440 &zc->zc_history_len, hist_buf)) == 0) { | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1441 error = ddi_copyout(hist_buf, |
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1442 (void *)(uintptr_t)zc->zc_history, |
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1443 zc->zc_history_len, zc->zc_iflags); |
2926 | 1444 } |
1445 | |
1446 spa_close(spa, FTAG); | |
1447 kmem_free(hist_buf, size); | |
1448 return (error); | |
1449 } | |
1450 | |
1451 static int | |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1452 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
|
1453 { |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1454 int error; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1455 |
3912 | 1456 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
|
1457 return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1458 |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1459 return (0); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1460 } |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1461 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1462 /* |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1463 * inputs: |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1464 * zc_name name of filesystem |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1465 * zc_obj object to find |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1466 * |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1467 * outputs: |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1468 * zc_value name of object |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1469 */ |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1470 static int |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1471 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
|
1472 { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1473 objset_t *os; |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1474 int error; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1475 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1476 /* XXX reading from objset not owned */ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1477 if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os)) != 0) |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1478 return (error); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1479 if (dmu_objset_type(os) != DMU_OST_ZFS) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1480 dmu_objset_rele(os, FTAG); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1481 return (EINVAL); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1482 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1483 error = zfs_obj_to_path(os, zc->zc_obj, zc->zc_value, |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1484 sizeof (zc->zc_value)); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1485 dmu_objset_rele(os, FTAG); |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1486 |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1487 return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1488 } |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1489 |
13055 | 1490 /* |
1491 * inputs: | |
1492 * zc_name name of filesystem | |
1493 * zc_obj object to find | |
1494 * | |
1495 * outputs: | |
1496 * zc_stat stats on object | |
1497 * zc_value path to object | |
1498 */ | |
1499 static int | |
1500 zfs_ioc_obj_to_stats(zfs_cmd_t *zc) | |
1501 { | |
1502 objset_t *os; | |
1503 int error; | |
1504 | |
1505 /* XXX reading from objset not owned */ | |
1506 if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os)) != 0) | |
1507 return (error); | |
1508 if (dmu_objset_type(os) != DMU_OST_ZFS) { | |
1509 dmu_objset_rele(os, FTAG); | |
1510 return (EINVAL); | |
1511 } | |
1512 error = zfs_obj_to_stats(os, zc->zc_obj, &zc->zc_stat, zc->zc_value, | |
1513 sizeof (zc->zc_value)); | |
1514 dmu_objset_rele(os, FTAG); | |
1515 | |
1516 return (error); | |
1517 } | |
1518 | |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1519 static int |
789 | 1520 zfs_ioc_vdev_add(zfs_cmd_t *zc) |
1521 { | |
1522 spa_t *spa; | |
1523 int error; | |
6423 | 1524 nvlist_t *config, **l2cache, **spares; |
1525 uint_t nl2cache = 0, nspares = 0; | |
789 | 1526 |
1527 error = spa_open(zc->zc_name, &spa, FTAG); | |
1528 if (error != 0) | |
1529 return (error); | |
1530 | |
5450 | 1531 error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1532 zc->zc_iflags, &config); |
5450 | 1533 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_L2CACHE, |
1534 &l2cache, &nl2cache); | |
1535 | |
6423 | 1536 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_SPARES, |
1537 &spares, &nspares); | |
1538 | |
3912 | 1539 /* |
1540 * A root pool with concatenated devices is not supported. | |
6423 | 1541 * Thus, can not add a device to a root pool. |
1542 * | |
1543 * Intent log device can not be added to a rootpool because | |
1544 * during mountroot, zil is replayed, a seperated log device | |
1545 * can not be accessed during the mountroot time. | |
1546 * | |
1547 * l2cache and spare devices are ok to be added to a rootpool. | |
3912 | 1548 */ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1549 if (spa_bootfs(spa) != 0 && nl2cache == 0 && nspares == 0) { |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1550 nvlist_free(config); |
3912 | 1551 spa_close(spa, FTAG); |
1552 return (EDOM); | |
1553 } | |
1554 | |
5450 | 1555 if (error == 0) { |
789 | 1556 error = spa_vdev_add(spa, config); |
1557 nvlist_free(config); | |
1558 } | |
1559 spa_close(spa, FTAG); | |
1560 return (error); | |
1561 } | |
1562 | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1563 /* |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1564 * inputs: |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1565 * zc_name name of the pool |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1566 * zc_nvlist_conf nvlist of devices to remove |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1567 * zc_cookie to stop the remove? |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1568 */ |
789 | 1569 static int |
1570 zfs_ioc_vdev_remove(zfs_cmd_t *zc) | |
1571 { | |
2082 | 1572 spa_t *spa; |
1573 int error; | |
1574 | |
1575 error = spa_open(zc->zc_name, &spa, FTAG); | |
1576 if (error != 0) | |
1577 return (error); | |
1578 error = spa_vdev_remove(spa, zc->zc_guid, B_FALSE); | |
1579 spa_close(spa, FTAG); | |
1580 return (error); | |
789 | 1581 } |
1582 | |
1583 static int | |
4451 | 1584 zfs_ioc_vdev_set_state(zfs_cmd_t *zc) |
789 | 1585 { |
1586 spa_t *spa; | |
1587 int error; | |
4451 | 1588 vdev_state_t newstate = VDEV_STATE_UNKNOWN; |
789 | 1589 |
2926 | 1590 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1591 return (error); |
4451 | 1592 switch (zc->zc_cookie) { |
1593 case VDEV_STATE_ONLINE: | |
1594 error = vdev_online(spa, zc->zc_guid, zc->zc_obj, &newstate); | |
1595 break; | |
1596 | |
1597 case VDEV_STATE_OFFLINE: | |
1598 error = vdev_offline(spa, zc->zc_guid, zc->zc_obj); | |
1599 break; | |
789 | 1600 |
4451 | 1601 case VDEV_STATE_FAULTED: |
10817
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1602 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED && |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1603 zc->zc_obj != VDEV_AUX_EXTERNAL) |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1604 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1605 |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1606 error = vdev_fault(spa, zc->zc_guid, zc->zc_obj); |
4451 | 1607 break; |
789 | 1608 |
4451 | 1609 case VDEV_STATE_DEGRADED: |
10817
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1610 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED && |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1611 zc->zc_obj != VDEV_AUX_EXTERNAL) |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1612 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1613 |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1614 error = vdev_degrade(spa, zc->zc_guid, zc->zc_obj); |
4451 | 1615 break; |
1616 | |
1617 default: | |
1618 error = EINVAL; | |
1619 } | |
1620 zc->zc_cookie = newstate; | |
789 | 1621 spa_close(spa, FTAG); |
1622 return (error); | |
1623 } | |
1624 | |
1625 static int | |
1626 zfs_ioc_vdev_attach(zfs_cmd_t *zc) | |
1627 { | |
1628 spa_t *spa; | |
1629 int replacing = zc->zc_cookie; | |
1630 nvlist_t *config; | |
1631 int error; | |
1632 | |
2926 | 1633 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1634 return (error); |
1635 | |
5094 | 1636 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1637 zc->zc_iflags, &config)) == 0) { |
1544 | 1638 error = spa_vdev_attach(spa, zc->zc_guid, config, replacing); |
789 | 1639 nvlist_free(config); |
1640 } | |
1641 | |
1642 spa_close(spa, FTAG); | |
1643 return (error); | |
1644 } | |
1645 | |
1646 static int | |
1647 zfs_ioc_vdev_detach(zfs_cmd_t *zc) | |
1648 { | |
1649 spa_t *spa; | |
1650 int error; | |
1651 | |
2926 | 1652 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1653 return (error); |
1654 | |
8241
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
8213
diff
changeset
|
1655 error = spa_vdev_detach(spa, zc->zc_guid, 0, B_FALSE); |
789 | 1656 |
1657 spa_close(spa, FTAG); | |
1658 return (error); | |
1659 } | |
1660 | |
1661 static int | |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1662 zfs_ioc_vdev_split(zfs_cmd_t *zc) |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1663 { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1664 spa_t *spa; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1665 nvlist_t *config, *props = NULL; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1666 int error; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1667 boolean_t exp = !!(zc->zc_cookie & ZPOOL_EXPORT_AFTER_SPLIT); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1668 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1669 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1670 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1671 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1672 if (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1673 zc->zc_iflags, &config)) { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1674 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1675 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1676 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1677 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1678 if (zc->zc_nvlist_src_size != 0 && (error = |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1679 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1680 zc->zc_iflags, &props))) { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1681 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1682 nvlist_free(config); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1683 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1684 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1685 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1686 error = spa_vdev_split_mirror(spa, zc->zc_string, config, props, exp); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1687 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1688 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1689 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1690 nvlist_free(config); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1691 nvlist_free(props); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1692 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1693 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1694 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1695 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1696 static int |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1697 zfs_ioc_vdev_setpath(zfs_cmd_t *zc) |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1698 { |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1699 spa_t *spa; |
2676 | 1700 char *path = zc->zc_value; |
1544 | 1701 uint64_t guid = zc->zc_guid; |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1702 int error; |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1703 |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1704 error = spa_open(zc->zc_name, &spa, FTAG); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1705 if (error != 0) |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1706 return (error); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1707 |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1708 error = spa_vdev_setpath(spa, guid, path); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1709 spa_close(spa, FTAG); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1710 return (error); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1711 } |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1712 |
9425
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1713 static int |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1714 zfs_ioc_vdev_setfru(zfs_cmd_t *zc) |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1715 { |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1716 spa_t *spa; |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1717 char *fru = zc->zc_value; |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1718 uint64_t guid = zc->zc_guid; |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1719 int error; |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1720 |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1721 error = spa_open(zc->zc_name, &spa, FTAG); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1722 if (error != 0) |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1723 return (error); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1724 |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1725 error = spa_vdev_setfru(spa, guid, fru); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1726 spa_close(spa, FTAG); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1727 return (error); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1728 } |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1729 |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1730 static int |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1731 zfs_ioc_objset_stats_impl(zfs_cmd_t *zc, objset_t *os) |
789 | 1732 { |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1733 int error = 0; |
1356
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1734 nvlist_t *nv; |
789 | 1735 |
2885 | 1736 dmu_objset_fast_stat(os, &zc->zc_objset_stats); |
789 | 1737 |
2856 | 1738 if (zc->zc_nvlist_dst != 0 && |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1739 (error = dsl_prop_get_all(os, &nv)) == 0) { |
2885 | 1740 dmu_objset_stats(os, nv); |
3087 | 1741 /* |
5147
5e950ccc9585
6596190 "zfs list" is slow due to version property
rm160521
parents:
5118
diff
changeset
|
1742 * NB: zvol_get_stats() will read the objset contents, |
3087 | 1743 * 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
|
1744 * DS_MODE_USER hold, because it could be |
3087 | 1745 * inconsistent. So this is a bit of a workaround... |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1746 * XXX reading with out owning |
3087 | 1747 */ |
4577 | 1748 if (!zc->zc_objset_stats.dds_inconsistent) { |
1749 if (dmu_objset_type(os) == DMU_OST_ZVOL) | |
1750 VERIFY(zvol_get_stats(os, nv) == 0); | |
1751 } | |
2676 | 1752 error = put_nvlist(zc, nv); |
1356
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1753 nvlist_free(nv); |
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1754 } |
789 | 1755 |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1756 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1757 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1758 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1759 /* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1760 * inputs: |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1761 * zc_name name of filesystem |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1762 * zc_nvlist_dst_size size of buffer for property nvlist |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1763 * |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1764 * outputs: |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1765 * zc_objset_stats stats |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1766 * zc_nvlist_dst property nvlist |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1767 * zc_nvlist_dst_size size of property nvlist |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1768 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1769 static int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1770 zfs_ioc_objset_stats(zfs_cmd_t *zc) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1771 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1772 objset_t *os = NULL; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1773 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1774 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1775 if (error = dmu_objset_hold(zc->zc_name, FTAG, &os)) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1776 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1777 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1778 error = zfs_ioc_objset_stats_impl(zc, os); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1779 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1780 dmu_objset_rele(os, FTAG); |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1781 |
789 | 1782 return (error); |
1783 } | |
1784 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1785 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1786 * inputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1787 * zc_name name of filesystem |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1788 * zc_nvlist_dst_size size of buffer for property nvlist |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1789 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1790 * outputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1791 * zc_nvlist_dst received property nvlist |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1792 * zc_nvlist_dst_size size of received property nvlist |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1793 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1794 * Gets received properties (distinct from local properties on or after |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1795 * SPA_VERSION_RECVD_PROPS) for callers who want to differentiate received from |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1796 * local property values. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1797 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1798 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1799 zfs_ioc_objset_recvd_props(zfs_cmd_t *zc) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1800 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1801 objset_t *os = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1802 int error; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1803 nvlist_t *nv; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1804 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1805 if (error = dmu_objset_hold(zc->zc_name, FTAG, &os)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1806 return (error); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1807 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1808 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1809 * Without this check, we would return local property values if the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1810 * caller has not already received properties on or after |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1811 * SPA_VERSION_RECVD_PROPS. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1812 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1813 if (!dsl_prop_get_hasrecvd(os)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1814 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1815 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1816 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1817 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1818 if (zc->zc_nvlist_dst != 0 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1819 (error = dsl_prop_get_received(os, &nv)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1820 error = put_nvlist(zc, nv); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1821 nvlist_free(nv); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1822 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1823 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1824 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1825 return (error); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1826 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1827 |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1828 static int |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1829 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
|
1830 { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1831 uint64_t value; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1832 int error; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1833 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1834 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1835 * 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
|
1836 * the default value (if there is one). |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1837 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1838 if ((error = zfs_get_zplprop(os, prop, &value)) != 0) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1839 return (error); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1840 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
|
1841 return (0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1842 } |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1843 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1844 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1845 * inputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1846 * zc_name name of filesystem |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1847 * 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
|
1848 * |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1849 * outputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1850 * zc_nvlist_dst zpl property nvlist |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1851 * zc_nvlist_dst_size size of zpl property nvlist |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1852 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1853 static int |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1854 zfs_ioc_objset_zplprops(zfs_cmd_t *zc) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1855 { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1856 objset_t *os; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1857 int err; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1858 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1859 /* XXX reading without owning */ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1860 if (err = dmu_objset_hold(zc->zc_name, FTAG, &os)) |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1861 return (err); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1862 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1863 dmu_objset_fast_stat(os, &zc->zc_objset_stats); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1864 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1865 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1866 * 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
|
1867 * 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
|
1868 * hold, because it could be inconsistent. |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1869 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1870 if (zc->zc_nvlist_dst != NULL && |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1871 !zc->zc_objset_stats.dds_inconsistent && |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1872 dmu_objset_type(os) == DMU_OST_ZFS) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1873 nvlist_t *nv; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1874 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1875 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
|
1876 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
|
1877 (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
|
1878 (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
|
1879 (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
|
1880 err = put_nvlist(zc, nv); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1881 nvlist_free(nv); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1882 } else { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1883 err = ENOENT; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1884 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1885 dmu_objset_rele(os, FTAG); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1886 return (err); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1887 } |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1888 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1889 static boolean_t |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1890 dataset_name_hidden(const char *name) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1891 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1892 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1893 * Skip over datasets that are not visible in this zone, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1894 * internal datasets (which have a $ in their name), and |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1895 * temporary datasets (which have a % in their name). |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1896 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1897 if (strchr(name, '$') != NULL) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1898 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1899 if (strchr(name, '%') != NULL) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1900 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1901 if (!INGLOBALZONE(curproc) && !zone_dataset_visible(name, NULL)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1902 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1903 return (B_FALSE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1904 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1905 |
5367 | 1906 /* |
1907 * inputs: | |
1908 * zc_name name of filesystem | |
1909 * zc_cookie zap cursor | |
1910 * zc_nvlist_dst_size size of buffer for property nvlist | |
1911 * | |
1912 * outputs: | |
1913 * zc_name name of next filesystem | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1914 * zc_cookie zap cursor |
5367 | 1915 * zc_objset_stats stats |
1916 * zc_nvlist_dst property nvlist | |
1917 * zc_nvlist_dst_size size of property nvlist | |
1918 */ | |
789 | 1919 static int |
1920 zfs_ioc_dataset_list_next(zfs_cmd_t *zc) | |
1921 { | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1922 objset_t *os; |
789 | 1923 int error; |
1924 char *p; | |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1925 size_t orig_len = strlen(zc->zc_name); |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1926 |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1927 top: |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1928 if (error = dmu_objset_hold(zc->zc_name, FTAG, &os)) { |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1929 if (error == ENOENT) |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1930 error = ESRCH; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1931 return (error); |
789 | 1932 } |
1933 | |
1934 p = strrchr(zc->zc_name, '/'); | |
1935 if (p == NULL || p[1] != '\0') | |
1936 (void) strlcat(zc->zc_name, "/", sizeof (zc->zc_name)); | |
1937 p = zc->zc_name + strlen(zc->zc_name); | |
1938 | |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1939 /* |
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1940 * 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
|
1941 * 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
|
1942 */ |
8415
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1943 if (zc->zc_cookie == 0) { |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1944 uint64_t cookie = 0; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1945 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
|
1946 |
13492
83d135508f56
1346 zfs incremental receive may leave behind temporary clones
Martin Matuska <mm@FreeBSD.org>
parents:
13061
diff
changeset
|
1947 while (dmu_dir_list_next(os, len, p, NULL, &cookie) == 0) { |
83d135508f56
1346 zfs incremental receive may leave behind temporary clones
Martin Matuska <mm@FreeBSD.org>
parents:
13061
diff
changeset
|
1948 if (!dataset_name_hidden(zc->zc_name)) |
83d135508f56
1346 zfs incremental receive may leave behind temporary clones
Martin Matuska <mm@FreeBSD.org>
parents:
13061
diff
changeset
|
1949 (void) dmu_objset_prefetch(zc->zc_name, NULL); |
83d135508f56
1346 zfs incremental receive may leave behind temporary clones
Martin Matuska <mm@FreeBSD.org>
parents:
13061
diff
changeset
|
1950 } |
8415
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1951 } |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1952 |
789 | 1953 do { |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1954 error = dmu_dir_list_next(os, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1955 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
|
1956 NULL, &zc->zc_cookie); |
789 | 1957 if (error == ENOENT) |
1958 error = ESRCH; | |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1959 } while (error == 0 && dataset_name_hidden(zc->zc_name) && |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1960 !(zc->zc_iflags & FKIOCTL)); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1961 dmu_objset_rele(os, FTAG); |
789 | 1962 |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1963 /* |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1964 * If it's an internal dataset (ie. with a '$' in its name), |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1965 * don't try to get stats for it, otherwise we'll return ENOENT. |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1966 */ |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1967 if (error == 0 && strchr(zc->zc_name, '$') == NULL) { |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1968 error = zfs_ioc_objset_stats(zc); /* fill in the stats */ |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1969 if (error == ENOENT) { |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1970 /* We lost a race with destroy, get the next one. */ |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1971 zc->zc_name[orig_len] = '\0'; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1972 goto top; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1973 } |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1974 } |
789 | 1975 return (error); |
1976 } | |
1977 | |
5367 | 1978 /* |
1979 * inputs: | |
1980 * zc_name name of filesystem | |
1981 * zc_cookie zap cursor | |
1982 * zc_nvlist_dst_size size of buffer for property nvlist | |
1983 * | |
1984 * outputs: | |
1985 * zc_name name of next snapshot | |
1986 * zc_objset_stats stats | |
1987 * zc_nvlist_dst property nvlist | |
1988 * zc_nvlist_dst_size size of property nvlist | |
1989 */ | |
789 | 1990 static int |
1991 zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) | |
1992 { | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1993 objset_t *os; |
789 | 1994 int error; |
1995 | |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1996 top: |
10474
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
1997 if (zc->zc_cookie == 0) |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
1998 (void) dmu_objset_find(zc->zc_name, dmu_objset_prefetch, |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
1999 NULL, DS_FIND_SNAPSHOTS); |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
2000 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2001 error = dmu_objset_hold(zc->zc_name, FTAG, &os); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2002 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2003 return (error == ENOENT ? ESRCH : error); |
789 | 2004 |
1003 | 2005 /* |
2006 * A dataset name of maximum length cannot have any snapshots, | |
2007 * so exit immediately. | |
2008 */ | |
2009 if (strlcat(zc->zc_name, "@", sizeof (zc->zc_name)) >= MAXNAMELEN) { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2010 dmu_objset_rele(os, FTAG); |
1003 | 2011 return (ESRCH); |
789 | 2012 } |
2013 | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
2014 error = dmu_snapshot_list_next(os, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
2015 sizeof (zc->zc_name) - strlen(zc->zc_name), |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2016 zc->zc_name + strlen(zc->zc_name), &zc->zc_obj, &zc->zc_cookie, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2017 NULL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2018 |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2019 if (error == 0) { |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2020 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2021 dsl_pool_t *dp = os->os_dsl_dataset->ds_dir->dd_pool; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2022 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2023 /* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2024 * Since we probably don't have a hold on this snapshot, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2025 * it's possible that the objsetid could have been destroyed |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2026 * and reused for a new objset. It's OK if this happens during |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2027 * a zfs send operation, since the new createtxg will be |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2028 * beyond the range we're interested in. |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2029 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2030 rw_enter(&dp->dp_config_rwlock, RW_READER); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2031 error = dsl_dataset_hold_obj(dp, zc->zc_obj, FTAG, &ds); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2032 rw_exit(&dp->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2033 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2034 if (error == ENOENT) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2035 /* Racing with destroy, get the next one. */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2036 *strchr(zc->zc_name, '@') = '\0'; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2037 dmu_objset_rele(os, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2038 goto top; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2039 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2040 } else { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2041 objset_t *ossnap; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2042 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2043 error = dmu_objset_from_ds(ds, &ossnap); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2044 if (error == 0) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2045 error = zfs_ioc_objset_stats_impl(zc, ossnap); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2046 dsl_dataset_rele(ds, FTAG); |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2047 } |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2048 } else if (error == ENOENT) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2049 error = ESRCH; |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2050 } |
789 | 2051 |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2052 dmu_objset_rele(os, FTAG); |
5367 | 2053 /* 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
|
2054 if (error) |
5367 | 2055 *strchr(zc->zc_name, '@') = '\0'; |
789 | 2056 return (error); |
2057 } | |
2058 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2059 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2060 zfs_prop_set_userquota(const char *dsname, nvpair_t *pair) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2061 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2062 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2063 uint64_t *valary; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2064 unsigned int vallen; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2065 const char *domain; |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2066 char *dash; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2067 zfs_userquota_prop_t type; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2068 uint64_t rid; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2069 uint64_t quota; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2070 zfsvfs_t *zfsvfs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2071 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2072 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2073 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2074 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2075 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2076 if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2077 &pair) != 0) |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2078 return (EINVAL); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2079 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2080 |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2081 /* |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2082 * A correctly constructed propname is encoded as |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2083 * userquota@<rid>-<domain>. |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2084 */ |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2085 if ((dash = strchr(propname, '-')) == NULL || |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2086 nvpair_value_uint64_array(pair, &valary, &vallen) != 0 || |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2087 vallen != 3) |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2088 return (EINVAL); |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2089 |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2090 domain = dash + 1; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2091 type = valary[0]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2092 rid = valary[1]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2093 quota = valary[2]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2094 |
12620
12fcd99a642d
6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents:
12527
diff
changeset
|
2095 err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_FALSE); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2096 if (err == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2097 err = zfs_set_userquota(zfsvfs, type, domain, rid, quota); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2098 zfsvfs_rele(zfsvfs, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2099 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2100 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2101 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2102 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2103 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2104 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2105 * If the named property is one that has a special function to set its value, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2106 * return 0 on success and a positive error code on failure; otherwise if it is |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2107 * not one of the special properties handled by this function, return -1. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2108 * |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2109 * XXX: It would be better for callers of the property interface if we handled |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2110 * these special cases in dsl_prop.c (in the dsl layer). |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2111 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2112 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2113 zfs_prop_set_special(const char *dsname, zprop_source_t source, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2114 nvpair_t *pair) |
789 | 2115 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2116 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2117 zfs_prop_t prop = zfs_name_to_prop(propname); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2118 uint64_t intval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2119 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2120 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2121 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2122 if (zfs_prop_userquota(propname)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2123 return (zfs_prop_set_userquota(dsname, pair)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2124 return (-1); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2125 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2126 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2127 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2128 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2129 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2130 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2131 &pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2132 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2133 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2134 if (zfs_prop_get_type(prop) == PROP_TYPE_STRING) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2135 return (-1); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2136 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2137 VERIFY(0 == nvpair_value_uint64(pair, &intval)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2138 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2139 switch (prop) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2140 case ZFS_PROP_QUOTA: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2141 err = dsl_dir_set_quota(dsname, source, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2142 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2143 case ZFS_PROP_REFQUOTA: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2144 err = dsl_dataset_set_quota(dsname, source, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2145 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2146 case ZFS_PROP_RESERVATION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2147 err = dsl_dir_set_reservation(dsname, source, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2148 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2149 case ZFS_PROP_REFRESERVATION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2150 err = dsl_dataset_set_reservation(dsname, source, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2151 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2152 case ZFS_PROP_VOLSIZE: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2153 err = zvol_set_volsize(dsname, ddi_driver_major(zfs_dip), |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2154 intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2155 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2156 case ZFS_PROP_VERSION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2157 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2158 zfsvfs_t *zfsvfs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2159 |
12620
12fcd99a642d
6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents:
12527
diff
changeset
|
2160 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0) |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2161 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2162 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2163 err = zfs_set_version(zfsvfs, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2164 zfsvfs_rele(zfsvfs, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2165 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2166 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) { |
11147
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2167 zfs_cmd_t *zc; |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2168 |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2169 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2170 (void) strcpy(zc->zc_name, dsname); |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2171 (void) zfs_ioc_userspace_upgrade(zc); |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2172 kmem_free(zc, sizeof (zfs_cmd_t)); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2173 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2174 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2175 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2176 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2177 default: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2178 err = -1; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2179 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2180 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2181 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2182 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2183 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2184 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2185 * This function is best effort. If it fails to set any of the given properties, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2186 * it continues to set as many as it can and returns the first error |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2187 * encountered. If the caller provides a non-NULL errlist, it also gives the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2188 * complete list of names of all the properties it failed to set along with the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2189 * corresponding error numbers. The caller is responsible for freeing the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2190 * returned errlist. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2191 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2192 * If every property is set successfully, zero is returned and the list pointed |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2193 * at by errlist is NULL. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2194 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2195 int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2196 zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2197 nvlist_t **errlist) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2198 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2199 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2200 nvpair_t *propval; |
11045
0db6e4248051
6900437 uninitialized variable in zfs_set_prop_nvlist() panics 'zpool create' during installation of zfsroot
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11022
diff
changeset
|
2201 int rv = 0; |
2676 | 2202 uint64_t intval; |
2203 char *strval; | |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2204 nvlist_t *genericnvl; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2205 nvlist_t *errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2206 nvlist_t *retrynvl; |
4543 | 2207 |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2208 VERIFY(nvlist_alloc(&genericnvl, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2209 VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2210 VERIFY(nvlist_alloc(&retrynvl, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2211 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2212 retry: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2213 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2214 while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2215 const char *propname = nvpair_name(pair); |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
2216 zfs_prop_t prop = zfs_name_to_prop(propname); |
11181
daeb45eeb9fb
6904147 spurious 'zfs receive' errors when receiving properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11147
diff
changeset
|
2217 int err = 0; |
4543 | 2218 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2219 /* decode the property value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2220 propval = pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2221 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2222 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2223 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2224 if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2225 &propval) != 0) |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2226 err = EINVAL; |
4543 | 2227 } |
2676 | 2228 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2229 /* Validate value type */ |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2230 if (err == 0 && prop == ZPROP_INVAL) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2231 if (zfs_prop_user(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2232 if (nvpair_type(propval) != DATA_TYPE_STRING) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2233 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2234 } else if (zfs_prop_userquota(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2235 if (nvpair_type(propval) != |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2236 DATA_TYPE_UINT64_ARRAY) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2237 err = EINVAL; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2238 } |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
2239 } else if (err == 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2240 if (nvpair_type(propval) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2241 if (zfs_prop_get_type(prop) != PROP_TYPE_STRING) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2242 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2243 } else if (nvpair_type(propval) == DATA_TYPE_UINT64) { |
2885 | 2244 const char *unused; |
2245 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2246 VERIFY(nvpair_value_uint64(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2247 &intval) == 0); |
2676 | 2248 |
2249 switch (zfs_prop_get_type(prop)) { | |
4787 | 2250 case PROP_TYPE_NUMBER: |
2676 | 2251 break; |
4787 | 2252 case PROP_TYPE_STRING: |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2253 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2254 break; |
4787 | 2255 case PROP_TYPE_INDEX: |
2717
ed589a32259d
6469385 zfs_set_prop_nvlist range checking is busted
eschrock
parents:
2676
diff
changeset
|
2256 if (zfs_prop_index_to_string(prop, |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2257 intval, &unused) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2258 err = EINVAL; |
2676 | 2259 break; |
2260 default: | |
4577 | 2261 cmn_err(CE_PANIC, |
2262 "unknown property type"); | |
2676 | 2263 } |
2264 } else { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2265 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2266 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2267 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2268 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2269 /* Validate permissions */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2270 if (err == 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2271 err = zfs_check_settable(dsname, pair, CRED()); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2272 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2273 if (err == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2274 err = zfs_prop_set_special(dsname, source, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2275 if (err == -1) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2276 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2277 * For better performance we build up a list of |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2278 * properties to set in a single transaction. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2279 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2280 err = nvlist_add_nvpair(genericnvl, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2281 } else if (err != 0 && nvl != retrynvl) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2282 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2283 * This may be a spurious error caused by |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2284 * receiving quota and reservation out of order. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2285 * Try again in a second pass. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2286 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2287 err = nvlist_add_nvpair(retrynvl, pair); |
2676 | 2288 } |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2289 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2290 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2291 if (err != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2292 VERIFY(nvlist_add_int32(errors, propname, err) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2293 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2294 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2295 if (nvl != retrynvl && !nvlist_empty(retrynvl)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2296 nvl = retrynvl; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2297 goto retry; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2298 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2299 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2300 if (!nvlist_empty(genericnvl) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2301 dsl_props_set(dsname, source, genericnvl) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2302 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2303 * If this fails, we still want to set as many properties as we |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2304 * can, so try setting them individually. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2305 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2306 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2307 while ((pair = nvlist_next_nvpair(genericnvl, pair)) != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2308 const char *propname = nvpair_name(pair); |
11181
daeb45eeb9fb
6904147 spurious 'zfs receive' errors when receiving properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11147
diff
changeset
|
2309 int err = 0; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2310 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2311 propval = pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2312 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2313 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2314 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2315 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2316 &propval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2317 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2318 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2319 if (nvpair_type(propval) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2320 VERIFY(nvpair_value_string(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2321 &strval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2322 err = dsl_prop_set(dsname, propname, source, 1, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2323 strlen(strval) + 1, strval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2324 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2325 VERIFY(nvpair_value_uint64(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2326 &intval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2327 err = dsl_prop_set(dsname, propname, source, 8, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2328 1, &intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2329 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2330 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2331 if (err != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2332 VERIFY(nvlist_add_int32(errors, propname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2333 err) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2334 } |
2676 | 2335 } |
2336 } | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2337 nvlist_free(genericnvl); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2338 nvlist_free(retrynvl); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2339 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2340 if ((pair = nvlist_next_nvpair(errors, NULL)) == NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2341 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2342 errors = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2343 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2344 VERIFY(nvpair_value_int32(pair, &rv) == 0); |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2345 } |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2346 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2347 if (errlist == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2348 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2349 else |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2350 *errlist = errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2351 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2352 return (rv); |
789 | 2353 } |
2354 | |
5367 | 2355 /* |
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
|
2356 * 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
|
2357 */ |
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
|
2358 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
|
2359 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
|
2360 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2361 nvpair_t *pair = NULL; |
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9234
diff
changeset
|
2362 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
|
2363 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2364 while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2365 const char *propname = nvpair_name(pair); |
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9234
diff
changeset
|
2366 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
|
2367 |
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
|
2368 if (!zfs_prop_user(propname) || |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2369 nvpair_type(pair) != DATA_TYPE_STRING) |
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9234
diff
changeset
|
2370 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
|
2371 |
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
|
2372 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
|
2373 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
|
2374 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
|
2375 |
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
|
2376 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
|
2377 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
|
2378 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2379 VERIFY(nvpair_value_string(pair, &valstr) == 0); |
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9234
diff
changeset
|
2380 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
|
2381 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
|
2382 } |
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
|
2383 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
|
2384 } |
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
|
2385 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2386 static void |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2387 props_skip(nvlist_t *props, nvlist_t *skipped, nvlist_t **newprops) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2388 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2389 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2390 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2391 VERIFY(nvlist_alloc(newprops, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2392 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2393 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2394 while ((pair = nvlist_next_nvpair(props, pair)) != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2395 if (nvlist_exists(skipped, nvpair_name(pair))) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2396 continue; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2397 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2398 VERIFY(nvlist_add_nvpair(*newprops, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2399 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2400 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2401 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2402 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2403 clear_received_props(objset_t *os, const char *fs, nvlist_t *props, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2404 nvlist_t *skipped) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2405 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2406 int err = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2407 nvlist_t *cleared_props = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2408 props_skip(props, skipped, &cleared_props); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2409 if (!nvlist_empty(cleared_props)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2410 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2411 * Acts on local properties until the dataset has received |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2412 * properties at least once on or after SPA_VERSION_RECVD_PROPS. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2413 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2414 zprop_source_t flags = (ZPROP_SRC_NONE | |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2415 (dsl_prop_get_hasrecvd(os) ? ZPROP_SRC_RECEIVED : 0)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2416 err = zfs_set_prop_nvlist(fs, flags, cleared_props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2417 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2418 nvlist_free(cleared_props); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2419 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2420 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2421 |
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
|
2422 /* |
5367 | 2423 * inputs: |
2424 * 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
|
2425 * zc_value name of property to set |
5367 | 2426 * zc_nvlist_src{_size} nvlist of properties to apply |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2427 * zc_cookie received properties flag |
5367 | 2428 * |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2429 * outputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2430 * zc_nvlist_dst{_size} error for each unapplied received property |
5367 | 2431 */ |
789 | 2432 static int |
2676 | 2433 zfs_ioc_set_prop(zfs_cmd_t *zc) |
789 | 2434 { |
2676 | 2435 nvlist_t *nvl; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2436 boolean_t received = zc->zc_cookie; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2437 zprop_source_t source = (received ? ZPROP_SRC_RECEIVED : |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2438 ZPROP_SRC_LOCAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2439 nvlist_t *errors = NULL; |
2676 | 2440 int error; |
789 | 2441 |
5094 | 2442 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
2443 zc->zc_iflags, &nvl)) != 0) |
2676 | 2444 return (error); |
2445 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2446 if (received) { |
7265 | 2447 nvlist_t *origprops; |
2448 objset_t *os; | |
2449 | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2450 if (dmu_objset_hold(zc->zc_name, FTAG, &os) == 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2451 if (dsl_prop_get_received(os, &origprops) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2452 (void) clear_received_props(os, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2453 zc->zc_name, origprops, nvl); |
7265 | 2454 nvlist_free(origprops); |
2455 } | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2456 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2457 dsl_prop_set_hasrecvd(os); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2458 dmu_objset_rele(os, FTAG); |
7265 | 2459 } |
2460 } | |
2461 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2462 error = zfs_set_prop_nvlist(zc->zc_name, source, nvl, &errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2463 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2464 if (zc->zc_nvlist_dst != NULL && errors != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2465 (void) put_nvlist(zc, errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2466 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2467 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2468 nvlist_free(errors); |
2676 | 2469 nvlist_free(nvl); |
2470 return (error); | |
789 | 2471 } |
2472 | |
5367 | 2473 /* |
2474 * inputs: | |
2475 * zc_name name of filesystem | |
2476 * zc_value name of property to inherit | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2477 * zc_cookie revert to received value if TRUE |
5367 | 2478 * |
2479 * outputs: none | |
2480 */ | |
789 | 2481 static int |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2482 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
|
2483 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2484 const char *propname = zc->zc_value; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2485 zfs_prop_t prop = zfs_name_to_prop(propname); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2486 boolean_t received = zc->zc_cookie; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2487 zprop_source_t source = (received |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2488 ? ZPROP_SRC_NONE /* revert to received value, if any */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2489 : ZPROP_SRC_INHERITED); /* explicitly inherit */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2490 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2491 if (received) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2492 nvlist_t *dummy; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2493 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2494 zprop_type_t type; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2495 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2496 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2497 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2498 * zfs_prop_set_special() expects properties in the form of an |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2499 * nvpair with type info. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2500 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2501 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2502 if (!zfs_prop_user(propname)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2503 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2504 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2505 type = PROP_TYPE_STRING; |
11515
a122949107d4
6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11454
diff
changeset
|
2506 } else if (prop == ZFS_PROP_VOLSIZE || |
a122949107d4
6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11454
diff
changeset
|
2507 prop == ZFS_PROP_VERSION) { |
a122949107d4
6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11454
diff
changeset
|
2508 return (EINVAL); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2509 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2510 type = zfs_prop_get_type(prop); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2511 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2512 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2513 VERIFY(nvlist_alloc(&dummy, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2514 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2515 switch (type) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2516 case PROP_TYPE_STRING: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2517 VERIFY(0 == nvlist_add_string(dummy, propname, "")); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2518 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2519 case PROP_TYPE_NUMBER: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2520 case PROP_TYPE_INDEX: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2521 VERIFY(0 == nvlist_add_uint64(dummy, propname, 0)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2522 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2523 default: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2524 nvlist_free(dummy); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2525 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2526 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2527 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2528 pair = nvlist_next_nvpair(dummy, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2529 err = zfs_prop_set_special(zc->zc_name, source, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2530 nvlist_free(dummy); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2531 if (err != -1) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2532 return (err); /* special property already handled */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2533 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2534 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2535 * Only check this in the non-received case. We want to allow |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2536 * 'inherit -S' to revert non-inheritable properties like quota |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2537 * and reservation to the received or default values even though |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2538 * they are not considered inheritable. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2539 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2540 if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2541 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2542 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2543 |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2544 /* the property name has been validated by zfs_secpolicy_inherit() */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2545 return (dsl_prop_set(zc->zc_name, zc->zc_value, source, 0, 0, NULL)); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2546 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2547 |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2548 static int |
4098
0a182c2128e6
6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents:
4007
diff
changeset
|
2549 zfs_ioc_pool_set_props(zfs_cmd_t *zc) |
3912 | 2550 { |
5094 | 2551 nvlist_t *props; |
3912 | 2552 spa_t *spa; |
5094 | 2553 int error; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2554 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2555 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2556 if (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2557 zc->zc_iflags, &props)) |
3912 | 2558 return (error); |
2559 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2560 /* |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2561 * 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
|
2562 * 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
|
2563 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2564 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2565 if (pair != NULL && strcmp(nvpair_name(pair), |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2566 zpool_prop_to_name(ZPOOL_PROP_CACHEFILE)) == 0 && |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2567 nvlist_next_nvpair(props, pair) == NULL) { |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2568 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
|
2569 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
|
2570 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
|
2571 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
|
2572 } |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2573 mutex_exit(&spa_namespace_lock); |
10672
cee5a0f557db
6836743 zfs_ioc_pool_set_props() leaks nvlist if configfile is only property
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
2574 if (spa != NULL) { |
cee5a0f557db
6836743 zfs_ioc_pool_set_props() leaks nvlist if configfile is only property
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
2575 nvlist_free(props); |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2576 return (0); |
10672
cee5a0f557db
6836743 zfs_ioc_pool_set_props() leaks nvlist if configfile is only property
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
2577 } |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2578 } |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2579 |
3912 | 2580 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) { |
5094 | 2581 nvlist_free(props); |
3912 | 2582 return (error); |
2583 } | |
2584 | |
5094 | 2585 error = spa_prop_set(spa, props); |
3912 | 2586 |
5094 | 2587 nvlist_free(props); |
3912 | 2588 spa_close(spa, FTAG); |
2589 | |
2590 return (error); | |
2591 } | |
2592 | |
2593 static int | |
4098
0a182c2128e6
6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents:
4007
diff
changeset
|
2594 zfs_ioc_pool_get_props(zfs_cmd_t *zc) |
3912 | 2595 { |
2596 spa_t *spa; | |
2597 int error; | |
2598 nvlist_t *nvp = NULL; | |
2599 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2600 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
|
2601 /* |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2602 * 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
|
2603 * 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
|
2604 * anyway. |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2605 */ |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2606 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
|
2607 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
|
2608 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
|
2609 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
|
2610 } else { |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2611 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
|
2612 spa_close(spa, FTAG); |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2613 } |
3912 | 2614 |
2615 if (error == 0 && zc->zc_nvlist_dst != NULL) | |
2616 error = put_nvlist(zc, nvp); | |
2617 else | |
2618 error = EFAULT; | |
2619 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2620 nvlist_free(nvp); |
3912 | 2621 return (error); |
2622 } | |
2623 | |
5367 | 2624 /* |
2625 * inputs: | |
2626 * zc_name name of filesystem | |
2627 * zc_nvlist_src{_size} nvlist of delegated permissions | |
2628 * zc_perm_action allow/unallow flag | |
2629 * | |
2630 * outputs: none | |
2631 */ | |
4543 | 2632 static int |
2633 zfs_ioc_set_fsacl(zfs_cmd_t *zc) | |
2634 { | |
2635 int error; | |
2636 nvlist_t *fsaclnv = NULL; | |
2637 | |
5094 | 2638 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
2639 zc->zc_iflags, &fsaclnv)) != 0) |
4543 | 2640 return (error); |
2641 | |
2642 /* | |
2643 * Verify nvlist is constructed correctly | |
2644 */ | |
2645 if ((error = zfs_deleg_verify_nvlist(fsaclnv)) != 0) { | |
2646 nvlist_free(fsaclnv); | |
2647 return (EINVAL); | |
2648 } | |
2649 | |
2650 /* | |
2651 * If we don't have PRIV_SYS_MOUNT, then validate | |
2652 * that user is allowed to hand out each permission in | |
2653 * the nvlist(s) | |
2654 */ | |
2655 | |
4787 | 2656 error = secpolicy_zfs(CRED()); |
4543 | 2657 if (error) { |
4787 | 2658 if (zc->zc_perm_action == B_FALSE) { |
2659 error = dsl_deleg_can_allow(zc->zc_name, | |
2660 fsaclnv, CRED()); | |
2661 } else { | |
2662 error = dsl_deleg_can_unallow(zc->zc_name, | |
2663 fsaclnv, CRED()); | |
2664 } | |
4543 | 2665 } |
2666 | |
2667 if (error == 0) | |
2668 error = dsl_deleg_set(zc->zc_name, fsaclnv, zc->zc_perm_action); | |
2669 | |
2670 nvlist_free(fsaclnv); | |
2671 return (error); | |
2672 } | |
2673 | |
5367 | 2674 /* |
2675 * inputs: | |
2676 * zc_name name of filesystem | |
2677 * | |
2678 * outputs: | |
2679 * zc_nvlist_src{_size} nvlist of delegated permissions | |
2680 */ | |
4543 | 2681 static int |
2682 zfs_ioc_get_fsacl(zfs_cmd_t *zc) | |
2683 { | |
2684 nvlist_t *nvp; | |
2685 int error; | |
2686 | |
2687 if ((error = dsl_deleg_get(zc->zc_name, &nvp)) == 0) { | |
2688 error = put_nvlist(zc, nvp); | |
2689 nvlist_free(nvp); | |
2690 } | |
2691 | |
2692 return (error); | |
2693 } | |
2694 | |
5367 | 2695 /* |
789 | 2696 * Search the vfs list for a specified resource. Returns a pointer to it |
2697 * or NULL if no suitable entry is found. The caller of this routine | |
2698 * is responsible for releasing the returned vfs pointer. | |
2699 */ | |
2700 static vfs_t * | |
2701 zfs_get_vfs(const char *resource) | |
2702 { | |
2703 struct vfs *vfsp; | |
2704 struct vfs *vfs_found = NULL; | |
2705 | |
2706 vfs_list_read_lock(); | |
2707 vfsp = rootvfs; | |
2708 do { | |
2709 if (strcmp(refstr_value(vfsp->vfs_resource), resource) == 0) { | |
2710 VFS_HOLD(vfsp); | |
2711 vfs_found = vfsp; | |
2712 break; | |
2713 } | |
2714 vfsp = vfsp->vfs_next; | |
2715 } while (vfsp != rootvfs); | |
2716 vfs_list_unlock(); | |
2717 return (vfs_found); | |
2718 } | |
2719 | |
4543 | 2720 /* ARGSUSED */ |
789 | 2721 static void |
4543 | 2722 zfs_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx) |
789 | 2723 { |
5331 | 2724 zfs_creat_t *zct = arg; |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2725 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2726 zfs_create_fs(os, cr, zct->zct_zplprops, tx); |
5331 | 2727 } |
2728 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2729 #define ZFS_PROP_UNDEFINED ((uint64_t)-1) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2730 |
5331 | 2731 /* |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2732 * inputs: |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2733 * createprops list of properties requested by creator |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2734 * 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
|
2735 * 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
|
2736 * os parent objset pointer (NULL if root fs) |
5331 | 2737 * |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2738 * outputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2739 * 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
|
2740 * is_ci true if requested file system will be purely case-insensitive |
5331 | 2741 * |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2742 * Determine the settings for utf8only, normalization and |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2743 * casesensitivity. Specific values may have been requested by the |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2744 * 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
|
2745 * 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
|
2746 * request settings for these properties, even if the requested |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2747 * 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
|
2748 * 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
|
2749 * processing. |
5331 | 2750 */ |
2751 static int | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2752 zfs_fill_zplprops_impl(objset_t *os, uint64_t zplver, |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2753 boolean_t fuids_ok, boolean_t sa_ok, nvlist_t *createprops, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2754 nvlist_t *zplprops, boolean_t *is_ci) |
5331 | 2755 { |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2756 uint64_t sense = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2757 uint64_t norm = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2758 uint64_t u8 = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2759 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2760 ASSERT(zplprops != NULL); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2761 |
5375 | 2762 /* |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2763 * Pull out creator prop choices, if any. |
5375 | 2764 */ |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2765 if (createprops) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2766 (void) nvlist_lookup_uint64(createprops, |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2767 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
|
2768 (void) nvlist_lookup_uint64(createprops, |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2769 zfs_prop_to_name(ZFS_PROP_NORMALIZE), &norm); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2770 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2771 zfs_prop_to_name(ZFS_PROP_NORMALIZE)); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2772 (void) nvlist_lookup_uint64(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2773 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), &u8); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2774 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2775 zfs_prop_to_name(ZFS_PROP_UTF8ONLY)); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2776 (void) nvlist_lookup_uint64(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2777 zfs_prop_to_name(ZFS_PROP_CASE), &sense); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2778 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2779 zfs_prop_to_name(ZFS_PROP_CASE)); |
5331 | 2780 } |
2781 | |
5375 | 2782 /* |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2783 * 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
|
2784 * 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
|
2785 * 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
|
2786 * error out. |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2787 */ |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2788 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
|
2789 (zplver >= ZPL_VERSION_FUID && !fuids_ok) || |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2790 (zplver >= ZPL_VERSION_SA && !sa_ok) || |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2791 (zplver < ZPL_VERSION_NORMALIZATION && |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2792 (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
|
2793 sense != ZFS_PROP_UNDEFINED))) |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2794 return (ENOTSUP); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2795 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2796 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2797 * Put the version in the zplprops |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2798 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2799 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2800 zfs_prop_to_name(ZFS_PROP_VERSION), zplver) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2801 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2802 if (norm == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2803 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
|
2804 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2805 zfs_prop_to_name(ZFS_PROP_NORMALIZE), norm) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2806 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2807 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2808 * 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
|
2809 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2810 if (norm) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2811 u8 = 1; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2812 if (u8 == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2813 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
|
2814 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2815 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), u8) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2816 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2817 if (sense == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2818 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
|
2819 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2820 zfs_prop_to_name(ZFS_PROP_CASE), sense) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2821 |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2822 if (is_ci) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2823 *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
|
2824 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2825 return (0); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2826 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2827 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2828 static int |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2829 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
|
2830 nvlist_t *zplprops, boolean_t *is_ci) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2831 { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2832 boolean_t fuids_ok, sa_ok; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2833 uint64_t zplver = ZPL_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2834 objset_t *os = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2835 char parentname[MAXNAMELEN]; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2836 char *cp; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2837 spa_t *spa; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2838 uint64_t spa_vers; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2839 int error; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2840 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2841 (void) strlcpy(parentname, dataset, sizeof (parentname)); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2842 cp = strrchr(parentname, '/'); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2843 ASSERT(cp != NULL); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2844 cp[0] = '\0'; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2845 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2846 if ((error = spa_open(dataset, &spa, FTAG)) != 0) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2847 return (error); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2848 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2849 spa_vers = spa_version(spa); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2850 spa_close(spa, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2851 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2852 zplver = zfs_zpl_version_map(spa_vers); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2853 fuids_ok = (zplver >= ZPL_VERSION_FUID); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2854 sa_ok = (zplver >= ZPL_VERSION_SA); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2855 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2856 /* |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2857 * 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
|
2858 */ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2859 if ((error = dmu_objset_hold(parentname, FTAG, &os)) != 0) |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2860 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2861 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2862 error = zfs_fill_zplprops_impl(os, zplver, fuids_ok, sa_ok, createprops, |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2863 zplprops, is_ci); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2864 dmu_objset_rele(os, FTAG); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2865 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2866 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2867 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2868 static int |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2869 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
|
2870 nvlist_t *zplprops, boolean_t *is_ci) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2871 { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2872 boolean_t fuids_ok; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2873 boolean_t sa_ok; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2874 uint64_t zplver = ZPL_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2875 int error; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2876 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2877 zplver = zfs_zpl_version_map(spa_vers); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2878 fuids_ok = (zplver >= ZPL_VERSION_FUID); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2879 sa_ok = (zplver >= ZPL_VERSION_SA); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2880 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2881 error = zfs_fill_zplprops_impl(NULL, zplver, fuids_ok, sa_ok, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2882 createprops, zplprops, is_ci); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2883 return (error); |
789 | 2884 } |
2885 | |
5367 | 2886 /* |
2887 * inputs: | |
2888 * zc_objset_type type of objset to create (fs vs zvol) | |
2889 * zc_name name of new objset | |
2890 * zc_value name of snapshot to clone from (may be empty) | |
2891 * zc_nvlist_src{_size} nvlist of properties to apply | |
2892 * | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2893 * outputs: none |
5367 | 2894 */ |
789 | 2895 static int |
2896 zfs_ioc_create(zfs_cmd_t *zc) | |
2897 { | |
2898 objset_t *clone; | |
2899 int error = 0; | |
5331 | 2900 zfs_creat_t zct; |
4543 | 2901 nvlist_t *nvprops = NULL; |
2902 void (*cbfunc)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx); | |
789 | 2903 dmu_objset_type_t type = zc->zc_objset_type; |
2904 | |
2905 switch (type) { | |
2906 | |
2907 case DMU_OST_ZFS: | |
2908 cbfunc = zfs_create_cb; | |
2909 break; | |
2910 | |
2911 case DMU_OST_ZVOL: | |
2912 cbfunc = zvol_create_cb; | |
2913 break; | |
2914 | |
2915 default: | |
2199 | 2916 cbfunc = NULL; |
6423 | 2917 break; |
2199 | 2918 } |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
2919 if (strchr(zc->zc_name, '@') || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
2920 strchr(zc->zc_name, '%')) |
789 | 2921 return (EINVAL); |
2922 | |
2676 | 2923 if (zc->zc_nvlist_src != NULL && |
5094 | 2924 (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
2925 zc->zc_iflags, &nvprops)) != 0) |
2676 | 2926 return (error); |
2927 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2928 zct.zct_zplprops = NULL; |
5331 | 2929 zct.zct_props = nvprops; |
2930 | |
2676 | 2931 if (zc->zc_value[0] != '\0') { |
789 | 2932 /* |
2933 * We're creating a clone of an existing snapshot. | |
2934 */ | |
2676 | 2935 zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; |
2936 if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0) { | |
4543 | 2937 nvlist_free(nvprops); |
789 | 2938 return (EINVAL); |
2676 | 2939 } |
789 | 2940 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2941 error = dmu_objset_hold(zc->zc_value, FTAG, &clone); |
2676 | 2942 if (error) { |
4543 | 2943 nvlist_free(nvprops); |
789 | 2944 return (error); |
2676 | 2945 } |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2946 |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
2947 error = dmu_objset_clone(zc->zc_name, dmu_objset_ds(clone), 0); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2948 dmu_objset_rele(clone, FTAG); |
5331 | 2949 if (error) { |
2950 nvlist_free(nvprops); | |
2951 return (error); | |
2952 } | |
789 | 2953 } else { |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2954 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
|
2955 |
2676 | 2956 if (cbfunc == NULL) { |
4543 | 2957 nvlist_free(nvprops); |
2199 | 2958 return (EINVAL); |
2676 | 2959 } |
2960 | |
789 | 2961 if (type == DMU_OST_ZVOL) { |
2676 | 2962 uint64_t volsize, volblocksize; |
2963 | |
4543 | 2964 if (nvprops == NULL || |
2965 nvlist_lookup_uint64(nvprops, | |
2676 | 2966 zfs_prop_to_name(ZFS_PROP_VOLSIZE), |
2967 &volsize) != 0) { | |
4543 | 2968 nvlist_free(nvprops); |
2676 | 2969 return (EINVAL); |
2970 } | |
2971 | |
4543 | 2972 if ((error = nvlist_lookup_uint64(nvprops, |
2676 | 2973 zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), |
2974 &volblocksize)) != 0 && error != ENOENT) { | |
4543 | 2975 nvlist_free(nvprops); |
2676 | 2976 return (EINVAL); |
2977 } | |
1133
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
1003
diff
changeset
|
2978 |
2676 | 2979 if (error != 0) |
2980 volblocksize = zfs_prop_default_numeric( | |
2981 ZFS_PROP_VOLBLOCKSIZE); | |
2982 | |
2983 if ((error = zvol_check_volblocksize( | |
2984 volblocksize)) != 0 || | |
2985 (error = zvol_check_volsize(volsize, | |
2986 volblocksize)) != 0) { | |
4543 | 2987 nvlist_free(nvprops); |
789 | 2988 return (error); |
2676 | 2989 } |
4577 | 2990 } else if (type == DMU_OST_ZFS) { |
5331 | 2991 int error; |
2992 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2993 /* |
5331 | 2994 * We have to have normalization and |
2995 * case-folding flags correct when we do the | |
2996 * file system creation, so go figure them out | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2997 * now. |
5331 | 2998 */ |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2999 VERIFY(nvlist_alloc(&zct.zct_zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3000 NV_UNIQUE_NAME, KM_SLEEP) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3001 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
|
3002 zct.zct_zplprops, &is_insensitive); |
5331 | 3003 if (error != 0) { |
3004 nvlist_free(nvprops); | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3005 nvlist_free(zct.zct_zplprops); |
5331 | 3006 return (error); |
4577 | 3007 } |
2676 | 3008 } |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3009 error = dmu_objset_create(zc->zc_name, type, |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
3010 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
|
3011 nvlist_free(zct.zct_zplprops); |
789 | 3012 } |
2676 | 3013 |
3014 /* | |
3015 * It would be nice to do this atomically. | |
3016 */ | |
3017 if (error == 0) { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3018 error = zfs_set_prop_nvlist(zc->zc_name, ZPROP_SRC_LOCAL, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3019 nvprops, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3020 if (error != 0) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
3021 (void) dmu_objset_destroy(zc->zc_name, B_FALSE); |
2676 | 3022 } |
4543 | 3023 nvlist_free(nvprops); |
789 | 3024 return (error); |
3025 } | |
3026 | |
5367 | 3027 /* |
3028 * inputs: | |
3029 * zc_name name of filesystem | |
3030 * zc_value short name of snapshot | |
3031 * zc_cookie recursive flag | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3032 * zc_nvlist_src[_size] property list |
5367 | 3033 * |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3034 * outputs: |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3035 * zc_value short snapname (i.e. part after the '@') |
5367 | 3036 */ |
789 | 3037 static int |
2199 | 3038 zfs_ioc_snapshot(zfs_cmd_t *zc) |
3039 { | |
7265 | 3040 nvlist_t *nvprops = NULL; |
3041 int error; | |
3042 boolean_t recursive = zc->zc_cookie; | |
3043 | |
2676 | 3044 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
2199 | 3045 return (EINVAL); |
7265 | 3046 |
3047 if (zc->zc_nvlist_src != NULL && | |
3048 (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
3049 zc->zc_iflags, &nvprops)) != 0) |
7265 | 3050 return (error); |
3051 | |
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
|
3052 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
|
3053 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
|
3054 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
|
3055 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3056 if (!nvlist_empty(nvprops) && |
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9234
diff
changeset
|
3057 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
|
3058 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
|
3059 goto out; |
7265 | 3060 } |
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
|
3061 |
13055 | 3062 error = dmu_objset_snapshot(zc->zc_name, zc->zc_value, NULL, |
3063 nvprops, recursive, B_FALSE, -1); | |
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
|
3064 |
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
|
3065 out: |
7265 | 3066 nvlist_free(nvprops); |
3067 return (error); | |
2199 | 3068 } |
3069 | |
4007 | 3070 int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
3071 zfs_unmount_snap(const char *name, void *arg) |
789 | 3072 { |
2417 | 3073 vfs_t *vfsp = NULL; |
2199 | 3074 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3075 if (arg) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3076 char *snapname = arg; |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
3077 char *fullname = kmem_asprintf("%s@%s", name, snapname); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
3078 vfsp = zfs_get_vfs(fullname); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
3079 strfree(fullname); |
2417 | 3080 } else if (strchr(name, '@')) { |
2199 | 3081 vfsp = zfs_get_vfs(name); |
3082 } | |
3083 | |
3084 if (vfsp) { | |
3085 /* | |
3086 * Always force the unmount for snapshots. | |
3087 */ | |
3088 int flag = MS_FORCE; | |
789 | 3089 int err; |
3090 | |
2199 | 3091 if ((err = vn_vfswlock(vfsp->vfs_vnodecovered)) != 0) { |
3092 VFS_RELE(vfsp); | |
3093 return (err); | |
3094 } | |
3095 VFS_RELE(vfsp); | |
3096 if ((err = dounmount(vfsp, flag, kcred)) != 0) | |
3097 return (err); | |
3098 } | |
3099 return (0); | |
3100 } | |
3101 | |
5367 | 3102 /* |
3103 * inputs: | |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3104 * zc_name name of filesystem |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3105 * zc_value short name of snapshot |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
3106 * zc_defer_destroy mark for deferred destroy |
5367 | 3107 * |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3108 * outputs: none |
5367 | 3109 */ |
2199 | 3110 static int |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3111 zfs_ioc_destroy_snaps(zfs_cmd_t *zc) |
2199 | 3112 { |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3113 int err; |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3114 |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3115 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3116 return (EINVAL); |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3117 err = dmu_objset_find(zc->zc_name, |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3118 zfs_unmount_snap, zc->zc_value, DS_FIND_CHILDREN); |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3119 if (err) |
2199 | 3120 return (err); |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3121 return (dmu_snapshots_destroy(zc->zc_name, zc->zc_value, |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3122 zc->zc_defer_destroy)); |
2199 | 3123 } |
3124 | |
5367 | 3125 /* |
3126 * inputs: | |
3127 * zc_name name of dataset to destroy | |
3128 * zc_objset_type type of objset | |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
3129 * zc_defer_destroy mark for deferred destroy |
5367 | 3130 * |
3131 * outputs: none | |
3132 */ | |
2199 | 3133 static int |
3134 zfs_ioc_destroy(zfs_cmd_t *zc) | |
3135 { | |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3136 int err; |
2199 | 3137 if (strchr(zc->zc_name, '@') && zc->zc_objset_type == DMU_OST_ZFS) { |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3138 err = zfs_unmount_snap(zc->zc_name, NULL); |
2199 | 3139 if (err) |
3140 return (err); | |
789 | 3141 } |
3142 | |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3143 err = dmu_objset_destroy(zc->zc_name, zc->zc_defer_destroy); |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3144 if (zc->zc_objset_type == DMU_OST_ZVOL && err == 0) |
10693
aaa91fcac595
6871683 ztest should exercise deferred destroy
Chris Kirby <chris.kirby@sun.com>
parents:
10685
diff
changeset
|
3145 (void) zvol_remove_minor(zc->zc_name); |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3146 return (err); |
789 | 3147 } |
3148 | |
5367 | 3149 /* |
3150 * inputs: | |
5446 | 3151 * zc_name name of dataset to rollback (to most recent snapshot) |
5367 | 3152 * |
3153 * outputs: none | |
3154 */ | |
789 | 3155 static int |
3156 zfs_ioc_rollback(zfs_cmd_t *zc) | |
3157 { | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3158 dsl_dataset_t *ds, *clone; |
5446 | 3159 int error; |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3160 zfsvfs_t *zfsvfs; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3161 char *clone_name; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3162 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3163 error = dsl_dataset_hold(zc->zc_name, FTAG, &ds); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3164 if (error) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3165 return (error); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3166 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3167 /* must not be a snapshot */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3168 if (dsl_dataset_is_snapshot(ds)) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3169 dsl_dataset_rele(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3170 return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3171 } |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3172 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3173 /* must have a most recent snapshot */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3174 if (ds->ds_phys->ds_prev_snap_txg < TXG_INITIAL) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3175 dsl_dataset_rele(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3176 return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3177 } |
5446 | 3178 |
3179 /* | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3180 * Create clone of most recent snapshot. |
5446 | 3181 */ |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3182 clone_name = kmem_asprintf("%s/%%rollback", zc->zc_name); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3183 error = dmu_objset_clone(clone_name, ds->ds_prev, DS_FLAG_INCONSISTENT); |
5446 | 3184 if (error) |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3185 goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3186 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3187 error = dsl_dataset_own(clone_name, B_TRUE, FTAG, &clone); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3188 if (error) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3189 goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3190 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3191 /* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3192 * Do clone swap. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3193 */ |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3194 if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3195 error = zfs_suspend_fs(zfsvfs); |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5977
diff
changeset
|
3196 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
|
3197 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
|
3198 |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3199 if (dsl_dataset_tryown(ds, B_FALSE, FTAG)) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3200 error = dsl_dataset_clone_swap(clone, ds, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3201 B_TRUE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3202 dsl_dataset_disown(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3203 ds = NULL; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3204 } else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3205 error = EBUSY; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3206 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3207 resume_err = zfs_resume_fs(zfsvfs, zc->zc_name); |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5977
diff
changeset
|
3208 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
|
3209 } |
5446 | 3210 VFS_RELE(zfsvfs->z_vfs); |
3211 } else { | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3212 if (dsl_dataset_tryown(ds, B_FALSE, FTAG)) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3213 error = dsl_dataset_clone_swap(clone, ds, B_TRUE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3214 dsl_dataset_disown(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3215 ds = NULL; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3216 } else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3217 error = EBUSY; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3218 } |
5446 | 3219 } |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3220 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3221 /* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3222 * Destroy clone (which also closes it). |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3223 */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3224 (void) dsl_dataset_destroy(clone, FTAG, B_FALSE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3225 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3226 out: |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3227 strfree(clone_name); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3228 if (ds) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3229 dsl_dataset_rele(ds, FTAG); |
5446 | 3230 return (error); |
789 | 3231 } |
3232 | |
5367 | 3233 /* |
3234 * inputs: | |
3235 * zc_name old name of dataset | |
3236 * zc_value new name of dataset | |
3237 * zc_cookie recursive flag (only valid for snapshots) | |
3238 * | |
3239 * outputs: none | |
3240 */ | |
789 | 3241 static int |
3242 zfs_ioc_rename(zfs_cmd_t *zc) | |
3243 { | |
4490 | 3244 boolean_t recursive = zc->zc_cookie & 1; |
4007 | 3245 |
2676 | 3246 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
|
3247 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
|
3248 strchr(zc->zc_value, '%')) |
789 | 3249 return (EINVAL); |
3250 | |
4007 | 3251 /* |
3252 * Unmount snapshot unless we're doing a recursive rename, | |
3253 * in which case the dataset code figures out which snapshots | |
3254 * to unmount. | |
3255 */ | |
3256 if (!recursive && strchr(zc->zc_name, '@') != NULL && | |
789 | 3257 zc->zc_objset_type == DMU_OST_ZFS) { |
2199 | 3258 int err = zfs_unmount_snap(zc->zc_name, NULL); |
3259 if (err) | |
3260 return (err); | |
789 | 3261 } |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3262 if (zc->zc_objset_type == DMU_OST_ZVOL) |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3263 (void) zvol_remove_minor(zc->zc_name); |
4007 | 3264 return (dmu_objset_rename(zc->zc_name, zc->zc_value, recursive)); |
789 | 3265 } |
3266 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3267 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3268 zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3269 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3270 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3271 boolean_t issnap = (strchr(dsname, '@') != NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3272 zfs_prop_t prop = zfs_name_to_prop(propname); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3273 uint64_t intval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3274 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3275 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3276 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3277 if (zfs_prop_user(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3278 if (err = zfs_secpolicy_write_perms(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3279 ZFS_DELEG_PERM_USERPROP, cr)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3280 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3281 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3282 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3283 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3284 if (!issnap && zfs_prop_userquota(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3285 const char *perm = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3286 const char *uq_prefix = |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3287 zfs_userquota_prop_prefixes[ZFS_PROP_USERQUOTA]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3288 const char *gq_prefix = |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3289 zfs_userquota_prop_prefixes[ZFS_PROP_GROUPQUOTA]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3290 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3291 if (strncmp(propname, uq_prefix, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3292 strlen(uq_prefix)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3293 perm = ZFS_DELEG_PERM_USERQUOTA; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3294 } else if (strncmp(propname, gq_prefix, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3295 strlen(gq_prefix)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3296 perm = ZFS_DELEG_PERM_GROUPQUOTA; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3297 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3298 /* USERUSED and GROUPUSED are read-only */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3299 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3300 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3301 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3302 if (err = zfs_secpolicy_write_perms(dsname, perm, cr)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3303 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3304 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3305 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3306 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3307 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3308 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3309 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3310 if (issnap) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3311 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3312 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3313 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3314 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3315 * dsl_prop_get_all_impl() returns properties in this |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3316 * format. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3317 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3318 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3319 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3320 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3321 &pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3322 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3323 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3324 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3325 * Check that this value is valid for this pool version |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3326 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3327 switch (prop) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3328 case ZFS_PROP_COMPRESSION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3329 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3330 * If the user specified gzip compression, make sure |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3331 * the SPA supports it. We ignore any errors here since |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3332 * we'll catch them later. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3333 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3334 if (nvpair_type(pair) == DATA_TYPE_UINT64 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3335 nvpair_value_uint64(pair, &intval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3336 if (intval >= ZIO_COMPRESS_GZIP_1 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3337 intval <= ZIO_COMPRESS_GZIP_9 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3338 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3339 SPA_VERSION_GZIP_COMPRESSION)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3340 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3341 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3342 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3343 if (intval == ZIO_COMPRESS_ZLE && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3344 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3345 SPA_VERSION_ZLE_COMPRESSION)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3346 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3347 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3348 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3349 * If this is a bootable dataset then |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3350 * verify that the compression algorithm |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3351 * is supported for booting. We must return |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3352 * something other than ENOTSUP since it |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3353 * implies a downrev pool version. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3354 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3355 if (zfs_is_bootfs(dsname) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3356 !BOOTFS_COMPRESS_VALID(intval)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3357 return (ERANGE); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3358 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3359 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3360 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3361 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3362 case ZFS_PROP_COPIES: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3363 if (zfs_earlier_version(dsname, SPA_VERSION_DITTO_BLOCKS)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3364 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3365 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3366 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3367 case ZFS_PROP_DEDUP: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3368 if (zfs_earlier_version(dsname, SPA_VERSION_DEDUP)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3369 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3370 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3371 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3372 case ZFS_PROP_SHARESMB: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3373 if (zpl_earlier_version(dsname, ZPL_VERSION_FUID)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3374 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3375 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3376 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3377 case ZFS_PROP_ACLINHERIT: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3378 if (nvpair_type(pair) == DATA_TYPE_UINT64 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3379 nvpair_value_uint64(pair, &intval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3380 if (intval == ZFS_ACL_PASSTHROUGH_X && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3381 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3382 SPA_VERSION_PASSTHROUGH_X)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3383 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3384 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3385 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3386 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3387 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3388 return (zfs_secpolicy_setprop(dsname, prop, pair, CRED())); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3389 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3390 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3391 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3392 * Removes properties from the given props list that fail permission checks |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3393 * needed to clear them and to restore them in case of a receive error. For each |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3394 * property, make sure we have both set and inherit permissions. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3395 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3396 * Returns the first error encountered if any permission checks fail. If the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3397 * caller provides a non-NULL errlist, it also gives the complete list of names |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3398 * of all the properties that failed a permission check along with the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3399 * corresponding error numbers. The caller is responsible for freeing the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3400 * returned errlist. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3401 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3402 * If every property checks out successfully, zero is returned and the list |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3403 * pointed at by errlist is NULL. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3404 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3405 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3406 zfs_check_clearable(char *dataset, nvlist_t *props, nvlist_t **errlist) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3407 { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3408 zfs_cmd_t *zc; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3409 nvpair_t *pair, *next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3410 nvlist_t *errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3411 int err, rv = 0; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3412 |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3413 if (props == NULL) |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3414 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3415 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3416 VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3417 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3418 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
|
3419 (void) strcpy(zc->zc_name, dataset); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3420 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3421 while (pair != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3422 next_pair = nvlist_next_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3423 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3424 (void) strcpy(zc->zc_value, nvpair_name(pair)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3425 if ((err = zfs_check_settable(dataset, pair, CRED())) != 0 || |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3426 (err = zfs_secpolicy_inherit(zc, CRED())) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3427 VERIFY(nvlist_remove_nvpair(props, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3428 VERIFY(nvlist_add_int32(errors, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3429 zc->zc_value, err) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3430 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3431 pair = next_pair; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3432 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3433 kmem_free(zc, sizeof (zfs_cmd_t)); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3434 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3435 if ((pair = nvlist_next_nvpair(errors, NULL)) == NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3436 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3437 errors = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3438 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3439 VERIFY(nvpair_value_int32(pair, &rv) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3440 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3441 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3442 if (errlist == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3443 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3444 else |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3445 *errlist = errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3446 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3447 return (rv); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3448 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3449 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3450 static boolean_t |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3451 propval_equals(nvpair_t *p1, nvpair_t *p2) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3452 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3453 if (nvpair_type(p1) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3454 /* dsl_prop_get_all_impl() format */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3455 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3456 VERIFY(nvpair_value_nvlist(p1, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3457 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3458 &p1) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3459 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3460 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3461 if (nvpair_type(p2) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3462 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3463 VERIFY(nvpair_value_nvlist(p2, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3464 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3465 &p2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3466 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3467 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3468 if (nvpair_type(p1) != nvpair_type(p2)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3469 return (B_FALSE); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3470 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3471 if (nvpair_type(p1) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3472 char *valstr1, *valstr2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3473 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3474 VERIFY(nvpair_value_string(p1, (char **)&valstr1) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3475 VERIFY(nvpair_value_string(p2, (char **)&valstr2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3476 return (strcmp(valstr1, valstr2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3477 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3478 uint64_t intval1, intval2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3479 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3480 VERIFY(nvpair_value_uint64(p1, &intval1) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3481 VERIFY(nvpair_value_uint64(p2, &intval2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3482 return (intval1 == intval2); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3483 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3484 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3485 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3486 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3487 * Remove properties from props if they are not going to change (as determined |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3488 * by comparison with origprops). Remove them from origprops as well, since we |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3489 * do not need to clear or restore properties that won't change. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3490 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3491 static void |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3492 props_reduce(nvlist_t *props, nvlist_t *origprops) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3493 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3494 nvpair_t *pair, *next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3495 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3496 if (origprops == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3497 return; /* all props need to be received */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3498 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3499 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3500 while (pair != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3501 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3502 nvpair_t *match; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3503 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3504 next_pair = nvlist_next_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3505 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3506 if ((nvlist_lookup_nvpair(origprops, propname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3507 &match) != 0) || !propval_equals(pair, match)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3508 goto next; /* need to set received value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3509 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3510 /* don't clear the existing received value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3511 (void) nvlist_remove_nvpair(origprops, match); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3512 /* don't bother receiving the property */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3513 (void) nvlist_remove_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3514 next: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3515 pair = next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3516 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3517 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3518 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3519 #ifdef DEBUG |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3520 static boolean_t zfs_ioc_recv_inject_err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3521 #endif |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3522 |
5367 | 3523 /* |
3524 * inputs: | |
3525 * zc_name name of containing filesystem | |
3526 * zc_nvlist_src{_size} nvlist of properties to apply | |
3527 * zc_value name of snapshot to create | |
3528 * zc_string name of clone origin (if DRR_FLAG_CLONE) | |
3529 * zc_cookie file descriptor to recv from | |
3530 * zc_begin_record the BEGIN record of the stream (not byteswapped) | |
3531 * zc_guid force flag | |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
3532 * zc_cleanup_fd cleanup-on-exit file descriptor |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
3533 * zc_action_handle handle for this guid/ds mapping (or zero on first call) |
5367 | 3534 * |
3535 * outputs: | |
3536 * zc_cookie number of bytes read | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3537 * zc_nvlist_dst{_size} error for each unapplied received property |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3538 * zc_obj zprop_errflags_t |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
3539 * zc_action_handle handle for this guid/ds mapping |
5367 | 3540 */ |
789 | 3541 static int |
5367 | 3542 zfs_ioc_recv(zfs_cmd_t *zc) |
789 | 3543 { |
3544 file_t *fp; | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3545 objset_t *os; |
5367 | 3546 dmu_recv_cookie_t drc; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3547 boolean_t force = (boolean_t)zc->zc_guid; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3548 int fd; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3549 int error = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3550 int props_error = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3551 nvlist_t *errors; |
5367 | 3552 offset_t off; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3553 nvlist_t *props = NULL; /* sent properties */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3554 nvlist_t *origprops = NULL; /* existing properties */ |
5367 | 3555 objset_t *origin = NULL; |
3556 char *tosnap; | |
3557 char tofs[ZFS_MAXNAMELEN]; | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3558 boolean_t first_recvd_props = B_FALSE; |
789 | 3559 |
3265
967e0fca6143
6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents:
3087
diff
changeset
|
3560 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
|
3561 strchr(zc->zc_value, '@') == NULL || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3562 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
|
3563 return (EINVAL); |
967e0fca6143
6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents:
3087
diff
changeset
|
3564 |
5367 | 3565 (void) strcpy(tofs, zc->zc_value); |
3566 tosnap = strchr(tofs, '@'); | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3567 *tosnap++ = '\0'; |
5367 | 3568 |
3569 if (zc->zc_nvlist_src != NULL && | |
3570 (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
3571 zc->zc_iflags, &props)) != 0) |
5367 | 3572 return (error); |
3573 | |
789 | 3574 fd = zc->zc_cookie; |
3575 fp = getf(fd); | |
5367 | 3576 if (fp == NULL) { |
3577 nvlist_free(props); | |
789 | 3578 return (EBADF); |
5367 | 3579 } |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3580 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3581 VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3582 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3583 if (props && dmu_objset_hold(tofs, FTAG, &os) == 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3584 if ((spa_version(os->os_spa) >= SPA_VERSION_RECVD_PROPS) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3585 !dsl_prop_get_hasrecvd(os)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3586 first_recvd_props = B_TRUE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3587 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3588 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3589 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3590 * If new received properties are supplied, they are to |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3591 * completely replace the existing received properties, so stash |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3592 * away the existing ones. |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3593 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3594 if (dsl_prop_get_received(os, &origprops) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3595 nvlist_t *errlist = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3596 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3597 * Don't bother writing a property if its value won't |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3598 * change (and avoid the unnecessary security checks). |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3599 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3600 * The first receive after SPA_VERSION_RECVD_PROPS is a |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3601 * special case where we blow away all local properties |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3602 * regardless. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3603 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3604 if (!first_recvd_props) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3605 props_reduce(props, origprops); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3606 if (zfs_check_clearable(tofs, origprops, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3607 &errlist) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3608 (void) nvlist_merge(errors, errlist, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3609 nvlist_free(errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3610 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3611 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3612 dmu_objset_rele(os, FTAG); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3613 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3614 |
5367 | 3615 if (zc->zc_string[0]) { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3616 error = dmu_objset_hold(zc->zc_string, FTAG, &origin); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3617 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3618 goto out; |
5367 | 3619 } |
3620 | |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10972
diff
changeset
|
3621 error = dmu_recv_begin(tofs, tosnap, zc->zc_top_ds, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10972
diff
changeset
|
3622 &zc->zc_begin_record, force, origin, &drc); |
5367 | 3623 if (origin) |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3624 dmu_objset_rele(origin, FTAG); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3625 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3626 goto out; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3627 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3628 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3629 * Set properties before we receive the stream so that they are applied |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3630 * to the new data. Note that we must call dmu_recv_stream() if |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3631 * dmu_recv_begin() succeeds. |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3632 */ |
5367 | 3633 if (props) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3634 nvlist_t *errlist; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3635 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3636 if (dmu_objset_from_ds(drc.drc_logical_ds, &os) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3637 if (drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3638 if (spa_version(os->os_spa) >= |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3639 SPA_VERSION_RECVD_PROPS) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3640 first_recvd_props = B_TRUE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3641 } else if (origprops != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3642 if (clear_received_props(os, tofs, origprops, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3643 first_recvd_props ? NULL : props) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3644 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3645 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3646 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3647 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3648 dsl_prop_set_hasrecvd(os); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3649 } else if (!drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3650 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3651 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3652 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3653 (void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_RECEIVED, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3654 props, &errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3655 (void) nvlist_merge(errors, errlist, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3656 nvlist_free(errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3657 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3658 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3659 if (fit_error_list(zc, &errors) != 0 || put_nvlist(zc, errors) != 0) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3660 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3661 * Caller made zc->zc_nvlist_dst less than the minimum expected |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3662 * size or supplied an invalid address. |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3663 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3664 props_error = EINVAL; |
5367 | 3665 } |
3666 | |
3667 off = fp->f_offset; | |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
3668 error = dmu_recv_stream(&drc, fp->f_vnode, &off, zc->zc_cleanup_fd, |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
3669 &zc->zc_action_handle); |
5367 | 3670 |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3671 if (error == 0) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3672 zfsvfs_t *zfsvfs = NULL; |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3673 |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3674 if (getzfsvfs(tofs, &zfsvfs) == 0) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3675 /* online recv */ |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3676 int end_err; |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3677 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3678 error = zfs_suspend_fs(zfsvfs); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3679 /* |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3680 * If the suspend fails, then the recv_end will |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3681 * likely also fail, and clean up after itself. |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3682 */ |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3683 end_err = dmu_recv_end(&drc); |
11812
453b88fd62f1
6891437 DEADCODE in zfs_ioc_recv after dmu_recv_end.
George Wilson <George.Wilson@Sun.COM>
parents:
11807
diff
changeset
|
3684 if (error == 0) |
453b88fd62f1
6891437 DEADCODE in zfs_ioc_recv after dmu_recv_end.
George Wilson <George.Wilson@Sun.COM>
parents:
11807
diff
changeset
|
3685 error = zfs_resume_fs(zfsvfs, tofs); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3686 error = error ? error : end_err; |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3687 VFS_RELE(zfsvfs->z_vfs); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3688 } else { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3689 error = dmu_recv_end(&drc); |
5367 | 3690 } |
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
|
3691 } |
5367 | 3692 |
3693 zc->zc_cookie = off - fp->f_offset; | |
3694 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) | |
3695 fp->f_offset = off; | |
2885 | 3696 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3697 #ifdef DEBUG |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3698 if (zfs_ioc_recv_inject_err) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3699 zfs_ioc_recv_inject_err = B_FALSE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3700 error = 1; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3701 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3702 #endif |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3703 /* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3704 * On error, restore the original props. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3705 */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3706 if (error && props) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3707 if (dmu_objset_hold(tofs, FTAG, &os) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3708 if (clear_received_props(os, tofs, props, NULL) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3709 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3710 * We failed to clear the received properties. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3711 * Since we may have left a $recvd value on the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3712 * system, we can't clear the $hasrecvd flag. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3713 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3714 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3715 } else if (first_recvd_props) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3716 dsl_prop_unset_hasrecvd(os); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3717 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3718 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3719 } else if (!drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3720 /* We failed to clear the received properties. */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3721 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3722 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3723 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3724 if (origprops == NULL && !drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3725 /* We failed to stash the original properties. */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3726 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3727 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3728 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3729 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3730 * dsl_props_set() will not convert RECEIVED to LOCAL on or |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3731 * after SPA_VERSION_RECVD_PROPS, so we need to specify LOCAL |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3732 * explictly if we're restoring local properties cleared in the |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3733 * first new-style receive. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3734 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3735 if (origprops != NULL && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3736 zfs_set_prop_nvlist(tofs, (first_recvd_props ? |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3737 ZPROP_SRC_LOCAL : ZPROP_SRC_RECEIVED), |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3738 origprops, NULL) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3739 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3740 * We stashed the original properties but failed to |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3741 * restore them. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3742 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3743 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3744 } |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3745 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3746 out: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3747 nvlist_free(props); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3748 nvlist_free(origprops); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3749 nvlist_free(errors); |
789 | 3750 releasef(fd); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3751 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3752 if (error == 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3753 error = props_error; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3754 |
789 | 3755 return (error); |
3756 } | |
3757 | |
5367 | 3758 /* |
3759 * inputs: | |
3760 * zc_name name of snapshot to send | |
3761 * zc_cookie file descriptor to send stream to | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3762 * zc_obj fromorigin flag (mutually exclusive with zc_fromobj) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3763 * zc_sendobj objsetid of snapshot to send |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3764 * zc_fromobj objsetid of incremental fromsnap (may be zero) |
5367 | 3765 * |
3766 * outputs: none | |
3767 */ | |
789 | 3768 static int |
5367 | 3769 zfs_ioc_send(zfs_cmd_t *zc) |
789 | 3770 { |
3771 objset_t *fromsnap = NULL; | |
3772 objset_t *tosnap; | |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3773 file_t *fp; |
789 | 3774 int error; |
5367 | 3775 offset_t off; |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3776 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3777 dsl_dataset_t *dsfrom = NULL; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3778 spa_t *spa; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3779 dsl_pool_t *dp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3780 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3781 error = spa_open(zc->zc_name, &spa, FTAG); |
789 | 3782 if (error) |
3783 return (error); | |
3784 | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3785 dp = spa_get_dsl(spa); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3786 rw_enter(&dp->dp_config_rwlock, RW_READER); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3787 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &ds); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3788 rw_exit(&dp->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3789 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3790 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3791 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3792 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3793 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3794 error = dmu_objset_from_ds(ds, &tosnap); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3795 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3796 dsl_dataset_rele(ds, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3797 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3798 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3799 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3800 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3801 if (zc->zc_fromobj != 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3802 rw_enter(&dp->dp_config_rwlock, RW_READER); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3803 error = dsl_dataset_hold_obj(dp, zc->zc_fromobj, FTAG, &dsfrom); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3804 rw_exit(&dp->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3805 spa_close(spa, FTAG); |
789 | 3806 if (error) { |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3807 dsl_dataset_rele(ds, FTAG); |
789 | 3808 return (error); |
3809 } | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3810 error = dmu_objset_from_ds(dsfrom, &fromsnap); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3811 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3812 dsl_dataset_rele(dsfrom, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3813 dsl_dataset_rele(ds, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3814 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3815 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3816 } else { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3817 spa_close(spa, FTAG); |
789 | 3818 } |
3819 | |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3820 fp = getf(zc->zc_cookie); |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3821 if (fp == NULL) { |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3822 dsl_dataset_rele(ds, FTAG); |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3823 if (dsfrom) |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3824 dsl_dataset_rele(dsfrom, FTAG); |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3825 return (EBADF); |
789 | 3826 } |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3827 |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3828 off = fp->f_offset; |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3829 error = dmu_sendbackup(tosnap, fromsnap, zc->zc_obj, fp->f_vnode, &off); |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3830 |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3831 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3832 fp->f_offset = off; |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
3833 releasef(zc->zc_cookie); |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3834 if (dsfrom) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3835 dsl_dataset_rele(dsfrom, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3836 dsl_dataset_rele(ds, FTAG); |
789 | 3837 return (error); |
3838 } | |
3839 | |
1544 | 3840 static int |
3841 zfs_ioc_inject_fault(zfs_cmd_t *zc) | |
3842 { | |
3843 int id, error; | |
3844 | |
3845 error = zio_inject_fault(zc->zc_name, (int)zc->zc_guid, &id, | |
3846 &zc->zc_inject_record); | |
3847 | |
3848 if (error == 0) | |
3849 zc->zc_guid = (uint64_t)id; | |
3850 | |
3851 return (error); | |
3852 } | |
3853 | |
3854 static int | |
3855 zfs_ioc_clear_fault(zfs_cmd_t *zc) | |
3856 { | |
3857 return (zio_clear_fault((int)zc->zc_guid)); | |
3858 } | |
3859 | |
3860 static int | |
3861 zfs_ioc_inject_list_next(zfs_cmd_t *zc) | |
3862 { | |
3863 int id = (int)zc->zc_guid; | |
3864 int error; | |
3865 | |
3866 error = zio_inject_list_next(&id, zc->zc_name, sizeof (zc->zc_name), | |
3867 &zc->zc_inject_record); | |
3868 | |
3869 zc->zc_guid = id; | |
3870 | |
3871 return (error); | |
3872 } | |
3873 | |
3874 static int | |
3875 zfs_ioc_error_log(zfs_cmd_t *zc) | |
3876 { | |
3877 spa_t *spa; | |
3878 int error; | |
2676 | 3879 size_t count = (size_t)zc->zc_nvlist_dst_size; |
1544 | 3880 |
3881 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) | |
3882 return (error); | |
3883 | |
2676 | 3884 error = spa_get_errlog(spa, (void *)(uintptr_t)zc->zc_nvlist_dst, |
1544 | 3885 &count); |
3886 if (error == 0) | |
2676 | 3887 zc->zc_nvlist_dst_size = count; |
1544 | 3888 else |
2676 | 3889 zc->zc_nvlist_dst_size = spa_get_errlog_size(spa); |
1544 | 3890 |
3891 spa_close(spa, FTAG); | |
3892 | |
3893 return (error); | |
3894 } | |
3895 | |
3896 static int | |
3897 zfs_ioc_clear(zfs_cmd_t *zc) | |
3898 { | |
3899 spa_t *spa; | |
3900 vdev_t *vd; | |
3901 int error; | |
3902 | |
7294 | 3903 /* |
3904 * On zpool clear we also fix up missing slogs | |
3905 */ | |
3906 mutex_enter(&spa_namespace_lock); | |
3907 spa = spa_lookup(zc->zc_name); | |
3908 if (spa == NULL) { | |
3909 mutex_exit(&spa_namespace_lock); | |
3910 return (EIO); | |
3911 } | |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
3912 if (spa_get_log_state(spa) == SPA_LOG_MISSING) { |
7294 | 3913 /* we need to let spa_open/spa_load clear the chains */ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
3914 spa_set_log_state(spa, SPA_LOG_CLEAR); |
7294 | 3915 } |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3916 spa->spa_last_open_failed = 0; |
7294 | 3917 mutex_exit(&spa_namespace_lock); |
3918 | |
11727
497d03ab2824
6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11546
diff
changeset
|
3919 if (zc->zc_cookie & ZPOOL_NO_REWIND) { |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3920 error = spa_open(zc->zc_name, &spa, FTAG); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3921 } else { |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3922 nvlist_t *policy; |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3923 nvlist_t *config = NULL; |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3924 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3925 if (zc->zc_nvlist_src == NULL) |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3926 return (EINVAL); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3927 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3928 if ((error = get_nvlist(zc->zc_nvlist_src, |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3929 zc->zc_nvlist_src_size, zc->zc_iflags, &policy)) == 0) { |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3930 error = spa_open_rewind(zc->zc_name, &spa, FTAG, |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3931 policy, &config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3932 if (config != NULL) { |
12961
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
3933 int err; |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
3934 |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
3935 if ((err = put_nvlist(zc, config)) != 0) |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
3936 error = err; |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3937 nvlist_free(config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3938 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3939 nvlist_free(policy); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3940 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3941 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3942 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
3943 if (error) |
1544 | 3944 return (error); |
3945 | |
10685
931790026ac6
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents:
10672
diff
changeset
|
3946 spa_vdev_state_enter(spa, SCL_NONE); |
1544 | 3947 |
2676 | 3948 if (zc->zc_guid == 0) { |
1544 | 3949 vd = NULL; |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6492
diff
changeset
|
3950 } else { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6492
diff
changeset
|
3951 vd = spa_lookup_by_guid(spa, zc->zc_guid, B_TRUE); |
5450 | 3952 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
|
3953 (void) spa_vdev_state_exit(spa, NULL, ENODEV); |
5450 | 3954 spa_close(spa, FTAG); |
3955 return (ENODEV); | |
3956 } | |
1544 | 3957 } |
3958 | |
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
|
3959 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
|
3960 |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
3961 (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
|
3962 |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
3963 /* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
3964 * 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
|
3965 */ |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
3966 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
|
3967 error = EIO; |
1544 | 3968 |
3969 spa_close(spa, FTAG); | |
3970 | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
3971 return (error); |
1544 | 3972 } |
3973 | |
5367 | 3974 /* |
3975 * inputs: | |
3976 * zc_name name of filesystem | |
3977 * zc_value name of origin snapshot | |
3978 * | |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3979 * outputs: |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3980 * zc_string name of conflicting snapshot, if there is one |
5367 | 3981 */ |
1544 | 3982 static int |
2082 | 3983 zfs_ioc_promote(zfs_cmd_t *zc) |
3984 { | |
2417 | 3985 char *cp; |
3986 | |
3987 /* | |
3988 * We don't need to unmount *all* the origin fs's snapshots, but | |
3989 * it's easier. | |
3990 */ | |
2676 | 3991 cp = strchr(zc->zc_value, '@'); |
2417 | 3992 if (cp) |
3993 *cp = '\0'; | |
2676 | 3994 (void) dmu_objset_find(zc->zc_value, |
2417 | 3995 zfs_unmount_snap, NULL, DS_FIND_SNAPSHOTS); |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
3996 return (dsl_dataset_promote(zc->zc_name, zc->zc_string)); |
2082 | 3997 } |
3998 | |
4543 | 3999 /* |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4000 * Retrieve a single {user|group}{used|quota}@... property. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4001 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4002 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4003 * zc_name name of filesystem |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4004 * zc_objset_type zfs_userquota_prop_t |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4005 * zc_value domain name (eg. "S-1-234-567-89") |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4006 * zc_guid RID/UID/GID |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4007 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4008 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4009 * zc_cookie property value |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4010 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4011 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4012 zfs_ioc_userspace_one(zfs_cmd_t *zc) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4013 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4014 zfsvfs_t *zfsvfs; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4015 int error; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4016 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4017 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4018 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4019 |
12620
12fcd99a642d
6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents:
12527
diff
changeset
|
4020 error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4021 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4022 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4023 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4024 error = zfs_userspace_one(zfsvfs, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4025 zc->zc_objset_type, zc->zc_value, zc->zc_guid, &zc->zc_cookie); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4026 zfsvfs_rele(zfsvfs, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4027 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4028 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4029 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4030 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4031 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4032 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4033 * zc_name name of filesystem |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4034 * zc_cookie zap cursor |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4035 * zc_objset_type zfs_userquota_prop_t |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4036 * zc_nvlist_dst[_size] buffer to fill (not really an nvlist) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4037 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4038 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4039 * zc_nvlist_dst[_size] data buffer (array of zfs_useracct_t) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4040 * zc_cookie zap cursor |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4041 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4042 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4043 zfs_ioc_userspace_many(zfs_cmd_t *zc) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4044 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4045 zfsvfs_t *zfsvfs; |
11933
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
4046 int bufsize = zc->zc_nvlist_dst_size; |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
4047 |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
4048 if (bufsize <= 0) |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
4049 return (ENOMEM); |
76670fc4178f
6931083 incorrect zfs userquota nvlist propnames can break Solaris 10 Containers and panic systems
Tim Haley <Tim.Haley@Sun.COM>
parents:
11889
diff
changeset
|
4050 |
12620
12fcd99a642d
6957974 assertion failed: 0 == sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs)
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents:
12527
diff
changeset
|
4051 int error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4052 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4053 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4054 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4055 void *buf = kmem_alloc(bufsize, KM_SLEEP); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4056 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4057 error = zfs_userspace_many(zfsvfs, zc->zc_objset_type, &zc->zc_cookie, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4058 buf, &zc->zc_nvlist_dst_size); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4059 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4060 if (error == 0) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4061 error = xcopyout(buf, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4062 (void *)(uintptr_t)zc->zc_nvlist_dst, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4063 zc->zc_nvlist_dst_size); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4064 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4065 kmem_free(buf, bufsize); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4066 zfsvfs_rele(zfsvfs, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4067 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4068 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4069 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4070 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4071 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4072 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4073 * zc_name name of filesystem |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4074 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4075 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4076 * none |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4077 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4078 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4079 zfs_ioc_userspace_upgrade(zfs_cmd_t *zc) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4080 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4081 objset_t *os; |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4082 int error = 0; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4083 zfsvfs_t *zfsvfs; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4084 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4085 if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4086 if (!dmu_objset_userused_enabled(zfsvfs->z_os)) { |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4087 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4088 * If userused is not enabled, it may be because the |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4089 * objset needs to be closed & reopened (to grow the |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4090 * objset_phys_t). Suspend/resume the fs will do that. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4091 */ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4092 error = zfs_suspend_fs(zfsvfs); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4093 if (error == 0) |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4094 error = zfs_resume_fs(zfsvfs, zc->zc_name); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4095 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4096 if (error == 0) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4097 error = dmu_objset_userspace_upgrade(zfsvfs->z_os); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4098 VFS_RELE(zfsvfs->z_vfs); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4099 } else { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4100 /* XXX kind of reading contents without owning */ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4101 error = dmu_objset_hold(zc->zc_name, FTAG, &os); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4102 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4103 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4104 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4105 error = dmu_objset_userspace_upgrade(os); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4106 dmu_objset_rele(os, FTAG); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4107 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4108 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4109 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4110 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4111 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4112 /* |
4543 | 4113 * We don't want to have a hard dependency |
4114 * against some special symbols in sharefs | |
5331 | 4115 * nfs, and smbsrv. Determine them if needed when |
4543 | 4116 * the first file system is shared. |
5331 | 4117 * Neither sharefs, nfs or smbsrv are unloadable modules. |
4543 | 4118 */ |
5331 | 4119 int (*znfsexport_fs)(void *arg); |
4543 | 4120 int (*zshare_fs)(enum sharefs_sys_op, share_t *, uint32_t); |
5331 | 4121 int (*zsmbexport_fs)(void *arg, boolean_t add_share); |
4122 | |
4123 int zfs_nfsshare_inited; | |
4124 int zfs_smbshare_inited; | |
4125 | |
4543 | 4126 ddi_modhandle_t nfs_mod; |
4127 ddi_modhandle_t sharefs_mod; | |
5331 | 4128 ddi_modhandle_t smbsrv_mod; |
4543 | 4129 kmutex_t zfs_share_lock; |
4130 | |
4131 static int | |
5331 | 4132 zfs_init_sharefs() |
4133 { | |
4134 int error; | |
4135 | |
4136 ASSERT(MUTEX_HELD(&zfs_share_lock)); | |
4137 /* Both NFS and SMB shares also require sharetab support. */ | |
4138 if (sharefs_mod == NULL && ((sharefs_mod = | |
4139 ddi_modopen("fs/sharefs", | |
4140 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
4141 return (ENOSYS); | |
4142 } | |
4143 if (zshare_fs == NULL && ((zshare_fs = | |
4144 (int (*)(enum sharefs_sys_op, share_t *, uint32_t)) | |
4145 ddi_modsym(sharefs_mod, "sharefs_impl", &error)) == NULL)) { | |
4146 return (ENOSYS); | |
4147 } | |
4148 return (0); | |
4149 } | |
4150 | |
4151 static int | |
4543 | 4152 zfs_ioc_share(zfs_cmd_t *zc) |
4153 { | |
4154 int error; | |
4155 int opcode; | |
4156 | |
5331 | 4157 switch (zc->zc_share.z_sharetype) { |
4158 case ZFS_SHARE_NFS: | |
4159 case ZFS_UNSHARE_NFS: | |
4160 if (zfs_nfsshare_inited == 0) { | |
4161 mutex_enter(&zfs_share_lock); | |
4162 if (nfs_mod == NULL && ((nfs_mod = ddi_modopen("fs/nfs", | |
4163 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
4164 mutex_exit(&zfs_share_lock); | |
4165 return (ENOSYS); | |
4166 } | |
4167 if (znfsexport_fs == NULL && | |
4168 ((znfsexport_fs = (int (*)(void *)) | |
4169 ddi_modsym(nfs_mod, | |
4170 "nfs_export", &error)) == NULL)) { | |
4171 mutex_exit(&zfs_share_lock); | |
4172 return (ENOSYS); | |
4173 } | |
4174 error = zfs_init_sharefs(); | |
4175 if (error) { | |
4176 mutex_exit(&zfs_share_lock); | |
4177 return (ENOSYS); | |
4178 } | |
4179 zfs_nfsshare_inited = 1; | |
4543 | 4180 mutex_exit(&zfs_share_lock); |
4181 } | |
5331 | 4182 break; |
4183 case ZFS_SHARE_SMB: | |
4184 case ZFS_UNSHARE_SMB: | |
4185 if (zfs_smbshare_inited == 0) { | |
4186 mutex_enter(&zfs_share_lock); | |
4187 if (smbsrv_mod == NULL && ((smbsrv_mod = | |
4188 ddi_modopen("drv/smbsrv", | |
4189 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
4190 mutex_exit(&zfs_share_lock); | |
4191 return (ENOSYS); | |
4192 } | |
4193 if (zsmbexport_fs == NULL && ((zsmbexport_fs = | |
4194 (int (*)(void *, boolean_t))ddi_modsym(smbsrv_mod, | |
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6083
diff
changeset
|
4195 "smb_server_share", &error)) == NULL)) { |
5331 | 4196 mutex_exit(&zfs_share_lock); |
4197 return (ENOSYS); | |
4198 } | |
4199 error = zfs_init_sharefs(); | |
4200 if (error) { | |
4201 mutex_exit(&zfs_share_lock); | |
4202 return (ENOSYS); | |
4203 } | |
4204 zfs_smbshare_inited = 1; | |
4543 | 4205 mutex_exit(&zfs_share_lock); |
4206 } | |
5331 | 4207 break; |
4208 default: | |
4209 return (EINVAL); | |
4543 | 4210 } |
4211 | |
5331 | 4212 switch (zc->zc_share.z_sharetype) { |
4213 case ZFS_SHARE_NFS: | |
4214 case ZFS_UNSHARE_NFS: | |
4215 if (error = | |
4216 znfsexport_fs((void *) | |
4217 (uintptr_t)zc->zc_share.z_exportdata)) | |
4218 return (error); | |
4219 break; | |
4220 case ZFS_SHARE_SMB: | |
4221 case ZFS_UNSHARE_SMB: | |
4222 if (error = zsmbexport_fs((void *) | |
4223 (uintptr_t)zc->zc_share.z_exportdata, | |
4224 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
|
4225 B_TRUE: B_FALSE)) { |
5331 | 4226 return (error); |
4227 } | |
4228 break; | |
4229 } | |
4230 | |
4231 opcode = (zc->zc_share.z_sharetype == ZFS_SHARE_NFS || | |
4232 zc->zc_share.z_sharetype == ZFS_SHARE_SMB) ? | |
4543 | 4233 SHAREFS_ADD : SHAREFS_REMOVE; |
4234 | |
5331 | 4235 /* |
4236 * Add or remove share from sharetab | |
4237 */ | |
4543 | 4238 error = zshare_fs(opcode, |
4239 (void *)(uintptr_t)zc->zc_share.z_sharedata, | |
4240 zc->zc_share.z_sharemax); | |
4241 | |
4242 return (error); | |
4243 | |
4244 } | |
4245 | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4246 ace_t full_access[] = { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4247 {(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
|
4248 }; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4249 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4250 /* |
13055 | 4251 * inputs: |
4252 * zc_name name of containing filesystem | |
4253 * zc_obj object # beyond which we want next in-use object # | |
4254 * | |
4255 * outputs: | |
4256 * zc_obj next in-use object # | |
4257 */ | |
4258 static int | |
4259 zfs_ioc_next_obj(zfs_cmd_t *zc) | |
4260 { | |
4261 objset_t *os = NULL; | |
4262 int error; | |
4263 | |
4264 error = dmu_objset_hold(zc->zc_name, FTAG, &os); | |
4265 if (error) | |
4266 return (error); | |
4267 | |
4268 error = dmu_object_next(os, &zc->zc_obj, B_FALSE, | |
4269 os->os_dsl_dataset->ds_phys->ds_prev_snap_txg); | |
4270 | |
4271 dmu_objset_rele(os, FTAG); | |
4272 return (error); | |
4273 } | |
4274 | |
4275 /* | |
4276 * inputs: | |
4277 * zc_name name of filesystem | |
4278 * zc_value prefix name for snapshot | |
4279 * zc_cleanup_fd cleanup-on-exit file descriptor for calling process | |
4280 * | |
4281 * outputs: | |
4282 */ | |
4283 static int | |
4284 zfs_ioc_tmp_snapshot(zfs_cmd_t *zc) | |
4285 { | |
4286 char *snap_name; | |
4287 int error; | |
4288 | |
4289 snap_name = kmem_asprintf("%s-%016llx", zc->zc_value, | |
4290 (u_longlong_t)ddi_get_lbolt64()); | |
4291 | |
4292 if (strlen(snap_name) >= MAXNAMELEN) { | |
4293 strfree(snap_name); | |
4294 return (E2BIG); | |
4295 } | |
4296 | |
4297 error = dmu_objset_snapshot(zc->zc_name, snap_name, snap_name, | |
4298 NULL, B_FALSE, B_TRUE, zc->zc_cleanup_fd); | |
4299 if (error != 0) { | |
4300 strfree(snap_name); | |
4301 return (error); | |
4302 } | |
4303 | |
4304 (void) strcpy(zc->zc_value, snap_name); | |
4305 strfree(snap_name); | |
4306 return (0); | |
4307 } | |
4308 | |
4309 /* | |
4310 * inputs: | |
4311 * zc_name name of "to" snapshot | |
4312 * zc_value name of "from" snapshot | |
4313 * zc_cookie file descriptor to write diff data on | |
4314 * | |
4315 * outputs: | |
4316 * dmu_diff_record_t's to the file descriptor | |
4317 */ | |
4318 static int | |
4319 zfs_ioc_diff(zfs_cmd_t *zc) | |
4320 { | |
4321 objset_t *fromsnap; | |
4322 objset_t *tosnap; | |
4323 file_t *fp; | |
4324 offset_t off; | |
4325 int error; | |
4326 | |
4327 error = dmu_objset_hold(zc->zc_name, FTAG, &tosnap); | |
4328 if (error) | |
4329 return (error); | |
4330 | |
4331 error = dmu_objset_hold(zc->zc_value, FTAG, &fromsnap); | |
4332 if (error) { | |
4333 dmu_objset_rele(tosnap, FTAG); | |
4334 return (error); | |
4335 } | |
4336 | |
4337 fp = getf(zc->zc_cookie); | |
4338 if (fp == NULL) { | |
4339 dmu_objset_rele(fromsnap, FTAG); | |
4340 dmu_objset_rele(tosnap, FTAG); | |
4341 return (EBADF); | |
4342 } | |
4343 | |
4344 off = fp->f_offset; | |
4345 | |
4346 error = dmu_diff(tosnap, fromsnap, fp->f_vnode, &off); | |
4347 | |
4348 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) | |
4349 fp->f_offset = off; | |
4350 releasef(zc->zc_cookie); | |
4351 | |
4352 dmu_objset_rele(fromsnap, FTAG); | |
4353 dmu_objset_rele(tosnap, FTAG); | |
4354 return (error); | |
4355 } | |
4356 | |
4357 /* | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4358 * 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
|
4359 */ |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4360 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4361 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
|
4362 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4363 zap_cursor_t zc; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4364 zap_attribute_t zap; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4365 zfsvfs_t *zfsvfs = dzp->z_zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4366 int error; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4367 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4368 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
|
4369 (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
|
4370 zap_cursor_advance(&zc)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4371 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
|
4372 NULL, 0)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4373 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4374 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4375 zap_cursor_fini(&zc); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4376 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4377 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4378 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4379 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4380 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
|
4381 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4382 vnode_t *vp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4383 znode_t *dzp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4384 vnode_t *resourcevp = NULL; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4385 znode_t *sharedir; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4386 zfsvfs_t *zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4387 nvlist_t *nvlist; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4388 char *src, *target; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4389 vattr_t vattr; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4390 vsecattr_t vsec; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4391 int error = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4392 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4393 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
|
4394 NO_FOLLOW, NULL, &vp)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4395 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4396 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4397 /* 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
|
4398 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4399 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
|
4400 (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
|
4401 zc->zc_name) != 0)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4402 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4403 return (EINVAL); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4404 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4405 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4406 dzp = VTOZ(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4407 zfsvfs = dzp->z_zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4408 ZFS_ENTER(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4409 |
9030
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4410 /* |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4411 * 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
|
4412 */ |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4413 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
|
4414 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
|
4415 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
|
4416 |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4417 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
|
4418 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
|
4419 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
|
4420 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
|
4421 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
|
4422 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
|
4423 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
|
4424 } else { |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4425 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
|
4426 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
|
4427 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4428 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
|
4429 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
|
4430 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
|
4431 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
|
4432 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
|
4433 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4434 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4435 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
|
4436 |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4437 ASSERT(zfsvfs->z_shares_dir); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4438 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
|
4439 VN_RELE(vp); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4440 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4441 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4442 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4443 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4444 switch (zc->zc_cookie) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4445 case ZFS_SMB_ACL_ADD: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4446 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
|
4447 vattr.va_type = VREG; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4448 vattr.va_mode = S_IFREG|0777; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4449 vattr.va_uid = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4450 vattr.va_gid = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4451 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4452 vsec.vsa_mask = VSA_ACE; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4453 vsec.vsa_aclentp = &full_access; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4454 vsec.vsa_aclentsz = sizeof (full_access); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4455 vsec.vsa_aclcnt = 1; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4456 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4457 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
|
4458 &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
|
4459 if (resourcevp) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4460 VN_RELE(resourcevp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4461 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4462 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4463 case ZFS_SMB_ACL_REMOVE: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4464 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
|
4465 NULL, 0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4466 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4467 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4468 case ZFS_SMB_ACL_RENAME: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4469 if ((error = get_nvlist(zc->zc_nvlist_src, |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
4470 zc->zc_nvlist_src_size, zc->zc_iflags, &nvlist)) != 0) { |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4471 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4472 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4473 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4474 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4475 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
|
4476 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
|
4477 &target)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4478 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
|
4479 VN_RELE(ZTOV(sharedir)); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4480 ZFS_EXIT(zfsvfs); |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4481 nvlist_free(nvlist); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4482 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4483 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4484 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
|
4485 kcred, NULL, 0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4486 nvlist_free(nvlist); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4487 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4488 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4489 case ZFS_SMB_ACL_PURGE: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4490 error = zfs_smb_acl_purge(sharedir); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4491 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4492 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4493 default: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4494 error = EINVAL; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4495 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4496 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4497 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4498 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4499 VN_RELE(ZTOV(sharedir)); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4500 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4501 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4502 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4503 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4504 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4505 |
4543 | 4506 /* |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4507 * inputs: |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4508 * zc_name name of filesystem |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4509 * zc_value short name of snap |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4510 * zc_string user-supplied tag for this hold |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4511 * zc_cookie recursive flag |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4512 * zc_temphold set if hold is temporary |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4513 * zc_cleanup_fd cleanup-on-exit file descriptor for calling process |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4514 * zc_sendobj if non-zero, the objid for zc_name@zc_value |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4515 * zc_createtxg if zc_sendobj is non-zero, snap must have zc_createtxg |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4516 * |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4517 * outputs: none |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4518 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4519 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4520 zfs_ioc_hold(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4521 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4522 boolean_t recursive = zc->zc_cookie; |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4523 spa_t *spa; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4524 dsl_pool_t *dp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4525 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4526 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4527 minor_t minor = 0; |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4528 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4529 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4530 return (EINVAL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4531 |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4532 if (zc->zc_sendobj == 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4533 return (dsl_dataset_user_hold(zc->zc_name, zc->zc_value, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4534 zc->zc_string, recursive, zc->zc_temphold, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4535 zc->zc_cleanup_fd)); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4536 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4537 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4538 if (recursive) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4539 return (EINVAL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4540 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4541 error = spa_open(zc->zc_name, &spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4542 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4543 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4544 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4545 dp = spa_get_dsl(spa); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4546 rw_enter(&dp->dp_config_rwlock, RW_READER); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4547 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &ds); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4548 rw_exit(&dp->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4549 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4550 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4551 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4552 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4553 /* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4554 * Until we have a hold on this snapshot, it's possible that |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4555 * zc_sendobj could've been destroyed and reused as part |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4556 * of a later txg. Make sure we're looking at the right object. |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4557 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4558 if (zc->zc_createtxg != ds->ds_phys->ds_creation_txg) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4559 dsl_dataset_rele(ds, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4560 return (ENOENT); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4561 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4562 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4563 if (zc->zc_cleanup_fd != -1 && zc->zc_temphold) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4564 error = zfs_onexit_fd_hold(zc->zc_cleanup_fd, &minor); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4565 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4566 dsl_dataset_rele(ds, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4567 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4568 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4569 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4570 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4571 error = dsl_dataset_user_hold_for_send(ds, zc->zc_string, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4572 zc->zc_temphold); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4573 if (minor != 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4574 if (error == 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4575 dsl_register_onexit_hold_cleanup(ds, zc->zc_string, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4576 minor); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4577 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4578 zfs_onexit_fd_rele(zc->zc_cleanup_fd); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4579 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4580 dsl_dataset_rele(ds, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4581 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4582 return (error); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4583 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4584 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4585 /* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4586 * inputs: |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4587 * zc_name name of dataset from which we're releasing a user hold |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4588 * zc_value short name of snap |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4589 * zc_string user-supplied tag for this hold |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4590 * zc_cookie recursive flag |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4591 * |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4592 * outputs: none |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4593 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4594 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4595 zfs_ioc_release(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4596 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4597 boolean_t recursive = zc->zc_cookie; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4598 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4599 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4600 return (EINVAL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4601 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4602 return (dsl_dataset_user_release(zc->zc_name, zc->zc_value, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4603 zc->zc_string, recursive)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4604 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4605 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4606 /* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4607 * inputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4608 * zc_name name of filesystem |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4609 * |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4610 * outputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4611 * zc_nvlist_src{_size} nvlist of snapshot holds |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4612 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4613 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4614 zfs_ioc_get_holds(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4615 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4616 nvlist_t *nvp; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4617 int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4618 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4619 if ((error = dsl_dataset_get_holds(zc->zc_name, &nvp)) == 0) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4620 error = put_nvlist(zc, nvp); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4621 nvlist_free(nvp); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4622 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4623 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4624 return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4625 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4626 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4627 /* |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
4628 * 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
|
4629 * 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
|
4630 * do the logging of those commands. |
4543 | 4631 */ |
789 | 4632 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
|
4633 { zfs_ioc_pool_create, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4634 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4635 { zfs_ioc_pool_destroy, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4636 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4637 { zfs_ioc_pool_import, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4638 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4639 { zfs_ioc_pool_export, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4640 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4641 { zfs_ioc_pool_configs, zfs_secpolicy_none, NO_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4642 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4643 { zfs_ioc_pool_stats, zfs_secpolicy_read, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4644 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4645 { zfs_ioc_pool_tryimport, zfs_secpolicy_config, NO_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4646 POOL_CHECK_NONE }, |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
4647 { zfs_ioc_pool_scan, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4648 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4649 { zfs_ioc_pool_freeze, zfs_secpolicy_config, NO_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4650 POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4651 { zfs_ioc_pool_upgrade, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4652 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4653 { zfs_ioc_pool_get_history, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4654 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4655 { zfs_ioc_vdev_add, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4656 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4657 { zfs_ioc_vdev_remove, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4658 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4659 { zfs_ioc_vdev_set_state, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4660 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4661 { zfs_ioc_vdev_attach, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4662 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4663 { zfs_ioc_vdev_detach, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4664 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4665 { zfs_ioc_vdev_setpath, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4666 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9425
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
4667 { zfs_ioc_vdev_setfru, zfs_secpolicy_config, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4668 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4669 { zfs_ioc_objset_stats, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4670 POOL_CHECK_SUSPENDED }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4671 { zfs_ioc_objset_zplprops, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4672 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4673 { zfs_ioc_dataset_list_next, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4674 POOL_CHECK_SUSPENDED }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4675 { zfs_ioc_snapshot_list_next, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4676 POOL_CHECK_SUSPENDED }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4677 { zfs_ioc_set_prop, zfs_secpolicy_none, DATASET_NAME, B_TRUE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4678 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4679 { zfs_ioc_create, zfs_secpolicy_create, DATASET_NAME, B_TRUE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4680 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4681 { zfs_ioc_destroy, zfs_secpolicy_destroy, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4682 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4683 { zfs_ioc_rollback, zfs_secpolicy_rollback, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4684 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4685 { zfs_ioc_rename, zfs_secpolicy_rename, DATASET_NAME, B_TRUE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4686 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4687 { zfs_ioc_recv, zfs_secpolicy_receive, DATASET_NAME, B_TRUE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4688 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
4689 { zfs_ioc_send, zfs_secpolicy_send, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4690 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4691 { zfs_ioc_inject_fault, zfs_secpolicy_inject, NO_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4692 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4693 { zfs_ioc_clear_fault, zfs_secpolicy_inject, NO_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4694 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4695 { zfs_ioc_inject_list_next, zfs_secpolicy_inject, NO_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4696 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4697 { zfs_ioc_error_log, zfs_secpolicy_inject, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4698 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4699 { zfs_ioc_clear, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4700 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4701 { zfs_ioc_promote, zfs_secpolicy_promote, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4702 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
4703 { zfs_ioc_destroy_snaps, zfs_secpolicy_destroy_snaps, DATASET_NAME, |
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
4704 B_TRUE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4705 { zfs_ioc_snapshot, zfs_secpolicy_snapshot, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4706 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13055 | 4707 { zfs_ioc_dsobj_to_dsname, zfs_secpolicy_diff, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4708 POOL_CHECK_NONE }, |
13055 | 4709 { zfs_ioc_obj_to_path, zfs_secpolicy_diff, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4710 POOL_CHECK_SUSPENDED }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4711 { zfs_ioc_pool_set_props, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4712 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4713 { zfs_ioc_pool_get_props, zfs_secpolicy_read, POOL_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4714 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4715 { zfs_ioc_set_fsacl, zfs_secpolicy_fsacl, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4716 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4717 { zfs_ioc_get_fsacl, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4718 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4719 { zfs_ioc_share, zfs_secpolicy_share, DATASET_NAME, B_FALSE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4720 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4721 { zfs_ioc_inherit_prop, zfs_secpolicy_inherit, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4722 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4723 { zfs_ioc_smb_acl, zfs_secpolicy_smb_acl, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4724 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4725 { zfs_ioc_userspace_one, zfs_secpolicy_userspace_one, DATASET_NAME, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4726 B_FALSE, POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4727 { zfs_ioc_userspace_many, zfs_secpolicy_userspace_many, DATASET_NAME, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4728 B_FALSE, POOL_CHECK_NONE }, |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4729 { zfs_ioc_userspace_upgrade, zfs_secpolicy_userspace_upgrade, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4730 DATASET_NAME, B_FALSE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4731 { zfs_ioc_hold, zfs_secpolicy_hold, DATASET_NAME, B_TRUE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4732 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4733 { zfs_ioc_release, zfs_secpolicy_release, DATASET_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4734 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4735 { zfs_ioc_get_holds, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4736 POOL_CHECK_SUSPENDED }, |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
4737 { zfs_ioc_objset_recvd_props, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4738 POOL_CHECK_NONE }, |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4739 { zfs_ioc_vdev_split, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4740 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13055 | 4741 { zfs_ioc_next_obj, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4742 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4743 { zfs_ioc_diff, zfs_secpolicy_diff, DATASET_NAME, B_FALSE, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4744 POOL_CHECK_NONE }, |
13055 | 4745 { zfs_ioc_tmp_snapshot, zfs_secpolicy_tmp_snapshot, DATASET_NAME, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4746 B_FALSE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13055 | 4747 { zfs_ioc_obj_to_stats, zfs_secpolicy_diff, DATASET_NAME, B_FALSE, |
13512
060607df0c9d
backout 1644/1645/1646/1647/1708: Breaks 'zfs snapshot', boot environments
Richard Lowe <richlowe@richlowe.net>
parents:
13509
diff
changeset
|
4748 POOL_CHECK_SUSPENDED } |
789 | 4749 }; |
4750 | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4751 int |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4752 pool_status_check(const char *name, zfs_ioc_namecheck_t type, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4753 zfs_ioc_poolcheck_t check) |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4754 { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4755 spa_t *spa; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4756 int error; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4757 |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4758 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
|
4759 |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4760 if (check & POOL_CHECK_NONE) |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4761 return (0); |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4762 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4763 error = spa_open(name, &spa, FTAG); |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4764 if (error == 0) { |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4765 if ((check & POOL_CHECK_SUSPENDED) && spa_suspended(spa)) |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4766 error = EAGAIN; |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4767 else if ((check & POOL_CHECK_READONLY) && !spa_writeable(spa)) |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4768 error = EROFS; |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4769 spa_close(spa, FTAG); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4770 } |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4771 return (error); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4772 } |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4773 |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4774 /* |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4775 * Find a free minor number. |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4776 */ |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4777 minor_t |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4778 zfsdev_minor_alloc(void) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4779 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4780 static minor_t last_minor; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4781 minor_t m; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4782 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4783 ASSERT(MUTEX_HELD(&zfsdev_state_lock)); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4784 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4785 for (m = last_minor + 1; m != last_minor; m++) { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4786 if (m > ZFSDEV_MAX_MINOR) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4787 m = 1; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4788 if (ddi_get_soft_state(zfsdev_state, m) == NULL) { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4789 last_minor = m; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4790 return (m); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4791 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4792 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4793 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4794 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4795 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4796 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4797 static int |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4798 zfs_ctldev_init(dev_t *devp) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4799 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4800 minor_t minor; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4801 zfs_soft_state_t *zs; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4802 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4803 ASSERT(MUTEX_HELD(&zfsdev_state_lock)); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4804 ASSERT(getminor(*devp) == 0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4805 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4806 minor = zfsdev_minor_alloc(); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4807 if (minor == 0) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4808 return (ENXIO); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4809 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4810 if (ddi_soft_state_zalloc(zfsdev_state, minor) != DDI_SUCCESS) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4811 return (EAGAIN); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4812 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4813 *devp = makedevice(getemajor(*devp), minor); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4814 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4815 zs = ddi_get_soft_state(zfsdev_state, minor); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4816 zs->zss_type = ZSST_CTLDEV; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4817 zfs_onexit_init((zfs_onexit_t **)&zs->zss_data); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4818 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4819 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4820 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4821 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4822 static void |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4823 zfs_ctldev_destroy(zfs_onexit_t *zo, minor_t minor) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4824 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4825 ASSERT(MUTEX_HELD(&zfsdev_state_lock)); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4826 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4827 zfs_onexit_destroy(zo); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4828 ddi_soft_state_free(zfsdev_state, minor); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4829 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4830 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4831 void * |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4832 zfsdev_get_soft_state(minor_t minor, enum zfs_soft_state_type which) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4833 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4834 zfs_soft_state_t *zp; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4835 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4836 zp = ddi_get_soft_state(zfsdev_state, minor); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4837 if (zp == NULL || zp->zss_type != which) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4838 return (NULL); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4839 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4840 return (zp->zss_data); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4841 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4842 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4843 static int |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4844 zfsdev_open(dev_t *devp, int flag, int otyp, cred_t *cr) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4845 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4846 int error = 0; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4847 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4848 if (getminor(*devp) != 0) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4849 return (zvol_open(devp, flag, otyp, cr)); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4850 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4851 /* This is the control device. Allocate a new minor if requested. */ |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4852 if (flag & FEXCL) { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4853 mutex_enter(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4854 error = zfs_ctldev_init(devp); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4855 mutex_exit(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4856 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4857 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4858 return (error); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4859 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4860 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4861 static int |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4862 zfsdev_close(dev_t dev, int flag, int otyp, cred_t *cr) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4863 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4864 zfs_onexit_t *zo; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4865 minor_t minor = getminor(dev); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4866 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4867 if (minor == 0) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4868 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4869 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4870 mutex_enter(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4871 zo = zfsdev_get_soft_state(minor, ZSST_CTLDEV); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4872 if (zo == NULL) { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4873 mutex_exit(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4874 return (zvol_close(dev, flag, otyp, cr)); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4875 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4876 zfs_ctldev_destroy(zo, minor); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4877 mutex_exit(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4878 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4879 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4880 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4881 |
789 | 4882 static int |
4883 zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) | |
4884 { | |
4885 zfs_cmd_t *zc; | |
4886 uint_t vec; | |
2199 | 4887 int error, rc; |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4888 minor_t minor = getminor(dev); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4889 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4890 if (minor != 0 && |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4891 zfsdev_get_soft_state(minor, ZSST_CTLDEV) == NULL) |
789 | 4892 return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp)); |
4893 | |
4894 vec = cmd - ZFS_IOC; | |
4787 | 4895 ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip)); |
789 | 4896 |
4897 if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0])) | |
4898 return (EINVAL); | |
4899 | |
4900 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); | |
4901 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
4902 error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag); |
11807
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
4903 if (error != 0) |
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
4904 error = EFAULT; |
789 | 4905 |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
4906 if ((error == 0) && !(flag & FKIOCTL)) |
4543 | 4907 error = zfs_ioc_vec[vec].zvec_secpolicy(zc, cr); |
789 | 4908 |
4909 /* | |
4910 * Ensure that all pool/dataset names are valid before we pass down to | |
4911 * the lower layers. | |
4912 */ | |
4913 if (error == 0) { | |
4914 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
4915 zc->zc_iflags = flag & FKIOCTL; |
789 | 4916 switch (zfs_ioc_vec[vec].zvec_namecheck) { |
4577 | 4917 case POOL_NAME: |
789 | 4918 if (pool_namecheck(zc->zc_name, NULL, NULL) != 0) |
4919 error = EINVAL; | |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4920 error = pool_status_check(zc->zc_name, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4921 zfs_ioc_vec[vec].zvec_namecheck, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4922 zfs_ioc_vec[vec].zvec_pool_check); |
789 | 4923 break; |
4924 | |
4577 | 4925 case DATASET_NAME: |
789 | 4926 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0) |
4927 error = EINVAL; | |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4928 error = pool_status_check(zc->zc_name, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4929 zfs_ioc_vec[vec].zvec_namecheck, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4930 zfs_ioc_vec[vec].zvec_pool_check); |
789 | 4931 break; |
2856 | 4932 |
4577 | 4933 case NO_NAME: |
2856 | 4934 break; |
789 | 4935 } |
4936 } | |
4937 | |
4938 if (error == 0) | |
4939 error = zfs_ioc_vec[vec].zvec_func(zc); | |
4940 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
4941 rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag); |
4543 | 4942 if (error == 0) { |
11807
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
4943 if (rc != 0) |
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
4944 error = EFAULT; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4945 if (zfs_ioc_vec[vec].zvec_his_log) |
4543 | 4946 zfs_log_history(zc); |
4947 } | |
789 | 4948 |
4949 kmem_free(zc, sizeof (zfs_cmd_t)); | |
4950 return (error); | |
4951 } | |
4952 | |
4953 static int | |
4954 zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) | |
4955 { | |
4956 if (cmd != DDI_ATTACH) | |
4957 return (DDI_FAILURE); | |
4958 | |
4959 if (ddi_create_minor_node(dip, "zfs", S_IFCHR, 0, | |
4960 DDI_PSEUDO, 0) == DDI_FAILURE) | |
4961 return (DDI_FAILURE); | |
4962 | |
4963 zfs_dip = dip; | |
4964 | |
4965 ddi_report_dev(dip); | |
4966 | |
4967 return (DDI_SUCCESS); | |
4968 } | |
4969 | |
4970 static int | |
4971 zfs_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) | |
4972 { | |
4973 if (spa_busy() || zfs_busy() || zvol_busy()) | |
4974 return (DDI_FAILURE); | |
4975 | |
4976 if (cmd != DDI_DETACH) | |
4977 return (DDI_FAILURE); | |
4978 | |
4979 zfs_dip = NULL; | |
4980 | |
4981 ddi_prop_remove_all(dip); | |
4982 ddi_remove_minor_node(dip, NULL); | |
4983 | |
4984 return (DDI_SUCCESS); | |
4985 } | |
4986 | |
4987 /*ARGSUSED*/ | |
4988 static int | |
4989 zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) | |
4990 { | |
4991 switch (infocmd) { | |
4992 case DDI_INFO_DEVT2DEVINFO: | |
4993 *result = zfs_dip; | |
4994 return (DDI_SUCCESS); | |
4995 | |
4996 case DDI_INFO_DEVT2INSTANCE: | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
4997 *result = (void *)0; |
789 | 4998 return (DDI_SUCCESS); |
4999 } | |
5000 | |
5001 return (DDI_FAILURE); | |
5002 } | |
5003 | |
5004 /* | |
5005 * OK, so this is a little weird. | |
5006 * | |
5007 * /dev/zfs is the control node, i.e. minor 0. | |
5008 * /dev/zvol/[r]dsk/pool/dataset are the zvols, minor > 0. | |
5009 * | |
5010 * /dev/zfs has basically nothing to do except serve up ioctls, | |
5011 * so most of the standard driver entry points are in zvol.c. | |
5012 */ | |
5013 static struct cb_ops zfs_cb_ops = { | |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5014 zfsdev_open, /* open */ |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5015 zfsdev_close, /* close */ |
789 | 5016 zvol_strategy, /* strategy */ |
5017 nodev, /* print */ | |
6423 | 5018 zvol_dump, /* dump */ |
789 | 5019 zvol_read, /* read */ |
5020 zvol_write, /* write */ | |
5021 zfsdev_ioctl, /* ioctl */ | |
5022 nodev, /* devmap */ | |
5023 nodev, /* mmap */ | |
5024 nodev, /* segmap */ | |
5025 nochpoll, /* poll */ | |
5026 ddi_prop_op, /* prop_op */ | |
5027 NULL, /* streamtab */ | |
5028 D_NEW | D_MP | D_64BIT, /* Driver compatibility flag */ | |
5029 CB_REV, /* version */ | |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3444
diff
changeset
|
5030 nodev, /* async read */ |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3444
diff
changeset
|
5031 nodev, /* async write */ |
789 | 5032 }; |
5033 | |
5034 static struct dev_ops zfs_dev_ops = { | |
5035 DEVO_REV, /* version */ | |
5036 0, /* refcnt */ | |
5037 zfs_info, /* info */ | |
5038 nulldev, /* identify */ | |
5039 nulldev, /* probe */ | |
5040 zfs_attach, /* attach */ | |
5041 zfs_detach, /* detach */ | |
5042 nodev, /* reset */ | |
5043 &zfs_cb_ops, /* driver operations */ | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5044 NULL, /* no bus operations */ |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5045 NULL, /* power */ |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5046 ddi_quiesce_not_needed, /* quiesce */ |
789 | 5047 }; |
5048 | |
5049 static struct modldrv zfs_modldrv = { | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5050 &mod_driverops, |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5051 "ZFS storage pool", |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5052 &zfs_dev_ops |
789 | 5053 }; |
5054 | |
5055 static struct modlinkage modlinkage = { | |
5056 MODREV_1, | |
5057 (void *)&zfs_modlfs, | |
5058 (void *)&zfs_modldrv, | |
5059 NULL | |
5060 }; | |
5061 | |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5062 |
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5063 uint_t zfs_fsyncer_key; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
5064 extern uint_t rrw_tsd_key; |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5065 |
789 | 5066 int |
5067 _init(void) | |
5068 { | |
5069 int error; | |
5070 | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5071 spa_init(FREAD | FWRITE); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5072 zfs_init(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5073 zvol_init(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5074 |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5075 if ((error = mod_install(&modlinkage)) != 0) { |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5076 zvol_fini(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5077 zfs_fini(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5078 spa_fini(); |
789 | 5079 return (error); |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5080 } |
789 | 5081 |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5082 tsd_create(&zfs_fsyncer_key, NULL); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
5083 tsd_create(&rrw_tsd_key, NULL); |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5084 |
789 | 5085 error = ldi_ident_from_mod(&modlinkage, &zfs_li); |
5086 ASSERT(error == 0); | |
4543 | 5087 mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL); |
789 | 5088 |
5089 return (0); | |
5090 } | |
5091 | |
5092 int | |
5093 _fini(void) | |
5094 { | |
5095 int error; | |
5096 | |
1544 | 5097 if (spa_busy() || zfs_busy() || zvol_busy() || zio_injection_enabled) |
789 | 5098 return (EBUSY); |
5099 | |
5100 if ((error = mod_remove(&modlinkage)) != 0) | |
5101 return (error); | |
5102 | |
5103 zvol_fini(); | |
5104 zfs_fini(); | |
5105 spa_fini(); | |
5331 | 5106 if (zfs_nfsshare_inited) |
4543 | 5107 (void) ddi_modclose(nfs_mod); |
5331 | 5108 if (zfs_smbshare_inited) |
5109 (void) ddi_modclose(smbsrv_mod); | |
5110 if (zfs_nfsshare_inited || zfs_smbshare_inited) | |
4543 | 5111 (void) ddi_modclose(sharefs_mod); |
789 | 5112 |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5113 tsd_destroy(&zfs_fsyncer_key); |
789 | 5114 ldi_ident_release(zfs_li); |
5115 zfs_li = NULL; | |
4543 | 5116 mutex_destroy(&zfs_share_lock); |
789 | 5117 |
5118 return (error); | |
5119 } | |
5120 | |
5121 int | |
5122 _info(struct modinfo *modinfop) | |
5123 { | |
5124 return (mod_info(&modlinkage, modinfop)); | |
5125 } |