annotate usr/src/uts/common/fs/zfs/zfs_vfsops.c @ 5331:3047ad28a67b

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