Mercurial > illumos > illumos-gate
annotate usr/src/uts/common/fs/zfs/zfs_vfsops.c @ 6689:47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
6695465 divide by zero in txg_sync_thread() under heavy load
author | maybee |
---|---|
date | Thu, 22 May 2008 11:13:47 -0700 |
parents | bbfcb773718e |
children | 361307ae060d |
rev | line source |
---|---|
789 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
4 * The contents of this file are subject to the terms of the | |
1484
d330e98f8ed7
6350001 ZFS lookup performance still much slower than UFS : help tar : help spec SFS
ek110237
parents:
1298
diff
changeset
|
5 * Common Development and Distribution License (the "License"). |
d330e98f8ed7
6350001 ZFS lookup performance still much slower than UFS : help tar : help spec SFS
ek110237
parents:
1298
diff
changeset
|
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 /* | |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
789 | 23 * Use is subject to license terms. |
24 */ | |
25 | |
3246
7a46b8f56ee0
6351954 zfs missing noxattr mount flag (fix keywords)
ck153898
parents:
3234
diff
changeset
|
26 #pragma ident "%Z%%M% %I% %E% SMI" |
789 | 27 |
28 #include <sys/types.h> | |
29 #include <sys/param.h> | |
30 #include <sys/systm.h> | |
31 #include <sys/sysmacros.h> | |
32 #include <sys/kmem.h> | |
33 #include <sys/pathname.h> | |
34 #include <sys/vnode.h> | |
35 #include <sys/vfs.h> | |
3898
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
36 #include <sys/vfs_opreg.h> |
789 | 37 #include <sys/mntent.h> |
38 #include <sys/mount.h> | |
39 #include <sys/cmn_err.h> | |
40 #include "fs/fs_subr.h" | |
41 #include <sys/zfs_znode.h> | |
3461 | 42 #include <sys/zfs_dir.h> |
789 | 43 #include <sys/zil.h> |
44 #include <sys/fs/zfs.h> | |
45 #include <sys/dmu.h> | |
46 #include <sys/dsl_prop.h> | |
3912 | 47 #include <sys/dsl_dataset.h> |
4543 | 48 #include <sys/dsl_deleg.h> |
789 | 49 #include <sys/spa.h> |
50 #include <sys/zap.h> | |
51 #include <sys/varargs.h> | |
52 #include <sys/policy.h> | |
53 #include <sys/atomic.h> | |
54 #include <sys/mkdev.h> | |
55 #include <sys/modctl.h> | |
4543 | 56 #include <sys/refstr.h> |
789 | 57 #include <sys/zfs_ioctl.h> |
58 #include <sys/zfs_ctldir.h> | |
5331 | 59 #include <sys/zfs_fuid.h> |
1544 | 60 #include <sys/bootconf.h> |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
61 #include <sys/sunddi.h> |
1484
d330e98f8ed7
6350001 ZFS lookup performance still much slower than UFS : help tar : help spec SFS
ek110237
parents:
1298
diff
changeset
|
62 #include <sys/dnlc.h> |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
63 #include <sys/dmu_objset.h> |
6423 | 64 #include <sys/spa_boot.h> |
789 | 65 |
66 int zfsfstype; | |
67 vfsops_t *zfs_vfsops = NULL; | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
68 static major_t zfs_major; |
789 | 69 static minor_t zfs_minor; |
70 static kmutex_t zfs_dev_mtx; | |
71 | |
72 static int zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr); | |
73 static int zfs_umount(vfs_t *vfsp, int fflag, cred_t *cr); | |
1544 | 74 static int zfs_mountroot(vfs_t *vfsp, enum whymountroot); |
789 | 75 static int zfs_root(vfs_t *vfsp, vnode_t **vpp); |
76 static int zfs_statvfs(vfs_t *vfsp, struct statvfs64 *statp); | |
77 static int zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp); | |
78 static void zfs_freevfs(vfs_t *vfsp); | |
79 | |
80 static const fs_operation_def_t zfs_vfsops_template[] = { | |
3898
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
81 VFSNAME_MOUNT, { .vfs_mount = zfs_mount }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
82 VFSNAME_MOUNTROOT, { .vfs_mountroot = zfs_mountroot }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
83 VFSNAME_UNMOUNT, { .vfs_unmount = zfs_umount }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
84 VFSNAME_ROOT, { .vfs_root = zfs_root }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
85 VFSNAME_STATVFS, { .vfs_statvfs = zfs_statvfs }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
86 VFSNAME_SYNC, { .vfs_sync = zfs_sync }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
87 VFSNAME_VGET, { .vfs_vget = zfs_vget }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
88 VFSNAME_FREEVFS, { .vfs_freevfs = zfs_freevfs }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
89 NULL, NULL |
789 | 90 }; |
91 | |
92 static const fs_operation_def_t zfs_vfsops_eio_template[] = { | |
3898
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
93 VFSNAME_FREEVFS, { .vfs_freevfs = zfs_freevfs }, |
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3461
diff
changeset
|
94 NULL, NULL |
789 | 95 }; |
96 | |
97 /* | |
98 * We need to keep a count of active fs's. | |
99 * This is necessary to prevent our module | |
100 * from being unloaded after a umount -f | |
101 */ | |
102 static uint32_t zfs_active_fs_count = 0; | |
103 | |
104 static char *noatime_cancel[] = { MNTOPT_ATIME, NULL }; | |
105 static char *atime_cancel[] = { MNTOPT_NOATIME, NULL }; | |
3234 | 106 static char *noxattr_cancel[] = { MNTOPT_XATTR, NULL }; |
107 static char *xattr_cancel[] = { MNTOPT_NOXATTR, NULL }; | |
789 | 108 |
3234 | 109 /* |
4596
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
110 * MO_DEFAULT is not used since the default value is determined |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
111 * by the equivalent property. |
3234 | 112 */ |
789 | 113 static mntopt_t mntopts[] = { |
3234 | 114 { MNTOPT_NOXATTR, noxattr_cancel, NULL, 0, NULL }, |
115 { MNTOPT_XATTR, xattr_cancel, NULL, 0, NULL }, | |
4596
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
116 { MNTOPT_NOATIME, noatime_cancel, NULL, 0, NULL }, |
789 | 117 { MNTOPT_ATIME, atime_cancel, NULL, 0, NULL } |
118 }; | |
119 | |
120 static mntopts_t zfs_mntopts = { | |
121 sizeof (mntopts) / sizeof (mntopt_t), | |
122 mntopts | |
123 }; | |
124 | |
125 /*ARGSUSED*/ | |
126 int | |
127 zfs_sync(vfs_t *vfsp, short flag, cred_t *cr) | |
128 { | |
129 /* | |
130 * Data integrity is job one. We don't want a compromised kernel | |
131 * writing to the storage pool, so we never sync during panic. | |
132 */ | |
133 if (panicstr) | |
134 return (0); | |
135 | |
136 /* | |
137 * SYNC_ATTR is used by fsflush() to force old filesystems like UFS | |
138 * to sync metadata, which they would otherwise cache indefinitely. | |
139 * Semantically, the only requirement is that the sync be initiated. | |
140 * The DMU syncs out txgs frequently, so there's nothing to do. | |
141 */ | |
142 if (flag & SYNC_ATTR) | |
143 return (0); | |
144 | |
145 if (vfsp != NULL) { | |
146 /* | |
147 * Sync a specific filesystem. | |
148 */ | |
149 zfsvfs_t *zfsvfs = vfsp->vfs_data; | |
150 | |
151 ZFS_ENTER(zfsvfs); | |
152 if (zfsvfs->z_log != NULL) | |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2474
diff
changeset
|
153 zil_commit(zfsvfs->z_log, UINT64_MAX, 0); |
789 | 154 else |
155 txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0); | |
156 ZFS_EXIT(zfsvfs); | |
157 } else { | |
158 /* | |
159 * Sync all ZFS filesystems. This is what happens when you | |
160 * run sync(1M). Unlike other filesystems, ZFS honors the | |
161 * request by waiting for all pools to commit all dirty data. | |
162 */ | |
163 spa_sync_allpools(); | |
164 } | |
165 | |
166 return (0); | |
167 } | |
168 | |
1544 | 169 static int |
170 zfs_create_unique_device(dev_t *dev) | |
171 { | |
172 major_t new_major; | |
173 | |
174 do { | |
175 ASSERT3U(zfs_minor, <=, MAXMIN32); | |
176 minor_t start = zfs_minor; | |
177 do { | |
178 mutex_enter(&zfs_dev_mtx); | |
179 if (zfs_minor >= MAXMIN32) { | |
180 /* | |
181 * If we're still using the real major | |
182 * keep out of /dev/zfs and /dev/zvol minor | |
183 * number space. If we're using a getudev()'ed | |
184 * major number, we can use all of its minors. | |
185 */ | |
186 if (zfs_major == ddi_name_to_major(ZFS_DRIVER)) | |
187 zfs_minor = ZFS_MIN_MINOR; | |
188 else | |
189 zfs_minor = 0; | |
190 } else { | |
191 zfs_minor++; | |
192 } | |
193 *dev = makedevice(zfs_major, zfs_minor); | |
194 mutex_exit(&zfs_dev_mtx); | |
195 } while (vfs_devismounted(*dev) && zfs_minor != start); | |
196 if (zfs_minor == start) { | |
197 /* | |
198 * We are using all ~262,000 minor numbers for the | |
199 * current major number. Create a new major number. | |
200 */ | |
201 if ((new_major = getudev()) == (major_t)-1) { | |
202 cmn_err(CE_WARN, | |
203 "zfs_mount: Can't get unique major " | |
204 "device number."); | |
205 return (-1); | |
206 } | |
207 mutex_enter(&zfs_dev_mtx); | |
208 zfs_major = new_major; | |
209 zfs_minor = 0; | |
210 | |
211 mutex_exit(&zfs_dev_mtx); | |
212 } else { | |
213 break; | |
214 } | |
215 /* CONSTANTCONDITION */ | |
216 } while (1); | |
217 | |
218 return (0); | |
219 } | |
220 | |
789 | 221 static void |
222 atime_changed_cb(void *arg, uint64_t newval) | |
223 { | |
224 zfsvfs_t *zfsvfs = arg; | |
225 | |
226 if (newval == TRUE) { | |
227 zfsvfs->z_atime = TRUE; | |
228 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_NOATIME); | |
229 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_ATIME, NULL, 0); | |
230 } else { | |
231 zfsvfs->z_atime = FALSE; | |
232 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_ATIME); | |
233 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_NOATIME, NULL, 0); | |
234 } | |
235 } | |
236 | |
237 static void | |
3234 | 238 xattr_changed_cb(void *arg, uint64_t newval) |
239 { | |
240 zfsvfs_t *zfsvfs = arg; | |
241 | |
242 if (newval == TRUE) { | |
243 /* XXX locking on vfs_flag? */ | |
244 zfsvfs->z_vfs->vfs_flag |= VFS_XATTR; | |
245 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_NOXATTR); | |
246 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_XATTR, NULL, 0); | |
247 } else { | |
248 /* XXX locking on vfs_flag? */ | |
249 zfsvfs->z_vfs->vfs_flag &= ~VFS_XATTR; | |
250 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_XATTR); | |
251 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_NOXATTR, NULL, 0); | |
252 } | |
253 } | |
254 | |
255 static void | |
789 | 256 blksz_changed_cb(void *arg, uint64_t newval) |
257 { | |
258 zfsvfs_t *zfsvfs = arg; | |
259 | |
260 if (newval < SPA_MINBLOCKSIZE || | |
261 newval > SPA_MAXBLOCKSIZE || !ISP2(newval)) | |
262 newval = SPA_MAXBLOCKSIZE; | |
263 | |
264 zfsvfs->z_max_blksz = newval; | |
265 zfsvfs->z_vfs->vfs_bsize = newval; | |
266 } | |
267 | |
268 static void | |
269 readonly_changed_cb(void *arg, uint64_t newval) | |
270 { | |
271 zfsvfs_t *zfsvfs = arg; | |
272 | |
273 if (newval) { | |
274 /* XXX locking on vfs_flag? */ | |
275 zfsvfs->z_vfs->vfs_flag |= VFS_RDONLY; | |
276 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_RW); | |
277 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_RO, NULL, 0); | |
278 } else { | |
279 /* XXX locking on vfs_flag? */ | |
280 zfsvfs->z_vfs->vfs_flag &= ~VFS_RDONLY; | |
281 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_RO); | |
282 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_RW, NULL, 0); | |
283 } | |
284 } | |
285 | |
286 static void | |
287 devices_changed_cb(void *arg, uint64_t newval) | |
288 { | |
289 zfsvfs_t *zfsvfs = arg; | |
290 | |
291 if (newval == FALSE) { | |
292 zfsvfs->z_vfs->vfs_flag |= VFS_NODEVICES; | |
293 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_DEVICES); | |
294 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_NODEVICES, NULL, 0); | |
295 } else { | |
296 zfsvfs->z_vfs->vfs_flag &= ~VFS_NODEVICES; | |
297 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_NODEVICES); | |
298 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_DEVICES, NULL, 0); | |
299 } | |
300 } | |
301 | |
302 static void | |
303 setuid_changed_cb(void *arg, uint64_t newval) | |
304 { | |
305 zfsvfs_t *zfsvfs = arg; | |
306 | |
307 if (newval == FALSE) { | |
308 zfsvfs->z_vfs->vfs_flag |= VFS_NOSETUID; | |
309 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_SETUID); | |
310 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_NOSETUID, NULL, 0); | |
311 } else { | |
312 zfsvfs->z_vfs->vfs_flag &= ~VFS_NOSETUID; | |
313 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_NOSETUID); | |
314 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_SETUID, NULL, 0); | |
315 } | |
316 } | |
317 | |
318 static void | |
319 exec_changed_cb(void *arg, uint64_t newval) | |
320 { | |
321 zfsvfs_t *zfsvfs = arg; | |
322 | |
323 if (newval == FALSE) { | |
324 zfsvfs->z_vfs->vfs_flag |= VFS_NOEXEC; | |
325 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_EXEC); | |
326 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_NOEXEC, NULL, 0); | |
327 } else { | |
328 zfsvfs->z_vfs->vfs_flag &= ~VFS_NOEXEC; | |
329 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_NOEXEC); | |
330 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_EXEC, NULL, 0); | |
331 } | |
332 } | |
333 | |
5331 | 334 /* |
335 * The nbmand mount option can be changed at mount time. | |
336 * We can't allow it to be toggled on live file systems or incorrect | |
337 * behavior may be seen from cifs clients | |
338 * | |
339 * This property isn't registered via dsl_prop_register(), but this callback | |
340 * will be called when a file system is first mounted | |
341 */ | |
342 static void | |
343 nbmand_changed_cb(void *arg, uint64_t newval) | |
344 { | |
345 zfsvfs_t *zfsvfs = arg; | |
346 if (newval == FALSE) { | |
347 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_NBMAND); | |
348 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_NONBMAND, NULL, 0); | |
349 } else { | |
350 vfs_clearmntopt(zfsvfs->z_vfs, MNTOPT_NONBMAND); | |
351 vfs_setmntopt(zfsvfs->z_vfs, MNTOPT_NBMAND, NULL, 0); | |
352 } | |
353 } | |
354 | |
789 | 355 static void |
356 snapdir_changed_cb(void *arg, uint64_t newval) | |
357 { | |
358 zfsvfs_t *zfsvfs = arg; | |
359 | |
360 zfsvfs->z_show_ctldir = newval; | |
361 } | |
362 | |
363 static void | |
5331 | 364 vscan_changed_cb(void *arg, uint64_t newval) |
365 { | |
366 zfsvfs_t *zfsvfs = arg; | |
367 | |
368 zfsvfs->z_vscan = newval; | |
369 } | |
370 | |
371 static void | |
789 | 372 acl_mode_changed_cb(void *arg, uint64_t newval) |
373 { | |
374 zfsvfs_t *zfsvfs = arg; | |
375 | |
376 zfsvfs->z_acl_mode = newval; | |
377 } | |
378 | |
379 static void | |
380 acl_inherit_changed_cb(void *arg, uint64_t newval) | |
381 { | |
382 zfsvfs_t *zfsvfs = arg; | |
383 | |
384 zfsvfs->z_acl_inherit = newval; | |
385 } | |
386 | |
1544 | 387 static int |
388 zfs_register_callbacks(vfs_t *vfsp) | |
389 { | |
390 struct dsl_dataset *ds = NULL; | |
391 objset_t *os = NULL; | |
392 zfsvfs_t *zfsvfs = NULL; | |
5331 | 393 uint64_t nbmand; |
394 int readonly, do_readonly = B_FALSE; | |
395 int setuid, do_setuid = B_FALSE; | |
396 int exec, do_exec = B_FALSE; | |
397 int devices, do_devices = B_FALSE; | |
398 int xattr, do_xattr = B_FALSE; | |
399 int atime, do_atime = B_FALSE; | |
1544 | 400 int error = 0; |
401 | |
402 ASSERT(vfsp); | |
403 zfsvfs = vfsp->vfs_data; | |
404 ASSERT(zfsvfs); | |
405 os = zfsvfs->z_os; | |
406 | |
407 /* | |
408 * The act of registering our callbacks will destroy any mount | |
409 * options we may have. In order to enable temporary overrides | |
3234 | 410 * of mount options, we stash away the current values and |
1544 | 411 * restore them after we register the callbacks. |
412 */ | |
413 if (vfs_optionisset(vfsp, MNTOPT_RO, NULL)) { | |
414 readonly = B_TRUE; | |
415 do_readonly = B_TRUE; | |
416 } else if (vfs_optionisset(vfsp, MNTOPT_RW, NULL)) { | |
417 readonly = B_FALSE; | |
418 do_readonly = B_TRUE; | |
419 } | |
420 if (vfs_optionisset(vfsp, MNTOPT_NOSUID, NULL)) { | |
421 devices = B_FALSE; | |
422 setuid = B_FALSE; | |
423 do_devices = B_TRUE; | |
424 do_setuid = B_TRUE; | |
425 } else { | |
426 if (vfs_optionisset(vfsp, MNTOPT_NODEVICES, NULL)) { | |
427 devices = B_FALSE; | |
428 do_devices = B_TRUE; | |
3912 | 429 } else if (vfs_optionisset(vfsp, MNTOPT_DEVICES, NULL)) { |
1544 | 430 devices = B_TRUE; |
431 do_devices = B_TRUE; | |
432 } | |
433 | |
434 if (vfs_optionisset(vfsp, MNTOPT_NOSETUID, NULL)) { | |
435 setuid = B_FALSE; | |
436 do_setuid = B_TRUE; | |
437 } else if (vfs_optionisset(vfsp, MNTOPT_SETUID, NULL)) { | |
438 setuid = B_TRUE; | |
439 do_setuid = B_TRUE; | |
440 } | |
441 } | |
442 if (vfs_optionisset(vfsp, MNTOPT_NOEXEC, NULL)) { | |
443 exec = B_FALSE; | |
444 do_exec = B_TRUE; | |
445 } else if (vfs_optionisset(vfsp, MNTOPT_EXEC, NULL)) { | |
446 exec = B_TRUE; | |
447 do_exec = B_TRUE; | |
448 } | |
3234 | 449 if (vfs_optionisset(vfsp, MNTOPT_NOXATTR, NULL)) { |
450 xattr = B_FALSE; | |
451 do_xattr = B_TRUE; | |
452 } else if (vfs_optionisset(vfsp, MNTOPT_XATTR, NULL)) { | |
453 xattr = B_TRUE; | |
454 do_xattr = B_TRUE; | |
455 } | |
4596
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
456 if (vfs_optionisset(vfsp, MNTOPT_NOATIME, NULL)) { |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
457 atime = B_FALSE; |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
458 do_atime = B_TRUE; |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
459 } else if (vfs_optionisset(vfsp, MNTOPT_ATIME, NULL)) { |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
460 atime = B_TRUE; |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
461 do_atime = B_TRUE; |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
462 } |
1544 | 463 |
464 /* | |
5331 | 465 * nbmand is a special property. It can only be changed at |
466 * mount time. | |
467 * | |
468 * This is weird, but it is documented to only be changeable | |
469 * at mount time. | |
470 */ | |
471 if (vfs_optionisset(vfsp, MNTOPT_NONBMAND, NULL)) { | |
472 nbmand = B_FALSE; | |
473 } else if (vfs_optionisset(vfsp, MNTOPT_NBMAND, NULL)) { | |
474 nbmand = B_TRUE; | |
475 } else { | |
476 char osname[MAXNAMELEN]; | |
477 | |
478 dmu_objset_name(os, osname); | |
479 if (error = dsl_prop_get_integer(osname, "nbmand", &nbmand, | |
480 NULL)) | |
481 return (error); | |
482 } | |
483 | |
484 /* | |
1544 | 485 * Register property callbacks. |
486 * | |
487 * It would probably be fine to just check for i/o error from | |
488 * the first prop_register(), but I guess I like to go | |
489 * overboard... | |
490 */ | |
491 ds = dmu_objset_ds(os); | |
492 error = dsl_prop_register(ds, "atime", atime_changed_cb, zfsvfs); | |
493 error = error ? error : dsl_prop_register(ds, | |
3234 | 494 "xattr", xattr_changed_cb, zfsvfs); |
495 error = error ? error : dsl_prop_register(ds, | |
1544 | 496 "recordsize", blksz_changed_cb, zfsvfs); |
497 error = error ? error : dsl_prop_register(ds, | |
498 "readonly", readonly_changed_cb, zfsvfs); | |
499 error = error ? error : dsl_prop_register(ds, | |
500 "devices", devices_changed_cb, zfsvfs); | |
501 error = error ? error : dsl_prop_register(ds, | |
502 "setuid", setuid_changed_cb, zfsvfs); | |
503 error = error ? error : dsl_prop_register(ds, | |
504 "exec", exec_changed_cb, zfsvfs); | |
505 error = error ? error : dsl_prop_register(ds, | |
506 "snapdir", snapdir_changed_cb, zfsvfs); | |
507 error = error ? error : dsl_prop_register(ds, | |
508 "aclmode", acl_mode_changed_cb, zfsvfs); | |
509 error = error ? error : dsl_prop_register(ds, | |
510 "aclinherit", acl_inherit_changed_cb, zfsvfs); | |
5331 | 511 error = error ? error : dsl_prop_register(ds, |
512 "vscan", vscan_changed_cb, zfsvfs); | |
1544 | 513 if (error) |
514 goto unregister; | |
515 | |
516 /* | |
517 * Invoke our callbacks to restore temporary mount options. | |
518 */ | |
519 if (do_readonly) | |
520 readonly_changed_cb(zfsvfs, readonly); | |
521 if (do_setuid) | |
522 setuid_changed_cb(zfsvfs, setuid); | |
523 if (do_exec) | |
524 exec_changed_cb(zfsvfs, exec); | |
525 if (do_devices) | |
526 devices_changed_cb(zfsvfs, devices); | |
3234 | 527 if (do_xattr) |
528 xattr_changed_cb(zfsvfs, xattr); | |
4596
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
529 if (do_atime) |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
530 atime_changed_cb(zfsvfs, atime); |
1544 | 531 |
5331 | 532 nbmand_changed_cb(zfsvfs, nbmand); |
533 | |
1544 | 534 return (0); |
535 | |
536 unregister: | |
537 /* | |
538 * We may attempt to unregister some callbacks that are not | |
539 * registered, but this is OK; it will simply return ENOMSG, | |
540 * which we will ignore. | |
541 */ | |
542 (void) dsl_prop_unregister(ds, "atime", atime_changed_cb, zfsvfs); | |
3234 | 543 (void) dsl_prop_unregister(ds, "xattr", xattr_changed_cb, zfsvfs); |
1544 | 544 (void) dsl_prop_unregister(ds, "recordsize", blksz_changed_cb, zfsvfs); |
545 (void) dsl_prop_unregister(ds, "readonly", readonly_changed_cb, zfsvfs); | |
546 (void) dsl_prop_unregister(ds, "devices", devices_changed_cb, zfsvfs); | |
547 (void) dsl_prop_unregister(ds, "setuid", setuid_changed_cb, zfsvfs); | |
548 (void) dsl_prop_unregister(ds, "exec", exec_changed_cb, zfsvfs); | |
549 (void) dsl_prop_unregister(ds, "snapdir", snapdir_changed_cb, zfsvfs); | |
550 (void) dsl_prop_unregister(ds, "aclmode", acl_mode_changed_cb, zfsvfs); | |
551 (void) dsl_prop_unregister(ds, "aclinherit", acl_inherit_changed_cb, | |
552 zfsvfs); | |
5331 | 553 (void) dsl_prop_unregister(ds, "vscan", vscan_changed_cb, zfsvfs); |
1544 | 554 return (error); |
555 | |
556 } | |
557 | |
558 static int | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
559 zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
560 { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
561 uint_t readonly; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
562 int error; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
563 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
564 error = zfs_register_callbacks(zfsvfs->z_vfs); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
565 if (error) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
566 return (error); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
567 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
568 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
569 * Set the objset user_ptr to track its zfsvfs. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
570 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
571 mutex_enter(&zfsvfs->z_os->os->os_user_ptr_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
572 dmu_objset_set_user(zfsvfs->z_os, zfsvfs); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
573 mutex_exit(&zfsvfs->z_os->os->os_user_ptr_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
574 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
575 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
576 * If we are not mounting (ie: online recv), then we don't |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
577 * have to worry about replaying the log as we blocked all |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
578 * operations out since we closed the ZIL. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
579 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
580 if (mounting) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
581 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
582 * During replay we remove the read only flag to |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
583 * allow replays to succeed. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
584 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
585 readonly = zfsvfs->z_vfs->vfs_flag & VFS_RDONLY; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
586 if (readonly != 0) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
587 zfsvfs->z_vfs->vfs_flag &= ~VFS_RDONLY; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
588 else |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
589 zfs_unlinked_drain(zfsvfs); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
590 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
591 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
592 * Parse and replay the intent log. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
593 * |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
594 * Because of ziltest, this must be done after |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
595 * zfs_unlinked_drain(). (Further note: ziltest doesn't |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
596 * use readonly mounts, where zfs_unlinked_drain() isn't |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
597 * called.) This is because ziltest causes spa_sync() |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
598 * to think it's committed, but actually it is not, so |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
599 * the intent log contains many txg's worth of changes. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
600 * |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
601 * In particular, if object N is in the unlinked set in |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
602 * the last txg to actually sync, then it could be |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
603 * actually freed in a later txg and then reallocated in |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
604 * a yet later txg. This would write a "create object |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
605 * N" record to the intent log. Normally, this would be |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
606 * fine because the spa_sync() would have written out |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
607 * the fact that object N is free, before we could write |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
608 * the "create object N" intent log record. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
609 * |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
610 * But when we are in ziltest mode, we advance the "open |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
611 * txg" without actually spa_sync()-ing the changes to |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
612 * disk. So we would see that object N is still |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
613 * allocated and in the unlinked set, and there is an |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
614 * intent log record saying to allocate it. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
615 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
616 zil_replay(zfsvfs->z_os, zfsvfs, &zfsvfs->z_assign, |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
617 zfs_replay_vector); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
618 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
619 zfsvfs->z_vfs->vfs_flag |= readonly; /* restore readonly bit */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
620 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
621 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
622 if (!zil_disable) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
623 zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
624 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
625 return (0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
626 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
627 |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
628 static void |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
629 zfs_freezfsvfs(zfsvfs_t *zfsvfs) |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
630 { |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
631 mutex_destroy(&zfsvfs->z_znodes_lock); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
632 mutex_destroy(&zfsvfs->z_online_recv_lock); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
633 list_destroy(&zfsvfs->z_all_znodes); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
634 rrw_destroy(&zfsvfs->z_teardown_lock); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
635 rw_destroy(&zfsvfs->z_teardown_inactive_lock); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
636 rw_destroy(&zfsvfs->z_fuid_lock); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
637 kmem_free(zfsvfs, sizeof (zfsvfs_t)); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
638 } |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
639 |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
640 static int |
1544 | 641 zfs_domount(vfs_t *vfsp, char *osname, cred_t *cr) |
642 { | |
643 dev_t mount_dev; | |
644 uint64_t recordsize, readonly; | |
645 int error = 0; | |
646 int mode; | |
647 zfsvfs_t *zfsvfs; | |
648 znode_t *zp = NULL; | |
649 | |
650 ASSERT(vfsp); | |
651 ASSERT(osname); | |
652 | |
653 /* | |
654 * Initialize the zfs-specific filesystem structure. | |
655 * Should probably make this a kmem cache, shuffle fields, | |
656 * and just bzero up to z_hold_mtx[]. | |
657 */ | |
658 zfsvfs = kmem_zalloc(sizeof (zfsvfs_t), KM_SLEEP); | |
659 zfsvfs->z_vfs = vfsp; | |
660 zfsvfs->z_parent = zfsvfs; | |
661 zfsvfs->z_assign = TXG_NOWAIT; | |
662 zfsvfs->z_max_blksz = SPA_MAXBLOCKSIZE; | |
663 zfsvfs->z_show_ctldir = ZFS_SNAPDIR_VISIBLE; | |
664 | |
665 mutex_init(&zfsvfs->z_znodes_lock, NULL, MUTEX_DEFAULT, NULL); | |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
666 mutex_init(&zfsvfs->z_online_recv_lock, NULL, MUTEX_DEFAULT, NULL); |
1544 | 667 list_create(&zfsvfs->z_all_znodes, sizeof (znode_t), |
668 offsetof(znode_t, z_link_node)); | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
669 rrw_init(&zfsvfs->z_teardown_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
670 rw_init(&zfsvfs->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
671 rw_init(&zfsvfs->z_fuid_lock, NULL, RW_DEFAULT, NULL); |
1544 | 672 |
673 /* Initialize the generic filesystem structure. */ | |
674 vfsp->vfs_bcount = 0; | |
675 vfsp->vfs_data = NULL; | |
676 | |
677 if (zfs_create_unique_device(&mount_dev) == -1) { | |
678 error = ENODEV; | |
679 goto out; | |
680 } | |
681 ASSERT(vfs_devismounted(mount_dev) == 0); | |
682 | |
683 if (error = dsl_prop_get_integer(osname, "recordsize", &recordsize, | |
684 NULL)) | |
685 goto out; | |
686 | |
687 vfsp->vfs_dev = mount_dev; | |
688 vfsp->vfs_fstype = zfsfstype; | |
689 vfsp->vfs_bsize = recordsize; | |
690 vfsp->vfs_flag |= VFS_NOTRUNC; | |
691 vfsp->vfs_data = zfsvfs; | |
692 | |
693 if (error = dsl_prop_get_integer(osname, "readonly", &readonly, NULL)) | |
694 goto out; | |
695 | |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6570
diff
changeset
|
696 mode = DS_MODE_OWNER; |
1544 | 697 if (readonly) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6570
diff
changeset
|
698 mode |= DS_MODE_READONLY; |
1544 | 699 |
700 error = dmu_objset_open(osname, DMU_OST_ZFS, mode, &zfsvfs->z_os); | |
701 if (error == EROFS) { | |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6570
diff
changeset
|
702 mode = DS_MODE_OWNER | DS_MODE_READONLY; |
1544 | 703 error = dmu_objset_open(osname, DMU_OST_ZFS, mode, |
704 &zfsvfs->z_os); | |
705 } | |
706 | |
707 if (error) | |
708 goto out; | |
709 | |
710 if (error = zfs_init_fs(zfsvfs, &zp, cr)) | |
711 goto out; | |
712 | |
713 /* The call to zfs_init_fs leaves the vnode held, release it here. */ | |
714 VN_RELE(ZTOV(zp)); | |
715 | |
5331 | 716 /* |
717 * Set features for file system. | |
718 */ | |
719 zfsvfs->z_use_fuids = USE_FUIDS(zfsvfs->z_version, zfsvfs->z_os); | |
720 if (zfsvfs->z_use_fuids) { | |
721 vfs_set_feature(vfsp, VFSFT_XVATTR); | |
722 vfs_set_feature(vfsp, VFSFT_ACEMASKONACCESS); | |
723 vfs_set_feature(vfsp, VFSFT_ACLONCREATE); | |
724 } | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
725 if (zfsvfs->z_case == ZFS_CASE_INSENSITIVE) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
726 vfs_set_feature(vfsp, VFSFT_DIRENTFLAGS); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
727 vfs_set_feature(vfsp, VFSFT_CASEINSENSITIVE); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
728 vfs_set_feature(vfsp, VFSFT_NOCASESENSITIVE); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
729 } else if (zfsvfs->z_case == ZFS_CASE_MIXED) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
730 vfs_set_feature(vfsp, VFSFT_DIRENTFLAGS); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
731 vfs_set_feature(vfsp, VFSFT_CASEINSENSITIVE); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
732 } |
5331 | 733 |
1544 | 734 if (dmu_objset_is_snapshot(zfsvfs->z_os)) { |
5331 | 735 uint64_t pval; |
3234 | 736 |
1544 | 737 ASSERT(mode & DS_MODE_READONLY); |
738 atime_changed_cb(zfsvfs, B_FALSE); | |
739 readonly_changed_cb(zfsvfs, B_TRUE); | |
5331 | 740 if (error = dsl_prop_get_integer(osname, "xattr", &pval, NULL)) |
3234 | 741 goto out; |
5331 | 742 xattr_changed_cb(zfsvfs, pval); |
1544 | 743 zfsvfs->z_issnap = B_TRUE; |
744 } else { | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
745 error = zfsvfs_setup(zfsvfs, B_TRUE); |
1544 | 746 } |
747 | |
748 if (!zfsvfs->z_issnap) | |
749 zfsctl_create(zfsvfs); | |
750 out: | |
751 if (error) { | |
752 if (zfsvfs->z_os) | |
753 dmu_objset_close(zfsvfs->z_os); | |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
754 zfs_freezfsvfs(zfsvfs); |
1544 | 755 } else { |
756 atomic_add_32(&zfs_active_fs_count, 1); | |
757 } | |
758 | |
759 return (error); | |
760 } | |
761 | |
762 void | |
763 zfs_unregister_callbacks(zfsvfs_t *zfsvfs) | |
764 { | |
765 objset_t *os = zfsvfs->z_os; | |
766 struct dsl_dataset *ds; | |
767 | |
768 /* | |
769 * Unregister properties. | |
770 */ | |
771 if (!dmu_objset_is_snapshot(os)) { | |
772 ds = dmu_objset_ds(os); | |
773 VERIFY(dsl_prop_unregister(ds, "atime", atime_changed_cb, | |
774 zfsvfs) == 0); | |
775 | |
3234 | 776 VERIFY(dsl_prop_unregister(ds, "xattr", xattr_changed_cb, |
777 zfsvfs) == 0); | |
778 | |
1544 | 779 VERIFY(dsl_prop_unregister(ds, "recordsize", blksz_changed_cb, |
780 zfsvfs) == 0); | |
781 | |
782 VERIFY(dsl_prop_unregister(ds, "readonly", readonly_changed_cb, | |
783 zfsvfs) == 0); | |
784 | |
785 VERIFY(dsl_prop_unregister(ds, "devices", devices_changed_cb, | |
786 zfsvfs) == 0); | |
787 | |
788 VERIFY(dsl_prop_unregister(ds, "setuid", setuid_changed_cb, | |
789 zfsvfs) == 0); | |
790 | |
791 VERIFY(dsl_prop_unregister(ds, "exec", exec_changed_cb, | |
792 zfsvfs) == 0); | |
793 | |
794 VERIFY(dsl_prop_unregister(ds, "snapdir", snapdir_changed_cb, | |
795 zfsvfs) == 0); | |
796 | |
797 VERIFY(dsl_prop_unregister(ds, "aclmode", acl_mode_changed_cb, | |
798 zfsvfs) == 0); | |
799 | |
800 VERIFY(dsl_prop_unregister(ds, "aclinherit", | |
801 acl_inherit_changed_cb, zfsvfs) == 0); | |
5331 | 802 |
803 VERIFY(dsl_prop_unregister(ds, "vscan", | |
804 vscan_changed_cb, zfsvfs) == 0); | |
1544 | 805 } |
806 } | |
807 | |
3912 | 808 /* |
809 * Convert a decimal digit string to a uint64_t integer. | |
810 */ | |
811 static int | |
812 str_to_uint64(char *str, uint64_t *objnum) | |
813 { | |
814 uint64_t num = 0; | |
815 | |
816 while (*str) { | |
817 if (*str < '0' || *str > '9') | |
818 return (EINVAL); | |
819 | |
820 num = num*10 + *str++ - '0'; | |
821 } | |
822 | |
823 *objnum = num; | |
824 return (0); | |
825 } | |
826 | |
827 /* | |
828 * The boot path passed from the boot loader is in the form of | |
829 * "rootpool-name/root-filesystem-object-number'. Convert this | |
830 * string to a dataset name: "rootpool-name/root-filesystem-name". | |
831 */ | |
832 static int | |
6423 | 833 zfs_parse_bootfs(char *bpath, char *outpath) |
3912 | 834 { |
835 char *slashp; | |
836 uint64_t objnum; | |
837 int error; | |
838 | |
839 if (*bpath == 0 || *bpath == '/') | |
840 return (EINVAL); | |
841 | |
842 slashp = strchr(bpath, '/'); | |
843 | |
844 /* if no '/', just return the pool name */ | |
845 if (slashp == NULL) { | |
846 (void) strcpy(outpath, bpath); | |
847 return (0); | |
848 } | |
849 | |
850 if (error = str_to_uint64(slashp+1, &objnum)) | |
851 return (error); | |
852 | |
853 *slashp = '\0'; | |
854 error = dsl_dsobj_to_dsname(bpath, objnum, outpath); | |
855 *slashp = '/'; | |
856 | |
857 return (error); | |
858 } | |
859 | |
1544 | 860 static int |
861 zfs_mountroot(vfs_t *vfsp, enum whymountroot why) | |
862 { | |
863 int error = 0; | |
864 static int zfsrootdone = 0; | |
865 zfsvfs_t *zfsvfs = NULL; | |
866 znode_t *zp = NULL; | |
867 vnode_t *vp = NULL; | |
6423 | 868 char *zfs_bootfs; |
1544 | 869 |
870 ASSERT(vfsp); | |
871 | |
872 /* | |
3912 | 873 * The filesystem that we mount as root is defined in the |
6423 | 874 * boot property "zfs-bootfs" with a format of |
875 * "poolname/root-dataset-objnum". | |
1544 | 876 */ |
877 if (why == ROOT_INIT) { | |
878 if (zfsrootdone++) | |
879 return (EBUSY); | |
6423 | 880 /* |
881 * the process of doing a spa_load will require the | |
882 * clock to be set before we could (for example) do | |
883 * something better by looking at the timestamp on | |
884 * an uberblock, so just set it to -1. | |
885 */ | |
886 clkset(-1); | |
1544 | 887 |
6423 | 888 if ((zfs_bootfs = spa_get_bootfs()) == NULL) { |
889 cmn_err(CE_NOTE, "\nspa_get_bootfs: can not get " | |
890 "bootfs name \n"); | |
891 return (EINVAL); | |
5648 | 892 } |
6423 | 893 |
894 if (error = spa_import_rootpool(rootfs.bo_name)) { | |
895 spa_free_bootfs(zfs_bootfs); | |
896 cmn_err(CE_NOTE, "\nspa_import_rootpool: error %d\n", | |
897 error); | |
898 return (error); | |
899 } | |
3912 | 900 |
6423 | 901 if (error = zfs_parse_bootfs(zfs_bootfs, rootfs.bo_name)) { |
902 spa_free_bootfs(zfs_bootfs); | |
903 cmn_err(CE_NOTE, "\nzfs_parse_bootfs: error %d\n", | |
904 error); | |
905 return (error); | |
906 } | |
3912 | 907 |
6423 | 908 spa_free_bootfs(zfs_bootfs); |
1544 | 909 |
910 if (error = vfs_lock(vfsp)) | |
911 return (error); | |
912 | |
6423 | 913 if (error = zfs_domount(vfsp, rootfs.bo_name, CRED())) { |
914 cmn_err(CE_NOTE, "\nzfs_domount: error %d\n", error); | |
1544 | 915 goto out; |
6423 | 916 } |
1544 | 917 |
918 zfsvfs = (zfsvfs_t *)vfsp->vfs_data; | |
919 ASSERT(zfsvfs); | |
6423 | 920 if (error = zfs_zget(zfsvfs, zfsvfs->z_root, &zp)) { |
921 cmn_err(CE_NOTE, "\nzfs_zget: error %d\n", error); | |
1544 | 922 goto out; |
6423 | 923 } |
1544 | 924 |
925 vp = ZTOV(zp); | |
926 mutex_enter(&vp->v_lock); | |
927 vp->v_flag |= VROOT; | |
928 mutex_exit(&vp->v_lock); | |
929 rootvp = vp; | |
930 | |
931 /* | |
6570
bbfcb773718e
6698415 on zfs root, ace_walk oversteps its bounds, causing panic when kmem_flags is set to 0x4f
marks
parents:
6423
diff
changeset
|
932 * Leave rootvp held. The root file system is never unmounted. |
1544 | 933 */ |
934 | |
935 vfs_add((struct vnode *)0, vfsp, | |
936 (vfsp->vfs_flag & VFS_RDONLY) ? MS_RDONLY : 0); | |
937 out: | |
938 vfs_unlock(vfsp); | |
6423 | 939 return (error); |
1544 | 940 } else if (why == ROOT_REMOUNT) { |
941 readonly_changed_cb(vfsp->vfs_data, B_FALSE); | |
942 vfsp->vfs_flag |= VFS_REMOUNT; | |
4596
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
943 |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
944 /* refresh mount options */ |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
945 zfs_unregister_callbacks(vfsp->vfs_data); |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
946 return (zfs_register_callbacks(vfsp)); |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
947 |
1544 | 948 } else if (why == ROOT_UNMOUNT) { |
949 zfs_unregister_callbacks((zfsvfs_t *)vfsp->vfs_data); | |
950 (void) zfs_sync(vfsp, 0, 0); | |
951 return (0); | |
952 } | |
953 | |
954 /* | |
955 * if "why" is equal to anything else other than ROOT_INIT, | |
956 * ROOT_REMOUNT, or ROOT_UNMOUNT, we do not support it. | |
957 */ | |
958 return (ENOTSUP); | |
959 } | |
960 | |
789 | 961 /*ARGSUSED*/ |
962 static int | |
963 zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr) | |
964 { | |
965 char *osname; | |
966 pathname_t spn; | |
967 int error = 0; | |
968 uio_seg_t fromspace = (uap->flags & MS_SYSSPACE) ? | |
3912 | 969 UIO_SYSSPACE : UIO_USERSPACE; |
789 | 970 int canwrite; |
971 | |
972 if (mvp->v_type != VDIR) | |
973 return (ENOTDIR); | |
974 | |
975 mutex_enter(&mvp->v_lock); | |
976 if ((uap->flags & MS_REMOUNT) == 0 && | |
977 (uap->flags & MS_OVERLAY) == 0 && | |
978 (mvp->v_count != 1 || (mvp->v_flag & VROOT))) { | |
979 mutex_exit(&mvp->v_lock); | |
980 return (EBUSY); | |
981 } | |
982 mutex_exit(&mvp->v_lock); | |
983 | |
984 /* | |
985 * ZFS does not support passing unparsed data in via MS_DATA. | |
986 * Users should use the MS_OPTIONSTR interface; this means | |
987 * that all option parsing is already done and the options struct | |
988 * can be interrogated. | |
989 */ | |
990 if ((uap->flags & MS_DATA) && uap->datalen > 0) | |
991 return (EINVAL); | |
992 | |
993 /* | |
994 * Get the objset name (the "special" mount argument). | |
995 */ | |
996 if (error = pn_get(uap->spec, fromspace, &spn)) | |
997 return (error); | |
998 | |
999 osname = spn.pn_path; | |
1000 | |
4543 | 1001 /* |
1002 * Check for mount privilege? | |
1003 * | |
1004 * If we don't have privilege then see if | |
1005 * we have local permission to allow it | |
1006 */ | |
1007 error = secpolicy_fs_mount(cr, mvp, vfsp); | |
1008 if (error) { | |
1009 error = dsl_deleg_access(osname, ZFS_DELEG_PERM_MOUNT, cr); | |
1010 if (error == 0) { | |
1011 vattr_t vattr; | |
1012 | |
1013 /* | |
1014 * Make sure user is the owner of the mount point | |
1015 * or has sufficient privileges. | |
1016 */ | |
1017 | |
1018 vattr.va_mask = AT_UID; | |
1019 | |
5331 | 1020 if (error = VOP_GETATTR(mvp, &vattr, 0, cr, NULL)) { |
4543 | 1021 goto out; |
1022 } | |
1023 | |
5489
25bfaf065197
6601830 mismatch between zfs_mount() behavior and comment
marks
parents:
5446
diff
changeset
|
1024 if (secpolicy_vnode_owner(cr, vattr.va_uid) != 0 && |
25bfaf065197
6601830 mismatch between zfs_mount() behavior and comment
marks
parents:
5446
diff
changeset
|
1025 VOP_ACCESS(mvp, VWRITE, 0, cr, NULL) != 0) { |
25bfaf065197
6601830 mismatch between zfs_mount() behavior and comment
marks
parents:
5446
diff
changeset
|
1026 error = EPERM; |
4543 | 1027 goto out; |
1028 } | |
1029 | |
1030 secpolicy_fs_mount_clearopts(cr, vfsp); | |
1031 } else { | |
1032 goto out; | |
1033 } | |
1034 } | |
789 | 1035 |
1036 /* | |
1037 * Refuse to mount a filesystem if we are in a local zone and the | |
1038 * dataset is not visible. | |
1039 */ | |
1040 if (!INGLOBALZONE(curproc) && | |
1041 (!zone_dataset_visible(osname, &canwrite) || !canwrite)) { | |
1042 error = EPERM; | |
1043 goto out; | |
1044 } | |
1045 | |
4596
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1046 /* |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1047 * When doing a remount, we simply refresh our temporary properties |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1048 * according to those options set in the current VFS options. |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1049 */ |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1050 if (uap->flags & MS_REMOUNT) { |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1051 /* refresh mount options */ |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1052 zfs_unregister_callbacks(vfsp->vfs_data); |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1053 error = zfs_register_callbacks(vfsp); |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1054 goto out; |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1055 } |
3aa6e3b5dfca
6561658 xattrs aren't enabled on zfs root filesystem, weirdness with mount output
lling
parents:
4577
diff
changeset
|
1056 |
1544 | 1057 error = zfs_domount(vfsp, osname, cr); |
789 | 1058 |
1059 out: | |
1060 pn_free(&spn); | |
1061 return (error); | |
1062 } | |
1063 | |
1064 static int | |
1065 zfs_statvfs(vfs_t *vfsp, struct statvfs64 *statp) | |
1066 { | |
1067 zfsvfs_t *zfsvfs = vfsp->vfs_data; | |
1068 dev32_t d32; | |
2885 | 1069 uint64_t refdbytes, availbytes, usedobjs, availobjs; |
789 | 1070 |
1071 ZFS_ENTER(zfsvfs); | |
1072 | |
2885 | 1073 dmu_objset_space(zfsvfs->z_os, |
1074 &refdbytes, &availbytes, &usedobjs, &availobjs); | |
789 | 1075 |
1076 /* | |
1077 * The underlying storage pool actually uses multiple block sizes. | |
1078 * We report the fragsize as the smallest block size we support, | |
1079 * and we report our blocksize as the filesystem's maximum blocksize. | |
1080 */ | |
1081 statp->f_frsize = 1UL << SPA_MINBLOCKSHIFT; | |
1082 statp->f_bsize = zfsvfs->z_max_blksz; | |
1083 | |
1084 /* | |
1085 * The following report "total" blocks of various kinds in the | |
1086 * file system, but reported in terms of f_frsize - the | |
1087 * "fragment" size. | |
1088 */ | |
1089 | |
2885 | 1090 statp->f_blocks = (refdbytes + availbytes) >> SPA_MINBLOCKSHIFT; |
1091 statp->f_bfree = availbytes >> SPA_MINBLOCKSHIFT; | |
789 | 1092 statp->f_bavail = statp->f_bfree; /* no root reservation */ |
1093 | |
1094 /* | |
1095 * statvfs() should really be called statufs(), because it assumes | |
1096 * static metadata. ZFS doesn't preallocate files, so the best | |
1097 * we can do is report the max that could possibly fit in f_files, | |
1098 * and that minus the number actually used in f_ffree. | |
1099 * For f_ffree, report the smaller of the number of object available | |
1100 * and the number of blocks (each object will take at least a block). | |
1101 */ | |
2885 | 1102 statp->f_ffree = MIN(availobjs, statp->f_bfree); |
789 | 1103 statp->f_favail = statp->f_ffree; /* no "root reservation" */ |
2885 | 1104 statp->f_files = statp->f_ffree + usedobjs; |
789 | 1105 |
1106 (void) cmpldev(&d32, vfsp->vfs_dev); | |
1107 statp->f_fsid = d32; | |
1108 | |
1109 /* | |
1110 * We're a zfs filesystem. | |
1111 */ | |
1112 (void) strcpy(statp->f_basetype, vfssw[vfsp->vfs_fstype].vsw_name); | |
1113 | |
1123
02a0390fbc7d
6363529 UNIX03/UNIX98 *vsx* CAPI.os/files/fstatvfs/T.fstatvfs 11 FAILS
marks
parents:
849
diff
changeset
|
1114 statp->f_flag = vf_to_stf(vfsp->vfs_flag); |
789 | 1115 |
1116 statp->f_namemax = ZFS_MAXNAMELEN; | |
1117 | |
1118 /* | |
1119 * We have all of 32 characters to stuff a string here. | |
1120 * Is there anything useful we could/should provide? | |
1121 */ | |
1122 bzero(statp->f_fstr, sizeof (statp->f_fstr)); | |
1123 | |
1124 ZFS_EXIT(zfsvfs); | |
1125 return (0); | |
1126 } | |
1127 | |
1128 static int | |
1129 zfs_root(vfs_t *vfsp, vnode_t **vpp) | |
1130 { | |
1131 zfsvfs_t *zfsvfs = vfsp->vfs_data; | |
1132 znode_t *rootzp; | |
1133 int error; | |
1134 | |
1135 ZFS_ENTER(zfsvfs); | |
1136 | |
1137 error = zfs_zget(zfsvfs, zfsvfs->z_root, &rootzp); | |
1138 if (error == 0) | |
1139 *vpp = ZTOV(rootzp); | |
1140 | |
1141 ZFS_EXIT(zfsvfs); | |
1142 return (error); | |
1143 } | |
1144 | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1145 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1146 * Teardown the zfsvfs::z_os. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1147 * |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1148 * Note, if 'unmounting' if FALSE, we return with the 'z_teardown_lock' |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1149 * and 'z_teardown_inactive_lock' held. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1150 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1151 static int |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1152 zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1153 { |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5498
diff
changeset
|
1154 znode_t *zp; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1155 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1156 rrw_enter(&zfsvfs->z_teardown_lock, RW_WRITER, FTAG); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1157 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1158 if (!unmounting) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1159 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1160 * We purge the parent filesystem's vfsp as the parent |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1161 * filesystem and all of its snapshots have their vnode's |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1162 * v_vfsp set to the parent's filesystem's vfsp. Note, |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1163 * 'z_parent' is self referential for non-snapshots. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1164 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1165 (void) dnlc_purge_vfsp(zfsvfs->z_parent->z_vfs, 0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1166 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1167 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1168 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1169 * Close the zil. NB: Can't close the zil while zfs_inactive |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1170 * threads are blocked as zil_close can call zfs_inactive. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1171 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1172 if (zfsvfs->z_log) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1173 zil_close(zfsvfs->z_log); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1174 zfsvfs->z_log = NULL; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1175 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1176 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1177 rw_enter(&zfsvfs->z_teardown_inactive_lock, RW_WRITER); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1178 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1179 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1180 * If we are not unmounting (ie: online recv) and someone already |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1181 * unmounted this file system while we were doing the switcheroo, |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1182 * or a reopen of z_os failed then just bail out now. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1183 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1184 if (!unmounting && (zfsvfs->z_unmounted || zfsvfs->z_os == NULL)) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1185 rw_exit(&zfsvfs->z_teardown_inactive_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1186 rrw_exit(&zfsvfs->z_teardown_lock, FTAG); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1187 return (EIO); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1188 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1189 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1190 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1191 * At this point there are no vops active, and any new vops will |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1192 * fail with EIO since we have z_teardown_lock for writer (only |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1193 * relavent for forced unmount). |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1194 * |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1195 * Release all holds on dbufs. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1196 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1197 mutex_enter(&zfsvfs->z_znodes_lock); |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5498
diff
changeset
|
1198 for (zp = list_head(&zfsvfs->z_all_znodes); zp != NULL; |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5498
diff
changeset
|
1199 zp = list_next(&zfsvfs->z_all_znodes, zp)) |
5446 | 1200 if (zp->z_dbuf) { |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5498
diff
changeset
|
1201 ASSERT(ZTOV(zp)->v_count > 0); |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5498
diff
changeset
|
1202 zfs_znode_dmu_fini(zp); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1203 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1204 mutex_exit(&zfsvfs->z_znodes_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1205 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1206 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1207 * If we are unmounting, set the unmounted flag and let new vops |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1208 * unblock. zfs_inactive will have the unmounted behavior, and all |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1209 * other vops will fail with EIO. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1210 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1211 if (unmounting) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1212 zfsvfs->z_unmounted = B_TRUE; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1213 rrw_exit(&zfsvfs->z_teardown_lock, FTAG); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1214 rw_exit(&zfsvfs->z_teardown_inactive_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1215 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1216 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1217 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1218 * z_os will be NULL if there was an error in attempting to reopen |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1219 * zfsvfs, so just return as the properties had already been |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1220 * unregistered and cached data had been evicted before. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1221 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1222 if (zfsvfs->z_os == NULL) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1223 return (0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1224 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1225 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1226 * Unregister properties. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1227 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1228 zfs_unregister_callbacks(zfsvfs); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1229 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1230 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1231 * Evict cached data |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1232 */ |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
1233 if (dmu_objset_evict_dbufs(zfsvfs->z_os)) { |
5429
f0cb3b884d95
6597432 cannot rename filesystem and return busy at the first time
maybee
parents:
5331
diff
changeset
|
1234 txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0); |
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5648
diff
changeset
|
1235 (void) dmu_objset_evict_dbufs(zfsvfs->z_os); |
5429
f0cb3b884d95
6597432 cannot rename filesystem and return busy at the first time
maybee
parents:
5331
diff
changeset
|
1236 } |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1237 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1238 return (0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1239 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1240 |
789 | 1241 /*ARGSUSED*/ |
1242 static int | |
1243 zfs_umount(vfs_t *vfsp, int fflag, cred_t *cr) | |
1244 { | |
1245 zfsvfs_t *zfsvfs = vfsp->vfs_data; | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1246 objset_t *os; |
789 | 1247 int ret; |
1248 | |
4543 | 1249 ret = secpolicy_fs_unmount(cr, vfsp); |
1250 if (ret) { | |
1251 ret = dsl_deleg_access((char *)refstr_value(vfsp->vfs_resource), | |
1252 ZFS_DELEG_PERM_MOUNT, cr); | |
1253 if (ret) | |
1254 return (ret); | |
1255 } | |
1484
d330e98f8ed7
6350001 ZFS lookup performance still much slower than UFS : help tar : help spec SFS
ek110237
parents:
1298
diff
changeset
|
1256 |
4736
f8714efb3e12
6509628 unmount of a snapshot (from 'zfs destroy') is slow
ek110237
parents:
4614
diff
changeset
|
1257 /* |
f8714efb3e12
6509628 unmount of a snapshot (from 'zfs destroy') is slow
ek110237
parents:
4614
diff
changeset
|
1258 * We purge the parent filesystem's vfsp as the parent filesystem |
f8714efb3e12
6509628 unmount of a snapshot (from 'zfs destroy') is slow
ek110237
parents:
4614
diff
changeset
|
1259 * and all of its snapshots have their vnode's v_vfsp set to the |
f8714efb3e12
6509628 unmount of a snapshot (from 'zfs destroy') is slow
ek110237
parents:
4614
diff
changeset
|
1260 * parent's filesystem's vfsp. Note, 'z_parent' is self |
f8714efb3e12
6509628 unmount of a snapshot (from 'zfs destroy') is slow
ek110237
parents:
4614
diff
changeset
|
1261 * referential for non-snapshots. |
f8714efb3e12
6509628 unmount of a snapshot (from 'zfs destroy') is slow
ek110237
parents:
4614
diff
changeset
|
1262 */ |
f8714efb3e12
6509628 unmount of a snapshot (from 'zfs destroy') is slow
ek110237
parents:
4614
diff
changeset
|
1263 (void) dnlc_purge_vfsp(zfsvfs->z_parent->z_vfs, 0); |
1484
d330e98f8ed7
6350001 ZFS lookup performance still much slower than UFS : help tar : help spec SFS
ek110237
parents:
1298
diff
changeset
|
1264 |
789 | 1265 /* |
1266 * Unmount any snapshots mounted under .zfs before unmounting the | |
1267 * dataset itself. | |
1268 */ | |
1269 if (zfsvfs->z_ctldir != NULL && | |
4543 | 1270 (ret = zfsctl_umount_snapshots(vfsp, fflag, cr)) != 0) { |
789 | 1271 return (ret); |
4543 | 1272 } |
789 | 1273 |
4787 | 1274 if (!(fflag & MS_FORCE)) { |
4480
0976678e58c5
6544140 assertion failed: err == 0 (0x11 == 0x0), file: ../../common/fs/zfs/zfs_znode.c, line: 555
gw25295
parents:
3912
diff
changeset
|
1275 /* |
4787 | 1276 * Check the number of active vnodes in the file system. |
1277 * Our count is maintained in the vfs structure, but the | |
1278 * number is off by 1 to indicate a hold on the vfs | |
1279 * structure itself. | |
1280 * | |
1281 * The '.zfs' directory maintains a reference of its | |
1282 * own, and any active references underneath are | |
1283 * reflected in the vnode count. | |
789 | 1284 */ |
4787 | 1285 if (zfsvfs->z_ctldir == NULL) { |
1286 if (vfsp->vfs_count > 1) | |
1287 return (EBUSY); | |
1288 } else { | |
1289 if (vfsp->vfs_count > 2 || | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1290 zfsvfs->z_ctldir->v_count > 1) |
4787 | 1291 return (EBUSY); |
789 | 1292 } |
1293 } | |
1294 | |
1295 vfsp->vfs_flag |= VFS_UNMOUNTED; | |
4787 | 1296 |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1297 VERIFY(zfsvfs_teardown(zfsvfs, B_TRUE) == 0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1298 os = zfsvfs->z_os; |
4787 | 1299 |
1300 /* | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1301 * z_os will be NULL if there was an error in |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1302 * attempting to reopen zfsvfs. |
4787 | 1303 */ |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1304 if (os != NULL) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1305 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1306 * Unset the objset user_ptr. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1307 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1308 mutex_enter(&os->os->os_user_ptr_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1309 dmu_objset_set_user(os, NULL); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1310 mutex_exit(&os->os->os_user_ptr_lock); |
4787 | 1311 |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1312 /* |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6570
diff
changeset
|
1313 * Finally release the objset |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1314 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1315 dmu_objset_close(os); |
4787 | 1316 } |
1317 | |
1318 /* | |
1319 * We can now safely destroy the '.zfs' directory node. | |
1320 */ | |
1321 if (zfsvfs->z_ctldir != NULL) | |
1322 zfsctl_destroy(zfsvfs); | |
789 | 1323 |
1324 return (0); | |
1325 } | |
1326 | |
1327 static int | |
1328 zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp) | |
1329 { | |
1330 zfsvfs_t *zfsvfs = vfsp->vfs_data; | |
1331 znode_t *zp; | |
1332 uint64_t object = 0; | |
1333 uint64_t fid_gen = 0; | |
1334 uint64_t gen_mask; | |
1335 uint64_t zp_gen; | |
1336 int i, err; | |
1337 | |
1338 *vpp = NULL; | |
1339 | |
1340 ZFS_ENTER(zfsvfs); | |
1341 | |
1342 if (fidp->fid_len == LONG_FID_LEN) { | |
1343 zfid_long_t *zlfid = (zfid_long_t *)fidp; | |
1344 uint64_t objsetid = 0; | |
1345 uint64_t setgen = 0; | |
1346 | |
1347 for (i = 0; i < sizeof (zlfid->zf_setid); i++) | |
1348 objsetid |= ((uint64_t)zlfid->zf_setid[i]) << (8 * i); | |
1349 | |
1350 for (i = 0; i < sizeof (zlfid->zf_setgen); i++) | |
1351 setgen |= ((uint64_t)zlfid->zf_setgen[i]) << (8 * i); | |
1352 | |
1353 ZFS_EXIT(zfsvfs); | |
1354 | |
1355 err = zfsctl_lookup_objset(vfsp, objsetid, &zfsvfs); | |
1356 if (err) | |
1357 return (EINVAL); | |
1358 ZFS_ENTER(zfsvfs); | |
1359 } | |
1360 | |
1361 if (fidp->fid_len == SHORT_FID_LEN || fidp->fid_len == LONG_FID_LEN) { | |
1362 zfid_short_t *zfid = (zfid_short_t *)fidp; | |
1363 | |
1364 for (i = 0; i < sizeof (zfid->zf_object); i++) | |
1365 object |= ((uint64_t)zfid->zf_object[i]) << (8 * i); | |
1366 | |
1367 for (i = 0; i < sizeof (zfid->zf_gen); i++) | |
1368 fid_gen |= ((uint64_t)zfid->zf_gen[i]) << (8 * i); | |
1369 } else { | |
1370 ZFS_EXIT(zfsvfs); | |
1371 return (EINVAL); | |
1372 } | |
1373 | |
1374 /* A zero fid_gen means we are in the .zfs control directories */ | |
1375 if (fid_gen == 0 && | |
1376 (object == ZFSCTL_INO_ROOT || object == ZFSCTL_INO_SNAPDIR)) { | |
1377 *vpp = zfsvfs->z_ctldir; | |
1378 ASSERT(*vpp != NULL); | |
1379 if (object == ZFSCTL_INO_SNAPDIR) { | |
1380 VERIFY(zfsctl_root_lookup(*vpp, "snapshot", vpp, NULL, | |
5331 | 1381 0, NULL, NULL, NULL, NULL, NULL) == 0); |
789 | 1382 } else { |
1383 VN_HOLD(*vpp); | |
1384 } | |
1385 ZFS_EXIT(zfsvfs); | |
1386 return (0); | |
1387 } | |
1388 | |
1389 gen_mask = -1ULL >> (64 - 8 * i); | |
1390 | |
1391 dprintf("getting %llu [%u mask %llx]\n", object, fid_gen, gen_mask); | |
1392 if (err = zfs_zget(zfsvfs, object, &zp)) { | |
1393 ZFS_EXIT(zfsvfs); | |
1394 return (err); | |
1395 } | |
1396 zp_gen = zp->z_phys->zp_gen & gen_mask; | |
1397 if (zp_gen == 0) | |
1398 zp_gen = 1; | |
3461 | 1399 if (zp->z_unlinked || zp_gen != fid_gen) { |
789 | 1400 dprintf("znode gen (%u) != fid gen (%u)\n", zp_gen, fid_gen); |
1401 VN_RELE(ZTOV(zp)); | |
1402 ZFS_EXIT(zfsvfs); | |
1403 return (EINVAL); | |
1404 } | |
1405 | |
1406 *vpp = ZTOV(zp); | |
1407 ZFS_EXIT(zfsvfs); | |
1408 return (0); | |
1409 } | |
1410 | |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1411 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1412 * Block out VOPs and close zfsvfs_t::z_os |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1413 * |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1414 * Note, if successful, then we return with the 'z_teardown_lock' and |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1415 * 'z_teardown_inactive_lock' write held. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1416 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1417 int |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1418 zfs_suspend_fs(zfsvfs_t *zfsvfs, char *name, int *mode) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1419 { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1420 int error; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1421 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1422 if ((error = zfsvfs_teardown(zfsvfs, B_FALSE)) != 0) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1423 return (error); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1424 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1425 *mode = zfsvfs->z_os->os_mode; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1426 dmu_objset_name(zfsvfs->z_os, name); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1427 dmu_objset_close(zfsvfs->z_os); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1428 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1429 return (0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1430 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1431 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1432 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1433 * Reopen zfsvfs_t::z_os and release VOPs. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1434 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1435 int |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1436 zfs_resume_fs(zfsvfs_t *zfsvfs, const char *osname, int mode) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1437 { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1438 int err; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1439 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1440 ASSERT(RRW_WRITE_HELD(&zfsvfs->z_teardown_lock)); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1441 ASSERT(RW_WRITE_HELD(&zfsvfs->z_teardown_inactive_lock)); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1442 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1443 err = dmu_objset_open(osname, DMU_OST_ZFS, mode, &zfsvfs->z_os); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1444 if (err) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1445 zfsvfs->z_os = NULL; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1446 } else { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1447 znode_t *zp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1448 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1449 VERIFY(zfsvfs_setup(zfsvfs, B_FALSE) == 0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1450 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1451 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1452 * Attempt to re-establish all the active znodes with |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1453 * their dbufs. If a zfs_rezget() fails, then we'll let |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1454 * any potential callers discover that via ZFS_ENTER_VERIFY_VP |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1455 * when they try to use their znode. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1456 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1457 mutex_enter(&zfsvfs->z_znodes_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1458 for (zp = list_head(&zfsvfs->z_all_znodes); zp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1459 zp = list_next(&zfsvfs->z_all_znodes, zp)) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1460 (void) zfs_rezget(zp); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1461 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1462 mutex_exit(&zfsvfs->z_znodes_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1463 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1464 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1465 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1466 /* release the VOPs */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1467 rw_exit(&zfsvfs->z_teardown_inactive_lock); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1468 rrw_exit(&zfsvfs->z_teardown_lock, FTAG); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1469 |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1470 if (err) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1471 /* |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1472 * Since we couldn't reopen zfsvfs::z_os, force |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1473 * unmount this file system. |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1474 */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1475 if (vn_vfswlock(zfsvfs->z_vfs->vfs_vnodecovered) == 0) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1476 (void) dounmount(zfsvfs->z_vfs, MS_FORCE, CRED()); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1477 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1478 return (err); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1479 } |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1480 |
789 | 1481 static void |
1482 zfs_freevfs(vfs_t *vfsp) | |
1483 { | |
1484 zfsvfs_t *zfsvfs = vfsp->vfs_data; | |
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
1485 int i; |
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
1486 |
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
1487 for (i = 0; i != ZFS_OBJ_MTX_SZ; i++) |
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
1488 mutex_destroy(&zfsvfs->z_hold_mtx[i]); |
789 | 1489 |
5331 | 1490 zfs_fuid_destroy(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:
5648
diff
changeset
|
1491 zfs_freezfsvfs(zfsvfs); |
789 | 1492 |
1493 atomic_add_32(&zfs_active_fs_count, -1); | |
1494 } | |
1495 | |
1496 /* | |
1497 * VFS_INIT() initialization. Note that there is no VFS_FINI(), | |
1498 * so we can't safely do any non-idempotent initialization here. | |
1499 * Leave that to zfs_init() and zfs_fini(), which are called | |
1500 * from the module's _init() and _fini() entry points. | |
1501 */ | |
1502 /*ARGSUSED*/ | |
1503 static int | |
1504 zfs_vfsinit(int fstype, char *name) | |
1505 { | |
1506 int error; | |
1507 | |
1508 zfsfstype = fstype; | |
1509 | |
1510 /* | |
1511 * Setup vfsops and vnodeops tables. | |
1512 */ | |
1513 error = vfs_setfsops(fstype, zfs_vfsops_template, &zfs_vfsops); | |
1514 if (error != 0) { | |
1515 cmn_err(CE_WARN, "zfs: bad vfs ops template"); | |
1516 } | |
1517 | |
1518 error = zfs_create_op_tables(); | |
1519 if (error) { | |
1520 zfs_remove_op_tables(); | |
1521 cmn_err(CE_WARN, "zfs: bad vnode ops template"); | |
1522 (void) vfs_freevfsops_by_type(zfsfstype); | |
1523 return (error); | |
1524 } | |
1525 | |
1526 mutex_init(&zfs_dev_mtx, NULL, MUTEX_DEFAULT, NULL); | |
1527 | |
1528 /* | |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
1529 * Unique major number for all zfs mounts. |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
1530 * If we run out of 32-bit minors, we'll getudev() another major. |
789 | 1531 */ |
849
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
1532 zfs_major = ddi_name_to_major(ZFS_DRIVER); |
8d799fd81a9b
6345023 /dev/zfs fails to open once ZFS module is unloaded
bonwick
parents:
789
diff
changeset
|
1533 zfs_minor = ZFS_MIN_MINOR; |
789 | 1534 |
1535 return (0); | |
1536 } | |
1537 | |
1538 void | |
1539 zfs_init(void) | |
1540 { | |
1541 /* | |
1542 * Initialize .zfs directory structures | |
1543 */ | |
1544 zfsctl_init(); | |
1545 | |
1546 /* | |
1547 * Initialize znode cache, vnode ops, etc... | |
1548 */ | |
1549 zfs_znode_init(); | |
1550 } | |
1551 | |
1552 void | |
1553 zfs_fini(void) | |
1554 { | |
1555 zfsctl_fini(); | |
1556 zfs_znode_fini(); | |
1557 } | |
1558 | |
1559 int | |
1560 zfs_busy(void) | |
1561 { | |
1562 return (zfs_active_fs_count != 0); | |
1563 } | |
1564 | |
4577 | 1565 int |
1566 zfs_set_version(const char *name, uint64_t newvers) | |
1567 { | |
1568 int error; | |
1569 objset_t *os; | |
1570 dmu_tx_t *tx; | |
1571 uint64_t curvers; | |
1572 | |
1573 /* | |
1574 * XXX for now, require that the filesystem be unmounted. Would | |
1575 * be nice to find the zfsvfs_t and just update that if | |
1576 * possible. | |
1577 */ | |
1578 | |
1579 if (newvers < ZPL_VERSION_INITIAL || newvers > ZPL_VERSION) | |
1580 return (EINVAL); | |
1581 | |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6570
diff
changeset
|
1582 error = dmu_objset_open(name, DMU_OST_ZFS, DS_MODE_OWNER, &os); |
4577 | 1583 if (error) |
1584 return (error); | |
1585 | |
1586 error = zap_lookup(os, MASTER_NODE_OBJ, ZPL_VERSION_STR, | |
1587 8, 1, &curvers); | |
1588 if (error) | |
1589 goto out; | |
1590 if (newvers < curvers) { | |
1591 error = EINVAL; | |
1592 goto out; | |
1593 } | |
1594 | |
1595 tx = dmu_tx_create(os); | |
1596 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, 0, ZPL_VERSION_STR); | |
1597 error = dmu_tx_assign(tx, TXG_WAIT); | |
1598 if (error) { | |
1599 dmu_tx_abort(tx); | |
1600 goto out; | |
1601 } | |
1602 error = zap_update(os, MASTER_NODE_OBJ, ZPL_VERSION_STR, 8, 1, | |
1603 &newvers, tx); | |
1604 | |
1605 spa_history_internal_log(LOG_DS_UPGRADE, | |
1606 dmu_objset_spa(os), tx, CRED(), | |
1607 "oldver=%llu newver=%llu dataset = %llu", curvers, newvers, | |
1608 dmu_objset_id(os)); | |
1609 dmu_tx_commit(tx); | |
1610 | |
1611 out: | |
1612 dmu_objset_close(os); | |
1613 return (error); | |
1614 } | |
1615 | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1616 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1617 * Read a property stored within the master node. |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1618 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1619 int |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1620 zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1621 { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1622 const char *pname; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1623 int error; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1624 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1625 /* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1626 * Look up the file system's value for the property. For the |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1627 * version property, we look up a slightly different string. |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1628 */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1629 if (prop == ZFS_PROP_VERSION) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1630 pname = ZPL_VERSION_STR; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1631 else |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1632 pname = zfs_prop_to_name(prop); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1633 |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1634 error = zap_lookup(os, MASTER_NODE_OBJ, pname, 8, 1, value); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1635 |
6404 | 1636 if (error == ENOENT) { |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1637 /* No value set, use the default value */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1638 switch (prop) { |
6404 | 1639 case ZFS_PROP_VERSION: |
1640 *value = ZPL_VERSION; | |
1641 break; | |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1642 case ZFS_PROP_NORMALIZE: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1643 case ZFS_PROP_UTF8ONLY: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1644 *value = 0; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1645 break; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1646 case ZFS_PROP_CASE: |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1647 *value = ZFS_CASE_SENSITIVE; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1648 break; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1649 default: |
6404 | 1650 return (error); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1651 } |
6404 | 1652 error = 0; |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1653 } |
6404 | 1654 return (error); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1655 } |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5489
diff
changeset
|
1656 |
789 | 1657 static vfsdef_t vfw = { |
1658 VFSDEF_VERSION, | |
1659 MNTTYPE_ZFS, | |
1660 zfs_vfsinit, | |
5331 | 1661 VSW_HASPROTO|VSW_CANRWRO|VSW_CANREMOUNT|VSW_VOLATILEDEV|VSW_STATS| |
1662 VSW_XID, | |
789 | 1663 &zfs_mntopts |
1664 }; | |
1665 | |
1666 struct modlfs zfs_modlfs = { | |
4577 | 1667 &mod_fsops, "ZFS filesystem version " SPA_VERSION_STRING, &vfw |
789 | 1668 }; |