Mercurial > illumos > illumos-gate
annotate usr/src/uts/common/fs/zfs/zfs_ioctl.c @ 13686:4bc0783f6064
2703 add mechanism to report ZFS send progress
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Eric Schrock <Eric.Schrock@delphix.com>
author | Bill Pijewski <wdp@joyent.com> |
---|---|
date | Wed, 09 May 2012 15:05:14 -0700 |
parents | 3411fd5f1589 |
children | 2889e2596bd6 |
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 |
13514
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. |
13570
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
25 * Copyright (c) 2012 by Delphix. All rights reserved. |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
26 * Copyright (c) 2012, Joyent, Inc. All rights reserved. |
13514
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
27 */ |
789 | 28 |
29 #include <sys/types.h> | |
30 #include <sys/param.h> | |
31 #include <sys/errno.h> | |
32 #include <sys/uio.h> | |
33 #include <sys/buf.h> | |
34 #include <sys/modctl.h> | |
35 #include <sys/open.h> | |
36 #include <sys/file.h> | |
37 #include <sys/kmem.h> | |
38 #include <sys/conf.h> | |
39 #include <sys/cmn_err.h> | |
40 #include <sys/stat.h> | |
41 #include <sys/zfs_ioctl.h> | |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
42 #include <sys/zfs_vfsops.h> |
5331 | 43 #include <sys/zfs_znode.h> |
789 | 44 #include <sys/zap.h> |
45 #include <sys/spa.h> | |
3912 | 46 #include <sys/spa_impl.h> |
789 | 47 #include <sys/vdev.h> |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
48 #include <sys/priv_impl.h> |
789 | 49 #include <sys/dmu.h> |
50 #include <sys/dsl_dir.h> | |
51 #include <sys/dsl_dataset.h> | |
52 #include <sys/dsl_prop.h> | |
4543 | 53 #include <sys/dsl_deleg.h> |
54 #include <sys/dmu_objset.h> | |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
55 #include <sys/dmu_impl.h> |
789 | 56 #include <sys/ddi.h> |
57 #include <sys/sunddi.h> | |
58 #include <sys/sunldi.h> | |
59 #include <sys/policy.h> | |
60 #include <sys/zone.h> | |
61 #include <sys/nvpair.h> | |
62 #include <sys/pathname.h> | |
63 #include <sys/mount.h> | |
64 #include <sys/sdt.h> | |
65 #include <sys/fs/zfs.h> | |
66 #include <sys/zfs_ctldir.h> | |
5331 | 67 #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
|
68 #include <sys/zfs_onexit.h> |
2885 | 69 #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
|
70 #include <sys/dsl_scan.h> |
4543 | 71 #include <sharefs/share.h> |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
72 #include <sys/dmu_objset.h> |
789 | 73 |
74 #include "zfs_namecheck.h" | |
2676 | 75 #include "zfs_prop.h" |
4543 | 76 #include "zfs_deleg.h" |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
77 #include "zfs_comutil.h" |
789 | 78 |
79 extern struct modlfs zfs_modlfs; | |
80 | |
81 extern void zfs_init(void); | |
82 extern void zfs_fini(void); | |
83 | |
84 ldi_ident_t zfs_li = NULL; | |
85 dev_info_t *zfs_dip; | |
86 | |
87 typedef int zfs_ioc_func_t(zfs_cmd_t *); | |
4543 | 88 typedef int zfs_secpolicy_func_t(zfs_cmd_t *, cred_t *); |
789 | 89 |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
90 typedef enum { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
91 NO_NAME, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
92 POOL_NAME, |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
93 DATASET_NAME |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
94 } zfs_ioc_namecheck_t; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
95 |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
96 typedef enum { |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
97 POOL_CHECK_NONE = 1 << 0, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
98 POOL_CHECK_SUSPENDED = 1 << 1, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
99 POOL_CHECK_READONLY = 1 << 2 |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
100 } zfs_ioc_poolcheck_t; |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
101 |
789 | 102 typedef struct zfs_ioc_vec { |
103 zfs_ioc_func_t *zvec_func; | |
104 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
|
105 zfs_ioc_namecheck_t zvec_namecheck; |
4543 | 106 boolean_t zvec_his_log; |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
107 zfs_ioc_poolcheck_t zvec_pool_check; |
789 | 108 } zfs_ioc_vec_t; |
109 | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
110 /* 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
|
111 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
|
112 ZFS_DELEG_PERM_USERUSED, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
113 ZFS_DELEG_PERM_USERQUOTA, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
114 ZFS_DELEG_PERM_GROUPUSED, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
115 ZFS_DELEG_PERM_GROUPQUOTA, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
116 }; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
117 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
118 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
|
119 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
|
120 cred_t *cr); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
121 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
|
122 nvlist_t **errors); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
123 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
|
124 boolean_t *); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
125 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
|
126 |
789 | 127 /* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */ |
128 void | |
129 __dprintf(const char *file, const char *func, int line, const char *fmt, ...) | |
130 { | |
131 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
|
132 char buf[512]; |
789 | 133 va_list adx; |
134 | |
135 /* | |
136 * Get rid of annoying "../common/" prefix to filename. | |
137 */ | |
138 newfile = strrchr(file, '/'); | |
139 if (newfile != NULL) { | |
140 newfile = newfile + 1; /* Get rid of leading / */ | |
141 } else { | |
142 newfile = file; | |
143 } | |
144 | |
145 va_start(adx, fmt); | |
146 (void) vsnprintf(buf, sizeof (buf), fmt, adx); | |
147 va_end(adx); | |
148 | |
149 /* | |
150 * To get this data, use the zfs-dprintf probe as so: | |
151 * dtrace -q -n 'zfs-dprintf \ | |
152 * /stringof(arg0) == "dbuf.c"/ \ | |
153 * {printf("%s: %s", stringof(arg1), stringof(arg3))}' | |
154 * arg0 = file name | |
155 * arg1 = function name | |
156 * arg2 = line number | |
157 * arg3 = message | |
158 */ | |
159 DTRACE_PROBE4(zfs__dprintf, | |
160 char *, newfile, char *, func, int, line, char *, buf); | |
161 } | |
162 | |
4543 | 163 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
|
164 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
|
165 { |
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4670
diff
changeset
|
166 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
|
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 |
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 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
|
170 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
|
171 { |
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 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
|
173 |
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 (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
|
175 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
|
176 |
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 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 } |
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 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
|
185 |
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
|
186 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
|
187 } |
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
|
188 |
5375 | 189 /* |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
190 * 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
|
191 */ |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
192 static boolean_t |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
193 zfs_is_bootfs(const char *name) |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
194 { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
195 objset_t *os; |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
196 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
197 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
|
198 boolean_t ret; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
199 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
|
200 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
|
201 return (ret); |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
202 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
203 return (B_FALSE); |
7042
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
204 } |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
205 |
46fc4b6db23e
6721094 Setting certain properties on root pools should not be allowed
gw25295
parents:
6865
diff
changeset
|
206 /* |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
207 * zfs_earlier_version |
5375 | 208 * |
209 * Return non-zero if the spa version is less than requested version. | |
210 */ | |
5331 | 211 static int |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
212 zfs_earlier_version(const char *name, int version) |
5331 | 213 { |
214 spa_t *spa; | |
215 | |
216 if (spa_open(name, &spa, FTAG) == 0) { | |
217 if (spa_version(spa) < version) { | |
218 spa_close(spa, FTAG); | |
219 return (1); | |
220 } | |
221 spa_close(spa, FTAG); | |
222 } | |
223 return (0); | |
224 } | |
225 | |
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 * zpl_earlier_version |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
228 * |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
229 * 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
|
230 */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
231 static boolean_t |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
232 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
|
233 { |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
234 objset_t *os; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
235 boolean_t rc = B_TRUE; |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
236 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
237 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
|
238 uint64_t zplversion; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
239 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
240 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
|
241 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
|
242 return (B_TRUE); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
243 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
244 /* 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
|
245 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
|
246 rc = zplversion < version; |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
247 dmu_objset_rele(os, FTAG); |
5977
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
248 } |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
249 return (rc); |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
250 } |
33727f49aeaa
6654731 sharesmb property should only be settable on CIFS aware ZPL
marks
parents:
5663
diff
changeset
|
251 |
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
|
252 static void |
4543 | 253 zfs_log_history(zfs_cmd_t *zc) |
254 { | |
255 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
|
256 char *buf; |
4543 | 257 |
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
|
258 if ((buf = history_str_get(zc)) == NULL) |
4577 | 259 return; |
260 | |
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
|
261 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
|
262 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
|
263 (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
|
264 spa_close(spa, FTAG); |
4543 | 265 } |
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
|
266 history_str_free(buf); |
4543 | 267 } |
268 | |
789 | 269 /* |
270 * Policy for top-level read operations (list pools). Requires no privileges, | |
271 * and can be used in the local zone, as there is no associated dataset. | |
272 */ | |
273 /* ARGSUSED */ | |
274 static int | |
4543 | 275 zfs_secpolicy_none(zfs_cmd_t *zc, cred_t *cr) |
789 | 276 { |
277 return (0); | |
278 } | |
279 | |
280 /* | |
281 * Policy for dataset read operations (list children, get statistics). Requires | |
282 * no privileges, but must be visible in the local zone. | |
283 */ | |
284 /* ARGSUSED */ | |
285 static int | |
4543 | 286 zfs_secpolicy_read(zfs_cmd_t *zc, cred_t *cr) |
789 | 287 { |
288 if (INGLOBALZONE(curproc) || | |
4543 | 289 zone_dataset_visible(zc->zc_name, NULL)) |
789 | 290 return (0); |
291 | |
292 return (ENOENT); | |
293 } | |
294 | |
295 static int | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
296 zfs_dozonecheck_impl(const char *dataset, uint64_t zoned, cred_t *cr) |
789 | 297 { |
298 int writable = 1; | |
299 | |
300 /* | |
301 * The dataset must be visible by this zone -- check this first | |
302 * so they don't see EPERM on something they shouldn't know about. | |
303 */ | |
304 if (!INGLOBALZONE(curproc) && | |
305 !zone_dataset_visible(dataset, &writable)) | |
306 return (ENOENT); | |
307 | |
308 if (INGLOBALZONE(curproc)) { | |
309 /* | |
310 * If the fs is zoned, only root can access it from the | |
311 * global zone. | |
312 */ | |
313 if (secpolicy_zfs(cr) && zoned) | |
314 return (EPERM); | |
315 } else { | |
316 /* | |
317 * If we are in a local zone, the 'zoned' property must be set. | |
318 */ | |
319 if (!zoned) | |
320 return (EPERM); | |
321 | |
322 /* must be writable by this zone */ | |
323 if (!writable) | |
324 return (EPERM); | |
325 } | |
326 return (0); | |
327 } | |
328 | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
329 static int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
330 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
|
331 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
332 uint64_t zoned; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
333 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
334 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
|
335 return (ENOENT); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
336 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
337 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
|
338 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
339 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
340 static int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
341 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
|
342 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
343 uint64_t zoned; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
344 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
345 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
|
346 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
|
347 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
|
348 return (ENOENT); |
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 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
|
351 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
352 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
|
353 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
354 |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
355 /* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
356 * If name ends in a '@', then require recursive permissions. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
357 */ |
789 | 358 int |
4543 | 359 zfs_secpolicy_write_perms(const char *name, const char *perm, cred_t *cr) |
789 | 360 { |
361 int error; | |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
362 boolean_t descendent = B_FALSE; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
363 dsl_dataset_t *ds; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
364 char *at; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
365 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
366 at = strchr(name, '@'); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
367 if (at != NULL && at[1] == '\0') { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
368 *at = '\0'; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
369 descendent = B_TRUE; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
370 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
371 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
372 error = dsl_dataset_hold(name, FTAG, &ds); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
373 if (at != NULL) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
374 *at = '@'; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
375 if (error != 0) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
376 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
377 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
378 error = zfs_dozonecheck_ds(name, ds, cr); |
4543 | 379 if (error == 0) { |
380 error = secpolicy_zfs(cr); | |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
381 if (error) |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
382 error = dsl_deleg_access_impl(ds, descendent, perm, cr); |
4543 | 383 } |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
384 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
385 dsl_dataset_rele(ds, FTAG); |
4543 | 386 return (error); |
387 } | |
388 | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
389 int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
390 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
|
391 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
|
392 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
393 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
394 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
395 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
|
396 if (error == 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
397 error = secpolicy_zfs(cr); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
398 if (error) |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
399 error = dsl_deleg_access_impl(ds, B_FALSE, perm, cr); |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
400 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
401 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
402 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
403 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
404 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
405 * 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
|
406 * |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
407 * 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
|
408 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
409 static int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
410 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
|
411 { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
412 char ds_hexsl[MAXNAMELEN]; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
413 bslabel_t ds_sl, new_sl; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
414 boolean_t new_default = FALSE; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
415 uint64_t zoned; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
416 int needed_priv = -1; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
417 int error; |
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 /* First get the existing dataset label. */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
420 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
|
421 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
|
422 if (error) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
423 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
424 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
425 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
|
426 new_default = TRUE; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
427 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
428 /* The label must be translatable */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
429 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
|
430 return (EINVAL); |
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 * 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
|
434 * 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
|
435 * are needed. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
436 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
437 if (!INGLOBALZONE(curproc)) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
438 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
|
439 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
440 return (0); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
441 } |
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 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
444 * 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
|
445 * "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
|
446 * global zone. |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
447 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
448 if (dsl_prop_get_integer(name, |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
449 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
|
450 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
451 if (!zoned) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
452 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
|
453 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
454 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
455 |
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 * 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
|
458 * 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
|
459 * 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
|
460 * 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
|
461 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
462 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
|
463 objset_t *os; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
464 static char *setsl_tag = "setsl_tag"; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
465 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
466 /* |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
467 * 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
|
468 * (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
|
469 */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
470 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
|
471 setsl_tag, &os); |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
472 if (error) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
473 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
474 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
475 dmu_objset_disown(os, setsl_tag); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
476 |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
477 if (new_default) { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
478 needed_priv = PRIV_FILE_DOWNGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
479 goto out_check; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
480 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
481 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
482 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
|
483 return (EPERM); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
484 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
485 if (blstrictdom(&ds_sl, &new_sl)) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
486 needed_priv = PRIV_FILE_DOWNGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
487 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
|
488 needed_priv = PRIV_FILE_UPGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
489 } else { |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
490 /* dataset currently has a default label */ |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
491 if (!new_default) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
492 needed_priv = PRIV_FILE_UPGRADE_SL; |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
493 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
494 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
495 out_check: |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
496 if (needed_priv != -1) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
497 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
|
498 return (0); |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
499 } |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
500 |
4543 | 501 static int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
502 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
|
503 cred_t *cr) |
4543 | 504 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
505 char *strval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
506 |
4543 | 507 /* |
508 * Check permissions for special properties. | |
509 */ | |
510 switch (prop) { | |
511 case ZFS_PROP_ZONED: | |
512 /* | |
513 * Disallow setting of 'zoned' from within a local zone. | |
514 */ | |
515 if (!INGLOBALZONE(curproc)) | |
516 return (EPERM); | |
517 break; | |
789 | 518 |
4543 | 519 case ZFS_PROP_QUOTA: |
520 if (!INGLOBALZONE(curproc)) { | |
521 uint64_t zoned; | |
522 char setpoint[MAXNAMELEN]; | |
523 /* | |
524 * Unprivileged users are allowed to modify the | |
525 * quota on things *under* (ie. contained by) | |
526 * the thing they own. | |
527 */ | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
528 if (dsl_prop_get_integer(dsname, "zoned", &zoned, |
4543 | 529 setpoint)) |
530 return (EPERM); | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
531 if (!zoned || strlen(dsname) <= strlen(setpoint)) |
4543 | 532 return (EPERM); |
533 } | |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
534 break; |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
535 |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
536 case ZFS_PROP_MLSLABEL: |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
537 if (!is_system_labeled()) |
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
538 return (EPERM); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
539 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
540 if (nvpair_value_string(propval, &strval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
541 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
542 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
543 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
|
544 if (err != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
545 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
546 } |
10972
807794d41b3a
PSARC 2009/348 Security Labels for ZFS
Ric Aleshire <Ric.Aleshire@Sun.COM>
parents:
10969
diff
changeset
|
547 break; |
4543 | 548 } |
549 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
550 return (zfs_secpolicy_write_perms(dsname, zfs_prop_to_name(prop), cr)); |
789 | 551 } |
552 | |
4543 | 553 int |
554 zfs_secpolicy_fsacl(zfs_cmd_t *zc, cred_t *cr) | |
555 { | |
556 int error; | |
557 | |
558 error = zfs_dozonecheck(zc->zc_name, cr); | |
559 if (error) | |
560 return (error); | |
561 | |
562 /* | |
563 * permission to set permissions will be evaluated later in | |
564 * dsl_deleg_can_allow() | |
565 */ | |
566 return (0); | |
567 } | |
568 | |
569 int | |
570 zfs_secpolicy_rollback(zfs_cmd_t *zc, cred_t *cr) | |
571 { | |
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
|
572 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
|
573 ZFS_DELEG_PERM_ROLLBACK, cr)); |
4543 | 574 } |
575 | |
576 int | |
577 zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr) | |
578 { | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
579 spa_t *spa; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
580 dsl_pool_t *dp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
581 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
582 char *cp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
583 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
584 |
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 * 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
|
587 * 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
|
588 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
589 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
|
590 if (cp == NULL) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
591 return (EINVAL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
592 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
|
593 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
594 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
595 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
596 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
|
597 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
|
598 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
|
599 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
|
600 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
601 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
602 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
603 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
604 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
|
605 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
606 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
|
607 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
|
608 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
|
609 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
610 return (error); |
4543 | 611 } |
612 | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
613 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
614 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
|
615 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
616 vnode_t *vp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
617 int error; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
618 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
619 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
|
620 NO_FOLLOW, NULL, &vp)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
621 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
622 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
623 /* 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
|
624 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
625 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
|
626 (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
|
627 zc->zc_name) != 0)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
628 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
629 return (EPERM); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
630 } |
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 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
633 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
|
634 ZFS_DELEG_PERM_SHARE, cr)); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
635 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
636 |
4543 | 637 int |
638 zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr) | |
639 { | |
640 if (!INGLOBALZONE(curproc)) | |
641 return (EPERM); | |
642 | |
5367 | 643 if (secpolicy_nfs(cr) == 0) { |
4543 | 644 return (0); |
645 } else { | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
646 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
|
647 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
648 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
649 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
650 int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
651 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
|
652 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
653 if (!INGLOBALZONE(curproc)) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
654 return (EPERM); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
655 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
656 if (secpolicy_smb(cr) == 0) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
657 return (0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
658 } else { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
659 return (zfs_secpolicy_deleg_share(zc, cr)); |
4543 | 660 } |
661 } | |
662 | |
789 | 663 static int |
4543 | 664 zfs_get_parent(const char *datasetname, char *parent, int parentsize) |
789 | 665 { |
666 char *cp; | |
667 | |
668 /* | |
669 * Remove the @bla or /bla from the end of the name to get the parent. | |
670 */ | |
4543 | 671 (void) strncpy(parent, datasetname, parentsize); |
672 cp = strrchr(parent, '@'); | |
789 | 673 if (cp != NULL) { |
674 cp[0] = '\0'; | |
675 } else { | |
4543 | 676 cp = strrchr(parent, '/'); |
789 | 677 if (cp == NULL) |
678 return (ENOENT); | |
679 cp[0] = '\0'; | |
680 } | |
681 | |
4543 | 682 return (0); |
683 } | |
684 | |
685 int | |
686 zfs_secpolicy_destroy_perms(const char *name, cred_t *cr) | |
687 { | |
688 int error; | |
689 | |
690 if ((error = zfs_secpolicy_write_perms(name, | |
691 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
692 return (error); | |
693 | |
694 return (zfs_secpolicy_write_perms(name, ZFS_DELEG_PERM_DESTROY, cr)); | |
695 } | |
696 | |
697 static int | |
698 zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr) | |
699 { | |
700 return (zfs_secpolicy_destroy_perms(zc->zc_name, cr)); | |
701 } | |
702 | |
703 /* | |
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
|
704 * 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
|
705 * descendent mount and destroy permissions. |
489ae7372a1f
6901122 destroy snapshot by delegated user succeeds without descendent permissions when -r or -R used.
William Gorrell <william.gorrell@sun.com>
parents:
11209
diff
changeset
|
706 */ |
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
|
707 static int |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
708 zfs_secpolicy_destroy_recursive(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
|
709 { |
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
|
710 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
|
711 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
|
712 |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
713 dsname = kmem_asprintf("%s@", zc->zc_name); |
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
|
714 |
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
|
715 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
|
716 |
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
|
717 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
|
718 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
|
719 } |
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
|
720 |
4543 | 721 int |
722 zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr) | |
723 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
724 char parentname[MAXNAMELEN]; |
4543 | 725 int error; |
726 | |
727 if ((error = zfs_secpolicy_write_perms(from, | |
728 ZFS_DELEG_PERM_RENAME, cr)) != 0) | |
729 return (error); | |
730 | |
731 if ((error = zfs_secpolicy_write_perms(from, | |
732 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
733 return (error); | |
734 | |
735 if ((error = zfs_get_parent(to, parentname, | |
736 sizeof (parentname))) != 0) | |
737 return (error); | |
738 | |
739 if ((error = zfs_secpolicy_write_perms(parentname, | |
740 ZFS_DELEG_PERM_CREATE, cr)) != 0) | |
741 return (error); | |
742 | |
743 if ((error = zfs_secpolicy_write_perms(parentname, | |
744 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
745 return (error); | |
746 | |
747 return (error); | |
748 } | |
749 | |
750 static int | |
751 zfs_secpolicy_rename(zfs_cmd_t *zc, cred_t *cr) | |
752 { | |
753 return (zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr)); | |
754 } | |
755 | |
756 static int | |
757 zfs_secpolicy_promote(zfs_cmd_t *zc, cred_t *cr) | |
758 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
759 char parentname[MAXNAMELEN]; |
4543 | 760 objset_t *clone; |
761 int error; | |
762 | |
763 error = zfs_secpolicy_write_perms(zc->zc_name, | |
764 ZFS_DELEG_PERM_PROMOTE, cr); | |
765 if (error) | |
766 return (error); | |
767 | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
768 error = dmu_objset_hold(zc->zc_name, FTAG, &clone); |
4543 | 769 |
770 if (error == 0) { | |
771 dsl_dataset_t *pclone = NULL; | |
772 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
|
773 dd = clone->os_dsl_dataset->ds_dir; |
4543 | 774 |
775 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
|
776 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
|
777 dd->dd_phys->dd_origin_obj, FTAG, &pclone); |
4543 | 778 rw_exit(&dd->dd_pool->dp_config_rwlock); |
779 if (error) { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
780 dmu_objset_rele(clone, FTAG); |
4543 | 781 return (error); |
782 } | |
783 | |
784 error = zfs_secpolicy_write_perms(zc->zc_name, | |
785 ZFS_DELEG_PERM_MOUNT, cr); | |
786 | |
787 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
|
788 dmu_objset_rele(clone, FTAG); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
789 dsl_dataset_rele(pclone, FTAG); |
4543 | 790 if (error == 0) |
791 error = zfs_secpolicy_write_perms(parentname, | |
792 ZFS_DELEG_PERM_PROMOTE, cr); | |
793 } | |
794 return (error); | |
795 } | |
796 | |
797 static int | |
798 zfs_secpolicy_receive(zfs_cmd_t *zc, cred_t *cr) | |
799 { | |
800 int error; | |
801 | |
802 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
803 ZFS_DELEG_PERM_RECEIVE, cr)) != 0) | |
804 return (error); | |
805 | |
806 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
807 ZFS_DELEG_PERM_MOUNT, cr)) != 0) | |
808 return (error); | |
809 | |
810 return (zfs_secpolicy_write_perms(zc->zc_name, | |
811 ZFS_DELEG_PERM_CREATE, cr)); | |
812 } | |
813 | |
814 int | |
815 zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr) | |
816 { | |
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
|
817 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
|
818 ZFS_DELEG_PERM_SNAPSHOT, cr)); |
4543 | 819 } |
820 | |
821 static int | |
822 zfs_secpolicy_snapshot(zfs_cmd_t *zc, cred_t *cr) | |
823 { | |
824 | |
825 return (zfs_secpolicy_snapshot_perms(zc->zc_name, cr)); | |
826 } | |
827 | |
828 static int | |
829 zfs_secpolicy_create(zfs_cmd_t *zc, cred_t *cr) | |
830 { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
831 char parentname[MAXNAMELEN]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
832 int error; |
4543 | 833 |
834 if ((error = zfs_get_parent(zc->zc_name, parentname, | |
835 sizeof (parentname))) != 0) | |
836 return (error); | |
837 | |
838 if (zc->zc_value[0] != '\0') { | |
839 if ((error = zfs_secpolicy_write_perms(zc->zc_value, | |
840 ZFS_DELEG_PERM_CLONE, cr)) != 0) | |
841 return (error); | |
842 } | |
843 | |
844 if ((error = zfs_secpolicy_write_perms(parentname, | |
845 ZFS_DELEG_PERM_CREATE, cr)) != 0) | |
846 return (error); | |
847 | |
848 error = zfs_secpolicy_write_perms(parentname, | |
849 ZFS_DELEG_PERM_MOUNT, cr); | |
850 | |
851 return (error); | |
852 } | |
853 | |
854 static int | |
855 zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr) | |
856 { | |
857 int error; | |
858 | |
859 error = secpolicy_fs_unmount(cr, NULL); | |
860 if (error) { | |
861 error = dsl_deleg_access(zc->zc_name, ZFS_DELEG_PERM_MOUNT, cr); | |
862 } | |
863 return (error); | |
789 | 864 } |
865 | |
866 /* | |
867 * Policy for pool operations - create/destroy pools, add vdevs, etc. Requires | |
868 * SYS_CONFIG privilege, which is not available in a local zone. | |
869 */ | |
870 /* ARGSUSED */ | |
871 static int | |
4543 | 872 zfs_secpolicy_config(zfs_cmd_t *zc, cred_t *cr) |
789 | 873 { |
874 if (secpolicy_sys_config(cr, B_FALSE) != 0) | |
875 return (EPERM); | |
876 | |
877 return (0); | |
878 } | |
879 | |
880 /* | |
13055 | 881 * Policy for object to name lookups. |
882 */ | |
883 /* ARGSUSED */ | |
884 static int | |
885 zfs_secpolicy_diff(zfs_cmd_t *zc, cred_t *cr) | |
886 { | |
887 int error; | |
888 | |
889 if ((error = secpolicy_sys_config(cr, B_FALSE)) == 0) | |
890 return (0); | |
891 | |
892 error = zfs_secpolicy_write_perms(zc->zc_name, ZFS_DELEG_PERM_DIFF, cr); | |
893 return (error); | |
894 } | |
895 | |
896 /* | |
1544 | 897 * Policy for fault injection. Requires all privileges. |
898 */ | |
899 /* ARGSUSED */ | |
900 static int | |
4543 | 901 zfs_secpolicy_inject(zfs_cmd_t *zc, cred_t *cr) |
1544 | 902 { |
903 return (secpolicy_zinject(cr)); | |
904 } | |
905 | |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
906 static int |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
907 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
|
908 { |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
909 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
|
910 |
5094 | 911 if (prop == ZPROP_INVAL) { |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
912 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
|
913 return (EINVAL); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
914 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
|
915 ZFS_DELEG_PERM_USERPROP, cr)); |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
916 } else { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
917 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
|
918 NULL, cr)); |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
919 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
920 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
921 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
922 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
923 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
|
924 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
925 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
|
926 if (err) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
927 return (err); |
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 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
|
930 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
931 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
932 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
|
933 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
934 * 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
|
935 * themself, allow it. |
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 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
|
938 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
|
939 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
|
940 return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
941 } else { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
942 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
|
943 return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
944 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
945 } |
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 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
|
948 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
|
949 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
950 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
951 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
952 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
|
953 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
954 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
|
955 if (err) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
956 return (err); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
957 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
958 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
|
959 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
960 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
961 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
|
962 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
|
963 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
964 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
965 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
966 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
|
967 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
968 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
|
969 NULL, cr)); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
970 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
971 |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
972 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
973 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
|
974 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
975 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
|
976 ZFS_DELEG_PERM_HOLD, cr)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
977 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
978 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
979 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
980 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
|
981 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
982 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
|
983 ZFS_DELEG_PERM_RELEASE, cr)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
984 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
985 |
1544 | 986 /* |
13055 | 987 * Policy for allowing temporary snapshots to be taken or released |
988 */ | |
989 static int | |
990 zfs_secpolicy_tmp_snapshot(zfs_cmd_t *zc, cred_t *cr) | |
991 { | |
992 /* | |
993 * A temporary snapshot is the same as a snapshot, | |
994 * hold, destroy and release all rolled into one. | |
995 * Delegated diff alone is sufficient that we allow this. | |
996 */ | |
997 int error; | |
998 | |
999 if ((error = zfs_secpolicy_write_perms(zc->zc_name, | |
1000 ZFS_DELEG_PERM_DIFF, cr)) == 0) | |
1001 return (0); | |
1002 | |
1003 error = zfs_secpolicy_snapshot(zc, cr); | |
1004 if (!error) | |
1005 error = zfs_secpolicy_hold(zc, cr); | |
1006 if (!error) | |
1007 error = zfs_secpolicy_release(zc, cr); | |
1008 if (!error) | |
1009 error = zfs_secpolicy_destroy(zc, cr); | |
1010 return (error); | |
1011 } | |
1012 | |
1013 /* | |
789 | 1014 * Returns the nvlist as specified by the user in the zfs_cmd_t. |
1015 */ | |
1016 static int | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1017 get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp) |
789 | 1018 { |
1019 char *packed; | |
1020 int error; | |
5094 | 1021 nvlist_t *list = NULL; |
789 | 1022 |
1023 /* | |
2676 | 1024 * Read in and unpack the user-supplied nvlist. |
789 | 1025 */ |
5094 | 1026 if (size == 0) |
789 | 1027 return (EINVAL); |
1028 | |
1029 packed = kmem_alloc(size, KM_SLEEP); | |
1030 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
1031 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
|
1032 iflag)) != 0) { |
789 | 1033 kmem_free(packed, size); |
1034 return (error); | |
1035 } | |
1036 | |
5094 | 1037 if ((error = nvlist_unpack(packed, size, &list, 0)) != 0) { |
789 | 1038 kmem_free(packed, size); |
1039 return (error); | |
1040 } | |
1041 | |
1042 kmem_free(packed, size); | |
1043 | |
5094 | 1044 *nvp = list; |
789 | 1045 return (0); |
1046 } | |
1047 | |
1048 static int | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1049 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
|
1050 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1051 size_t size; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1052 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1053 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
|
1054 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1055 if (size > zc->zc_nvlist_dst_size) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1056 nvpair_t *more_errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1057 int n = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1058 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1059 if (zc->zc_nvlist_dst_size < 1024) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1060 return (ENOMEM); |
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 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
|
1063 more_errors = nvlist_prev_nvpair(*errors, NULL); |
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 do { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1066 nvpair_t *pair = nvlist_prev_nvpair(*errors, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1067 more_errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1068 VERIFY(nvlist_remove_nvpair(*errors, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1069 n++; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1070 VERIFY(nvlist_size(*errors, &size, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1071 NV_ENCODE_NATIVE) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1072 } while (size > zc->zc_nvlist_dst_size); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1073 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1074 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
|
1075 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
|
1076 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
|
1077 ASSERT(size <= zc->zc_nvlist_dst_size); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1078 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1079 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1080 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1081 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1082 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1083 static int |
2676 | 1084 put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl) |
1085 { | |
1086 char *packed = NULL; | |
11807
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
1087 int error = 0; |
2676 | 1088 size_t size; |
1089 | |
1090 VERIFY(nvlist_size(nvl, &size, NV_ENCODE_NATIVE) == 0); | |
1091 | |
1092 if (size > zc->zc_nvlist_dst_size) { | |
1093 error = ENOMEM; | |
1094 } else { | |
4611 | 1095 packed = kmem_alloc(size, KM_SLEEP); |
2676 | 1096 VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE, |
1097 KM_SLEEP) == 0); | |
11807
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
1098 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
|
1099 size, zc->zc_iflags) != 0) |
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
1100 error = EFAULT; |
2676 | 1101 kmem_free(packed, size); |
1102 } | |
1103 | |
1104 zc->zc_nvlist_dst_size = size; | |
1105 return (error); | |
1106 } | |
1107 | |
1108 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
|
1109 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
|
1110 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1111 objset_t *os; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1112 int error; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1113 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1114 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
|
1115 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1116 return (error); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1117 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
|
1118 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
|
1119 return (EINVAL); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1120 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1121 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1122 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
|
1123 *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
|
1124 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
|
1125 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
|
1126 } else { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1127 error = ESRCH; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1128 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1129 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
|
1130 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
|
1131 return (error); |
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 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1134 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1135 * 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
|
1136 * 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
|
1137 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1138 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
|
1139 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
|
1140 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1141 int error = 0; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1142 |
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
|
1143 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
|
1144 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
|
1145 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
|
1146 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
|
1147 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
|
1148 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
|
1149 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1150 * 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
|
1151 * 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
|
1152 * objset from the zfsvfs. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1153 */ |
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
|
1154 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
|
1155 return (EBUSY); |
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 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1158 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1159 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1160 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1161 static void |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1162 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
|
1163 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1164 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
|
1165 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1166 if (zfsvfs->z_vfs) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1167 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
|
1168 } else { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1169 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
|
1170 zfsvfs_free(zfsvfs); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1171 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1172 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1173 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1174 static int |
789 | 1175 zfs_ioc_pool_create(zfs_cmd_t *zc) |
1176 { | |
1177 int error; | |
5094 | 1178 nvlist_t *config, *props = NULL; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1179 nvlist_t *rootprops = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1180 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
|
1181 char *buf; |
789 | 1182 |
5094 | 1183 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
|
1184 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
|
1185 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
|
1186 |
5094 | 1187 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
|
1188 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
|
1189 zc->zc_iflags, &props))) { |
5094 | 1190 nvlist_free(config); |
1191 return (error); | |
1192 } | |
1193 | |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1194 if (props) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1195 nvlist_t *nvl = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1196 uint64_t version = SPA_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1197 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1198 (void) nvlist_lookup_uint64(props, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1199 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
|
1200 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
|
1201 error = EINVAL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1202 goto pool_props_bad; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1203 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1204 (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
|
1205 if (nvl) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1206 error = nvlist_dup(nvl, &rootprops, KM_SLEEP); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1207 if (error != 0) { |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1208 nvlist_free(config); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1209 nvlist_free(props); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1210 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1211 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1212 (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
|
1213 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1214 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
|
1215 error = zfs_fill_zplprops_root(version, rootprops, |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1216 zplprops, NULL); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1217 if (error) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1218 goto pool_props_bad; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1219 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1220 |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1221 buf = history_str_get(zc); |
789 | 1222 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1223 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
|
1224 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1225 /* |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1226 * Set the remaining root properties |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1227 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1228 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
|
1229 ZPROP_SRC_LOCAL, rootprops, NULL)) != 0) |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1230 (void) spa_destroy(zc->zc_name); |
789 | 1231 |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1232 if (buf != NULL) |
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
1233 history_str_free(buf); |
5094 | 1234 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1235 pool_props_bad: |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1236 nvlist_free(rootprops); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1237 nvlist_free(zplprops); |
789 | 1238 nvlist_free(config); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
1239 nvlist_free(props); |
5094 | 1240 |
789 | 1241 return (error); |
1242 } | |
1243 | |
1244 static int | |
1245 zfs_ioc_pool_destroy(zfs_cmd_t *zc) | |
1246 { | |
4543 | 1247 int error; |
1248 zfs_log_history(zc); | |
1249 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
|
1250 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
|
1251 zvol_remove_minors(zc->zc_name); |
4543 | 1252 return (error); |
789 | 1253 } |
1254 | |
1255 static int | |
1256 zfs_ioc_pool_import(zfs_cmd_t *zc) | |
1257 { | |
5094 | 1258 nvlist_t *config, *props = NULL; |
789 | 1259 uint64_t guid; |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1260 int error; |
789 | 1261 |
5094 | 1262 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
|
1263 zc->zc_iflags, &config)) != 0) |
789 | 1264 return (error); |
1265 | |
5094 | 1266 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
|
1267 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
|
1268 zc->zc_iflags, &props))) { |
5094 | 1269 nvlist_free(config); |
1270 return (error); | |
1271 } | |
1272 | |
789 | 1273 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) != 0 || |
1544 | 1274 guid != zc->zc_guid) |
789 | 1275 error = EINVAL; |
1276 else | |
12961
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1277 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
|
1278 |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1279 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
|
1280 int err; |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1281 |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1282 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
|
1283 error = err; |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
1284 } |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
1285 |
789 | 1286 nvlist_free(config); |
1287 | |
5094 | 1288 if (props) |
1289 nvlist_free(props); | |
1290 | |
789 | 1291 return (error); |
1292 } | |
1293 | |
1294 static int | |
1295 zfs_ioc_pool_export(zfs_cmd_t *zc) | |
1296 { | |
4543 | 1297 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
|
1298 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
|
1299 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
|
1300 |
4543 | 1301 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
|
1302 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
|
1303 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
|
1304 zvol_remove_minors(zc->zc_name); |
4543 | 1305 return (error); |
789 | 1306 } |
1307 | |
1308 static int | |
1309 zfs_ioc_pool_configs(zfs_cmd_t *zc) | |
1310 { | |
1311 nvlist_t *configs; | |
1312 int error; | |
1313 | |
1314 if ((configs = spa_all_configs(&zc->zc_cookie)) == NULL) | |
1315 return (EEXIST); | |
1316 | |
2676 | 1317 error = put_nvlist(zc, configs); |
789 | 1318 |
1319 nvlist_free(configs); | |
1320 | |
1321 return (error); | |
1322 } | |
1323 | |
1324 static int | |
1325 zfs_ioc_pool_stats(zfs_cmd_t *zc) | |
1326 { | |
1327 nvlist_t *config; | |
1328 int error; | |
1544 | 1329 int ret = 0; |
789 | 1330 |
2676 | 1331 error = spa_get_stats(zc->zc_name, &config, zc->zc_value, |
1332 sizeof (zc->zc_value)); | |
789 | 1333 |
1334 if (config != NULL) { | |
2676 | 1335 ret = put_nvlist(zc, config); |
789 | 1336 nvlist_free(config); |
1544 | 1337 |
1338 /* | |
1339 * The config may be present even if 'error' is non-zero. | |
1340 * In this case we return success, and preserve the real errno | |
1341 * in 'zc_cookie'. | |
1342 */ | |
1343 zc->zc_cookie = error; | |
789 | 1344 } else { |
1544 | 1345 ret = error; |
789 | 1346 } |
1347 | |
1544 | 1348 return (ret); |
789 | 1349 } |
1350 | |
1351 /* | |
1352 * Try to import the given pool, returning pool stats as appropriate so that | |
1353 * user land knows which devices are available and overall pool health. | |
1354 */ | |
1355 static int | |
1356 zfs_ioc_pool_tryimport(zfs_cmd_t *zc) | |
1357 { | |
1358 nvlist_t *tryconfig, *config; | |
1359 int error; | |
1360 | |
5094 | 1361 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
|
1362 zc->zc_iflags, &tryconfig)) != 0) |
789 | 1363 return (error); |
1364 | |
1365 config = spa_tryimport(tryconfig); | |
1366 | |
1367 nvlist_free(tryconfig); | |
1368 | |
1369 if (config == NULL) | |
1370 return (EINVAL); | |
1371 | |
2676 | 1372 error = put_nvlist(zc, config); |
789 | 1373 nvlist_free(config); |
1374 | |
1375 return (error); | |
1376 } | |
1377 | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1378 /* |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1379 * inputs: |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1380 * 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
|
1381 * 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
|
1382 */ |
789 | 1383 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
|
1384 zfs_ioc_pool_scan(zfs_cmd_t *zc) |
789 | 1385 { |
1386 spa_t *spa; | |
1387 int error; | |
1388 | |
2926 | 1389 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
1390 return (error); | |
1391 | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1392 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
|
1393 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
|
1394 else |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1395 error = spa_scan(spa, zc->zc_cookie); |
2926 | 1396 |
1397 spa_close(spa, FTAG); | |
1398 | |
789 | 1399 return (error); |
1400 } | |
1401 | |
1402 static int | |
1403 zfs_ioc_pool_freeze(zfs_cmd_t *zc) | |
1404 { | |
1405 spa_t *spa; | |
1406 int error; | |
1407 | |
1408 error = spa_open(zc->zc_name, &spa, FTAG); | |
1409 if (error == 0) { | |
1410 spa_freeze(spa); | |
1411 spa_close(spa, FTAG); | |
1412 } | |
1413 return (error); | |
1414 } | |
1415 | |
1416 static int | |
1760 | 1417 zfs_ioc_pool_upgrade(zfs_cmd_t *zc) |
1418 { | |
1419 spa_t *spa; | |
1420 int error; | |
1421 | |
2926 | 1422 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
1423 return (error); | |
1424 | |
5118
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1425 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
|
1426 spa_close(spa, FTAG); |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1427 return (EINVAL); |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1428 } |
c723b1aa9f79
6607671 Able to zpool upgrade a pool to an unknown version number
lling
parents:
5094
diff
changeset
|
1429 |
5094 | 1430 spa_upgrade(spa, zc->zc_cookie); |
2926 | 1431 spa_close(spa, FTAG); |
1432 | |
1433 return (error); | |
1434 } | |
1435 | |
1436 static int | |
1437 zfs_ioc_pool_get_history(zfs_cmd_t *zc) | |
1438 { | |
1439 spa_t *spa; | |
1440 char *hist_buf; | |
1441 uint64_t size; | |
1442 int error; | |
1443 | |
1444 if ((size = zc->zc_history_len) == 0) | |
1445 return (EINVAL); | |
1446 | |
1447 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) | |
1448 return (error); | |
1449 | |
4577 | 1450 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
|
1451 spa_close(spa, FTAG); |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1452 return (ENOTSUP); |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1453 } |
d56571426115
6529406 zpool history needs to bump the on-disk version
ek110237
parents:
3741
diff
changeset
|
1454 |
2926 | 1455 hist_buf = kmem_alloc(size, KM_SLEEP); |
1456 if ((error = spa_history_get(spa, &zc->zc_history_offset, | |
1457 &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
|
1458 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
|
1459 (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
|
1460 zc->zc_history_len, zc->zc_iflags); |
2926 | 1461 } |
1462 | |
1463 spa_close(spa, FTAG); | |
1464 kmem_free(hist_buf, size); | |
1465 return (error); | |
1466 } | |
1467 | |
1468 static int | |
13514
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1469 zfs_ioc_pool_reguid(zfs_cmd_t *zc) |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1470 { |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1471 spa_t *spa; |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1472 int error; |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1473 |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1474 error = spa_open(zc->zc_name, &spa, FTAG); |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1475 if (error == 0) { |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1476 error = spa_change_guid(spa); |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1477 spa_close(spa, FTAG); |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1478 } |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1479 return (error); |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1480 } |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1481 |
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
1482 static int |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1483 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
|
1484 { |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1485 int error; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1486 |
3912 | 1487 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
|
1488 return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1489 |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1490 return (0); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1491 } |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1492 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1493 /* |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1494 * inputs: |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1495 * 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
|
1496 * 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
|
1497 * |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1498 * outputs: |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1499 * 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
|
1500 */ |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1501 static int |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1502 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
|
1503 { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1504 objset_t *os; |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1505 int error; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1506 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1507 /* 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
|
1508 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
|
1509 return (error); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1510 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
|
1511 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
|
1512 return (EINVAL); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1513 } |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1514 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
|
1515 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
|
1516 dmu_objset_rele(os, FTAG); |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1517 |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1518 return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1519 } |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1520 |
13055 | 1521 /* |
1522 * inputs: | |
1523 * zc_name name of filesystem | |
1524 * zc_obj object to find | |
1525 * | |
1526 * outputs: | |
1527 * zc_stat stats on object | |
1528 * zc_value path to object | |
1529 */ | |
1530 static int | |
1531 zfs_ioc_obj_to_stats(zfs_cmd_t *zc) | |
1532 { | |
1533 objset_t *os; | |
1534 int error; | |
1535 | |
1536 /* XXX reading from objset not owned */ | |
1537 if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os)) != 0) | |
1538 return (error); | |
1539 if (dmu_objset_type(os) != DMU_OST_ZFS) { | |
1540 dmu_objset_rele(os, FTAG); | |
1541 return (EINVAL); | |
1542 } | |
1543 error = zfs_obj_to_stats(os, zc->zc_obj, &zc->zc_stat, zc->zc_value, | |
1544 sizeof (zc->zc_value)); | |
1545 dmu_objset_rele(os, FTAG); | |
1546 | |
1547 return (error); | |
1548 } | |
1549 | |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3265
diff
changeset
|
1550 static int |
789 | 1551 zfs_ioc_vdev_add(zfs_cmd_t *zc) |
1552 { | |
1553 spa_t *spa; | |
1554 int error; | |
6423 | 1555 nvlist_t *config, **l2cache, **spares; |
1556 uint_t nl2cache = 0, nspares = 0; | |
789 | 1557 |
1558 error = spa_open(zc->zc_name, &spa, FTAG); | |
1559 if (error != 0) | |
1560 return (error); | |
1561 | |
5450 | 1562 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
|
1563 zc->zc_iflags, &config); |
5450 | 1564 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_L2CACHE, |
1565 &l2cache, &nl2cache); | |
1566 | |
6423 | 1567 (void) nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_SPARES, |
1568 &spares, &nspares); | |
1569 | |
3912 | 1570 /* |
1571 * A root pool with concatenated devices is not supported. | |
6423 | 1572 * Thus, can not add a device to a root pool. |
1573 * | |
1574 * Intent log device can not be added to a rootpool because | |
1575 * during mountroot, zil is replayed, a seperated log device | |
1576 * can not be accessed during the mountroot time. | |
1577 * | |
1578 * l2cache and spare devices are ok to be added to a rootpool. | |
3912 | 1579 */ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1580 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
|
1581 nvlist_free(config); |
3912 | 1582 spa_close(spa, FTAG); |
1583 return (EDOM); | |
1584 } | |
1585 | |
5450 | 1586 if (error == 0) { |
789 | 1587 error = spa_vdev_add(spa, config); |
1588 nvlist_free(config); | |
1589 } | |
1590 spa_close(spa, FTAG); | |
1591 return (error); | |
1592 } | |
1593 | |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1594 /* |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1595 * inputs: |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
1596 * 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
|
1597 * 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
|
1598 * 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
|
1599 */ |
789 | 1600 static int |
1601 zfs_ioc_vdev_remove(zfs_cmd_t *zc) | |
1602 { | |
2082 | 1603 spa_t *spa; |
1604 int error; | |
1605 | |
1606 error = spa_open(zc->zc_name, &spa, FTAG); | |
1607 if (error != 0) | |
1608 return (error); | |
1609 error = spa_vdev_remove(spa, zc->zc_guid, B_FALSE); | |
1610 spa_close(spa, FTAG); | |
1611 return (error); | |
789 | 1612 } |
1613 | |
1614 static int | |
4451 | 1615 zfs_ioc_vdev_set_state(zfs_cmd_t *zc) |
789 | 1616 { |
1617 spa_t *spa; | |
1618 int error; | |
4451 | 1619 vdev_state_t newstate = VDEV_STATE_UNKNOWN; |
789 | 1620 |
2926 | 1621 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1622 return (error); |
4451 | 1623 switch (zc->zc_cookie) { |
1624 case VDEV_STATE_ONLINE: | |
1625 error = vdev_online(spa, zc->zc_guid, zc->zc_obj, &newstate); | |
1626 break; | |
1627 | |
1628 case VDEV_STATE_OFFLINE: | |
1629 error = vdev_offline(spa, zc->zc_guid, zc->zc_obj); | |
1630 break; | |
789 | 1631 |
4451 | 1632 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
|
1633 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
|
1634 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
|
1635 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
|
1636 |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1637 error = vdev_fault(spa, zc->zc_guid, zc->zc_obj); |
4451 | 1638 break; |
789 | 1639 |
4451 | 1640 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
|
1641 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
|
1642 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
|
1643 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
|
1644 |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10693
diff
changeset
|
1645 error = vdev_degrade(spa, zc->zc_guid, zc->zc_obj); |
4451 | 1646 break; |
1647 | |
1648 default: | |
1649 error = EINVAL; | |
1650 } | |
1651 zc->zc_cookie = newstate; | |
789 | 1652 spa_close(spa, FTAG); |
1653 return (error); | |
1654 } | |
1655 | |
1656 static int | |
1657 zfs_ioc_vdev_attach(zfs_cmd_t *zc) | |
1658 { | |
1659 spa_t *spa; | |
1660 int replacing = zc->zc_cookie; | |
1661 nvlist_t *config; | |
1662 int error; | |
1663 | |
2926 | 1664 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1665 return (error); |
1666 | |
5094 | 1667 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
|
1668 zc->zc_iflags, &config)) == 0) { |
1544 | 1669 error = spa_vdev_attach(spa, zc->zc_guid, config, replacing); |
789 | 1670 nvlist_free(config); |
1671 } | |
1672 | |
1673 spa_close(spa, FTAG); | |
1674 return (error); | |
1675 } | |
1676 | |
1677 static int | |
1678 zfs_ioc_vdev_detach(zfs_cmd_t *zc) | |
1679 { | |
1680 spa_t *spa; | |
1681 int error; | |
1682 | |
2926 | 1683 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) |
789 | 1684 return (error); |
1685 | |
8241
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
8213
diff
changeset
|
1686 error = spa_vdev_detach(spa, zc->zc_guid, 0, B_FALSE); |
789 | 1687 |
1688 spa_close(spa, FTAG); | |
1689 return (error); | |
1690 } | |
1691 | |
1692 static int | |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1693 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
|
1694 { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1695 spa_t *spa; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1696 nvlist_t *config, *props = NULL; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1697 int error; |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1698 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
|
1699 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1700 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
|
1701 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1702 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1703 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
|
1704 zc->zc_iflags, &config)) { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1705 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1706 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1707 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1708 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1709 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
|
1710 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
|
1711 zc->zc_iflags, &props))) { |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1712 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1713 nvlist_free(config); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1714 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1715 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1716 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1717 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
|
1718 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1719 spa_close(spa, FTAG); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1720 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1721 nvlist_free(config); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1722 nvlist_free(props); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1723 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1724 return (error); |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1725 } |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1726 |
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
1727 static int |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1728 zfs_ioc_vdev_setpath(zfs_cmd_t *zc) |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1729 { |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1730 spa_t *spa; |
2676 | 1731 char *path = zc->zc_value; |
1544 | 1732 uint64_t guid = zc->zc_guid; |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1733 int error; |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1734 |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1735 error = spa_open(zc->zc_name, &spa, FTAG); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1736 if (error != 0) |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1737 return (error); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1738 |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1739 error = spa_vdev_setpath(spa, guid, path); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1740 spa_close(spa, FTAG); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1741 return (error); |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1742 } |
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1743 |
9425
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1744 static int |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1745 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
|
1746 { |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1747 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
|
1748 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
|
1749 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
|
1750 int error; |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1751 |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1752 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
|
1753 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
|
1754 return (error); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1755 |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1756 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
|
1757 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
|
1758 return (error); |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1759 } |
e7ffacaec3a8
6799895 spa_add_spares() needs to be protected by config lock
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
9396
diff
changeset
|
1760 |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
1133
diff
changeset
|
1761 static int |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1762 zfs_ioc_objset_stats_impl(zfs_cmd_t *zc, objset_t *os) |
789 | 1763 { |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1764 int error = 0; |
1356
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1765 nvlist_t *nv; |
789 | 1766 |
2885 | 1767 dmu_objset_fast_stat(os, &zc->zc_objset_stats); |
789 | 1768 |
2856 | 1769 if (zc->zc_nvlist_dst != 0 && |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1770 (error = dsl_prop_get_all(os, &nv)) == 0) { |
2885 | 1771 dmu_objset_stats(os, nv); |
3087 | 1772 /* |
5147
5e950ccc9585
6596190 "zfs list" is slow due to version property
rm160521
parents:
5118
diff
changeset
|
1773 * NB: zvol_get_stats() will read the objset contents, |
3087 | 1774 * 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
|
1775 * DS_MODE_USER hold, because it could be |
3087 | 1776 * 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
|
1777 * XXX reading with out owning |
3087 | 1778 */ |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
1779 if (!zc->zc_objset_stats.dds_inconsistent && |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
1780 dmu_objset_type(os) == DMU_OST_ZVOL) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
1781 error = zvol_get_stats(os, nv); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
1782 if (error == EIO) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
1783 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
1784 VERIFY3S(error, ==, 0); |
4577 | 1785 } |
2676 | 1786 error = put_nvlist(zc, nv); |
1356
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1787 nvlist_free(nv); |
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1354
diff
changeset
|
1788 } |
789 | 1789 |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1790 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1791 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1792 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1793 /* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1794 * inputs: |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1795 * 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
|
1796 * 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
|
1797 * |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1798 * outputs: |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1799 * zc_objset_stats stats |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1800 * 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
|
1801 * 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
|
1802 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1803 static int |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1804 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
|
1805 { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1806 objset_t *os = NULL; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1807 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1808 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1809 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
|
1810 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1811 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
1812 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
|
1813 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1814 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
|
1815 |
789 | 1816 return (error); |
1817 } | |
1818 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1819 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1820 * inputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1821 * zc_name name of filesystem |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1822 * 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
|
1823 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1824 * outputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1825 * zc_nvlist_dst received property nvlist |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1826 * 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
|
1827 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1828 * 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
|
1829 * 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
|
1830 * local property values. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1831 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1832 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1833 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
|
1834 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1835 objset_t *os = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1836 int error; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1837 nvlist_t *nv; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1838 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1839 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
|
1840 return (error); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1841 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1842 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1843 * 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
|
1844 * 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
|
1845 * SPA_VERSION_RECVD_PROPS. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1846 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1847 if (!dsl_prop_get_hasrecvd(os)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1848 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1849 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1850 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1851 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1852 if (zc->zc_nvlist_dst != 0 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1853 (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
|
1854 error = put_nvlist(zc, nv); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1855 nvlist_free(nv); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1856 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1857 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1858 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1859 return (error); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1860 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
1861 |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1862 static int |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1863 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
|
1864 { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1865 uint64_t value; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1866 int error; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1867 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1868 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1869 * 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
|
1870 * the default value (if there is one). |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1871 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1872 if ((error = zfs_get_zplprop(os, prop, &value)) != 0) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1873 return (error); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1874 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
|
1875 return (0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1876 } |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1877 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1878 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1879 * inputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1880 * zc_name name of filesystem |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1881 * 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
|
1882 * |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1883 * outputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1884 * zc_nvlist_dst zpl property nvlist |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1885 * zc_nvlist_dst_size size of zpl property nvlist |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1886 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1887 static int |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1888 zfs_ioc_objset_zplprops(zfs_cmd_t *zc) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1889 { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1890 objset_t *os; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1891 int err; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1892 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1893 /* XXX reading without owning */ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1894 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
|
1895 return (err); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1896 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1897 dmu_objset_fast_stat(os, &zc->zc_objset_stats); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1898 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1899 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1900 * 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
|
1901 * 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
|
1902 * hold, because it could be inconsistent. |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1903 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1904 if (zc->zc_nvlist_dst != NULL && |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1905 !zc->zc_objset_stats.dds_inconsistent && |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1906 dmu_objset_type(os) == DMU_OST_ZFS) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1907 nvlist_t *nv; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1908 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1909 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
|
1910 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
|
1911 (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
|
1912 (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
|
1913 (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
|
1914 err = put_nvlist(zc, nv); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1915 nvlist_free(nv); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1916 } else { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1917 err = ENOENT; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1918 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1919 dmu_objset_rele(os, FTAG); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1920 return (err); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1921 } |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
1922 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1923 static boolean_t |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1924 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
|
1925 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1926 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1927 * 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
|
1928 * 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
|
1929 * 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
|
1930 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1931 if (strchr(name, '$') != NULL) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1932 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1933 if (strchr(name, '%') != NULL) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1934 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1935 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
|
1936 return (B_TRUE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1937 return (B_FALSE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1938 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1939 |
5367 | 1940 /* |
1941 * inputs: | |
1942 * zc_name name of filesystem | |
1943 * zc_cookie zap cursor | |
1944 * zc_nvlist_dst_size size of buffer for property nvlist | |
1945 * | |
1946 * outputs: | |
1947 * 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
|
1948 * zc_cookie zap cursor |
5367 | 1949 * zc_objset_stats stats |
1950 * zc_nvlist_dst property nvlist | |
1951 * zc_nvlist_dst_size size of property nvlist | |
1952 */ | |
789 | 1953 static int |
1954 zfs_ioc_dataset_list_next(zfs_cmd_t *zc) | |
1955 { | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1956 objset_t *os; |
789 | 1957 int error; |
1958 char *p; | |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1959 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
|
1960 |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
1961 top: |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1962 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
|
1963 if (error == ENOENT) |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1964 error = ESRCH; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1965 return (error); |
789 | 1966 } |
1967 | |
1968 p = strrchr(zc->zc_name, '/'); | |
1969 if (p == NULL || p[1] != '\0') | |
1970 (void) strlcat(zc->zc_name, "/", sizeof (zc->zc_name)); | |
1971 p = zc->zc_name + strlen(zc->zc_name); | |
1972 | |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1973 /* |
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
1974 * 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
|
1975 * 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
|
1976 */ |
8415
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1977 if (zc->zc_cookie == 0) { |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1978 uint64_t cookie = 0; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1979 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
|
1980 |
13492
83d135508f56
1346 zfs incremental receive may leave behind temporary clones
Martin Matuska <mm@FreeBSD.org>
parents:
13061
diff
changeset
|
1981 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
|
1982 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
|
1983 (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
|
1984 } |
8415
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1985 } |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8241
diff
changeset
|
1986 |
789 | 1987 do { |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1988 error = dmu_dir_list_next(os, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
1989 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
|
1990 NULL, &zc->zc_cookie); |
789 | 1991 if (error == ENOENT) |
1992 error = ESRCH; | |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
1993 } while (error == 0 && dataset_name_hidden(zc->zc_name)); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1994 dmu_objset_rele(os, FTAG); |
789 | 1995 |
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
|
1996 /* |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10474
diff
changeset
|
1997 * 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
|
1998 * 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
|
1999 */ |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2000 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
|
2001 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
|
2002 if (error == ENOENT) { |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2003 /* 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
|
2004 zc->zc_name[orig_len] = '\0'; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2005 goto top; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2006 } |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2007 } |
789 | 2008 return (error); |
2009 } | |
2010 | |
5367 | 2011 /* |
2012 * inputs: | |
2013 * zc_name name of filesystem | |
2014 * zc_cookie zap cursor | |
2015 * zc_nvlist_dst_size size of buffer for property nvlist | |
2016 * | |
2017 * outputs: | |
2018 * zc_name name of next snapshot | |
2019 * zc_objset_stats stats | |
2020 * zc_nvlist_dst property nvlist | |
2021 * zc_nvlist_dst_size size of property nvlist | |
2022 */ | |
789 | 2023 static int |
2024 zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) | |
2025 { | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
2026 objset_t *os; |
789 | 2027 int error; |
2028 | |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2029 top: |
10474
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
2030 if (zc->zc_cookie == 0) |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
2031 (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
|
2032 NULL, DS_FIND_SNAPSHOTS); |
0e96dd3b905a
6859997 zfs caching performance problem
Rich Morris <Richard.Morris@Sun.COM>
parents:
10342
diff
changeset
|
2033 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2034 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
|
2035 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2036 return (error == ENOENT ? ESRCH : error); |
789 | 2037 |
1003 | 2038 /* |
2039 * A dataset name of maximum length cannot have any snapshots, | |
2040 * so exit immediately. | |
2041 */ | |
2042 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
|
2043 dmu_objset_rele(os, FTAG); |
1003 | 2044 return (ESRCH); |
789 | 2045 } |
2046 | |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
2047 error = dmu_snapshot_list_next(os, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
849
diff
changeset
|
2048 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
|
2049 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
|
2050 NULL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2051 |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2052 if (error == 0) { |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2053 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2054 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
|
2055 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2056 /* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2057 * 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
|
2058 * 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
|
2059 * 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
|
2060 * 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
|
2061 * 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
|
2062 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2063 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
|
2064 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
|
2065 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
|
2066 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2067 if (error == ENOENT) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2068 /* 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
|
2069 *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
|
2070 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
|
2071 goto top; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2072 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2073 } else { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2074 objset_t *ossnap; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2075 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2076 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
|
2077 if (error == 0) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2078 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
|
2079 dsl_dataset_rele(ds, FTAG); |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2080 } |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2081 } else if (error == ENOENT) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2082 error = ESRCH; |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11515
diff
changeset
|
2083 } |
789 | 2084 |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
2085 dmu_objset_rele(os, FTAG); |
5367 | 2086 /* 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
|
2087 if (error) |
5367 | 2088 *strchr(zc->zc_name, '@') = '\0'; |
789 | 2089 return (error); |
2090 } | |
2091 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2092 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2093 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
|
2094 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2095 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2096 uint64_t *valary; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2097 unsigned int vallen; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2098 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
|
2099 char *dash; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2100 zfs_userquota_prop_t type; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2101 uint64_t rid; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2102 uint64_t quota; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2103 zfsvfs_t *zfsvfs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2104 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2105 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2106 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2107 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2108 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
|
2109 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
|
2110 &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
|
2111 return (EINVAL); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2112 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2113 |
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
|
2114 /* |
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
|
2115 * 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
|
2116 * 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
|
2117 */ |
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
|
2118 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
|
2119 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
|
2120 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
|
2121 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
|
2122 |
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
|
2123 domain = dash + 1; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2124 type = valary[0]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2125 rid = valary[1]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2126 quota = valary[2]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2127 |
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
|
2128 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
|
2129 if (err == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2130 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
|
2131 zfsvfs_rele(zfsvfs, FTAG); |
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 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2135 } |
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 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2138 * 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
|
2139 * 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
|
2140 * 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
|
2141 * |
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
|
2142 * 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
|
2143 * 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
|
2144 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2145 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2146 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
|
2147 nvpair_t *pair) |
789 | 2148 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2149 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2150 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
|
2151 uint64_t intval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2152 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2153 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2154 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2155 if (zfs_prop_userquota(propname)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2156 return (zfs_prop_set_userquota(dsname, pair)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2157 return (-1); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2158 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2159 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2160 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2161 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2162 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2163 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2164 &pair) == 0); |
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 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2167 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
|
2168 return (-1); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2169 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2170 VERIFY(0 == nvpair_value_uint64(pair, &intval)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2171 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2172 switch (prop) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2173 case ZFS_PROP_QUOTA: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2174 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
|
2175 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2176 case ZFS_PROP_REFQUOTA: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2177 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
|
2178 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2179 case ZFS_PROP_RESERVATION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2180 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
|
2181 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2182 case ZFS_PROP_REFRESERVATION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2183 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
|
2184 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2185 case ZFS_PROP_VOLSIZE: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2186 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
|
2187 intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2188 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2189 case ZFS_PROP_VERSION: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2190 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2191 zfsvfs_t *zfsvfs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2192 |
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
|
2193 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
|
2194 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2195 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2196 err = zfs_set_version(zfsvfs, intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2197 zfsvfs_rele(zfsvfs, FTAG); |
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 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) { |
11147
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2200 zfs_cmd_t *zc; |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2201 |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2202 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
|
2203 (void) strcpy(zc->zc_name, dsname); |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2204 (void) zfs_ioc_userspace_upgrade(zc); |
74e8c05021f1
6678033 resilver code should prefetch
George Wilson <George.Wilson@Sun.COM>
parents:
11045
diff
changeset
|
2205 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
|
2206 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2207 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2208 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2209 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2210 default: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2211 err = -1; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2212 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2213 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2214 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2215 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2216 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2217 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2218 * 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
|
2219 * 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
|
2220 * 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
|
2221 * 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
|
2222 * 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
|
2223 * returned errlist. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2224 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2225 * 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
|
2226 * at by errlist is NULL. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2227 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2228 int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2229 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
|
2230 nvlist_t **errlist) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2231 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2232 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2233 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
|
2234 int rv = 0; |
2676 | 2235 uint64_t intval; |
2236 char *strval; | |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2237 nvlist_t *genericnvl; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2238 nvlist_t *errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2239 nvlist_t *retrynvl; |
4543 | 2240 |
8697
e62d2612c14d
6633095 creating a filesystem with many properties set is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8536
diff
changeset
|
2241 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
|
2242 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
|
2243 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
|
2244 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2245 retry: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2246 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2247 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
|
2248 const char *propname = nvpair_name(pair); |
4670
002728040e28
6580745 "zfs inherit" can be executed by ordinary user
ahrens
parents:
4611
diff
changeset
|
2249 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
|
2250 int err = 0; |
4543 | 2251 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2252 /* decode the property value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2253 propval = pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2254 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2255 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2256 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
|
2257 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
|
2258 &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
|
2259 err = EINVAL; |
4543 | 2260 } |
2676 | 2261 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2262 /* 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
|
2263 if (err == 0 && prop == ZPROP_INVAL) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2264 if (zfs_prop_user(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2265 if (nvpair_type(propval) != DATA_TYPE_STRING) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2266 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2267 } else if (zfs_prop_userquota(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2268 if (nvpair_type(propval) != |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2269 DATA_TYPE_UINT64_ARRAY) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2270 err = EINVAL; |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
2271 } else { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
2272 err = EINVAL; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2273 } |
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
|
2274 } else if (err == 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2275 if (nvpair_type(propval) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2276 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
|
2277 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2278 } else if (nvpair_type(propval) == DATA_TYPE_UINT64) { |
2885 | 2279 const char *unused; |
2280 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2281 VERIFY(nvpair_value_uint64(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2282 &intval) == 0); |
2676 | 2283 |
2284 switch (zfs_prop_get_type(prop)) { | |
4787 | 2285 case PROP_TYPE_NUMBER: |
2676 | 2286 break; |
4787 | 2287 case PROP_TYPE_STRING: |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2288 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2289 break; |
4787 | 2290 case PROP_TYPE_INDEX: |
2717
ed589a32259d
6469385 zfs_set_prop_nvlist range checking is busted
eschrock
parents:
2676
diff
changeset
|
2291 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
|
2292 intval, &unused) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2293 err = EINVAL; |
2676 | 2294 break; |
2295 default: | |
4577 | 2296 cmn_err(CE_PANIC, |
2297 "unknown property type"); | |
2676 | 2298 } |
2299 } else { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2300 err = EINVAL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2301 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2302 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2303 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2304 /* Validate permissions */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2305 if (err == 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2306 err = zfs_check_settable(dsname, pair, CRED()); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2307 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2308 if (err == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2309 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
|
2310 if (err == -1) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2311 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2312 * 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
|
2313 * properties to set in a single transaction. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2314 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2315 err = nvlist_add_nvpair(genericnvl, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2316 } else if (err != 0 && nvl != retrynvl) { |
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 * 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
|
2319 * receiving quota and reservation out of order. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2320 * Try again in a second pass. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2321 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2322 err = nvlist_add_nvpair(retrynvl, pair); |
2676 | 2323 } |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2324 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2325 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2326 if (err != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2327 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
|
2328 } |
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 if (nvl != retrynvl && !nvlist_empty(retrynvl)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2331 nvl = retrynvl; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2332 goto retry; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2333 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2334 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2335 if (!nvlist_empty(genericnvl) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2336 dsl_props_set(dsname, source, genericnvl) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2337 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2338 * 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
|
2339 * can, so try setting them individually. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2340 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2341 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2342 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
|
2343 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
|
2344 int err = 0; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2345 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2346 propval = pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2347 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2348 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2349 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2350 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2351 &propval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2352 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2353 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2354 if (nvpair_type(propval) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2355 VERIFY(nvpair_value_string(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2356 &strval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2357 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
|
2358 strlen(strval) + 1, strval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2359 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2360 VERIFY(nvpair_value_uint64(propval, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2361 &intval) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2362 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
|
2363 1, &intval); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2364 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2365 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2366 if (err != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2367 VERIFY(nvlist_add_int32(errors, propname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2368 err) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2369 } |
2676 | 2370 } |
2371 } | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2372 nvlist_free(genericnvl); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2373 nvlist_free(retrynvl); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2374 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2375 if ((pair = nvlist_next_nvpair(errors, NULL)) == NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2376 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2377 errors = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2378 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2379 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
|
2380 } |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2381 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2382 if (errlist == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2383 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2384 else |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2385 *errlist = errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2386 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2387 return (rv); |
789 | 2388 } |
2389 | |
5367 | 2390 /* |
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
|
2391 * 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
|
2392 */ |
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
|
2393 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
|
2394 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
|
2395 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2396 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
|
2397 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
|
2398 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2399 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
|
2400 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
|
2401 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
|
2402 |
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
|
2403 if (!zfs_prop_user(propname) || |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2404 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
|
2405 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
|
2406 |
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
|
2407 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
|
2408 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
|
2409 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
|
2410 |
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
|
2411 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
|
2412 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
|
2413 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2414 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
|
2415 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
|
2416 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
|
2417 } |
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
|
2418 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
|
2419 } |
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
|
2420 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2421 static void |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2422 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
|
2423 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2424 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2425 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2426 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
|
2427 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2428 pair = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2429 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
|
2430 if (nvlist_exists(skipped, nvpair_name(pair))) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2431 continue; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2432 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2433 VERIFY(nvlist_add_nvpair(*newprops, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2434 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2435 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2436 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2437 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2438 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
|
2439 nvlist_t *skipped) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2440 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2441 int err = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2442 nvlist_t *cleared_props = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2443 props_skip(props, skipped, &cleared_props); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2444 if (!nvlist_empty(cleared_props)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2445 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2446 * 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
|
2447 * 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
|
2448 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2449 zprop_source_t flags = (ZPROP_SRC_NONE | |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2450 (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
|
2451 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
|
2452 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2453 nvlist_free(cleared_props); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2454 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2455 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2456 |
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
|
2457 /* |
5367 | 2458 * inputs: |
2459 * 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
|
2460 * zc_value name of property to set |
5367 | 2461 * 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
|
2462 * zc_cookie received properties flag |
5367 | 2463 * |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2464 * outputs: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2465 * zc_nvlist_dst{_size} error for each unapplied received property |
5367 | 2466 */ |
789 | 2467 static int |
2676 | 2468 zfs_ioc_set_prop(zfs_cmd_t *zc) |
789 | 2469 { |
2676 | 2470 nvlist_t *nvl; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2471 boolean_t received = zc->zc_cookie; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2472 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
|
2473 ZPROP_SRC_LOCAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2474 nvlist_t *errors = NULL; |
2676 | 2475 int error; |
789 | 2476 |
5094 | 2477 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
|
2478 zc->zc_iflags, &nvl)) != 0) |
2676 | 2479 return (error); |
2480 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2481 if (received) { |
7265 | 2482 nvlist_t *origprops; |
2483 objset_t *os; | |
2484 | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2485 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
|
2486 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
|
2487 (void) clear_received_props(os, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2488 zc->zc_name, origprops, nvl); |
7265 | 2489 nvlist_free(origprops); |
2490 } | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2491 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2492 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
|
2493 dmu_objset_rele(os, FTAG); |
7265 | 2494 } |
2495 } | |
2496 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2497 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
|
2498 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2499 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
|
2500 (void) put_nvlist(zc, errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2501 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2502 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2503 nvlist_free(errors); |
2676 | 2504 nvlist_free(nvl); |
2505 return (error); | |
789 | 2506 } |
2507 | |
5367 | 2508 /* |
2509 * inputs: | |
2510 * zc_name name of filesystem | |
2511 * 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
|
2512 * zc_cookie revert to received value if TRUE |
5367 | 2513 * |
2514 * outputs: none | |
2515 */ | |
789 | 2516 static int |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2517 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
|
2518 { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2519 const char *propname = zc->zc_value; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2520 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
|
2521 boolean_t received = zc->zc_cookie; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2522 zprop_source_t source = (received |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2523 ? 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
|
2524 : ZPROP_SRC_INHERITED); /* explicitly inherit */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2525 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2526 if (received) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2527 nvlist_t *dummy; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2528 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2529 zprop_type_t type; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2530 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2531 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2532 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2533 * 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
|
2534 * nvpair with type info. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2535 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2536 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2537 if (!zfs_prop_user(propname)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2538 return (EINVAL); |
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 type = PROP_TYPE_STRING; |
11515
a122949107d4
6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11454
diff
changeset
|
2541 } 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
|
2542 prop == ZFS_PROP_VERSION) { |
a122949107d4
6908211 'zfs inherit -S volsize <volume>' core dumps
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11454
diff
changeset
|
2543 return (EINVAL); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2544 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2545 type = zfs_prop_get_type(prop); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2546 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2547 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2548 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
|
2549 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2550 switch (type) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2551 case PROP_TYPE_STRING: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2552 VERIFY(0 == nvlist_add_string(dummy, propname, "")); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2553 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2554 case PROP_TYPE_NUMBER: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2555 case PROP_TYPE_INDEX: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2556 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
|
2557 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2558 default: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2559 nvlist_free(dummy); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2560 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2561 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2562 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2563 pair = nvlist_next_nvpair(dummy, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2564 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
|
2565 nvlist_free(dummy); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2566 if (err != -1) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2567 return (err); /* special property already handled */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2568 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2569 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2570 * 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
|
2571 * '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
|
2572 * 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
|
2573 * they are not considered inheritable. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2574 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2575 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
|
2576 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2577 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2578 |
4849
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2579 /* 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
|
2580 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
|
2581 } |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2582 |
3a61e0a9a953
6536043 arc_byteswap_func_t and dmu_byteswap_func_t are redundant
ahrens
parents:
4808
diff
changeset
|
2583 static int |
4098
0a182c2128e6
6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents:
4007
diff
changeset
|
2584 zfs_ioc_pool_set_props(zfs_cmd_t *zc) |
3912 | 2585 { |
5094 | 2586 nvlist_t *props; |
3912 | 2587 spa_t *spa; |
5094 | 2588 int error; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2589 nvpair_t *pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2590 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2591 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
|
2592 zc->zc_iflags, &props)) |
3912 | 2593 return (error); |
2594 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2595 /* |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2596 * 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
|
2597 * 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
|
2598 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2599 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
2600 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
|
2601 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
|
2602 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
|
2603 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
|
2604 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
|
2605 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
|
2606 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
|
2607 } |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2608 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
|
2609 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
|
2610 nvlist_free(props); |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2611 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
|
2612 } |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2613 } |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2614 |
3912 | 2615 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) { |
5094 | 2616 nvlist_free(props); |
3912 | 2617 return (error); |
2618 } | |
2619 | |
5094 | 2620 error = spa_prop_set(spa, props); |
3912 | 2621 |
5094 | 2622 nvlist_free(props); |
3912 | 2623 spa_close(spa, FTAG); |
2624 | |
2625 return (error); | |
2626 } | |
2627 | |
2628 static int | |
4098
0a182c2128e6
6545726 make ZFS_IOC_POOL_*_PROPS in sync with zfs_ioc_pool_props_*
lling
parents:
4007
diff
changeset
|
2629 zfs_ioc_pool_get_props(zfs_cmd_t *zc) |
3912 | 2630 { |
2631 spa_t *spa; | |
2632 int error; | |
2633 nvlist_t *nvp = NULL; | |
2634 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2635 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
|
2636 /* |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2637 * 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
|
2638 * 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
|
2639 * anyway. |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2640 */ |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2641 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
|
2642 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
|
2643 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
|
2644 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
|
2645 } else { |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2646 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
|
2647 spa_close(spa, FTAG); |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2648 } |
3912 | 2649 |
2650 if (error == 0 && zc->zc_nvlist_dst != NULL) | |
2651 error = put_nvlist(zc, nvp); | |
2652 else | |
2653 error = EFAULT; | |
2654 | |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8415
diff
changeset
|
2655 nvlist_free(nvp); |
3912 | 2656 return (error); |
2657 } | |
2658 | |
5367 | 2659 /* |
2660 * inputs: | |
2661 * zc_name name of filesystem | |
2662 * zc_nvlist_src{_size} nvlist of delegated permissions | |
2663 * zc_perm_action allow/unallow flag | |
2664 * | |
2665 * outputs: none | |
2666 */ | |
4543 | 2667 static int |
2668 zfs_ioc_set_fsacl(zfs_cmd_t *zc) | |
2669 { | |
2670 int error; | |
2671 nvlist_t *fsaclnv = NULL; | |
2672 | |
5094 | 2673 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
|
2674 zc->zc_iflags, &fsaclnv)) != 0) |
4543 | 2675 return (error); |
2676 | |
2677 /* | |
2678 * Verify nvlist is constructed correctly | |
2679 */ | |
2680 if ((error = zfs_deleg_verify_nvlist(fsaclnv)) != 0) { | |
2681 nvlist_free(fsaclnv); | |
2682 return (EINVAL); | |
2683 } | |
2684 | |
2685 /* | |
2686 * If we don't have PRIV_SYS_MOUNT, then validate | |
2687 * that user is allowed to hand out each permission in | |
2688 * the nvlist(s) | |
2689 */ | |
2690 | |
4787 | 2691 error = secpolicy_zfs(CRED()); |
4543 | 2692 if (error) { |
4787 | 2693 if (zc->zc_perm_action == B_FALSE) { |
2694 error = dsl_deleg_can_allow(zc->zc_name, | |
2695 fsaclnv, CRED()); | |
2696 } else { | |
2697 error = dsl_deleg_can_unallow(zc->zc_name, | |
2698 fsaclnv, CRED()); | |
2699 } | |
4543 | 2700 } |
2701 | |
2702 if (error == 0) | |
2703 error = dsl_deleg_set(zc->zc_name, fsaclnv, zc->zc_perm_action); | |
2704 | |
2705 nvlist_free(fsaclnv); | |
2706 return (error); | |
2707 } | |
2708 | |
5367 | 2709 /* |
2710 * inputs: | |
2711 * zc_name name of filesystem | |
2712 * | |
2713 * outputs: | |
2714 * zc_nvlist_src{_size} nvlist of delegated permissions | |
2715 */ | |
4543 | 2716 static int |
2717 zfs_ioc_get_fsacl(zfs_cmd_t *zc) | |
2718 { | |
2719 nvlist_t *nvp; | |
2720 int error; | |
2721 | |
2722 if ((error = dsl_deleg_get(zc->zc_name, &nvp)) == 0) { | |
2723 error = put_nvlist(zc, nvp); | |
2724 nvlist_free(nvp); | |
2725 } | |
2726 | |
2727 return (error); | |
2728 } | |
2729 | |
5367 | 2730 /* |
789 | 2731 * Search the vfs list for a specified resource. Returns a pointer to it |
2732 * or NULL if no suitable entry is found. The caller of this routine | |
2733 * is responsible for releasing the returned vfs pointer. | |
2734 */ | |
2735 static vfs_t * | |
2736 zfs_get_vfs(const char *resource) | |
2737 { | |
2738 struct vfs *vfsp; | |
2739 struct vfs *vfs_found = NULL; | |
2740 | |
2741 vfs_list_read_lock(); | |
2742 vfsp = rootvfs; | |
2743 do { | |
2744 if (strcmp(refstr_value(vfsp->vfs_resource), resource) == 0) { | |
2745 VFS_HOLD(vfsp); | |
2746 vfs_found = vfsp; | |
2747 break; | |
2748 } | |
2749 vfsp = vfsp->vfs_next; | |
2750 } while (vfsp != rootvfs); | |
2751 vfs_list_unlock(); | |
2752 return (vfs_found); | |
2753 } | |
2754 | |
4543 | 2755 /* ARGSUSED */ |
789 | 2756 static void |
4543 | 2757 zfs_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx) |
789 | 2758 { |
5331 | 2759 zfs_creat_t *zct = arg; |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2760 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2761 zfs_create_fs(os, cr, zct->zct_zplprops, tx); |
5331 | 2762 } |
2763 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2764 #define ZFS_PROP_UNDEFINED ((uint64_t)-1) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2765 |
5331 | 2766 /* |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2767 * inputs: |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2768 * createprops list of properties requested by creator |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2769 * 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
|
2770 * 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
|
2771 * os parent objset pointer (NULL if root fs) |
5331 | 2772 * |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2773 * outputs: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2774 * 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
|
2775 * is_ci true if requested file system will be purely case-insensitive |
5331 | 2776 * |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2777 * Determine the settings for utf8only, normalization and |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2778 * casesensitivity. Specific values may have been requested by the |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2779 * 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
|
2780 * 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
|
2781 * request settings for these properties, even if the requested |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2782 * 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
|
2783 * 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
|
2784 * processing. |
5331 | 2785 */ |
2786 static int | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
2787 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
|
2788 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
|
2789 nvlist_t *zplprops, boolean_t *is_ci) |
5331 | 2790 { |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2791 uint64_t sense = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2792 uint64_t norm = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2793 uint64_t u8 = ZFS_PROP_UNDEFINED; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2794 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2795 ASSERT(zplprops != NULL); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2796 |
5375 | 2797 /* |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2798 * Pull out creator prop choices, if any. |
5375 | 2799 */ |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2800 if (createprops) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2801 (void) nvlist_lookup_uint64(createprops, |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2802 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
|
2803 (void) nvlist_lookup_uint64(createprops, |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2804 zfs_prop_to_name(ZFS_PROP_NORMALIZE), &norm); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2805 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2806 zfs_prop_to_name(ZFS_PROP_NORMALIZE)); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2807 (void) nvlist_lookup_uint64(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2808 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), &u8); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2809 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2810 zfs_prop_to_name(ZFS_PROP_UTF8ONLY)); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2811 (void) nvlist_lookup_uint64(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2812 zfs_prop_to_name(ZFS_PROP_CASE), &sense); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2813 (void) nvlist_remove_all(createprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2814 zfs_prop_to_name(ZFS_PROP_CASE)); |
5331 | 2815 } |
2816 | |
5375 | 2817 /* |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2818 * 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
|
2819 * 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
|
2820 * 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
|
2821 * error out. |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2822 */ |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2823 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
|
2824 (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
|
2825 (zplver >= ZPL_VERSION_SA && !sa_ok) || |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2826 (zplver < ZPL_VERSION_NORMALIZATION && |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2827 (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
|
2828 sense != ZFS_PROP_UNDEFINED))) |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2829 return (ENOTSUP); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2830 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2831 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2832 * Put the version in the zplprops |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2833 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2834 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2835 zfs_prop_to_name(ZFS_PROP_VERSION), zplver) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2836 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2837 if (norm == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2838 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
|
2839 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2840 zfs_prop_to_name(ZFS_PROP_NORMALIZE), norm) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2841 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2842 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2843 * 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
|
2844 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2845 if (norm) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2846 u8 = 1; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2847 if (u8 == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2848 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
|
2849 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2850 zfs_prop_to_name(ZFS_PROP_UTF8ONLY), u8) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2851 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2852 if (sense == ZFS_PROP_UNDEFINED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2853 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
|
2854 VERIFY(nvlist_add_uint64(zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2855 zfs_prop_to_name(ZFS_PROP_CASE), sense) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2856 |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2857 if (is_ci) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2858 *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
|
2859 |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2860 return (0); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2861 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2862 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2863 static int |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2864 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
|
2865 nvlist_t *zplprops, boolean_t *is_ci) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2866 { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2867 boolean_t fuids_ok, sa_ok; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2868 uint64_t zplver = ZPL_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2869 objset_t *os = NULL; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2870 char parentname[MAXNAMELEN]; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2871 char *cp; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2872 spa_t *spa; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2873 uint64_t spa_vers; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2874 int error; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2875 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2876 (void) strlcpy(parentname, dataset, sizeof (parentname)); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2877 cp = strrchr(parentname, '/'); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2878 ASSERT(cp != NULL); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2879 cp[0] = '\0'; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2880 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2881 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
|
2882 return (error); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2883 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2884 spa_vers = spa_version(spa); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2885 spa_close(spa, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2886 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2887 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
|
2888 fuids_ok = (zplver >= ZPL_VERSION_FUID); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2889 sa_ok = (zplver >= ZPL_VERSION_SA); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2890 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2891 /* |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2892 * 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
|
2893 */ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2894 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
|
2895 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2896 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2897 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
|
2898 zplprops, is_ci); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2899 dmu_objset_rele(os, FTAG); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2900 return (error); |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2901 } |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2902 |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2903 static int |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2904 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
|
2905 nvlist_t *zplprops, boolean_t *is_ci) |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2906 { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2907 boolean_t fuids_ok; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2908 boolean_t sa_ok; |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2909 uint64_t zplver = ZPL_VERSION; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2910 int error; |
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2911 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2912 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
|
2913 fuids_ok = (zplver >= ZPL_VERSION_FUID); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2914 sa_ok = (zplver >= ZPL_VERSION_SA); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2915 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11933
diff
changeset
|
2916 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
|
2917 createprops, zplprops, is_ci); |
7184
9508660f9c27
PSARC 2008/223 Pool root file system properties via zpool(1M)
timh
parents:
7046
diff
changeset
|
2918 return (error); |
789 | 2919 } |
2920 | |
5367 | 2921 /* |
2922 * inputs: | |
2923 * zc_objset_type type of objset to create (fs vs zvol) | |
2924 * zc_name name of new objset | |
2925 * zc_value name of snapshot to clone from (may be empty) | |
2926 * zc_nvlist_src{_size} nvlist of properties to apply | |
2927 * | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2928 * outputs: none |
5367 | 2929 */ |
789 | 2930 static int |
2931 zfs_ioc_create(zfs_cmd_t *zc) | |
2932 { | |
2933 objset_t *clone; | |
2934 int error = 0; | |
5331 | 2935 zfs_creat_t zct; |
4543 | 2936 nvlist_t *nvprops = NULL; |
2937 void (*cbfunc)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx); | |
789 | 2938 dmu_objset_type_t type = zc->zc_objset_type; |
2939 | |
2940 switch (type) { | |
2941 | |
2942 case DMU_OST_ZFS: | |
2943 cbfunc = zfs_create_cb; | |
2944 break; | |
2945 | |
2946 case DMU_OST_ZVOL: | |
2947 cbfunc = zvol_create_cb; | |
2948 break; | |
2949 | |
2950 default: | |
2199 | 2951 cbfunc = NULL; |
6423 | 2952 break; |
2199 | 2953 } |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
2954 if (strchr(zc->zc_name, '@') || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
2955 strchr(zc->zc_name, '%')) |
789 | 2956 return (EINVAL); |
2957 | |
2676 | 2958 if (zc->zc_nvlist_src != NULL && |
5094 | 2959 (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
|
2960 zc->zc_iflags, &nvprops)) != 0) |
2676 | 2961 return (error); |
2962 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
2963 zct.zct_zplprops = NULL; |
5331 | 2964 zct.zct_props = nvprops; |
2965 | |
2676 | 2966 if (zc->zc_value[0] != '\0') { |
789 | 2967 /* |
2968 * We're creating a clone of an existing snapshot. | |
2969 */ | |
2676 | 2970 zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; |
2971 if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0) { | |
4543 | 2972 nvlist_free(nvprops); |
789 | 2973 return (EINVAL); |
2676 | 2974 } |
789 | 2975 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2976 error = dmu_objset_hold(zc->zc_value, FTAG, &clone); |
2676 | 2977 if (error) { |
4543 | 2978 nvlist_free(nvprops); |
789 | 2979 return (error); |
2676 | 2980 } |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2981 |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
2982 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
|
2983 dmu_objset_rele(clone, FTAG); |
5331 | 2984 if (error) { |
2985 nvlist_free(nvprops); | |
2986 return (error); | |
2987 } | |
789 | 2988 } else { |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6423
diff
changeset
|
2989 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
|
2990 |
2676 | 2991 if (cbfunc == NULL) { |
4543 | 2992 nvlist_free(nvprops); |
2199 | 2993 return (EINVAL); |
2676 | 2994 } |
2995 | |
789 | 2996 if (type == DMU_OST_ZVOL) { |
2676 | 2997 uint64_t volsize, volblocksize; |
2998 | |
4543 | 2999 if (nvprops == NULL || |
3000 nvlist_lookup_uint64(nvprops, | |
2676 | 3001 zfs_prop_to_name(ZFS_PROP_VOLSIZE), |
3002 &volsize) != 0) { | |
4543 | 3003 nvlist_free(nvprops); |
2676 | 3004 return (EINVAL); |
3005 } | |
3006 | |
4543 | 3007 if ((error = nvlist_lookup_uint64(nvprops, |
2676 | 3008 zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), |
3009 &volblocksize)) != 0 && error != ENOENT) { | |
4543 | 3010 nvlist_free(nvprops); |
2676 | 3011 return (EINVAL); |
3012 } | |
1133
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
1003
diff
changeset
|
3013 |
2676 | 3014 if (error != 0) |
3015 volblocksize = zfs_prop_default_numeric( | |
3016 ZFS_PROP_VOLBLOCKSIZE); | |
3017 | |
3018 if ((error = zvol_check_volblocksize( | |
3019 volblocksize)) != 0 || | |
3020 (error = zvol_check_volsize(volsize, | |
3021 volblocksize)) != 0) { | |
4543 | 3022 nvlist_free(nvprops); |
789 | 3023 return (error); |
2676 | 3024 } |
4577 | 3025 } else if (type == DMU_OST_ZFS) { |
5331 | 3026 int error; |
3027 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3028 /* |
5331 | 3029 * We have to have normalization and |
3030 * case-folding flags correct when we do the | |
3031 * file system creation, so go figure them out | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3032 * now. |
5331 | 3033 */ |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3034 VERIFY(nvlist_alloc(&zct.zct_zplprops, |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3035 NV_UNIQUE_NAME, KM_SLEEP) == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3036 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
|
3037 zct.zct_zplprops, &is_insensitive); |
5331 | 3038 if (error != 0) { |
3039 nvlist_free(nvprops); | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5450
diff
changeset
|
3040 nvlist_free(zct.zct_zplprops); |
5331 | 3041 return (error); |
4577 | 3042 } |
2676 | 3043 } |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3044 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
|
3045 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
|
3046 nvlist_free(zct.zct_zplprops); |
789 | 3047 } |
2676 | 3048 |
3049 /* | |
3050 * It would be nice to do this atomically. | |
3051 */ | |
3052 if (error == 0) { | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3053 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
|
3054 nvprops, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3055 if (error != 0) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
3056 (void) dmu_objset_destroy(zc->zc_name, B_FALSE); |
2676 | 3057 } |
4543 | 3058 nvlist_free(nvprops); |
789 | 3059 return (error); |
3060 } | |
3061 | |
5367 | 3062 /* |
3063 * inputs: | |
3064 * zc_name name of filesystem | |
3065 * zc_value short name of snapshot | |
3066 * 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
|
3067 * zc_nvlist_src[_size] property list |
5367 | 3068 * |
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
|
3069 * 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
|
3070 * zc_value short snapname (i.e. part after the '@') |
5367 | 3071 */ |
789 | 3072 static int |
2199 | 3073 zfs_ioc_snapshot(zfs_cmd_t *zc) |
3074 { | |
7265 | 3075 nvlist_t *nvprops = NULL; |
3076 int error; | |
3077 boolean_t recursive = zc->zc_cookie; | |
3078 | |
2676 | 3079 if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) |
2199 | 3080 return (EINVAL); |
7265 | 3081 |
3082 if (zc->zc_nvlist_src != NULL && | |
3083 (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
|
3084 zc->zc_iflags, &nvprops)) != 0) |
7265 | 3085 return (error); |
3086 | |
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
|
3087 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
|
3088 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
|
3089 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
|
3090 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3091 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
|
3092 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
|
3093 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
|
3094 goto out; |
7265 | 3095 } |
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
|
3096 |
13055 | 3097 error = dmu_objset_snapshot(zc->zc_name, zc->zc_value, NULL, |
3098 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
|
3099 |
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
|
3100 out: |
7265 | 3101 nvlist_free(nvprops); |
3102 return (error); | |
2199 | 3103 } |
3104 | |
4007 | 3105 int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11185
diff
changeset
|
3106 zfs_unmount_snap(const char *name, void *arg) |
789 | 3107 { |
2417 | 3108 vfs_t *vfsp = NULL; |
2199 | 3109 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3110 if (arg) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3111 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
|
3112 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
|
3113 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
|
3114 strfree(fullname); |
2417 | 3115 } else if (strchr(name, '@')) { |
2199 | 3116 vfsp = zfs_get_vfs(name); |
3117 } | |
3118 | |
3119 if (vfsp) { | |
3120 /* | |
3121 * Always force the unmount for snapshots. | |
3122 */ | |
3123 int flag = MS_FORCE; | |
789 | 3124 int err; |
3125 | |
2199 | 3126 if ((err = vn_vfswlock(vfsp->vfs_vnodecovered)) != 0) { |
3127 VFS_RELE(vfsp); | |
3128 return (err); | |
3129 } | |
3130 VFS_RELE(vfsp); | |
3131 if ((err = dounmount(vfsp, flag, kcred)) != 0) | |
3132 return (err); | |
3133 } | |
3134 return (0); | |
3135 } | |
3136 | |
5367 | 3137 /* |
3138 * inputs: | |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3139 * zc_name name of filesystem, snaps must be under it |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3140 * zc_nvlist_src[_size] full names of snapshots to destroy |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
3141 * zc_defer_destroy mark for deferred destroy |
5367 | 3142 * |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3143 * outputs: |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3144 * zc_name on failure, name of failed snapshot |
5367 | 3145 */ |
2199 | 3146 static int |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3147 zfs_ioc_destroy_snaps_nvl(zfs_cmd_t *zc) |
2199 | 3148 { |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3149 int err, len; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3150 nvlist_t *nvl; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3151 nvpair_t *pair; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3152 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3153 if ((err = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3154 zc->zc_iflags, &nvl)) != 0) |
2199 | 3155 return (err); |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3156 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3157 len = strlen(zc->zc_name); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3158 for (pair = nvlist_next_nvpair(nvl, NULL); pair != NULL; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3159 pair = nvlist_next_nvpair(nvl, pair)) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3160 const char *name = nvpair_name(pair); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3161 /* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3162 * The snap name must be underneath the zc_name. This ensures |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3163 * that our permission checks were legitimate. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3164 */ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3165 if (strncmp(zc->zc_name, name, len) != 0 || |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3166 (name[len] != '@' && name[len] != '/')) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3167 nvlist_free(nvl); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3168 return (EINVAL); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3169 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3170 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3171 (void) zfs_unmount_snap(name, NULL); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3172 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3173 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3174 err = dmu_snapshots_destroy_nvl(nvl, zc->zc_defer_destroy, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3175 zc->zc_name); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3176 nvlist_free(nvl); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3177 return (err); |
2199 | 3178 } |
3179 | |
5367 | 3180 /* |
3181 * inputs: | |
3182 * zc_name name of dataset to destroy | |
3183 * zc_objset_type type of objset | |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
3184 * zc_defer_destroy mark for deferred destroy |
5367 | 3185 * |
3186 * outputs: none | |
3187 */ | |
2199 | 3188 static int |
3189 zfs_ioc_destroy(zfs_cmd_t *zc) | |
3190 { | |
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
|
3191 int err; |
2199 | 3192 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
|
3193 err = zfs_unmount_snap(zc->zc_name, NULL); |
2199 | 3194 if (err) |
3195 return (err); | |
789 | 3196 } |
3197 | |
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
|
3198 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
|
3199 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
|
3200 (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
|
3201 return (err); |
789 | 3202 } |
3203 | |
5367 | 3204 /* |
3205 * inputs: | |
5446 | 3206 * zc_name name of dataset to rollback (to most recent snapshot) |
5367 | 3207 * |
3208 * outputs: none | |
3209 */ | |
789 | 3210 static int |
3211 zfs_ioc_rollback(zfs_cmd_t *zc) | |
3212 { | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3213 dsl_dataset_t *ds, *clone; |
5446 | 3214 int error; |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3215 zfsvfs_t *zfsvfs; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3216 char *clone_name; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3217 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3218 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
|
3219 if (error) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3220 return (error); |
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 /* must not be a snapshot */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3223 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
|
3224 dsl_dataset_rele(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3225 return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3226 } |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3227 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3228 /* 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
|
3229 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
|
3230 dsl_dataset_rele(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3231 return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3232 } |
5446 | 3233 |
3234 /* | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3235 * Create clone of most recent snapshot. |
5446 | 3236 */ |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3237 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
|
3238 error = dmu_objset_clone(clone_name, ds->ds_prev, DS_FLAG_INCONSISTENT); |
5446 | 3239 if (error) |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3240 goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3241 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3242 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
|
3243 if (error) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3244 goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3245 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3246 /* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3247 * Do clone swap. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3248 */ |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
3249 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
|
3250 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
|
3251 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
|
3252 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
|
3253 |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3254 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
|
3255 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
|
3256 B_TRUE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3257 dsl_dataset_disown(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3258 ds = NULL; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3259 } else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3260 error = EBUSY; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3261 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3262 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
|
3263 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
|
3264 } |
5446 | 3265 VFS_RELE(zfsvfs->z_vfs); |
3266 } else { | |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3267 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
|
3268 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
|
3269 dsl_dataset_disown(ds, FTAG); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3270 ds = NULL; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3271 } else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3272 error = EBUSY; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3273 } |
5446 | 3274 } |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3275 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3276 /* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3277 * 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
|
3278 */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3279 (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
|
3280 |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3281 out: |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3282 strfree(clone_name); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3283 if (ds) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
3284 dsl_dataset_rele(ds, FTAG); |
5446 | 3285 return (error); |
789 | 3286 } |
3287 | |
5367 | 3288 /* |
3289 * inputs: | |
3290 * zc_name old name of dataset | |
3291 * zc_value new name of dataset | |
3292 * zc_cookie recursive flag (only valid for snapshots) | |
3293 * | |
3294 * outputs: none | |
3295 */ | |
789 | 3296 static int |
3297 zfs_ioc_rename(zfs_cmd_t *zc) | |
3298 { | |
4490 | 3299 boolean_t recursive = zc->zc_cookie & 1; |
4007 | 3300 |
2676 | 3301 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
|
3302 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
|
3303 strchr(zc->zc_value, '%')) |
789 | 3304 return (EINVAL); |
3305 | |
4007 | 3306 /* |
3307 * Unmount snapshot unless we're doing a recursive rename, | |
3308 * in which case the dataset code figures out which snapshots | |
3309 * to unmount. | |
3310 */ | |
3311 if (!recursive && strchr(zc->zc_name, '@') != NULL && | |
789 | 3312 zc->zc_objset_type == DMU_OST_ZFS) { |
2199 | 3313 int err = zfs_unmount_snap(zc->zc_name, NULL); |
3314 if (err) | |
3315 return (err); | |
789 | 3316 } |
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
|
3317 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
|
3318 (void) zvol_remove_minor(zc->zc_name); |
4007 | 3319 return (dmu_objset_rename(zc->zc_name, zc->zc_value, recursive)); |
789 | 3320 } |
3321 | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3322 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3323 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
|
3324 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3325 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3326 boolean_t issnap = (strchr(dsname, '@') != NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3327 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
|
3328 uint64_t intval; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3329 int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3330 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3331 if (prop == ZPROP_INVAL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3332 if (zfs_prop_user(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3333 if (err = zfs_secpolicy_write_perms(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3334 ZFS_DELEG_PERM_USERPROP, cr)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3335 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3336 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3337 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3338 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3339 if (!issnap && zfs_prop_userquota(propname)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3340 const char *perm = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3341 const char *uq_prefix = |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3342 zfs_userquota_prop_prefixes[ZFS_PROP_USERQUOTA]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3343 const char *gq_prefix = |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3344 zfs_userquota_prop_prefixes[ZFS_PROP_GROUPQUOTA]; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3345 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3346 if (strncmp(propname, uq_prefix, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3347 strlen(uq_prefix)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3348 perm = ZFS_DELEG_PERM_USERQUOTA; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3349 } else if (strncmp(propname, gq_prefix, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3350 strlen(gq_prefix)) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3351 perm = ZFS_DELEG_PERM_GROUPQUOTA; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3352 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3353 /* USERUSED and GROUPUSED are read-only */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3354 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3355 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3356 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3357 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
|
3358 return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3359 return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3360 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3361 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3362 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3363 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3364 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3365 if (issnap) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3366 return (EINVAL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3367 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3368 if (nvpair_type(pair) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3369 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3370 * 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
|
3371 * format. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3372 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3373 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3374 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3375 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3376 &pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3377 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3378 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3379 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3380 * 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
|
3381 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3382 switch (prop) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3383 case ZFS_PROP_COMPRESSION: |
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 * 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
|
3386 * 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
|
3387 * we'll catch them later. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3388 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3389 if (nvpair_type(pair) == DATA_TYPE_UINT64 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3390 nvpair_value_uint64(pair, &intval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3391 if (intval >= ZIO_COMPRESS_GZIP_1 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3392 intval <= ZIO_COMPRESS_GZIP_9 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3393 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3394 SPA_VERSION_GZIP_COMPRESSION)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3395 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3396 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3397 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3398 if (intval == ZIO_COMPRESS_ZLE && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3399 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3400 SPA_VERSION_ZLE_COMPRESSION)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3401 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3402 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3403 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3404 * If this is a bootable dataset then |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3405 * verify that the compression algorithm |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3406 * is supported for booting. We must return |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3407 * something other than ENOTSUP since it |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3408 * implies a downrev pool version. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3409 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3410 if (zfs_is_bootfs(dsname) && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3411 !BOOTFS_COMPRESS_VALID(intval)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3412 return (ERANGE); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3413 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3414 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3415 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3416 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3417 case ZFS_PROP_COPIES: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3418 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
|
3419 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3420 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3421 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3422 case ZFS_PROP_DEDUP: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3423 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
|
3424 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3425 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3426 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3427 case ZFS_PROP_SHARESMB: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3428 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
|
3429 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3430 break; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3431 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3432 case ZFS_PROP_ACLINHERIT: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3433 if (nvpair_type(pair) == DATA_TYPE_UINT64 && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3434 nvpair_value_uint64(pair, &intval) == 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3435 if (intval == ZFS_ACL_PASSTHROUGH_X && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3436 zfs_earlier_version(dsname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3437 SPA_VERSION_PASSTHROUGH_X)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3438 return (ENOTSUP); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3439 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3440 break; |
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 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3443 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
|
3444 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3445 |
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 * 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
|
3448 * 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
|
3449 * 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
|
3450 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3451 * 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
|
3452 * 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
|
3453 * 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
|
3454 * 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
|
3455 * returned errlist. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3456 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3457 * 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
|
3458 * pointed at by errlist is NULL. |
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 static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3461 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
|
3462 { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3463 zfs_cmd_t *zc; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3464 nvpair_t *pair, *next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3465 nvlist_t *errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3466 int err, rv = 0; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3467 |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3468 if (props == NULL) |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3469 return (0); |
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 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
|
3472 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3473 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
|
3474 (void) strcpy(zc->zc_name, dataset); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3475 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3476 while (pair != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3477 next_pair = nvlist_next_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3478 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3479 (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
|
3480 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
|
3481 (err = zfs_secpolicy_inherit(zc, CRED())) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3482 VERIFY(nvlist_remove_nvpair(props, pair) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3483 VERIFY(nvlist_add_int32(errors, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3484 zc->zc_value, err) == 0); |
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 pair = next_pair; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3487 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3488 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
|
3489 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3490 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
|
3491 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3492 errors = NULL; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3493 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3494 VERIFY(nvpair_value_int32(pair, &rv) == 0); |
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 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3497 if (errlist == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3498 nvlist_free(errors); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3499 else |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3500 *errlist = errors; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3501 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3502 return (rv); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3503 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3504 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3505 static boolean_t |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3506 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
|
3507 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3508 if (nvpair_type(p1) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3509 /* dsl_prop_get_all_impl() format */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3510 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3511 VERIFY(nvpair_value_nvlist(p1, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3512 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3513 &p1) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3514 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3515 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3516 if (nvpair_type(p2) == DATA_TYPE_NVLIST) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3517 nvlist_t *attrs; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3518 VERIFY(nvpair_value_nvlist(p2, &attrs) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3519 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3520 &p2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3521 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3522 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3523 if (nvpair_type(p1) != nvpair_type(p2)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3524 return (B_FALSE); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3525 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3526 if (nvpair_type(p1) == DATA_TYPE_STRING) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3527 char *valstr1, *valstr2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3528 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3529 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
|
3530 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
|
3531 return (strcmp(valstr1, valstr2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3532 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3533 uint64_t intval1, intval2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3534 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3535 VERIFY(nvpair_value_uint64(p1, &intval1) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3536 VERIFY(nvpair_value_uint64(p2, &intval2) == 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3537 return (intval1 == intval2); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3538 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3539 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3540 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3541 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3542 * 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
|
3543 * 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
|
3544 * 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
|
3545 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3546 static void |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3547 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
|
3548 { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3549 nvpair_t *pair, *next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3550 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3551 if (origprops == NULL) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3552 return; /* all props need to be received */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3553 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3554 pair = nvlist_next_nvpair(props, NULL); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3555 while (pair != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3556 const char *propname = nvpair_name(pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3557 nvpair_t *match; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3558 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3559 next_pair = nvlist_next_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3560 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3561 if ((nvlist_lookup_nvpair(origprops, propname, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3562 &match) != 0) || !propval_equals(pair, match)) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3563 goto next; /* need to set received value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3564 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3565 /* don't clear the existing received value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3566 (void) nvlist_remove_nvpair(origprops, match); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3567 /* don't bother receiving the property */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3568 (void) nvlist_remove_nvpair(props, pair); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3569 next: |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3570 pair = next_pair; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3571 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3572 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3573 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3574 #ifdef DEBUG |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3575 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
|
3576 #endif |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3577 |
5367 | 3578 /* |
3579 * inputs: | |
3580 * zc_name name of containing filesystem | |
3581 * zc_nvlist_src{_size} nvlist of properties to apply | |
3582 * zc_value name of snapshot to create | |
3583 * zc_string name of clone origin (if DRR_FLAG_CLONE) | |
3584 * zc_cookie file descriptor to recv from | |
3585 * zc_begin_record the BEGIN record of the stream (not byteswapped) | |
3586 * zc_guid force flag | |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
3587 * 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
|
3588 * zc_action_handle handle for this guid/ds mapping (or zero on first call) |
5367 | 3589 * |
3590 * outputs: | |
3591 * zc_cookie number of bytes read | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3592 * 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
|
3593 * 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
|
3594 * zc_action_handle handle for this guid/ds mapping |
5367 | 3595 */ |
789 | 3596 static int |
5367 | 3597 zfs_ioc_recv(zfs_cmd_t *zc) |
789 | 3598 { |
3599 file_t *fp; | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3600 objset_t *os; |
5367 | 3601 dmu_recv_cookie_t drc; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3602 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
|
3603 int fd; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3604 int error = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3605 int props_error = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3606 nvlist_t *errors; |
5367 | 3607 offset_t off; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3608 nvlist_t *props = NULL; /* sent properties */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3609 nvlist_t *origprops = NULL; /* existing properties */ |
5367 | 3610 objset_t *origin = NULL; |
3611 char *tosnap; | |
3612 char tofs[ZFS_MAXNAMELEN]; | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3613 boolean_t first_recvd_props = B_FALSE; |
789 | 3614 |
3265
967e0fca6143
6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents:
3087
diff
changeset
|
3615 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
|
3616 strchr(zc->zc_value, '@') == NULL || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3617 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
|
3618 return (EINVAL); |
967e0fca6143
6463140 zfs recv with a snapshot name that has 2 @@ in a row succeeds
ahrens
parents:
3087
diff
changeset
|
3619 |
5367 | 3620 (void) strcpy(tofs, zc->zc_value); |
3621 tosnap = strchr(tofs, '@'); | |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3622 *tosnap++ = '\0'; |
5367 | 3623 |
3624 if (zc->zc_nvlist_src != NULL && | |
3625 (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
|
3626 zc->zc_iflags, &props)) != 0) |
5367 | 3627 return (error); |
3628 | |
789 | 3629 fd = zc->zc_cookie; |
3630 fp = getf(fd); | |
5367 | 3631 if (fp == NULL) { |
3632 nvlist_free(props); | |
789 | 3633 return (EBADF); |
5367 | 3634 } |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3635 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3636 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
|
3637 |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3638 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
|
3639 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
|
3640 !dsl_prop_get_hasrecvd(os)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3641 first_recvd_props = B_TRUE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3642 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3643 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3644 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3645 * 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
|
3646 * 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
|
3647 * away the existing ones. |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3648 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3649 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
|
3650 nvlist_t *errlist = NULL; |
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 * 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
|
3653 * change (and avoid the unnecessary security checks). |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3654 * |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3655 * 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
|
3656 * 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
|
3657 * regardless. |
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 (!first_recvd_props) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3660 props_reduce(props, origprops); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3661 if (zfs_check_clearable(tofs, origprops, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3662 &errlist) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3663 (void) nvlist_merge(errors, errlist, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3664 nvlist_free(errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3665 } |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3666 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3667 dmu_objset_rele(os, FTAG); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3668 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3669 |
5367 | 3670 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
|
3671 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
|
3672 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3673 goto out; |
5367 | 3674 } |
3675 | |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10972
diff
changeset
|
3676 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
|
3677 &zc->zc_begin_record, force, origin, &drc); |
5367 | 3678 if (origin) |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3679 dmu_objset_rele(origin, FTAG); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3680 if (error) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3681 goto out; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3682 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3683 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3684 * 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
|
3685 * 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
|
3686 * dmu_recv_begin() succeeds. |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
3687 */ |
5367 | 3688 if (props) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3689 nvlist_t *errlist; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3690 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3691 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
|
3692 if (drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3693 if (spa_version(os->os_spa) >= |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3694 SPA_VERSION_RECVD_PROPS) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3695 first_recvd_props = B_TRUE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3696 } else if (origprops != NULL) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3697 if (clear_received_props(os, tofs, origprops, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3698 first_recvd_props ? NULL : props) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3699 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3700 } else { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3701 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3702 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3703 dsl_prop_set_hasrecvd(os); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3704 } else if (!drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3705 zc->zc_obj |= ZPROP_ERR_NOCLEAR; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3706 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3707 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3708 (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
|
3709 props, &errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3710 (void) nvlist_merge(errors, errlist, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3711 nvlist_free(errlist); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3712 } |
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 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
|
3715 /* |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3716 * 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
|
3717 * 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
|
3718 */ |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3719 props_error = EINVAL; |
5367 | 3720 } |
3721 | |
3722 off = fp->f_offset; | |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
3723 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
|
3724 &zc->zc_action_handle); |
5367 | 3725 |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3726 if (error == 0) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3727 zfsvfs_t *zfsvfs = NULL; |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3728 |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3729 if (getzfsvfs(tofs, &zfsvfs) == 0) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3730 /* online recv */ |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3731 int end_err; |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3732 |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3733 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
|
3734 /* |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3735 * 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
|
3736 * 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
|
3737 */ |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3738 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
|
3739 if (error == 0) |
453b88fd62f1
6891437 DEADCODE in zfs_ioc_recv after dmu_recv_end.
George Wilson <George.Wilson@Sun.COM>
parents:
11807
diff
changeset
|
3740 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
|
3741 error = error ? error : end_err; |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3742 VFS_RELE(zfsvfs->z_vfs); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9643
diff
changeset
|
3743 } else { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3744 error = dmu_recv_end(&drc); |
5367 | 3745 } |
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
|
3746 } |
5367 | 3747 |
3748 zc->zc_cookie = off - fp->f_offset; | |
3749 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) | |
3750 fp->f_offset = off; | |
2885 | 3751 |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3752 #ifdef DEBUG |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3753 if (zfs_ioc_recv_inject_err) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3754 zfs_ioc_recv_inject_err = B_FALSE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3755 error = 1; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3756 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3757 #endif |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3758 /* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3759 * On error, restore the original props. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3760 */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3761 if (error && props) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3762 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
|
3763 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
|
3764 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3765 * We failed to clear the received properties. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3766 * 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
|
3767 * 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
|
3768 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3769 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3770 } else if (first_recvd_props) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3771 dsl_prop_unset_hasrecvd(os); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3772 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3773 dmu_objset_rele(os, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3774 } else if (!drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3775 /* We failed to clear the received properties. */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3776 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3777 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3778 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3779 if (origprops == NULL && !drc.drc_newfs) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3780 /* We failed to stash the original properties. */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3781 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3782 } |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3783 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3784 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3785 * 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
|
3786 * 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
|
3787 * 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
|
3788 * first new-style receive. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3789 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3790 if (origprops != NULL && |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3791 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
|
3792 ZPROP_SRC_LOCAL : ZPROP_SRC_RECEIVED), |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3793 origprops, NULL) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3794 /* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3795 * 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
|
3796 * restore them. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3797 */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3798 zc->zc_obj |= ZPROP_ERR_NORESTORE; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3799 } |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3800 } |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3801 out: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3802 nvlist_free(props); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3803 nvlist_free(origprops); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3804 nvlist_free(errors); |
789 | 3805 releasef(fd); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3806 |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3807 if (error == 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3808 error = props_error; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
3809 |
789 | 3810 return (error); |
3811 } | |
3812 | |
5367 | 3813 /* |
3814 * inputs: | |
3815 * zc_name name of snapshot to send | |
3816 * 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
|
3817 * 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
|
3818 * 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
|
3819 * zc_fromobj objsetid of incremental fromsnap (may be zero) |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3820 * zc_guid if set, estimate size of stream only. zc_cookie is ignored. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3821 * output size in zc_objset_type. |
5367 | 3822 * |
3823 * outputs: none | |
3824 */ | |
789 | 3825 static int |
5367 | 3826 zfs_ioc_send(zfs_cmd_t *zc) |
789 | 3827 { |
3828 objset_t *fromsnap = NULL; | |
3829 objset_t *tosnap; | |
3830 int error; | |
5367 | 3831 offset_t off; |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3832 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3833 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
|
3834 spa_t *spa; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3835 dsl_pool_t *dp; |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3836 boolean_t estimate = (zc->zc_guid != 0); |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3837 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3838 error = spa_open(zc->zc_name, &spa, FTAG); |
789 | 3839 if (error) |
3840 return (error); | |
3841 | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3842 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
|
3843 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
|
3844 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
|
3845 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
|
3846 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3847 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3848 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3849 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3850 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3851 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
|
3852 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3853 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
|
3854 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3855 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3856 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3857 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3858 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
|
3859 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
|
3860 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
|
3861 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
|
3862 spa_close(spa, FTAG); |
789 | 3863 if (error) { |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3864 dsl_dataset_rele(ds, FTAG); |
789 | 3865 return (error); |
3866 } | |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3867 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
|
3868 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3869 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
|
3870 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
|
3871 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3872 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3873 } else { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3874 spa_close(spa, FTAG); |
789 | 3875 } |
3876 | |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3877 if (estimate) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3878 error = dmu_send_estimate(tosnap, fromsnap, zc->zc_obj, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3879 &zc->zc_objset_type); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3880 } else { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3881 file_t *fp = getf(zc->zc_cookie); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3882 if (fp == NULL) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3883 dsl_dataset_rele(ds, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3884 if (dsfrom) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3885 dsl_dataset_rele(dsfrom, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3886 return (EBADF); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3887 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3888 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3889 off = fp->f_offset; |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3890 error = dmu_send(tosnap, fromsnap, zc->zc_obj, |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3891 zc->zc_cookie, fp->f_vnode, &off); |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3892 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3893 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3894 fp->f_offset = off; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
3895 releasef(zc->zc_cookie); |
789 | 3896 } |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3897 if (dsfrom) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
3898 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
|
3899 dsl_dataset_rele(ds, FTAG); |
789 | 3900 return (error); |
3901 } | |
3902 | |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3903 /* |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3904 * inputs: |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3905 * zc_name name of snapshot on which to report progress |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3906 * zc_cookie file descriptor of send stream |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3907 * |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3908 * outputs: |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3909 * zc_cookie number of bytes written in send stream thus far |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3910 */ |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3911 static int |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3912 zfs_ioc_send_progress(zfs_cmd_t *zc) |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3913 { |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3914 dsl_dataset_t *ds; |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3915 dmu_sendarg_t *dsp = NULL; |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3916 int error; |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3917 |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3918 if ((error = dsl_dataset_hold(zc->zc_name, FTAG, &ds)) != 0) |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3919 return (error); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3920 |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3921 mutex_enter(&ds->ds_sendstream_lock); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3922 |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3923 /* |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3924 * Iterate over all the send streams currently active on this dataset. |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3925 * If there's one which matches the specified file descriptor _and_ the |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3926 * stream was started by the current process, return the progress of |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3927 * that stream. |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3928 */ |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3929 for (dsp = list_head(&ds->ds_sendstreams); dsp != NULL; |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3930 dsp = list_next(&ds->ds_sendstreams, dsp)) { |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3931 if (dsp->dsa_outfd == zc->zc_cookie && |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3932 dsp->dsa_proc == curproc) |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3933 break; |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3934 } |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3935 |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3936 if (dsp != NULL) |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3937 zc->zc_cookie = *(dsp->dsa_off); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3938 else |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3939 error = ENOENT; |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3940 |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3941 mutex_exit(&ds->ds_sendstream_lock); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3942 dsl_dataset_rele(ds, FTAG); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3943 return (error); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3944 } |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
3945 |
1544 | 3946 static int |
3947 zfs_ioc_inject_fault(zfs_cmd_t *zc) | |
3948 { | |
3949 int id, error; | |
3950 | |
3951 error = zio_inject_fault(zc->zc_name, (int)zc->zc_guid, &id, | |
3952 &zc->zc_inject_record); | |
3953 | |
3954 if (error == 0) | |
3955 zc->zc_guid = (uint64_t)id; | |
3956 | |
3957 return (error); | |
3958 } | |
3959 | |
3960 static int | |
3961 zfs_ioc_clear_fault(zfs_cmd_t *zc) | |
3962 { | |
3963 return (zio_clear_fault((int)zc->zc_guid)); | |
3964 } | |
3965 | |
3966 static int | |
3967 zfs_ioc_inject_list_next(zfs_cmd_t *zc) | |
3968 { | |
3969 int id = (int)zc->zc_guid; | |
3970 int error; | |
3971 | |
3972 error = zio_inject_list_next(&id, zc->zc_name, sizeof (zc->zc_name), | |
3973 &zc->zc_inject_record); | |
3974 | |
3975 zc->zc_guid = id; | |
3976 | |
3977 return (error); | |
3978 } | |
3979 | |
3980 static int | |
3981 zfs_ioc_error_log(zfs_cmd_t *zc) | |
3982 { | |
3983 spa_t *spa; | |
3984 int error; | |
2676 | 3985 size_t count = (size_t)zc->zc_nvlist_dst_size; |
1544 | 3986 |
3987 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) | |
3988 return (error); | |
3989 | |
2676 | 3990 error = spa_get_errlog(spa, (void *)(uintptr_t)zc->zc_nvlist_dst, |
1544 | 3991 &count); |
3992 if (error == 0) | |
2676 | 3993 zc->zc_nvlist_dst_size = count; |
1544 | 3994 else |
2676 | 3995 zc->zc_nvlist_dst_size = spa_get_errlog_size(spa); |
1544 | 3996 |
3997 spa_close(spa, FTAG); | |
3998 | |
3999 return (error); | |
4000 } | |
4001 | |
4002 static int | |
4003 zfs_ioc_clear(zfs_cmd_t *zc) | |
4004 { | |
4005 spa_t *spa; | |
4006 vdev_t *vd; | |
4007 int error; | |
4008 | |
7294 | 4009 /* |
4010 * On zpool clear we also fix up missing slogs | |
4011 */ | |
4012 mutex_enter(&spa_namespace_lock); | |
4013 spa = spa_lookup(zc->zc_name); | |
4014 if (spa == NULL) { | |
4015 mutex_exit(&spa_namespace_lock); | |
4016 return (EIO); | |
4017 } | |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
4018 if (spa_get_log_state(spa) == SPA_LOG_MISSING) { |
7294 | 4019 /* 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
|
4020 spa_set_log_state(spa, SPA_LOG_CLEAR); |
7294 | 4021 } |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4022 spa->spa_last_open_failed = 0; |
7294 | 4023 mutex_exit(&spa_namespace_lock); |
4024 | |
11727
497d03ab2824
6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11546
diff
changeset
|
4025 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
|
4026 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
|
4027 } else { |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4028 nvlist_t *policy; |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4029 nvlist_t *config = NULL; |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4030 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4031 if (zc->zc_nvlist_src == NULL) |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4032 return (EINVAL); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4033 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4034 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
|
4035 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
|
4036 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
|
4037 policy, &config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4038 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
|
4039 int err; |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
4040 |
b521d551715f
6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents:
12798
diff
changeset
|
4041 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
|
4042 error = err; |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4043 nvlist_free(config); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4044 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4045 nvlist_free(policy); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4046 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4047 } |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4048 |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10850
diff
changeset
|
4049 if (error) |
1544 | 4050 return (error); |
4051 | |
10685
931790026ac6
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents:
10672
diff
changeset
|
4052 spa_vdev_state_enter(spa, SCL_NONE); |
1544 | 4053 |
2676 | 4054 if (zc->zc_guid == 0) { |
1544 | 4055 vd = NULL; |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6492
diff
changeset
|
4056 } else { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6492
diff
changeset
|
4057 vd = spa_lookup_by_guid(spa, zc->zc_guid, B_TRUE); |
5450 | 4058 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
|
4059 (void) spa_vdev_state_exit(spa, NULL, ENODEV); |
5450 | 4060 spa_close(spa, FTAG); |
4061 return (ENODEV); | |
4062 } | |
1544 | 4063 } |
4064 | |
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
|
4065 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
|
4066 |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
4067 (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
|
4068 |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
4069 /* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7656
diff
changeset
|
4070 * 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
|
4071 */ |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4072 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
|
4073 error = EIO; |
1544 | 4074 |
4075 spa_close(spa, FTAG); | |
4076 | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4077 return (error); |
1544 | 4078 } |
4079 | |
13570
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4080 static int |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4081 zfs_ioc_pool_reopen(zfs_cmd_t *zc) |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4082 { |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4083 spa_t *spa; |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4084 int error; |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4085 |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4086 error = spa_open(zc->zc_name, &spa, FTAG); |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4087 if (error) |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4088 return (error); |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4089 |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4090 spa_vdev_state_enter(spa, SCL_NONE); |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4091 vdev_reopen(spa->spa_root_vdev); |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4092 (void) spa_vdev_state_exit(spa, NULL, 0); |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4093 spa_close(spa, FTAG); |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4094 return (0); |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4095 } |
5367 | 4096 /* |
4097 * inputs: | |
4098 * zc_name name of filesystem | |
4099 * zc_value name of origin snapshot | |
4100 * | |
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
|
4101 * 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
|
4102 * zc_string name of conflicting snapshot, if there is one |
5367 | 4103 */ |
1544 | 4104 static int |
2082 | 4105 zfs_ioc_promote(zfs_cmd_t *zc) |
4106 { | |
2417 | 4107 char *cp; |
4108 | |
4109 /* | |
4110 * We don't need to unmount *all* the origin fs's snapshots, but | |
4111 * it's easier. | |
4112 */ | |
2676 | 4113 cp = strchr(zc->zc_value, '@'); |
2417 | 4114 if (cp) |
4115 *cp = '\0'; | |
2676 | 4116 (void) dmu_objset_find(zc->zc_value, |
2417 | 4117 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
|
4118 return (dsl_dataset_promote(zc->zc_name, zc->zc_string)); |
2082 | 4119 } |
4120 | |
4543 | 4121 /* |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4122 * 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
|
4123 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4124 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4125 * 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
|
4126 * 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
|
4127 * 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
|
4128 * 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
|
4129 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4130 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4131 * zc_cookie property value |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4132 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4133 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4134 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
|
4135 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4136 zfsvfs_t *zfsvfs; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4137 int error; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4138 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4139 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
|
4140 return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4141 |
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
|
4142 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
|
4143 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4144 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4145 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4146 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
|
4147 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
|
4148 zfsvfs_rele(zfsvfs, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4149 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4150 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4151 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4152 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4153 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4154 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4155 * 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
|
4156 * zc_cookie zap cursor |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4157 * 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
|
4158 * 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
|
4159 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4160 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4161 * 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
|
4162 * zc_cookie zap cursor |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4163 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4164 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4165 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
|
4166 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4167 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
|
4168 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
|
4169 |
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
|
4170 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
|
4171 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
|
4172 |
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
|
4173 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
|
4174 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4175 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4176 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4177 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
|
4178 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4179 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
|
4180 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
|
4181 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4182 if (error == 0) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4183 error = xcopyout(buf, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4184 (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
|
4185 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
|
4186 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4187 kmem_free(buf, bufsize); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4188 zfsvfs_rele(zfsvfs, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4189 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4190 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4191 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4192 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4193 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4194 * inputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4195 * 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
|
4196 * |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4197 * outputs: |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4198 * none |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4199 */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4200 static int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4201 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
|
4202 { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4203 objset_t *os; |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4204 int error = 0; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4205 zfsvfs_t *zfsvfs; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4206 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4207 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
|
4208 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
|
4209 /* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4210 * 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
|
4211 * 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
|
4212 * 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
|
4213 */ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4214 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
|
4215 if (error == 0) |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4216 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
|
4217 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4218 if (error == 0) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4219 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
|
4220 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
|
4221 } else { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4222 /* 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
|
4223 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
|
4224 if (error) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4225 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4226 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4227 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
|
4228 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
|
4229 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4230 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4231 return (error); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4232 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4233 |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4234 /* |
4543 | 4235 * We don't want to have a hard dependency |
4236 * against some special symbols in sharefs | |
5331 | 4237 * nfs, and smbsrv. Determine them if needed when |
4543 | 4238 * the first file system is shared. |
5331 | 4239 * Neither sharefs, nfs or smbsrv are unloadable modules. |
4543 | 4240 */ |
5331 | 4241 int (*znfsexport_fs)(void *arg); |
4543 | 4242 int (*zshare_fs)(enum sharefs_sys_op, share_t *, uint32_t); |
5331 | 4243 int (*zsmbexport_fs)(void *arg, boolean_t add_share); |
4244 | |
4245 int zfs_nfsshare_inited; | |
4246 int zfs_smbshare_inited; | |
4247 | |
4543 | 4248 ddi_modhandle_t nfs_mod; |
4249 ddi_modhandle_t sharefs_mod; | |
5331 | 4250 ddi_modhandle_t smbsrv_mod; |
4543 | 4251 kmutex_t zfs_share_lock; |
4252 | |
4253 static int | |
5331 | 4254 zfs_init_sharefs() |
4255 { | |
4256 int error; | |
4257 | |
4258 ASSERT(MUTEX_HELD(&zfs_share_lock)); | |
4259 /* Both NFS and SMB shares also require sharetab support. */ | |
4260 if (sharefs_mod == NULL && ((sharefs_mod = | |
4261 ddi_modopen("fs/sharefs", | |
4262 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
4263 return (ENOSYS); | |
4264 } | |
4265 if (zshare_fs == NULL && ((zshare_fs = | |
4266 (int (*)(enum sharefs_sys_op, share_t *, uint32_t)) | |
4267 ddi_modsym(sharefs_mod, "sharefs_impl", &error)) == NULL)) { | |
4268 return (ENOSYS); | |
4269 } | |
4270 return (0); | |
4271 } | |
4272 | |
4273 static int | |
4543 | 4274 zfs_ioc_share(zfs_cmd_t *zc) |
4275 { | |
4276 int error; | |
4277 int opcode; | |
4278 | |
5331 | 4279 switch (zc->zc_share.z_sharetype) { |
4280 case ZFS_SHARE_NFS: | |
4281 case ZFS_UNSHARE_NFS: | |
4282 if (zfs_nfsshare_inited == 0) { | |
4283 mutex_enter(&zfs_share_lock); | |
4284 if (nfs_mod == NULL && ((nfs_mod = ddi_modopen("fs/nfs", | |
4285 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
4286 mutex_exit(&zfs_share_lock); | |
4287 return (ENOSYS); | |
4288 } | |
4289 if (znfsexport_fs == NULL && | |
4290 ((znfsexport_fs = (int (*)(void *)) | |
4291 ddi_modsym(nfs_mod, | |
4292 "nfs_export", &error)) == NULL)) { | |
4293 mutex_exit(&zfs_share_lock); | |
4294 return (ENOSYS); | |
4295 } | |
4296 error = zfs_init_sharefs(); | |
4297 if (error) { | |
4298 mutex_exit(&zfs_share_lock); | |
4299 return (ENOSYS); | |
4300 } | |
4301 zfs_nfsshare_inited = 1; | |
4543 | 4302 mutex_exit(&zfs_share_lock); |
4303 } | |
5331 | 4304 break; |
4305 case ZFS_SHARE_SMB: | |
4306 case ZFS_UNSHARE_SMB: | |
4307 if (zfs_smbshare_inited == 0) { | |
4308 mutex_enter(&zfs_share_lock); | |
4309 if (smbsrv_mod == NULL && ((smbsrv_mod = | |
4310 ddi_modopen("drv/smbsrv", | |
4311 KRTLD_MODE_FIRST, &error)) == NULL)) { | |
4312 mutex_exit(&zfs_share_lock); | |
4313 return (ENOSYS); | |
4314 } | |
4315 if (zsmbexport_fs == NULL && ((zsmbexport_fs = | |
4316 (int (*)(void *, boolean_t))ddi_modsym(smbsrv_mod, | |
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6083
diff
changeset
|
4317 "smb_server_share", &error)) == NULL)) { |
5331 | 4318 mutex_exit(&zfs_share_lock); |
4319 return (ENOSYS); | |
4320 } | |
4321 error = zfs_init_sharefs(); | |
4322 if (error) { | |
4323 mutex_exit(&zfs_share_lock); | |
4324 return (ENOSYS); | |
4325 } | |
4326 zfs_smbshare_inited = 1; | |
4543 | 4327 mutex_exit(&zfs_share_lock); |
4328 } | |
5331 | 4329 break; |
4330 default: | |
4331 return (EINVAL); | |
4543 | 4332 } |
4333 | |
5331 | 4334 switch (zc->zc_share.z_sharetype) { |
4335 case ZFS_SHARE_NFS: | |
4336 case ZFS_UNSHARE_NFS: | |
4337 if (error = | |
4338 znfsexport_fs((void *) | |
4339 (uintptr_t)zc->zc_share.z_exportdata)) | |
4340 return (error); | |
4341 break; | |
4342 case ZFS_SHARE_SMB: | |
4343 case ZFS_UNSHARE_SMB: | |
4344 if (error = zsmbexport_fs((void *) | |
4345 (uintptr_t)zc->zc_share.z_exportdata, | |
4346 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
|
4347 B_TRUE: B_FALSE)) { |
5331 | 4348 return (error); |
4349 } | |
4350 break; | |
4351 } | |
4352 | |
4353 opcode = (zc->zc_share.z_sharetype == ZFS_SHARE_NFS || | |
4354 zc->zc_share.z_sharetype == ZFS_SHARE_SMB) ? | |
4543 | 4355 SHAREFS_ADD : SHAREFS_REMOVE; |
4356 | |
5331 | 4357 /* |
4358 * Add or remove share from sharetab | |
4359 */ | |
4543 | 4360 error = zshare_fs(opcode, |
4361 (void *)(uintptr_t)zc->zc_share.z_sharedata, | |
4362 zc->zc_share.z_sharemax); | |
4363 | |
4364 return (error); | |
4365 | |
4366 } | |
4367 | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4368 ace_t full_access[] = { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4369 {(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
|
4370 }; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4371 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4372 /* |
13055 | 4373 * inputs: |
4374 * zc_name name of containing filesystem | |
4375 * zc_obj object # beyond which we want next in-use object # | |
4376 * | |
4377 * outputs: | |
4378 * zc_obj next in-use object # | |
4379 */ | |
4380 static int | |
4381 zfs_ioc_next_obj(zfs_cmd_t *zc) | |
4382 { | |
4383 objset_t *os = NULL; | |
4384 int error; | |
4385 | |
4386 error = dmu_objset_hold(zc->zc_name, FTAG, &os); | |
4387 if (error) | |
4388 return (error); | |
4389 | |
4390 error = dmu_object_next(os, &zc->zc_obj, B_FALSE, | |
4391 os->os_dsl_dataset->ds_phys->ds_prev_snap_txg); | |
4392 | |
4393 dmu_objset_rele(os, FTAG); | |
4394 return (error); | |
4395 } | |
4396 | |
4397 /* | |
4398 * inputs: | |
4399 * zc_name name of filesystem | |
4400 * zc_value prefix name for snapshot | |
4401 * zc_cleanup_fd cleanup-on-exit file descriptor for calling process | |
4402 * | |
4403 * outputs: | |
4404 */ | |
4405 static int | |
4406 zfs_ioc_tmp_snapshot(zfs_cmd_t *zc) | |
4407 { | |
4408 char *snap_name; | |
4409 int error; | |
4410 | |
4411 snap_name = kmem_asprintf("%s-%016llx", zc->zc_value, | |
4412 (u_longlong_t)ddi_get_lbolt64()); | |
4413 | |
4414 if (strlen(snap_name) >= MAXNAMELEN) { | |
4415 strfree(snap_name); | |
4416 return (E2BIG); | |
4417 } | |
4418 | |
4419 error = dmu_objset_snapshot(zc->zc_name, snap_name, snap_name, | |
4420 NULL, B_FALSE, B_TRUE, zc->zc_cleanup_fd); | |
4421 if (error != 0) { | |
4422 strfree(snap_name); | |
4423 return (error); | |
4424 } | |
4425 | |
4426 (void) strcpy(zc->zc_value, snap_name); | |
4427 strfree(snap_name); | |
4428 return (0); | |
4429 } | |
4430 | |
4431 /* | |
4432 * inputs: | |
4433 * zc_name name of "to" snapshot | |
4434 * zc_value name of "from" snapshot | |
4435 * zc_cookie file descriptor to write diff data on | |
4436 * | |
4437 * outputs: | |
4438 * dmu_diff_record_t's to the file descriptor | |
4439 */ | |
4440 static int | |
4441 zfs_ioc_diff(zfs_cmd_t *zc) | |
4442 { | |
4443 objset_t *fromsnap; | |
4444 objset_t *tosnap; | |
4445 file_t *fp; | |
4446 offset_t off; | |
4447 int error; | |
4448 | |
4449 error = dmu_objset_hold(zc->zc_name, FTAG, &tosnap); | |
4450 if (error) | |
4451 return (error); | |
4452 | |
4453 error = dmu_objset_hold(zc->zc_value, FTAG, &fromsnap); | |
4454 if (error) { | |
4455 dmu_objset_rele(tosnap, FTAG); | |
4456 return (error); | |
4457 } | |
4458 | |
4459 fp = getf(zc->zc_cookie); | |
4460 if (fp == NULL) { | |
4461 dmu_objset_rele(fromsnap, FTAG); | |
4462 dmu_objset_rele(tosnap, FTAG); | |
4463 return (EBADF); | |
4464 } | |
4465 | |
4466 off = fp->f_offset; | |
4467 | |
4468 error = dmu_diff(tosnap, fromsnap, fp->f_vnode, &off); | |
4469 | |
4470 if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0) | |
4471 fp->f_offset = off; | |
4472 releasef(zc->zc_cookie); | |
4473 | |
4474 dmu_objset_rele(fromsnap, FTAG); | |
4475 dmu_objset_rele(tosnap, FTAG); | |
4476 return (error); | |
4477 } | |
4478 | |
4479 /* | |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4480 * 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
|
4481 */ |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4482 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4483 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
|
4484 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4485 zap_cursor_t zc; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4486 zap_attribute_t zap; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4487 zfsvfs_t *zfsvfs = dzp->z_zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4488 int error; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4489 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4490 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
|
4491 (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
|
4492 zap_cursor_advance(&zc)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4493 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
|
4494 NULL, 0)) != 0) |
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 zap_cursor_fini(&zc); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4498 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4499 } |
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 static int |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4502 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
|
4503 { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4504 vnode_t *vp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4505 znode_t *dzp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4506 vnode_t *resourcevp = NULL; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4507 znode_t *sharedir; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4508 zfsvfs_t *zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4509 nvlist_t *nvlist; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4510 char *src, *target; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4511 vattr_t vattr; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4512 vsecattr_t vsec; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4513 int error = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4514 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4515 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
|
4516 NO_FOLLOW, NULL, &vp)) != 0) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4517 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4518 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4519 /* 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
|
4520 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4521 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
|
4522 (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
|
4523 zc->zc_name) != 0)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4524 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4525 return (EINVAL); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4526 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4527 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4528 dzp = VTOZ(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4529 zfsvfs = dzp->z_zfsvfs; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4530 ZFS_ENTER(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4531 |
9030
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4532 /* |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4533 * 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
|
4534 */ |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4535 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
|
4536 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
|
4537 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
|
4538 |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4539 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
|
4540 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
|
4541 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
|
4542 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
|
4543 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
|
4544 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
|
4545 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
|
4546 } else { |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4547 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
|
4548 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
|
4549 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4550 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
|
4551 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
|
4552 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
|
4553 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
|
4554 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
|
4555 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4556 } |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4557 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
|
4558 |
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
4559 ASSERT(zfsvfs->z_shares_dir); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4560 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
|
4561 VN_RELE(vp); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4562 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4563 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4564 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4565 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4566 switch (zc->zc_cookie) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4567 case ZFS_SMB_ACL_ADD: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4568 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
|
4569 vattr.va_type = VREG; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4570 vattr.va_mode = S_IFREG|0777; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4571 vattr.va_uid = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4572 vattr.va_gid = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4573 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4574 vsec.vsa_mask = VSA_ACE; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4575 vsec.vsa_aclentp = &full_access; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4576 vsec.vsa_aclentsz = sizeof (full_access); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4577 vsec.vsa_aclcnt = 1; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4578 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4579 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
|
4580 &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
|
4581 if (resourcevp) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4582 VN_RELE(resourcevp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4583 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4584 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4585 case ZFS_SMB_ACL_REMOVE: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4586 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
|
4587 NULL, 0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4588 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4589 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4590 case ZFS_SMB_ACL_RENAME: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4591 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
|
4592 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
|
4593 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4594 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4595 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4596 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4597 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
|
4598 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
|
4599 &target)) { |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4600 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
|
4601 VN_RELE(ZTOV(sharedir)); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4602 ZFS_EXIT(zfsvfs); |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4603 nvlist_free(nvlist); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4604 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4605 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4606 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
|
4607 kcred, NULL, 0); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4608 nvlist_free(nvlist); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4609 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4610 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4611 case ZFS_SMB_ACL_PURGE: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4612 error = zfs_smb_acl_purge(sharedir); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4613 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4614 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4615 default: |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4616 error = EINVAL; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4617 break; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4618 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4619 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4620 VN_RELE(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4621 VN_RELE(ZTOV(sharedir)); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4622 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4623 ZFS_EXIT(zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4624 |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4625 return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4626 } |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8724
diff
changeset
|
4627 |
4543 | 4628 /* |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4629 * inputs: |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4630 * zc_name name of filesystem |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4631 * 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
|
4632 * 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
|
4633 * zc_cookie recursive flag |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4634 * 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
|
4635 * 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
|
4636 * 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
|
4637 * 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
|
4638 * |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4639 * outputs: none |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4640 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4641 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4642 zfs_ioc_hold(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4643 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4644 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
|
4645 spa_t *spa; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4646 dsl_pool_t *dp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4647 dsl_dataset_t *ds; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4648 int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4649 minor_t minor = 0; |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4650 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4651 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
|
4652 return (EINVAL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4653 |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4654 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
|
4655 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
|
4656 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
|
4657 zc->zc_cleanup_fd)); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4658 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4659 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4660 if (recursive) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4661 return (EINVAL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4662 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4663 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
|
4664 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4665 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4666 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4667 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
|
4668 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
|
4669 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
|
4670 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
|
4671 spa_close(spa, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4672 if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4673 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4674 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4675 /* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4676 * 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
|
4677 * 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
|
4678 * 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
|
4679 */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4680 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
|
4681 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
|
4682 return (ENOENT); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4683 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4684 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4685 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
|
4686 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
|
4687 if (error) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4688 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
|
4689 return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4690 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4691 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4692 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4693 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
|
4694 zc->zc_temphold); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4695 if (minor != 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4696 if (error == 0) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4697 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
|
4698 minor); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4699 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4700 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
|
4701 } |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4702 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
|
4703 |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12620
diff
changeset
|
4704 return (error); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4705 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4706 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4707 /* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4708 * inputs: |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4709 * 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
|
4710 * 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
|
4711 * 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
|
4712 * zc_cookie recursive flag |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4713 * |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4714 * outputs: none |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4715 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4716 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4717 zfs_ioc_release(zfs_cmd_t *zc) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4718 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4719 boolean_t recursive = zc->zc_cookie; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4720 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4721 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
|
4722 return (EINVAL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4723 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4724 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
|
4725 zc->zc_string, recursive)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4726 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4727 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4728 /* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4729 * inputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4730 * zc_name name of filesystem |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4731 * |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4732 * outputs: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4733 * 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
|
4734 */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4735 static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4736 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
|
4737 { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4738 nvlist_t *nvp; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4739 int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4740 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4741 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
|
4742 error = put_nvlist(zc, nvp); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4743 nvlist_free(nvp); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4744 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4745 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4746 return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4747 } |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4748 |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4749 /* |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4750 * inputs: |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4751 * zc_name name of new filesystem or snapshot |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4752 * zc_value full name of old snapshot |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4753 * |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4754 * outputs: |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4755 * zc_cookie space in bytes |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4756 * zc_objset_type compressed space in bytes |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4757 * zc_perm_action uncompressed space in bytes |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4758 */ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4759 static int |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4760 zfs_ioc_space_written(zfs_cmd_t *zc) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4761 { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4762 int error; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4763 dsl_dataset_t *new, *old; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4764 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4765 error = dsl_dataset_hold(zc->zc_name, FTAG, &new); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4766 if (error != 0) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4767 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4768 error = dsl_dataset_hold(zc->zc_value, FTAG, &old); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4769 if (error != 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4770 dsl_dataset_rele(new, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4771 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4772 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4773 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4774 error = dsl_dataset_space_written(old, new, &zc->zc_cookie, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4775 &zc->zc_objset_type, &zc->zc_perm_action); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4776 dsl_dataset_rele(old, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4777 dsl_dataset_rele(new, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4778 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4779 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4780 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4781 /* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4782 * inputs: |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4783 * zc_name full name of last snapshot |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4784 * zc_value full name of first snapshot |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4785 * |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4786 * outputs: |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4787 * zc_cookie space in bytes |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4788 * zc_objset_type compressed space in bytes |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4789 * zc_perm_action uncompressed space in bytes |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4790 */ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4791 static int |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4792 zfs_ioc_space_snaps(zfs_cmd_t *zc) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4793 { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4794 int error; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4795 dsl_dataset_t *new, *old; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4796 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4797 error = dsl_dataset_hold(zc->zc_name, FTAG, &new); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4798 if (error != 0) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4799 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4800 error = dsl_dataset_hold(zc->zc_value, FTAG, &old); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4801 if (error != 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4802 dsl_dataset_rele(new, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4803 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4804 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4805 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4806 error = dsl_dataset_space_wouldfree(old, new, &zc->zc_cookie, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4807 &zc->zc_objset_type, &zc->zc_perm_action); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4808 dsl_dataset_rele(old, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4809 dsl_dataset_rele(new, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4810 return (error); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4811 } |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4812 |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4813 /* |
4988
db8abd9846d4
6595467 libzfs consumers should be allowed to write their own history (or none at all)
ek110237
parents:
4849
diff
changeset
|
4814 * 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
|
4815 * 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
|
4816 * do the logging of those commands. |
4543 | 4817 */ |
789 | 4818 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
|
4819 { 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
|
4820 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4821 { 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
|
4822 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4823 { 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
|
4824 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4825 { 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
|
4826 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4827 { 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
|
4828 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4829 { 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
|
4830 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4831 { 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
|
4832 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
|
4833 { 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
|
4834 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
|
4835 { 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
|
4836 POOL_CHECK_READONLY }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4837 { 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
|
4838 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
|
4839 { 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
|
4840 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4841 { 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
|
4842 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
|
4843 { 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
|
4844 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
|
4845 { 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
|
4846 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
|
4847 { 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
|
4848 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
|
4849 { 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
|
4850 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
|
4851 { 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
|
4852 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
|
4853 { 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
|
4854 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
|
4855 { 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
|
4856 POOL_CHECK_SUSPENDED }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4857 { 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
|
4858 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4859 { 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
|
4860 POOL_CHECK_SUSPENDED }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4861 { 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
|
4862 POOL_CHECK_SUSPENDED }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4863 { 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
|
4864 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4865 { 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
|
4866 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
|
4867 { 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
|
4868 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
|
4869 { 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
|
4870 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4871 { 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
|
4872 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4873 { 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
|
4874 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4875 { zfs_ioc_send, zfs_secpolicy_send, DATASET_NAME, B_FALSE, |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4876 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4877 { 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
|
4878 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4879 { 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
|
4880 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4881 { 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
|
4882 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4883 { 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
|
4884 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4885 { 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
|
4886 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4887 { 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
|
4888 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
|
4889 { 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
|
4890 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13055 | 4891 { 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
|
4892 POOL_CHECK_NONE }, |
13055 | 4893 { 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
|
4894 POOL_CHECK_SUSPENDED }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4895 { 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
|
4896 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
|
4897 { 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
|
4898 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4899 { 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
|
4900 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
|
4901 { 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
|
4902 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4903 { 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
|
4904 POOL_CHECK_NONE }, |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4905 { 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
|
4906 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
|
4907 { 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
|
4908 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4909 { 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
|
4910 B_FALSE, POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4911 { 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
|
4912 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
|
4913 { 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
|
4914 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
|
4915 { 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
|
4916 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4917 { 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
|
4918 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10233
diff
changeset
|
4919 { 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
|
4920 POOL_CHECK_SUSPENDED }, |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11007
diff
changeset
|
4921 { 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
|
4922 POOL_CHECK_NONE }, |
11422
42768837421d
PSARC/2009/511 zpool split
Mark J Musante <Mark.Musante@Sun.COM>
parents:
11314
diff
changeset
|
4923 { 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
|
4924 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13055 | 4925 { 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
|
4926 POOL_CHECK_NONE }, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4927 { 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
|
4928 POOL_CHECK_NONE }, |
13055 | 4929 { 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
|
4930 B_FALSE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13055 | 4931 { zfs_ioc_obj_to_stats, zfs_secpolicy_diff, DATASET_NAME, B_FALSE, |
13514
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
4932 POOL_CHECK_SUSPENDED }, |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4933 { zfs_ioc_space_written, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4934 POOL_CHECK_SUSPENDED }, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4935 { zfs_ioc_space_snaps, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4936 POOL_CHECK_SUSPENDED }, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4937 { zfs_ioc_destroy_snaps_nvl, zfs_secpolicy_destroy_recursive, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13514
diff
changeset
|
4938 DATASET_NAME, B_TRUE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
13514
417c34452f03
1748 desire support for reguid in zfs
Garrett D'Amore <garrett@nexenta.com>
parents:
13512
diff
changeset
|
4939 { zfs_ioc_pool_reguid, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
13570
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4940 POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY }, |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4941 { zfs_ioc_pool_reopen, zfs_secpolicy_config, POOL_NAME, B_TRUE, |
3411fd5f1589
1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents:
13524
diff
changeset
|
4942 POOL_CHECK_SUSPENDED }, |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
4943 { zfs_ioc_send_progress, zfs_secpolicy_read, DATASET_NAME, B_FALSE, |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13570
diff
changeset
|
4944 POOL_CHECK_NONE } |
789 | 4945 }; |
4946 | |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4947 int |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4948 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
|
4949 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
|
4950 { |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4951 spa_t *spa; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4952 int error; |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4953 |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4954 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
|
4955 |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4956 if (check & POOL_CHECK_NONE) |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4957 return (0); |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4958 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
4959 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
|
4960 if (error == 0) { |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4961 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
|
4962 error = EAGAIN; |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
4963 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
|
4964 error = EROFS; |
9234
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4965 spa_close(spa, FTAG); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4966 } |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4967 return (error); |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4968 } |
bffdc4fc05c4
6792139 recovering from a suspended pool needs some work
George Wilson <George.Wilson@Sun.COM>
parents:
9179
diff
changeset
|
4969 |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4970 /* |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4971 * Find a free minor number. |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4972 */ |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4973 minor_t |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4974 zfsdev_minor_alloc(void) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4975 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4976 static minor_t last_minor; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4977 minor_t m; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4978 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4979 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
|
4980 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4981 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
|
4982 if (m > ZFSDEV_MAX_MINOR) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4983 m = 1; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4984 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
|
4985 last_minor = m; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4986 return (m); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4987 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4988 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4989 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4990 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4991 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4992 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4993 static int |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4994 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
|
4995 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4996 minor_t minor; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4997 zfs_soft_state_t *zs; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4998 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
4999 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
|
5000 ASSERT(getminor(*devp) == 0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5001 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5002 minor = zfsdev_minor_alloc(); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5003 if (minor == 0) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5004 return (ENXIO); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5005 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5006 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
|
5007 return (EAGAIN); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5008 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5009 *devp = makedevice(getemajor(*devp), minor); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5010 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5011 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
|
5012 zs->zss_type = ZSST_CTLDEV; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5013 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
|
5014 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5015 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5016 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5017 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5018 static void |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5019 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
|
5020 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5021 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
|
5022 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5023 zfs_onexit_destroy(zo); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5024 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
|
5025 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5026 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5027 void * |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5028 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
|
5029 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5030 zfs_soft_state_t *zp; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5031 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5032 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
|
5033 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
|
5034 return (NULL); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5035 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5036 return (zp->zss_data); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5037 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5038 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5039 static int |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5040 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
|
5041 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5042 int error = 0; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5043 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5044 if (getminor(*devp) != 0) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5045 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
|
5046 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5047 /* 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
|
5048 if (flag & FEXCL) { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5049 mutex_enter(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5050 error = zfs_ctldev_init(devp); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5051 mutex_exit(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5052 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5053 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5054 return (error); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5055 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5056 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5057 static int |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5058 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
|
5059 { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5060 zfs_onexit_t *zo; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5061 minor_t minor = getminor(dev); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5062 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5063 if (minor == 0) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5064 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5065 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5066 mutex_enter(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5067 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
|
5068 if (zo == NULL) { |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5069 mutex_exit(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5070 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
|
5071 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5072 zfs_ctldev_destroy(zo, minor); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5073 mutex_exit(&zfsdev_state_lock); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5074 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5075 return (0); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5076 } |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5077 |
789 | 5078 static int |
5079 zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) | |
5080 { | |
5081 zfs_cmd_t *zc; | |
5082 uint_t vec; | |
2199 | 5083 int error, rc; |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5084 minor_t minor = getminor(dev); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5085 |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5086 if (minor != 0 && |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5087 zfsdev_get_soft_state(minor, ZSST_CTLDEV) == NULL) |
789 | 5088 return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp)); |
5089 | |
5090 vec = cmd - ZFS_IOC; | |
4787 | 5091 ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip)); |
789 | 5092 |
5093 if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0])) | |
5094 return (EINVAL); | |
5095 | |
5096 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); | |
5097 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
5098 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
|
5099 if (error != 0) |
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
5100 error = EFAULT; |
789 | 5101 |
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
|
5102 if ((error == 0) && !(flag & FKIOCTL)) |
4543 | 5103 error = zfs_ioc_vec[vec].zvec_secpolicy(zc, cr); |
789 | 5104 |
5105 /* | |
5106 * Ensure that all pool/dataset names are valid before we pass down to | |
5107 * the lower layers. | |
5108 */ | |
5109 if (error == 0) { | |
5110 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
|
5111 zc->zc_iflags = flag & FKIOCTL; |
789 | 5112 switch (zfs_ioc_vec[vec].zvec_namecheck) { |
4577 | 5113 case POOL_NAME: |
789 | 5114 if (pool_namecheck(zc->zc_name, NULL, NULL) != 0) |
5115 error = EINVAL; | |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
5116 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
|
5117 zfs_ioc_vec[vec].zvec_namecheck, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
5118 zfs_ioc_vec[vec].zvec_pool_check); |
789 | 5119 break; |
5120 | |
4577 | 5121 case DATASET_NAME: |
789 | 5122 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0) |
5123 error = EINVAL; | |
13061
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
5124 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
|
5125 zfs_ioc_vec[vec].zvec_namecheck, |
bda0decf867b
PSARC 2010/306 Read-only ZFS pools
George Wilson <George.Wilson@Sun.COM>
parents:
13055
diff
changeset
|
5126 zfs_ioc_vec[vec].zvec_pool_check); |
789 | 5127 break; |
2856 | 5128 |
4577 | 5129 case NO_NAME: |
2856 | 5130 break; |
789 | 5131 } |
5132 } | |
5133 | |
5134 if (error == 0) | |
5135 error = zfs_ioc_vec[vec].zvec_func(zc); | |
5136 | |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9425
diff
changeset
|
5137 rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag); |
4543 | 5138 if (error == 0) { |
11807
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
5139 if (rc != 0) |
73a3c0d27389
6911541 'zfs mount' coredump
Sam Falkner <Sam.Falkner@Sun.COM>
parents:
11727
diff
changeset
|
5140 error = EFAULT; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
5141 if (zfs_ioc_vec[vec].zvec_his_log) |
4543 | 5142 zfs_log_history(zc); |
5143 } | |
789 | 5144 |
5145 kmem_free(zc, sizeof (zfs_cmd_t)); | |
5146 return (error); | |
5147 } | |
5148 | |
5149 static int | |
5150 zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) | |
5151 { | |
5152 if (cmd != DDI_ATTACH) | |
5153 return (DDI_FAILURE); | |
5154 | |
5155 if (ddi_create_minor_node(dip, "zfs", S_IFCHR, 0, | |
5156 DDI_PSEUDO, 0) == DDI_FAILURE) | |
5157 return (DDI_FAILURE); | |
5158 | |
5159 zfs_dip = dip; | |
5160 | |
5161 ddi_report_dev(dip); | |
5162 | |
5163 return (DDI_SUCCESS); | |
5164 } | |
5165 | |
5166 static int | |
5167 zfs_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) | |
5168 { | |
5169 if (spa_busy() || zfs_busy() || zvol_busy()) | |
5170 return (DDI_FAILURE); | |
5171 | |
5172 if (cmd != DDI_DETACH) | |
5173 return (DDI_FAILURE); | |
5174 | |
5175 zfs_dip = NULL; | |
5176 | |
5177 ddi_prop_remove_all(dip); | |
5178 ddi_remove_minor_node(dip, NULL); | |
5179 | |
5180 return (DDI_SUCCESS); | |
5181 } | |
5182 | |
5183 /*ARGSUSED*/ | |
5184 static int | |
5185 zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) | |
5186 { | |
5187 switch (infocmd) { | |
5188 case DDI_INFO_DEVT2DEVINFO: | |
5189 *result = zfs_dip; | |
5190 return (DDI_SUCCESS); | |
5191 | |
5192 case DDI_INFO_DEVT2INSTANCE: | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5193 *result = (void *)0; |
789 | 5194 return (DDI_SUCCESS); |
5195 } | |
5196 | |
5197 return (DDI_FAILURE); | |
5198 } | |
5199 | |
5200 /* | |
5201 * OK, so this is a little weird. | |
5202 * | |
5203 * /dev/zfs is the control node, i.e. minor 0. | |
5204 * /dev/zvol/[r]dsk/pool/dataset are the zvols, minor > 0. | |
5205 * | |
5206 * /dev/zfs has basically nothing to do except serve up ioctls, | |
5207 * so most of the standard driver entry points are in zvol.c. | |
5208 */ | |
5209 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
|
5210 zfsdev_open, /* open */ |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
5211 zfsdev_close, /* close */ |
789 | 5212 zvol_strategy, /* strategy */ |
5213 nodev, /* print */ | |
6423 | 5214 zvol_dump, /* dump */ |
789 | 5215 zvol_read, /* read */ |
5216 zvol_write, /* write */ | |
5217 zfsdev_ioctl, /* ioctl */ | |
5218 nodev, /* devmap */ | |
5219 nodev, /* mmap */ | |
5220 nodev, /* segmap */ | |
5221 nochpoll, /* poll */ | |
5222 ddi_prop_op, /* prop_op */ | |
5223 NULL, /* streamtab */ | |
5224 D_NEW | D_MP | D_64BIT, /* Driver compatibility flag */ | |
5225 CB_REV, /* version */ | |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3444
diff
changeset
|
5226 nodev, /* async read */ |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3444
diff
changeset
|
5227 nodev, /* async write */ |
789 | 5228 }; |
5229 | |
5230 static struct dev_ops zfs_dev_ops = { | |
5231 DEVO_REV, /* version */ | |
5232 0, /* refcnt */ | |
5233 zfs_info, /* info */ | |
5234 nulldev, /* identify */ | |
5235 nulldev, /* probe */ | |
5236 zfs_attach, /* attach */ | |
5237 zfs_detach, /* detach */ | |
5238 nodev, /* reset */ | |
5239 &zfs_cb_ops, /* driver operations */ | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5240 NULL, /* no bus operations */ |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5241 NULL, /* power */ |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5242 ddi_quiesce_not_needed, /* quiesce */ |
789 | 5243 }; |
5244 | |
5245 static struct modldrv zfs_modldrv = { | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5246 &mod_driverops, |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5247 "ZFS storage pool", |
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7294
diff
changeset
|
5248 &zfs_dev_ops |
789 | 5249 }; |
5250 | |
5251 static struct modlinkage modlinkage = { | |
5252 MODREV_1, | |
5253 (void *)&zfs_modlfs, | |
5254 (void *)&zfs_modldrv, | |
5255 NULL | |
5256 }; | |
5257 | |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5258 |
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5259 uint_t zfs_fsyncer_key; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
5260 extern uint_t rrw_tsd_key; |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5261 |
789 | 5262 int |
5263 _init(void) | |
5264 { | |
5265 int error; | |
5266 | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5267 spa_init(FREAD | FWRITE); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5268 zfs_init(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5269 zvol_init(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5270 |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5271 if ((error = mod_install(&modlinkage)) != 0) { |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5272 zvol_fini(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5273 zfs_fini(); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5274 spa_fini(); |
789 | 5275 return (error); |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
5276 } |
789 | 5277 |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5278 tsd_create(&zfs_fsyncer_key, NULL); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
5279 tsd_create(&rrw_tsd_key, NULL); |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5280 |
789 | 5281 error = ldi_ident_from_mod(&modlinkage, &zfs_li); |
5282 ASSERT(error == 0); | |
4543 | 5283 mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL); |
789 | 5284 |
5285 return (0); | |
5286 } | |
5287 | |
5288 int | |
5289 _fini(void) | |
5290 { | |
5291 int error; | |
5292 | |
1544 | 5293 if (spa_busy() || zfs_busy() || zvol_busy() || zio_injection_enabled) |
789 | 5294 return (EBUSY); |
5295 | |
5296 if ((error = mod_remove(&modlinkage)) != 0) | |
5297 return (error); | |
5298 | |
5299 zvol_fini(); | |
5300 zfs_fini(); | |
5301 spa_fini(); | |
5331 | 5302 if (zfs_nfsshare_inited) |
4543 | 5303 (void) ddi_modclose(nfs_mod); |
5331 | 5304 if (zfs_smbshare_inited) |
5305 (void) ddi_modclose(smbsrv_mod); | |
5306 if (zfs_nfsshare_inited || zfs_smbshare_inited) | |
4543 | 5307 (void) ddi_modclose(sharefs_mod); |
789 | 5308 |
4720
8edc0d2e6f3f
6535160 Lock contention on zl_lock from zil_commit
fr157268
parents:
4715
diff
changeset
|
5309 tsd_destroy(&zfs_fsyncer_key); |
789 | 5310 ldi_ident_release(zfs_li); |
5311 zfs_li = NULL; | |
4543 | 5312 mutex_destroy(&zfs_share_lock); |
789 | 5313 |
5314 return (error); | |
5315 } | |
5316 | |
5317 int | |
5318 _info(struct modinfo *modinfop) | |
5319 { | |
5320 return (mod_info(&modlinkage, modinfop)); | |
5321 } |