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