xref: /titanic_53/usr/src/uts/common/fs/fem.c (revision de7d344565421a156b8bb2c7a41d5939f4b2ac86)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*de7d3445Sjwahlig  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <sys/types.h>
297c478bd9Sstevel@tonic-gate #include <sys/atomic.h>
307c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
317c478bd9Sstevel@tonic-gate #include <sys/mutex.h>
327c478bd9Sstevel@tonic-gate #include <sys/errno.h>
337c478bd9Sstevel@tonic-gate #include <sys/param.h>
347c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
357c478bd9Sstevel@tonic-gate #include <sys/systm.h>
367c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
377c478bd9Sstevel@tonic-gate #include <sys/debug.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #include <sys/fem.h>
407c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
417c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #define	NNODES_DEFAULT	8	/* Default number of nodes in a fem_list */
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * fl_ntob(n) - Fem_list: number of nodes to bytes
477c478bd9Sstevel@tonic-gate  * Given the number of nodes in a fem_list return the size, in bytes,
487c478bd9Sstevel@tonic-gate  * of the fem_list structure.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate #define	fl_ntob(n)	(sizeof (struct fem_list) + \
517c478bd9Sstevel@tonic-gate 			((n) - 1) * sizeof (struct fem_node))
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate typedef enum {
547c478bd9Sstevel@tonic-gate 	FEMTYPE_NULL,	/* Uninitialized */
557c478bd9Sstevel@tonic-gate 	FEMTYPE_VNODE,
567c478bd9Sstevel@tonic-gate 	FEMTYPE_VFS,
577c478bd9Sstevel@tonic-gate 	FEMTYPE_NTYPES
587c478bd9Sstevel@tonic-gate } femtype_t;
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #define	FEM_HEAD(_t) femtype[(_t)].head.fn_op.anon
617c478bd9Sstevel@tonic-gate #define	FEM_GUARD(_t) femtype[(_t)].guard
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate static struct fem_type_info {
647c478bd9Sstevel@tonic-gate 	struct fem_node		head;
657c478bd9Sstevel@tonic-gate 	struct fem_node		guard;
667c478bd9Sstevel@tonic-gate 	femop_t			*errf;
677c478bd9Sstevel@tonic-gate }	femtype[FEMTYPE_NTYPES];
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * For each type, two tables - the translation offset definition, which
727c478bd9Sstevel@tonic-gate  * is used by fs_build_vector to layout the operation(s) vector; and the
737c478bd9Sstevel@tonic-gate  * guard_operation_vector which protects from stack under-run.
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate int fem_err();
777c478bd9Sstevel@tonic-gate int fsem_err();
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	_FEMOPDEF(name, member)  \
817c478bd9Sstevel@tonic-gate 	{ VOPNAME_##name, offsetof(fem_t, vsop_##member), NULL, fem_err }
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate static fs_operation_trans_def_t	fem_opdef[] = {
847c478bd9Sstevel@tonic-gate 	_FEMOPDEF(OPEN,		open),
857c478bd9Sstevel@tonic-gate 	_FEMOPDEF(CLOSE,	close),
867c478bd9Sstevel@tonic-gate 	_FEMOPDEF(READ,		read),
877c478bd9Sstevel@tonic-gate 	_FEMOPDEF(WRITE,	write),
887c478bd9Sstevel@tonic-gate 	_FEMOPDEF(IOCTL,	ioctl),
897c478bd9Sstevel@tonic-gate 	_FEMOPDEF(SETFL,	setfl),
907c478bd9Sstevel@tonic-gate 	_FEMOPDEF(GETATTR,	getattr),
917c478bd9Sstevel@tonic-gate 	_FEMOPDEF(SETATTR,	setattr),
927c478bd9Sstevel@tonic-gate 	_FEMOPDEF(ACCESS,	access),
937c478bd9Sstevel@tonic-gate 	_FEMOPDEF(LOOKUP,	lookup),
947c478bd9Sstevel@tonic-gate 	_FEMOPDEF(CREATE,	create),
957c478bd9Sstevel@tonic-gate 	_FEMOPDEF(REMOVE,	remove),
967c478bd9Sstevel@tonic-gate 	_FEMOPDEF(LINK,		link),
977c478bd9Sstevel@tonic-gate 	_FEMOPDEF(RENAME,	rename),
987c478bd9Sstevel@tonic-gate 	_FEMOPDEF(MKDIR,	mkdir),
997c478bd9Sstevel@tonic-gate 	_FEMOPDEF(RMDIR,	rmdir),
1007c478bd9Sstevel@tonic-gate 	_FEMOPDEF(READDIR,	readdir),
1017c478bd9Sstevel@tonic-gate 	_FEMOPDEF(SYMLINK,	symlink),
1027c478bd9Sstevel@tonic-gate 	_FEMOPDEF(READLINK,	readlink),
1037c478bd9Sstevel@tonic-gate 	_FEMOPDEF(FSYNC,	fsync),
1047c478bd9Sstevel@tonic-gate 	_FEMOPDEF(INACTIVE,	inactive),
1057c478bd9Sstevel@tonic-gate 	_FEMOPDEF(FID,		fid),
1067c478bd9Sstevel@tonic-gate 	_FEMOPDEF(RWLOCK,	rwlock),
1077c478bd9Sstevel@tonic-gate 	_FEMOPDEF(RWUNLOCK,	rwunlock),
1087c478bd9Sstevel@tonic-gate 	_FEMOPDEF(SEEK,		seek),
1097c478bd9Sstevel@tonic-gate 	_FEMOPDEF(CMP,		cmp),
1107c478bd9Sstevel@tonic-gate 	_FEMOPDEF(FRLOCK,	frlock),
1117c478bd9Sstevel@tonic-gate 	_FEMOPDEF(SPACE,	space),
1127c478bd9Sstevel@tonic-gate 	_FEMOPDEF(REALVP,	realvp),
1137c478bd9Sstevel@tonic-gate 	_FEMOPDEF(GETPAGE,	getpage),
1147c478bd9Sstevel@tonic-gate 	_FEMOPDEF(PUTPAGE,	putpage),
1157c478bd9Sstevel@tonic-gate 	_FEMOPDEF(MAP,		map),
1167c478bd9Sstevel@tonic-gate 	_FEMOPDEF(ADDMAP,	addmap),
1177c478bd9Sstevel@tonic-gate 	_FEMOPDEF(DELMAP,	delmap),
1187c478bd9Sstevel@tonic-gate 	_FEMOPDEF(POLL,		poll),
1197c478bd9Sstevel@tonic-gate 	_FEMOPDEF(DUMP,		dump),
1207c478bd9Sstevel@tonic-gate 	_FEMOPDEF(PATHCONF,	pathconf),
1217c478bd9Sstevel@tonic-gate 	_FEMOPDEF(PAGEIO,	pageio),
1227c478bd9Sstevel@tonic-gate 	_FEMOPDEF(DUMPCTL,	dumpctl),
1237c478bd9Sstevel@tonic-gate 	_FEMOPDEF(DISPOSE,	dispose),
1247c478bd9Sstevel@tonic-gate 	_FEMOPDEF(SETSECATTR,	setsecattr),
1257c478bd9Sstevel@tonic-gate 	_FEMOPDEF(GETSECATTR,	getsecattr),
1267c478bd9Sstevel@tonic-gate 	_FEMOPDEF(SHRLOCK,	shrlock),
1277c478bd9Sstevel@tonic-gate 	_FEMOPDEF(VNEVENT,	vnevent),
1287c478bd9Sstevel@tonic-gate 	{ NULL, 0, NULL, NULL }
1297c478bd9Sstevel@tonic-gate };
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #define	_FEMGUARD(name, ignore)  \
1337c478bd9Sstevel@tonic-gate 	{ VOPNAME_##name, (femop_t *)fem_err }
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate static struct fs_operation_def fem_guard_ops[] = {
1367c478bd9Sstevel@tonic-gate 	_FEMGUARD(OPEN,		open),
1377c478bd9Sstevel@tonic-gate 	_FEMGUARD(CLOSE,	close),
1387c478bd9Sstevel@tonic-gate 	_FEMGUARD(READ,		read),
1397c478bd9Sstevel@tonic-gate 	_FEMGUARD(WRITE,	write),
1407c478bd9Sstevel@tonic-gate 	_FEMGUARD(IOCTL,	ioctl),
1417c478bd9Sstevel@tonic-gate 	_FEMGUARD(SETFL,	setfl),
1427c478bd9Sstevel@tonic-gate 	_FEMGUARD(GETATTR,	getattr),
1437c478bd9Sstevel@tonic-gate 	_FEMGUARD(SETATTR,	setattr),
1447c478bd9Sstevel@tonic-gate 	_FEMGUARD(ACCESS,	access),
1457c478bd9Sstevel@tonic-gate 	_FEMGUARD(LOOKUP,	lookup),
1467c478bd9Sstevel@tonic-gate 	_FEMGUARD(CREATE,	create),
1477c478bd9Sstevel@tonic-gate 	_FEMGUARD(REMOVE,	remove),
1487c478bd9Sstevel@tonic-gate 	_FEMGUARD(LINK,		link),
1497c478bd9Sstevel@tonic-gate 	_FEMGUARD(RENAME,	rename),
1507c478bd9Sstevel@tonic-gate 	_FEMGUARD(MKDIR,	mkdir),
1517c478bd9Sstevel@tonic-gate 	_FEMGUARD(RMDIR,	rmdir),
1527c478bd9Sstevel@tonic-gate 	_FEMGUARD(READDIR,	readdir),
1537c478bd9Sstevel@tonic-gate 	_FEMGUARD(SYMLINK,	symlink),
1547c478bd9Sstevel@tonic-gate 	_FEMGUARD(READLINK,	readlink),
1557c478bd9Sstevel@tonic-gate 	_FEMGUARD(FSYNC,	fsync),
1567c478bd9Sstevel@tonic-gate 	_FEMGUARD(INACTIVE,	inactive),
1577c478bd9Sstevel@tonic-gate 	_FEMGUARD(FID,		fid),
1587c478bd9Sstevel@tonic-gate 	_FEMGUARD(RWLOCK,	rwlock),
1597c478bd9Sstevel@tonic-gate 	_FEMGUARD(RWUNLOCK,	rwunlock),
1607c478bd9Sstevel@tonic-gate 	_FEMGUARD(SEEK,		seek),
1617c478bd9Sstevel@tonic-gate 	_FEMGUARD(CMP,		cmp),
1627c478bd9Sstevel@tonic-gate 	_FEMGUARD(FRLOCK,	frlock),
1637c478bd9Sstevel@tonic-gate 	_FEMGUARD(SPACE,	space),
1647c478bd9Sstevel@tonic-gate 	_FEMGUARD(REALVP,	realvp),
1657c478bd9Sstevel@tonic-gate 	_FEMGUARD(GETPAGE,	getpage),
1667c478bd9Sstevel@tonic-gate 	_FEMGUARD(PUTPAGE,	putpage),
1677c478bd9Sstevel@tonic-gate 	_FEMGUARD(MAP,		map),
1687c478bd9Sstevel@tonic-gate 	_FEMGUARD(ADDMAP,	addmap),
1697c478bd9Sstevel@tonic-gate 	_FEMGUARD(DELMAP,	delmap),
1707c478bd9Sstevel@tonic-gate 	_FEMGUARD(POLL,		poll),
1717c478bd9Sstevel@tonic-gate 	_FEMGUARD(DUMP,		dump),
1727c478bd9Sstevel@tonic-gate 	_FEMGUARD(PATHCONF,	pathconf),
1737c478bd9Sstevel@tonic-gate 	_FEMGUARD(PAGEIO,	pageio),
1747c478bd9Sstevel@tonic-gate 	_FEMGUARD(DUMPCTL,	dumpctl),
1757c478bd9Sstevel@tonic-gate 	_FEMGUARD(DISPOSE,	dispose),
1767c478bd9Sstevel@tonic-gate 	_FEMGUARD(SETSECATTR,	setsecattr),
1777c478bd9Sstevel@tonic-gate 	_FEMGUARD(GETSECATTR,	getsecattr),
1787c478bd9Sstevel@tonic-gate 	_FEMGUARD(SHRLOCK,	shrlock),
1797c478bd9Sstevel@tonic-gate 	_FEMGUARD(VNEVENT,	vnevent),
1807c478bd9Sstevel@tonic-gate 	{ NULL, NULL }
1817c478bd9Sstevel@tonic-gate };
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #define	_FSEMOPDEF(name, member)  \
1857c478bd9Sstevel@tonic-gate 	{ VFSNAME_##name, offsetof(fsem_t, vfsop_##member), NULL, fsem_err }
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate static fs_operation_trans_def_t fsem_opdef[] = {
1887c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(MOUNT, 	mount),
1897c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(UNMOUNT,	unmount),
1907c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(ROOT,	root),
1917c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(STATVFS,	statvfs),
1927c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(SYNC,	sync),
1937c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(VGET,	vget),
1947c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(MOUNTROOT,	mountroot),
1957c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(FREEVFS,	freevfs),
1967c478bd9Sstevel@tonic-gate 	_FSEMOPDEF(VNSTATE,	vnstate),
1977c478bd9Sstevel@tonic-gate 	{ NULL, 0, NULL, NULL }
1987c478bd9Sstevel@tonic-gate };
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate #define	_FSEMGUARD(name, ignore)  \
2017c478bd9Sstevel@tonic-gate 	{ VFSNAME_##name, (femop_t *)fsem_err }
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate static struct fs_operation_def fsem_guard_ops[] = {
2047c478bd9Sstevel@tonic-gate 	_FSEMGUARD(MOUNT, 	mount),
2057c478bd9Sstevel@tonic-gate 	_FSEMGUARD(UNMOUNT,	unmount),
2067c478bd9Sstevel@tonic-gate 	_FSEMGUARD(ROOT,	root),
2077c478bd9Sstevel@tonic-gate 	_FSEMGUARD(STATVFS,	statvfs),
2087c478bd9Sstevel@tonic-gate 	_FSEMGUARD(SYNC,	sync),
2097c478bd9Sstevel@tonic-gate 	_FSEMGUARD(VGET,	vget),
2107c478bd9Sstevel@tonic-gate 	_FSEMGUARD(MOUNTROOT,	mountroot),
2117c478bd9Sstevel@tonic-gate 	_FSEMGUARD(FREEVFS,	freevfs),
2127c478bd9Sstevel@tonic-gate 	_FSEMGUARD(VNSTATE,	vnstate),
2137c478bd9Sstevel@tonic-gate 	{ NULL, NULL}
2147c478bd9Sstevel@tonic-gate };
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * vsop_find, vfsop_find -
2197c478bd9Sstevel@tonic-gate  *
2207c478bd9Sstevel@tonic-gate  * These macros descend the stack until they find either a basic
2217c478bd9Sstevel@tonic-gate  * vnode/vfs operation [ indicated by a null fn_available ] or a
2227c478bd9Sstevel@tonic-gate  * stacked item where this method is non-null [_vsop].
2237c478bd9Sstevel@tonic-gate  *
2247c478bd9Sstevel@tonic-gate  * The DEBUG one is written with a single function which manually applies
2257c478bd9Sstevel@tonic-gate  * the structure offsets.  It can have additional debugging support.
2267c478bd9Sstevel@tonic-gate  */
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate #ifndef DEBUG
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate #define	vsop_find(ap, func, funct, arg0, _vop, _vsop) \
2317c478bd9Sstevel@tonic-gate for (;;) { \
2327c478bd9Sstevel@tonic-gate 	if ((ap)->fa_fnode->fn_available == NULL) { \
2337c478bd9Sstevel@tonic-gate 		*(func) = (funct (*)())((ap)->fa_fnode->fn_op.vnode->_vop); \
2347c478bd9Sstevel@tonic-gate 		*(arg0) = (void *)(ap)->fa_vnode.vp; \
2357c478bd9Sstevel@tonic-gate 		break;	\
2367c478bd9Sstevel@tonic-gate 	} else if ((*(func) = (funct (*)())((ap)->fa_fnode->fn_op.fem->_vsop))\
2377c478bd9Sstevel@tonic-gate 		    != NULL) { \
2387c478bd9Sstevel@tonic-gate 		*(arg0) = (void *) (ap); \
2397c478bd9Sstevel@tonic-gate 		break;	\
2407c478bd9Sstevel@tonic-gate 	} else { \
2417c478bd9Sstevel@tonic-gate 		(ap)->fa_fnode--; \
2427c478bd9Sstevel@tonic-gate 	} \
2437c478bd9Sstevel@tonic-gate } \
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate #define	vfsop_find(ap, func, funct, arg0, _vop, _vsop) \
2467c478bd9Sstevel@tonic-gate for (;;) { \
2477c478bd9Sstevel@tonic-gate 	if ((ap)->fa_fnode->fn_available == NULL) { \
2487c478bd9Sstevel@tonic-gate 		*(func) = (funct (*)())((ap)->fa_fnode->fn_op.vfs->_vop); \
2497c478bd9Sstevel@tonic-gate 		*(arg0) = (void *)(ap)->fa_vnode.vp; \
2507c478bd9Sstevel@tonic-gate 		break; \
2517c478bd9Sstevel@tonic-gate 	} else if ((*(func) = (funct (*)())((ap)->fa_fnode->fn_op.fsem->_vsop))\
2527c478bd9Sstevel@tonic-gate 		    != NULL) { \
2537c478bd9Sstevel@tonic-gate 		*(arg0) = (void *) (ap); \
2547c478bd9Sstevel@tonic-gate 		break; \
2557c478bd9Sstevel@tonic-gate 	} else { \
2567c478bd9Sstevel@tonic-gate 		(ap)->fa_fnode--; \
2577c478bd9Sstevel@tonic-gate 	} \
2587c478bd9Sstevel@tonic-gate } \
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate #else
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate #define	vsop_find(ap, func, funct, arg0, _vop, _vsop) \
2637c478bd9Sstevel@tonic-gate 	*(arg0) = _op_find((ap), (void **)(func), \
2647c478bd9Sstevel@tonic-gate 			offsetof(vnodeops_t, _vop), offsetof(fem_t, _vsop))
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate #define	vfsop_find(ap, func, funct, arg0, _fop, _fsop) \
2677c478bd9Sstevel@tonic-gate 	*(arg0) = _op_find((ap), (void **)(func), \
2687c478bd9Sstevel@tonic-gate 			offsetof(vfsops_t, _fop), offsetof(fsem_t, _fsop))
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate static void *
2717c478bd9Sstevel@tonic-gate _op_find(femarg_t *ap, void **fp, int offs0, int offs1)
2727c478bd9Sstevel@tonic-gate {
2737c478bd9Sstevel@tonic-gate 	void *ptr;
2747c478bd9Sstevel@tonic-gate 	for (;;) {
2757c478bd9Sstevel@tonic-gate 		struct fem_node	*fnod = ap->fa_fnode;
2767c478bd9Sstevel@tonic-gate 		if (fnod->fn_available == NULL) {
2777c478bd9Sstevel@tonic-gate 			*fp = *(void **)((char *)fnod->fn_op.anon + offs0);
2787c478bd9Sstevel@tonic-gate 			ptr = (void *)(ap->fa_vnode.anon);
2797c478bd9Sstevel@tonic-gate 			break;
2807c478bd9Sstevel@tonic-gate 		} else if ((*fp = *(void **)((char *)fnod->fn_op.anon+offs1))
2817c478bd9Sstevel@tonic-gate 			!= NULL) {
2827c478bd9Sstevel@tonic-gate 			ptr = (void *)(ap);
2837c478bd9Sstevel@tonic-gate 			break;
2847c478bd9Sstevel@tonic-gate 		} else {
2857c478bd9Sstevel@tonic-gate 			ap->fa_fnode--;
2867c478bd9Sstevel@tonic-gate 		}
2877c478bd9Sstevel@tonic-gate 	}
2887c478bd9Sstevel@tonic-gate 	return (ptr);
2897c478bd9Sstevel@tonic-gate }
2907c478bd9Sstevel@tonic-gate #endif
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate static fem_t *
2937c478bd9Sstevel@tonic-gate fem_alloc()
2947c478bd9Sstevel@tonic-gate {
2957c478bd9Sstevel@tonic-gate 	fem_t	*p;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	p = (fem_t *)kmem_alloc(sizeof (*p), KM_SLEEP);
2987c478bd9Sstevel@tonic-gate 	return (p);
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate void
3027c478bd9Sstevel@tonic-gate fem_free(fem_t *p)
3037c478bd9Sstevel@tonic-gate {
3047c478bd9Sstevel@tonic-gate 	kmem_free(p, sizeof (*p));
3057c478bd9Sstevel@tonic-gate }
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate static fsem_t *
3087c478bd9Sstevel@tonic-gate fsem_alloc()
3097c478bd9Sstevel@tonic-gate {
3107c478bd9Sstevel@tonic-gate 	fsem_t	*p;
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	p = (fsem_t *)kmem_alloc(sizeof (*p), KM_SLEEP);
3137c478bd9Sstevel@tonic-gate 	return (p);
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate void
3177c478bd9Sstevel@tonic-gate fsem_free(fsem_t *p)
3187c478bd9Sstevel@tonic-gate {
3197c478bd9Sstevel@tonic-gate 	kmem_free(p, sizeof (*p));
3207c478bd9Sstevel@tonic-gate }
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /*
3247c478bd9Sstevel@tonic-gate  * fem_get, fem_release - manage reference counts on the stack.
3257c478bd9Sstevel@tonic-gate  *
3267c478bd9Sstevel@tonic-gate  * The list of monitors can be updated while operations are in
3277c478bd9Sstevel@tonic-gate  * progress on the object.
3287c478bd9Sstevel@tonic-gate  *
3297c478bd9Sstevel@tonic-gate  * The reference count facilitates this by counting the number of
3307c478bd9Sstevel@tonic-gate  * current accessors, and deconstructing the list when it is exhausted.
3317c478bd9Sstevel@tonic-gate  *
3327c478bd9Sstevel@tonic-gate  * fem_lock() is required to:
3337c478bd9Sstevel@tonic-gate  *	look at femh_list
3347c478bd9Sstevel@tonic-gate  *	update what femh_list points to
3357c478bd9Sstevel@tonic-gate  *	update femh_list
3367c478bd9Sstevel@tonic-gate  *	increase femh_list->feml_refc.
3377c478bd9Sstevel@tonic-gate  *
3387c478bd9Sstevel@tonic-gate  * the feml_refc can decrement without holding the lock;
3397c478bd9Sstevel@tonic-gate  * when feml_refc becomes zero, the list is destroyed.
3407c478bd9Sstevel@tonic-gate  *
3417c478bd9Sstevel@tonic-gate  */
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate static struct fem_list *
3447c478bd9Sstevel@tonic-gate fem_lock(struct fem_head *fp)
3457c478bd9Sstevel@tonic-gate {
3467c478bd9Sstevel@tonic-gate 	struct fem_list	*sp = NULL;
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate 	ASSERT(fp != NULL);
3497c478bd9Sstevel@tonic-gate 	mutex_enter(&fp->femh_lock);
3507c478bd9Sstevel@tonic-gate 	sp = fp->femh_list;
3517c478bd9Sstevel@tonic-gate 	return (sp);
3527c478bd9Sstevel@tonic-gate }
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate static void
3557c478bd9Sstevel@tonic-gate fem_unlock(struct fem_head *fp)
3567c478bd9Sstevel@tonic-gate {
3577c478bd9Sstevel@tonic-gate 	ASSERT(fp != NULL);
3587c478bd9Sstevel@tonic-gate 	mutex_exit(&fp->femh_lock);
3597c478bd9Sstevel@tonic-gate }
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate /*
3627c478bd9Sstevel@tonic-gate  * Addref can only be called while its head->lock is held.
3637c478bd9Sstevel@tonic-gate  */
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate static void
3667c478bd9Sstevel@tonic-gate fem_addref(struct fem_list *sp)
3677c478bd9Sstevel@tonic-gate {
3687c478bd9Sstevel@tonic-gate 	atomic_add_32(&sp->feml_refc, 1);
3697c478bd9Sstevel@tonic-gate }
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate static void
3727c478bd9Sstevel@tonic-gate fem_delref(struct fem_list *sp)
3737c478bd9Sstevel@tonic-gate {
3747c478bd9Sstevel@tonic-gate 	(void) atomic_add_32_nv(&sp->feml_refc, -1);
3757c478bd9Sstevel@tonic-gate }
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate static struct fem_list *
3787c478bd9Sstevel@tonic-gate fem_get(struct fem_head *fp)
3797c478bd9Sstevel@tonic-gate {
3807c478bd9Sstevel@tonic-gate 	struct fem_list *sp = NULL;
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 	if (fp != NULL) {
3837c478bd9Sstevel@tonic-gate 		if ((sp = fem_lock(fp)) != NULL) {
3847c478bd9Sstevel@tonic-gate 			fem_addref(sp);
3857c478bd9Sstevel@tonic-gate 		}
3867c478bd9Sstevel@tonic-gate 		fem_unlock(fp);
3877c478bd9Sstevel@tonic-gate 	}
3887c478bd9Sstevel@tonic-gate 	return (sp);
3897c478bd9Sstevel@tonic-gate }
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate static void
3927c478bd9Sstevel@tonic-gate fem_release(struct fem_list *sp)
3937c478bd9Sstevel@tonic-gate {
3947c478bd9Sstevel@tonic-gate 	int	i;
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate 	if (sp->feml_refc != 0) {
3977c478bd9Sstevel@tonic-gate 		fem_delref(sp);
3987c478bd9Sstevel@tonic-gate 	}
3997c478bd9Sstevel@tonic-gate 	if (sp->feml_refc == 0) {
4007c478bd9Sstevel@tonic-gate 		/*
4017c478bd9Sstevel@tonic-gate 		 * Before freeing the list, we need to release the
4027c478bd9Sstevel@tonic-gate 		 * caller-provided data.
4037c478bd9Sstevel@tonic-gate 		 */
4047c478bd9Sstevel@tonic-gate 		for (i = sp->feml_tos; i > 0; i--) {
4057c478bd9Sstevel@tonic-gate 			struct fem_node *fnp = &sp->feml_nodes[i];
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate 			if (fnp->fn_av_rele)
4087c478bd9Sstevel@tonic-gate 				(*(fnp->fn_av_rele))(fnp->fn_available);
4097c478bd9Sstevel@tonic-gate 		}
4107c478bd9Sstevel@tonic-gate 		kmem_free(sp, fl_ntob(sp->feml_ssize));
4117c478bd9Sstevel@tonic-gate 	}
4127c478bd9Sstevel@tonic-gate }
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate /*
4167c478bd9Sstevel@tonic-gate  * These are the 'head' operations which perform the interposition.
4177c478bd9Sstevel@tonic-gate  *
4187c478bd9Sstevel@tonic-gate  * This set must be 1:1, onto with the (vnodeops, vfsos).
4197c478bd9Sstevel@tonic-gate  *
4207c478bd9Sstevel@tonic-gate  * If there is a desire to globally disable interposition for a particular
4217c478bd9Sstevel@tonic-gate  * method, the corresponding 'head' routine should unearth the base method
4227c478bd9Sstevel@tonic-gate  * and invoke it directly rather than bypassing the function.
4237c478bd9Sstevel@tonic-gate  *
4247c478bd9Sstevel@tonic-gate  * All the functions are virtually the same, save for names, types & args.
4257c478bd9Sstevel@tonic-gate  *  1. get a reference to the monitor stack for this object.
4267c478bd9Sstevel@tonic-gate  *  2. store the top of stack into the femarg structure.
4277c478bd9Sstevel@tonic-gate  *  3. store the basic object (vnode *, vnode **, vfs *) in the femarg struc.
4287c478bd9Sstevel@tonic-gate  *  4. invoke the "top" method for this object.
4297c478bd9Sstevel@tonic-gate  *  5. release the reference to the monitor stack.
4307c478bd9Sstevel@tonic-gate  *
4317c478bd9Sstevel@tonic-gate  */
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate static int
4347c478bd9Sstevel@tonic-gate vhead_open(vnode_t **vpp, int mode, cred_t *cr)
4357c478bd9Sstevel@tonic-gate {
4367c478bd9Sstevel@tonic-gate 	femarg_t	farg;
4377c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
4387c478bd9Sstevel@tonic-gate 	int		(*func)();
4397c478bd9Sstevel@tonic-gate 	void		*arg0;
4407c478bd9Sstevel@tonic-gate 	int		errc;
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock((*vpp)->v_femhead)) == NULL) {
4437c478bd9Sstevel@tonic-gate 		func = (int (*)()) ((*vpp)->v_op->vop_open);
4447c478bd9Sstevel@tonic-gate 		arg0 = (void *)vpp;
4457c478bd9Sstevel@tonic-gate 		fem_unlock((*vpp)->v_femhead);
4467c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, mode, cr);
4477c478bd9Sstevel@tonic-gate 	} else {
4487c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
4497c478bd9Sstevel@tonic-gate 		fem_unlock((*vpp)->v_femhead);
4507c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vpp = vpp;
4517c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
4527c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_open, vsop_open);
4537c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, mode, cr);
4547c478bd9Sstevel@tonic-gate 		fem_release(femsp);
4557c478bd9Sstevel@tonic-gate 	}
4567c478bd9Sstevel@tonic-gate 	return (errc);
4577c478bd9Sstevel@tonic-gate }
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate static int
4607c478bd9Sstevel@tonic-gate vhead_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr)
4617c478bd9Sstevel@tonic-gate {
4627c478bd9Sstevel@tonic-gate 	femarg_t	farg;
4637c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
4647c478bd9Sstevel@tonic-gate 	int		(*func)();
4657c478bd9Sstevel@tonic-gate 	void		*arg0;
4667c478bd9Sstevel@tonic-gate 	int		errc;
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
4697c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_close);
4707c478bd9Sstevel@tonic-gate 		arg0 = vp;
4717c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
4727c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, flag, count, offset, cr);
4737c478bd9Sstevel@tonic-gate 	} else {
4747c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
4757c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
4767c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
4777c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
4787c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_close, vsop_close);
4797c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, flag, count, offset, cr);
4807c478bd9Sstevel@tonic-gate 		fem_release(femsp);
4817c478bd9Sstevel@tonic-gate 	}
4827c478bd9Sstevel@tonic-gate 	return (errc);
4837c478bd9Sstevel@tonic-gate }
4847c478bd9Sstevel@tonic-gate 
4857c478bd9Sstevel@tonic-gate static int
4867c478bd9Sstevel@tonic-gate vhead_read(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr,
4877c478bd9Sstevel@tonic-gate 	struct caller_context *ct)
4887c478bd9Sstevel@tonic-gate {
4897c478bd9Sstevel@tonic-gate 	femarg_t	farg;
4907c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
4917c478bd9Sstevel@tonic-gate 	int		(*func)();
4927c478bd9Sstevel@tonic-gate 	void		*arg0;
4937c478bd9Sstevel@tonic-gate 	int		errc;
4947c478bd9Sstevel@tonic-gate 
4957c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
4967c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_read);
4977c478bd9Sstevel@tonic-gate 		arg0 = vp;
4987c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
4997c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, ioflag, cr, ct);
5007c478bd9Sstevel@tonic-gate 	} else {
5017c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
5027c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
5037c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
5047c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
5057c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_read, vsop_read);
5067c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, ioflag, cr, ct);
5077c478bd9Sstevel@tonic-gate 		fem_release(femsp);
5087c478bd9Sstevel@tonic-gate 	}
5097c478bd9Sstevel@tonic-gate 	return (errc);
5107c478bd9Sstevel@tonic-gate }
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate static int
5137c478bd9Sstevel@tonic-gate vhead_write(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr,
5147c478bd9Sstevel@tonic-gate 	struct caller_context *ct)
5157c478bd9Sstevel@tonic-gate {
5167c478bd9Sstevel@tonic-gate 	femarg_t	farg;
5177c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
5187c478bd9Sstevel@tonic-gate 	int		(*func)();
5197c478bd9Sstevel@tonic-gate 	void		*arg0;
5207c478bd9Sstevel@tonic-gate 	int		errc;
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
5237c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_write);
5247c478bd9Sstevel@tonic-gate 		arg0 = vp;
5257c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
5267c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, ioflag, cr, ct);
5277c478bd9Sstevel@tonic-gate 	} else {
5287c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
5297c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
5307c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
5317c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
5327c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_write, vsop_write);
5337c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, ioflag, cr, ct);
5347c478bd9Sstevel@tonic-gate 		fem_release(femsp);
5357c478bd9Sstevel@tonic-gate 	}
5367c478bd9Sstevel@tonic-gate 	return (errc);
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate 
5397c478bd9Sstevel@tonic-gate static int
5407c478bd9Sstevel@tonic-gate vhead_ioctl(vnode_t *vp, int cmd, intptr_t arg, int flag, cred_t *cr,
5417c478bd9Sstevel@tonic-gate 	int *rvalp)
5427c478bd9Sstevel@tonic-gate {
5437c478bd9Sstevel@tonic-gate 	femarg_t	farg;
5447c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
5457c478bd9Sstevel@tonic-gate 	int		(*func)();
5467c478bd9Sstevel@tonic-gate 	void		*arg0;
5477c478bd9Sstevel@tonic-gate 	int		errc;
5487c478bd9Sstevel@tonic-gate 
5497c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
5507c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_ioctl);
5517c478bd9Sstevel@tonic-gate 		arg0 = vp;
5527c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
5537c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, arg, flag, cr, rvalp);
5547c478bd9Sstevel@tonic-gate 	} else {
5557c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
5567c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
5577c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
5587c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
5597c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_ioctl, vsop_ioctl);
5607c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, arg, flag, cr, rvalp);
5617c478bd9Sstevel@tonic-gate 		fem_release(femsp);
5627c478bd9Sstevel@tonic-gate 	}
5637c478bd9Sstevel@tonic-gate 	return (errc);
5647c478bd9Sstevel@tonic-gate }
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate static int
5677c478bd9Sstevel@tonic-gate vhead_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr)
5687c478bd9Sstevel@tonic-gate {
5697c478bd9Sstevel@tonic-gate 	femarg_t	farg;
5707c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
5717c478bd9Sstevel@tonic-gate 	int		(*func)();
5727c478bd9Sstevel@tonic-gate 	void		*arg0;
5737c478bd9Sstevel@tonic-gate 	int		errc;
5747c478bd9Sstevel@tonic-gate 
5757c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
5767c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_setfl);
5777c478bd9Sstevel@tonic-gate 		arg0 = vp;
5787c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
5797c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, oflags, nflags, cr);
5807c478bd9Sstevel@tonic-gate 	} else {
5817c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
5827c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
5837c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
5847c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
5857c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_setfl, vsop_setfl);
5867c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, oflags, nflags, cr);
5877c478bd9Sstevel@tonic-gate 		fem_release(femsp);
5887c478bd9Sstevel@tonic-gate 	}
5897c478bd9Sstevel@tonic-gate 	return (errc);
5907c478bd9Sstevel@tonic-gate }
5917c478bd9Sstevel@tonic-gate 
5927c478bd9Sstevel@tonic-gate static int
5937c478bd9Sstevel@tonic-gate vhead_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr)
5947c478bd9Sstevel@tonic-gate {
5957c478bd9Sstevel@tonic-gate 	femarg_t	farg;
5967c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
5977c478bd9Sstevel@tonic-gate 	int		(*func)();
5987c478bd9Sstevel@tonic-gate 	void		*arg0;
5997c478bd9Sstevel@tonic-gate 	int		errc;
6007c478bd9Sstevel@tonic-gate 
6017c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
6027c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_getattr);
6037c478bd9Sstevel@tonic-gate 		arg0 = vp;
6047c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
6057c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vap, flags, cr);
6067c478bd9Sstevel@tonic-gate 	} else {
6077c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
6087c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
6097c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
6107c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
6117c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_getattr,
6127c478bd9Sstevel@tonic-gate 			vsop_getattr);
6137c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vap, flags, cr);
6147c478bd9Sstevel@tonic-gate 		fem_release(femsp);
6157c478bd9Sstevel@tonic-gate 	}
6167c478bd9Sstevel@tonic-gate 	return (errc);
6177c478bd9Sstevel@tonic-gate }
6187c478bd9Sstevel@tonic-gate 
6197c478bd9Sstevel@tonic-gate static int
6207c478bd9Sstevel@tonic-gate vhead_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
6217c478bd9Sstevel@tonic-gate 	caller_context_t *ct)
6227c478bd9Sstevel@tonic-gate {
6237c478bd9Sstevel@tonic-gate 	femarg_t	farg;
6247c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
6257c478bd9Sstevel@tonic-gate 	int		(*func)();
6267c478bd9Sstevel@tonic-gate 	void		*arg0;
6277c478bd9Sstevel@tonic-gate 	int		errc;
6287c478bd9Sstevel@tonic-gate 
6297c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
6307c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_setattr);
6317c478bd9Sstevel@tonic-gate 		arg0 = vp;
6327c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
6337c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vap, flags, cr, ct);
6347c478bd9Sstevel@tonic-gate 	} else {
6357c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
6367c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
6377c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
6387c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
6397c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_setattr,
6407c478bd9Sstevel@tonic-gate 			vsop_setattr);
6417c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vap, flags, cr, ct);
6427c478bd9Sstevel@tonic-gate 		fem_release(femsp);
6437c478bd9Sstevel@tonic-gate 	}
6447c478bd9Sstevel@tonic-gate 	return (errc);
6457c478bd9Sstevel@tonic-gate }
6467c478bd9Sstevel@tonic-gate 
6477c478bd9Sstevel@tonic-gate static int
6487c478bd9Sstevel@tonic-gate vhead_access(vnode_t *vp, int mode, int flags, cred_t *cr)
6497c478bd9Sstevel@tonic-gate {
6507c478bd9Sstevel@tonic-gate 	femarg_t	farg;
6517c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
6527c478bd9Sstevel@tonic-gate 	int		(*func)();
6537c478bd9Sstevel@tonic-gate 	void		*arg0;
6547c478bd9Sstevel@tonic-gate 	int		errc;
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
6577c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_access);
6587c478bd9Sstevel@tonic-gate 		arg0 = vp;
6597c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
6607c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, mode, flags, cr);
6617c478bd9Sstevel@tonic-gate 	} else {
6627c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
6637c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
6647c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
6657c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
6667c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_access,
6677c478bd9Sstevel@tonic-gate 			vsop_access);
6687c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, mode, flags, cr);
6697c478bd9Sstevel@tonic-gate 		fem_release(femsp);
6707c478bd9Sstevel@tonic-gate 	}
6717c478bd9Sstevel@tonic-gate 	return (errc);
6727c478bd9Sstevel@tonic-gate }
6737c478bd9Sstevel@tonic-gate 
6747c478bd9Sstevel@tonic-gate static int
6757c478bd9Sstevel@tonic-gate vhead_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
6767c478bd9Sstevel@tonic-gate 	int flags, vnode_t *rdir, cred_t *cr)
6777c478bd9Sstevel@tonic-gate {
6787c478bd9Sstevel@tonic-gate 	femarg_t	farg;
6797c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
6807c478bd9Sstevel@tonic-gate 	int		(*func)();
6817c478bd9Sstevel@tonic-gate 	void		*arg0;
6827c478bd9Sstevel@tonic-gate 	int		errc;
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
6857c478bd9Sstevel@tonic-gate 		func = (int (*)()) (dvp->v_op->vop_lookup);
6867c478bd9Sstevel@tonic-gate 		arg0 = dvp;
6877c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
6887c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, nm, vpp, pnp, flags, rdir, cr);
6897c478bd9Sstevel@tonic-gate 	} else {
6907c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
6917c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
6927c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = dvp;
6937c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
6947c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_lookup,
6957c478bd9Sstevel@tonic-gate 			vsop_lookup);
6967c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, nm, vpp, pnp, flags, rdir, cr);
6977c478bd9Sstevel@tonic-gate 		fem_release(femsp);
6987c478bd9Sstevel@tonic-gate 	}
6997c478bd9Sstevel@tonic-gate 	return (errc);
7007c478bd9Sstevel@tonic-gate }
7017c478bd9Sstevel@tonic-gate 
7027c478bd9Sstevel@tonic-gate static int
7037c478bd9Sstevel@tonic-gate vhead_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl,
7047c478bd9Sstevel@tonic-gate 	int mode, vnode_t **vpp, cred_t *cr, int flag)
7057c478bd9Sstevel@tonic-gate {
7067c478bd9Sstevel@tonic-gate 	femarg_t	farg;
7077c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
7087c478bd9Sstevel@tonic-gate 	int		(*func)();
7097c478bd9Sstevel@tonic-gate 	void		*arg0;
7107c478bd9Sstevel@tonic-gate 	int		errc;
7117c478bd9Sstevel@tonic-gate 
7127c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
7137c478bd9Sstevel@tonic-gate 		func = (int (*)()) (dvp->v_op->vop_create);
7147c478bd9Sstevel@tonic-gate 		arg0 = dvp;
7157c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
7167c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, name, vap, excl, mode, vpp, cr, flag);
7177c478bd9Sstevel@tonic-gate 	} else {
7187c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
7197c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
7207c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = dvp;
7217c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
7227c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_create,
7237c478bd9Sstevel@tonic-gate 			vsop_create);
7247c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, name, vap, excl, mode, vpp, cr, flag);
7257c478bd9Sstevel@tonic-gate 		fem_release(femsp);
7267c478bd9Sstevel@tonic-gate 	}
7277c478bd9Sstevel@tonic-gate 	return (errc);
7287c478bd9Sstevel@tonic-gate }
7297c478bd9Sstevel@tonic-gate 
7307c478bd9Sstevel@tonic-gate static int
7317c478bd9Sstevel@tonic-gate vhead_remove(vnode_t *dvp, char *nm, cred_t *cr)
7327c478bd9Sstevel@tonic-gate {
7337c478bd9Sstevel@tonic-gate 	femarg_t	farg;
7347c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
7357c478bd9Sstevel@tonic-gate 	int		(*func)();
7367c478bd9Sstevel@tonic-gate 	void		*arg0;
7377c478bd9Sstevel@tonic-gate 	int		errc;
7387c478bd9Sstevel@tonic-gate 
7397c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
7407c478bd9Sstevel@tonic-gate 		func = (int (*)()) (dvp->v_op->vop_remove);
7417c478bd9Sstevel@tonic-gate 		arg0 = dvp;
7427c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
7437c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, nm, cr);
7447c478bd9Sstevel@tonic-gate 	} else {
7457c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
7467c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
7477c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = dvp;
7487c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
7497c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_remove,
7507c478bd9Sstevel@tonic-gate 			vsop_remove);
7517c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, nm, cr);
7527c478bd9Sstevel@tonic-gate 		fem_release(femsp);
7537c478bd9Sstevel@tonic-gate 	}
7547c478bd9Sstevel@tonic-gate 	return (errc);
7557c478bd9Sstevel@tonic-gate }
7567c478bd9Sstevel@tonic-gate 
7577c478bd9Sstevel@tonic-gate static int
7587c478bd9Sstevel@tonic-gate vhead_link(vnode_t *tdvp, vnode_t *svp, char *tnm, cred_t *cr)
7597c478bd9Sstevel@tonic-gate {
7607c478bd9Sstevel@tonic-gate 	femarg_t	farg;
7617c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
7627c478bd9Sstevel@tonic-gate 	int		(*func)();
7637c478bd9Sstevel@tonic-gate 	void		*arg0;
7647c478bd9Sstevel@tonic-gate 	int		errc;
7657c478bd9Sstevel@tonic-gate 
7667c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(tdvp->v_femhead)) == NULL) {
7677c478bd9Sstevel@tonic-gate 		func = (int (*)()) (tdvp->v_op->vop_link);
7687c478bd9Sstevel@tonic-gate 		arg0 = tdvp;
7697c478bd9Sstevel@tonic-gate 		fem_unlock(tdvp->v_femhead);
7707c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, svp, tnm, cr);
7717c478bd9Sstevel@tonic-gate 	} else {
7727c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
7737c478bd9Sstevel@tonic-gate 		fem_unlock(tdvp->v_femhead);
7747c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = tdvp;
7757c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
7767c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_link, vsop_link);
7777c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, svp, tnm, cr);
7787c478bd9Sstevel@tonic-gate 		fem_release(femsp);
7797c478bd9Sstevel@tonic-gate 	}
7807c478bd9Sstevel@tonic-gate 	return (errc);
7817c478bd9Sstevel@tonic-gate }
7827c478bd9Sstevel@tonic-gate 
7837c478bd9Sstevel@tonic-gate static int
7847c478bd9Sstevel@tonic-gate vhead_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm,
7857c478bd9Sstevel@tonic-gate 	cred_t *cr)
7867c478bd9Sstevel@tonic-gate {
7877c478bd9Sstevel@tonic-gate 	femarg_t	farg;
7887c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
7897c478bd9Sstevel@tonic-gate 	int		(*func)();
7907c478bd9Sstevel@tonic-gate 	void		*arg0;
7917c478bd9Sstevel@tonic-gate 	int		errc;
7927c478bd9Sstevel@tonic-gate 
7937c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(sdvp->v_femhead)) == NULL) {
7947c478bd9Sstevel@tonic-gate 		func = (int (*)()) (sdvp->v_op->vop_rename);
7957c478bd9Sstevel@tonic-gate 		arg0 = sdvp;
7967c478bd9Sstevel@tonic-gate 		fem_unlock(sdvp->v_femhead);
7977c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, snm, tdvp, tnm, cr);
7987c478bd9Sstevel@tonic-gate 	} else {
7997c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
8007c478bd9Sstevel@tonic-gate 		fem_unlock(sdvp->v_femhead);
8017c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = sdvp;
8027c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
8037c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_rename,
8047c478bd9Sstevel@tonic-gate 			vsop_rename);
8057c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, snm, tdvp, tnm, cr);
8067c478bd9Sstevel@tonic-gate 		fem_release(femsp);
8077c478bd9Sstevel@tonic-gate 	}
8087c478bd9Sstevel@tonic-gate 	return (errc);
8097c478bd9Sstevel@tonic-gate }
8107c478bd9Sstevel@tonic-gate 
8117c478bd9Sstevel@tonic-gate static int
8127c478bd9Sstevel@tonic-gate vhead_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp,
8137c478bd9Sstevel@tonic-gate 	cred_t *cr)
8147c478bd9Sstevel@tonic-gate {
8157c478bd9Sstevel@tonic-gate 	femarg_t	farg;
8167c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
8177c478bd9Sstevel@tonic-gate 	int		(*func)();
8187c478bd9Sstevel@tonic-gate 	void		*arg0;
8197c478bd9Sstevel@tonic-gate 	int		errc;
8207c478bd9Sstevel@tonic-gate 
8217c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
8227c478bd9Sstevel@tonic-gate 		func = (int (*)()) (dvp->v_op->vop_mkdir);
8237c478bd9Sstevel@tonic-gate 		arg0 = dvp;
8247c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
8257c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, dirname, vap, vpp, cr);
8267c478bd9Sstevel@tonic-gate 	} else {
8277c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
8287c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
8297c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = dvp;
8307c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
8317c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_mkdir, vsop_mkdir);
8327c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, dirname, vap, vpp, cr);
8337c478bd9Sstevel@tonic-gate 		fem_release(femsp);
8347c478bd9Sstevel@tonic-gate 	}
8357c478bd9Sstevel@tonic-gate 	return (errc);
8367c478bd9Sstevel@tonic-gate }
8377c478bd9Sstevel@tonic-gate 
8387c478bd9Sstevel@tonic-gate static int
8397c478bd9Sstevel@tonic-gate vhead_rmdir(vnode_t *dvp, char *nm, vnode_t *cdir, cred_t *cr)
8407c478bd9Sstevel@tonic-gate {
8417c478bd9Sstevel@tonic-gate 	femarg_t	farg;
8427c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
8437c478bd9Sstevel@tonic-gate 	int		(*func)();
8447c478bd9Sstevel@tonic-gate 	void		*arg0;
8457c478bd9Sstevel@tonic-gate 	int		errc;
8467c478bd9Sstevel@tonic-gate 
8477c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
8487c478bd9Sstevel@tonic-gate 		func = (int (*)()) (dvp->v_op->vop_rmdir);
8497c478bd9Sstevel@tonic-gate 		arg0 = dvp;
8507c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
8517c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, nm, cdir, cr);
8527c478bd9Sstevel@tonic-gate 	} else {
8537c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
8547c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
8557c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = dvp;
8567c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
8577c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_rmdir, vsop_rmdir);
8587c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, nm, cdir, cr);
8597c478bd9Sstevel@tonic-gate 		fem_release(femsp);
8607c478bd9Sstevel@tonic-gate 	}
8617c478bd9Sstevel@tonic-gate 	return (errc);
8627c478bd9Sstevel@tonic-gate }
8637c478bd9Sstevel@tonic-gate 
8647c478bd9Sstevel@tonic-gate static int
8657c478bd9Sstevel@tonic-gate vhead_readdir(vnode_t *vp, uio_t *uiop, cred_t *cr, int *eofp)
8667c478bd9Sstevel@tonic-gate {
8677c478bd9Sstevel@tonic-gate 	femarg_t	farg;
8687c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
8697c478bd9Sstevel@tonic-gate 	int		(*func)();
8707c478bd9Sstevel@tonic-gate 	void		*arg0;
8717c478bd9Sstevel@tonic-gate 	int		errc;
8727c478bd9Sstevel@tonic-gate 
8737c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
8747c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_readdir);
8757c478bd9Sstevel@tonic-gate 		arg0 = vp;
8767c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
8777c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, cr, eofp);
8787c478bd9Sstevel@tonic-gate 	} else {
8797c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
8807c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
8817c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
8827c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
8837c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_readdir,
8847c478bd9Sstevel@tonic-gate 			vsop_readdir);
8857c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, cr, eofp);
8867c478bd9Sstevel@tonic-gate 		fem_release(femsp);
8877c478bd9Sstevel@tonic-gate 	}
8887c478bd9Sstevel@tonic-gate 	return (errc);
8897c478bd9Sstevel@tonic-gate }
8907c478bd9Sstevel@tonic-gate 
8917c478bd9Sstevel@tonic-gate static int
8927c478bd9Sstevel@tonic-gate vhead_symlink(vnode_t *dvp, char *linkname, vattr_t *vap, char *target,
8937c478bd9Sstevel@tonic-gate 	cred_t *cr)
8947c478bd9Sstevel@tonic-gate {
8957c478bd9Sstevel@tonic-gate 	femarg_t	farg;
8967c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
8977c478bd9Sstevel@tonic-gate 	int		(*func)();
8987c478bd9Sstevel@tonic-gate 	void		*arg0;
8997c478bd9Sstevel@tonic-gate 	int		errc;
9007c478bd9Sstevel@tonic-gate 
9017c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(dvp->v_femhead)) == NULL) {
9027c478bd9Sstevel@tonic-gate 		func = (int (*)()) (dvp->v_op->vop_symlink);
9037c478bd9Sstevel@tonic-gate 		arg0 = dvp;
9047c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
9057c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, linkname, vap, target, cr);
9067c478bd9Sstevel@tonic-gate 	} else {
9077c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
9087c478bd9Sstevel@tonic-gate 		fem_unlock(dvp->v_femhead);
9097c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = dvp;
9107c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
9117c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_symlink,
9127c478bd9Sstevel@tonic-gate 			vsop_symlink);
9137c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, linkname, vap, target, cr);
9147c478bd9Sstevel@tonic-gate 		fem_release(femsp);
9157c478bd9Sstevel@tonic-gate 	}
9167c478bd9Sstevel@tonic-gate 	return (errc);
9177c478bd9Sstevel@tonic-gate }
9187c478bd9Sstevel@tonic-gate 
9197c478bd9Sstevel@tonic-gate static int
9207c478bd9Sstevel@tonic-gate vhead_readlink(vnode_t *vp, uio_t *uiop, cred_t *cr)
9217c478bd9Sstevel@tonic-gate {
9227c478bd9Sstevel@tonic-gate 	femarg_t	farg;
9237c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
9247c478bd9Sstevel@tonic-gate 	int		(*func)();
9257c478bd9Sstevel@tonic-gate 	void		*arg0;
9267c478bd9Sstevel@tonic-gate 	int		errc;
9277c478bd9Sstevel@tonic-gate 
9287c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
9297c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_readlink);
9307c478bd9Sstevel@tonic-gate 		arg0 = vp;
9317c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
9327c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, cr);
9337c478bd9Sstevel@tonic-gate 	} else {
9347c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
9357c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
9367c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
9377c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
9387c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_readlink,
9397c478bd9Sstevel@tonic-gate 			vsop_readlink);
9407c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, uiop, cr);
9417c478bd9Sstevel@tonic-gate 		fem_release(femsp);
9427c478bd9Sstevel@tonic-gate 	}
9437c478bd9Sstevel@tonic-gate 	return (errc);
9447c478bd9Sstevel@tonic-gate }
9457c478bd9Sstevel@tonic-gate 
9467c478bd9Sstevel@tonic-gate static int
9477c478bd9Sstevel@tonic-gate vhead_fsync(vnode_t *vp, int syncflag, cred_t *cr)
9487c478bd9Sstevel@tonic-gate {
9497c478bd9Sstevel@tonic-gate 	femarg_t	farg;
9507c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
9517c478bd9Sstevel@tonic-gate 	int		(*func)();
9527c478bd9Sstevel@tonic-gate 	void		*arg0;
9537c478bd9Sstevel@tonic-gate 	int		errc;
9547c478bd9Sstevel@tonic-gate 
9557c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
9567c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_fsync);
9577c478bd9Sstevel@tonic-gate 		arg0 = vp;
9587c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
9597c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, syncflag, cr);
9607c478bd9Sstevel@tonic-gate 	} else {
9617c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
9627c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
9637c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
9647c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
9657c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_fsync, vsop_fsync);
9667c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, syncflag, cr);
9677c478bd9Sstevel@tonic-gate 		fem_release(femsp);
9687c478bd9Sstevel@tonic-gate 	}
9697c478bd9Sstevel@tonic-gate 	return (errc);
9707c478bd9Sstevel@tonic-gate }
9717c478bd9Sstevel@tonic-gate 
9727c478bd9Sstevel@tonic-gate static void
9737c478bd9Sstevel@tonic-gate vhead_inactive(vnode_t *vp, cred_t *cr)
9747c478bd9Sstevel@tonic-gate {
9757c478bd9Sstevel@tonic-gate 	femarg_t	farg;
9767c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
9777c478bd9Sstevel@tonic-gate 	void		(*func)();
9787c478bd9Sstevel@tonic-gate 	void		*arg0;
9797c478bd9Sstevel@tonic-gate 
9807c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
9817c478bd9Sstevel@tonic-gate 		func = (void (*)()) (vp->v_op->vop_inactive);
9827c478bd9Sstevel@tonic-gate 		arg0 = vp;
9837c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
9847c478bd9Sstevel@tonic-gate 		(*func)(arg0, cr);
9857c478bd9Sstevel@tonic-gate 	} else {
9867c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
9877c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
9887c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
9897c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
9907c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, void, &arg0, vop_inactive,
9917c478bd9Sstevel@tonic-gate 			vsop_inactive);
9927c478bd9Sstevel@tonic-gate 		(*func)(arg0, cr);
9937c478bd9Sstevel@tonic-gate 		fem_release(femsp);
9947c478bd9Sstevel@tonic-gate 	}
9957c478bd9Sstevel@tonic-gate }
9967c478bd9Sstevel@tonic-gate 
9977c478bd9Sstevel@tonic-gate static int
9987c478bd9Sstevel@tonic-gate vhead_fid(vnode_t *vp, fid_t *fidp)
9997c478bd9Sstevel@tonic-gate {
10007c478bd9Sstevel@tonic-gate 	femarg_t	farg;
10017c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
10027c478bd9Sstevel@tonic-gate 	int		(*func)();
10037c478bd9Sstevel@tonic-gate 	void		*arg0;
10047c478bd9Sstevel@tonic-gate 	int		errc;
10057c478bd9Sstevel@tonic-gate 
10067c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
10077c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_fid);
10087c478bd9Sstevel@tonic-gate 		arg0 = vp;
10097c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10107c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, fidp);
10117c478bd9Sstevel@tonic-gate 	} else {
10127c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
10137c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10147c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
10157c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
10167c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_fid, vsop_fid);
10177c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, fidp);
10187c478bd9Sstevel@tonic-gate 		fem_release(femsp);
10197c478bd9Sstevel@tonic-gate 	}
10207c478bd9Sstevel@tonic-gate 	return (errc);
10217c478bd9Sstevel@tonic-gate }
10227c478bd9Sstevel@tonic-gate 
10237c478bd9Sstevel@tonic-gate static int
10247c478bd9Sstevel@tonic-gate vhead_rwlock(vnode_t *vp, int write_lock, caller_context_t *ct)
10257c478bd9Sstevel@tonic-gate {
10267c478bd9Sstevel@tonic-gate 	femarg_t	farg;
10277c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
10287c478bd9Sstevel@tonic-gate 	int		(*func)();
10297c478bd9Sstevel@tonic-gate 	void		*arg0;
10307c478bd9Sstevel@tonic-gate 	int		errc;
10317c478bd9Sstevel@tonic-gate 
10327c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
10337c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_rwlock);
10347c478bd9Sstevel@tonic-gate 		arg0 = vp;
10357c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10367c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, write_lock, ct);
10377c478bd9Sstevel@tonic-gate 	} else {
10387c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
10397c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10407c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
10417c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
10427c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_rwlock,
10437c478bd9Sstevel@tonic-gate 			vsop_rwlock);
10447c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, write_lock, ct);
10457c478bd9Sstevel@tonic-gate 		fem_release(femsp);
10467c478bd9Sstevel@tonic-gate 	}
10477c478bd9Sstevel@tonic-gate 	return (errc);
10487c478bd9Sstevel@tonic-gate }
10497c478bd9Sstevel@tonic-gate 
10507c478bd9Sstevel@tonic-gate static void
10517c478bd9Sstevel@tonic-gate vhead_rwunlock(vnode_t *vp, int write_lock, caller_context_t *ct)
10527c478bd9Sstevel@tonic-gate {
10537c478bd9Sstevel@tonic-gate 	femarg_t	farg;
10547c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
10557c478bd9Sstevel@tonic-gate 	void		(*func)();
10567c478bd9Sstevel@tonic-gate 	void		*arg0;
10577c478bd9Sstevel@tonic-gate 
10587c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
10597c478bd9Sstevel@tonic-gate 		func = (void (*)()) (vp->v_op->vop_rwunlock);
10607c478bd9Sstevel@tonic-gate 		arg0 = vp;
10617c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10627c478bd9Sstevel@tonic-gate 		(*func)(arg0, write_lock, ct);
10637c478bd9Sstevel@tonic-gate 	} else {
10647c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
10657c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10667c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
10677c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
10687c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, void, &arg0, vop_rwunlock,
10697c478bd9Sstevel@tonic-gate 			vsop_rwunlock);
10707c478bd9Sstevel@tonic-gate 		(*func)(arg0, write_lock, ct);
10717c478bd9Sstevel@tonic-gate 		fem_release(femsp);
10727c478bd9Sstevel@tonic-gate 	}
10737c478bd9Sstevel@tonic-gate }
10747c478bd9Sstevel@tonic-gate 
10757c478bd9Sstevel@tonic-gate static int
10767c478bd9Sstevel@tonic-gate vhead_seek(vnode_t *vp, offset_t ooff, offset_t *noffp)
10777c478bd9Sstevel@tonic-gate {
10787c478bd9Sstevel@tonic-gate 	femarg_t	farg;
10797c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
10807c478bd9Sstevel@tonic-gate 	int		(*func)();
10817c478bd9Sstevel@tonic-gate 	void		*arg0;
10827c478bd9Sstevel@tonic-gate 	int		errc;
10837c478bd9Sstevel@tonic-gate 
10847c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
10857c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_seek);
10867c478bd9Sstevel@tonic-gate 		arg0 = vp;
10877c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10887c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, ooff, noffp);
10897c478bd9Sstevel@tonic-gate 	} else {
10907c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
10917c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
10927c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
10937c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
10947c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_seek, vsop_seek);
10957c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, ooff, noffp);
10967c478bd9Sstevel@tonic-gate 		fem_release(femsp);
10977c478bd9Sstevel@tonic-gate 	}
10987c478bd9Sstevel@tonic-gate 	return (errc);
10997c478bd9Sstevel@tonic-gate }
11007c478bd9Sstevel@tonic-gate 
11017c478bd9Sstevel@tonic-gate static int
11027c478bd9Sstevel@tonic-gate vhead_cmp(vnode_t *vp1, vnode_t *vp2)
11037c478bd9Sstevel@tonic-gate {
11047c478bd9Sstevel@tonic-gate 	femarg_t	farg;
11057c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
11067c478bd9Sstevel@tonic-gate 	int		(*func)();
11077c478bd9Sstevel@tonic-gate 	void		*arg0;
11087c478bd9Sstevel@tonic-gate 	int		errc;
11097c478bd9Sstevel@tonic-gate 
11107c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp1->v_femhead)) == NULL) {
11117c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp1->v_op->vop_cmp);
11127c478bd9Sstevel@tonic-gate 		arg0 = vp1;
11137c478bd9Sstevel@tonic-gate 		fem_unlock(vp1->v_femhead);
11147c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vp2);
11157c478bd9Sstevel@tonic-gate 	} else {
11167c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
11177c478bd9Sstevel@tonic-gate 		fem_unlock(vp1->v_femhead);
11187c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp1;
11197c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
11207c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_cmp, vsop_cmp);
11217c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vp2);
11227c478bd9Sstevel@tonic-gate 		fem_release(femsp);
11237c478bd9Sstevel@tonic-gate 	}
11247c478bd9Sstevel@tonic-gate 	return (errc);
11257c478bd9Sstevel@tonic-gate }
11267c478bd9Sstevel@tonic-gate 
11277c478bd9Sstevel@tonic-gate static int
11287c478bd9Sstevel@tonic-gate vhead_frlock(vnode_t *vp, int cmd, struct flock64 *bfp, int flag,
11297c478bd9Sstevel@tonic-gate 	offset_t offset, struct flk_callback *flk_cbp, cred_t *cr)
11307c478bd9Sstevel@tonic-gate {
11317c478bd9Sstevel@tonic-gate 	femarg_t	farg;
11327c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
11337c478bd9Sstevel@tonic-gate 	int		(*func)();
11347c478bd9Sstevel@tonic-gate 	void		*arg0;
11357c478bd9Sstevel@tonic-gate 	int		errc;
11367c478bd9Sstevel@tonic-gate 
11377c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
11387c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_frlock);
11397c478bd9Sstevel@tonic-gate 		arg0 = vp;
11407c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
11417c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, bfp, flag, offset, flk_cbp, cr);
11427c478bd9Sstevel@tonic-gate 	} else {
11437c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
11447c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
11457c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
11467c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
11477c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_frlock,
11487c478bd9Sstevel@tonic-gate 			vsop_frlock);
11497c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, bfp, flag, offset, flk_cbp, cr);
11507c478bd9Sstevel@tonic-gate 		fem_release(femsp);
11517c478bd9Sstevel@tonic-gate 	}
11527c478bd9Sstevel@tonic-gate 	return (errc);
11537c478bd9Sstevel@tonic-gate }
11547c478bd9Sstevel@tonic-gate 
11557c478bd9Sstevel@tonic-gate static int
11567c478bd9Sstevel@tonic-gate vhead_space(vnode_t *vp, int cmd, struct flock64 *bfp, int flag,
11577c478bd9Sstevel@tonic-gate 	offset_t offset, cred_t *cr, caller_context_t *ct)
11587c478bd9Sstevel@tonic-gate {
11597c478bd9Sstevel@tonic-gate 	femarg_t	farg;
11607c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
11617c478bd9Sstevel@tonic-gate 	int		(*func)();
11627c478bd9Sstevel@tonic-gate 	void		*arg0;
11637c478bd9Sstevel@tonic-gate 	int		errc;
11647c478bd9Sstevel@tonic-gate 
11657c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
11667c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_space);
11677c478bd9Sstevel@tonic-gate 		arg0 = vp;
11687c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
11697c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, bfp, flag, offset, cr, ct);
11707c478bd9Sstevel@tonic-gate 	} else {
11717c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
11727c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
11737c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
11747c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
11757c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_space, vsop_space);
11767c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, bfp, flag, offset, cr, ct);
11777c478bd9Sstevel@tonic-gate 		fem_release(femsp);
11787c478bd9Sstevel@tonic-gate 	}
11797c478bd9Sstevel@tonic-gate 	return (errc);
11807c478bd9Sstevel@tonic-gate }
11817c478bd9Sstevel@tonic-gate 
11827c478bd9Sstevel@tonic-gate static int
11837c478bd9Sstevel@tonic-gate vhead_realvp(vnode_t *vp, vnode_t **vpp)
11847c478bd9Sstevel@tonic-gate {
11857c478bd9Sstevel@tonic-gate 	femarg_t	farg;
11867c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
11877c478bd9Sstevel@tonic-gate 	int		(*func)();
11887c478bd9Sstevel@tonic-gate 	void		*arg0;
11897c478bd9Sstevel@tonic-gate 	int		errc;
11907c478bd9Sstevel@tonic-gate 
11917c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
11927c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_realvp);
11937c478bd9Sstevel@tonic-gate 		arg0 = vp;
11947c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
11957c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vpp);
11967c478bd9Sstevel@tonic-gate 	} else {
11977c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
11987c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
11997c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
12007c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
12017c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_realvp,
12027c478bd9Sstevel@tonic-gate 			vsop_realvp);
12037c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vpp);
12047c478bd9Sstevel@tonic-gate 		fem_release(femsp);
12057c478bd9Sstevel@tonic-gate 	}
12067c478bd9Sstevel@tonic-gate 	return (errc);
12077c478bd9Sstevel@tonic-gate }
12087c478bd9Sstevel@tonic-gate 
12097c478bd9Sstevel@tonic-gate static int
12107c478bd9Sstevel@tonic-gate vhead_getpage(vnode_t *vp, offset_t off, size_t len, uint_t *protp,
12117c478bd9Sstevel@tonic-gate 	struct page **plarr, size_t plsz, struct seg *seg, caddr_t addr,
12127c478bd9Sstevel@tonic-gate 	enum seg_rw rw, cred_t *cr)
12137c478bd9Sstevel@tonic-gate {
12147c478bd9Sstevel@tonic-gate 	femarg_t	farg;
12157c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
12167c478bd9Sstevel@tonic-gate 	int		(*func)();
12177c478bd9Sstevel@tonic-gate 	void		*arg0;
12187c478bd9Sstevel@tonic-gate 	int		errc;
12197c478bd9Sstevel@tonic-gate 
12207c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
12217c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_getpage);
12227c478bd9Sstevel@tonic-gate 		arg0 = vp;
12237c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
12247c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, len, protp, plarr, plsz, seg,
12257c478bd9Sstevel@tonic-gate 			addr, rw, cr);
12267c478bd9Sstevel@tonic-gate 	} else {
12277c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
12287c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
12297c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
12307c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
12317c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_getpage,
12327c478bd9Sstevel@tonic-gate 			vsop_getpage);
12337c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, len, protp, plarr, plsz, seg,
12347c478bd9Sstevel@tonic-gate 			addr, rw, cr);
12357c478bd9Sstevel@tonic-gate 		fem_release(femsp);
12367c478bd9Sstevel@tonic-gate 	}
12377c478bd9Sstevel@tonic-gate 	return (errc);
12387c478bd9Sstevel@tonic-gate }
12397c478bd9Sstevel@tonic-gate 
12407c478bd9Sstevel@tonic-gate static int
12417c478bd9Sstevel@tonic-gate vhead_putpage(vnode_t *vp, offset_t off, size_t len, int flags, cred_t *cr)
12427c478bd9Sstevel@tonic-gate {
12437c478bd9Sstevel@tonic-gate 	femarg_t	farg;
12447c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
12457c478bd9Sstevel@tonic-gate 	int		(*func)();
12467c478bd9Sstevel@tonic-gate 	void		*arg0;
12477c478bd9Sstevel@tonic-gate 	int		errc;
12487c478bd9Sstevel@tonic-gate 
12497c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
12507c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_putpage);
12517c478bd9Sstevel@tonic-gate 		arg0 = vp;
12527c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
12537c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, len, flags, cr);
12547c478bd9Sstevel@tonic-gate 	} else {
12557c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
12567c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
12577c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
12587c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
12597c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_putpage,
12607c478bd9Sstevel@tonic-gate 			vsop_putpage);
12617c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, len, flags, cr);
12627c478bd9Sstevel@tonic-gate 		fem_release(femsp);
12637c478bd9Sstevel@tonic-gate 	}
12647c478bd9Sstevel@tonic-gate 	return (errc);
12657c478bd9Sstevel@tonic-gate }
12667c478bd9Sstevel@tonic-gate 
12677c478bd9Sstevel@tonic-gate static int
12687c478bd9Sstevel@tonic-gate vhead_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,
12697c478bd9Sstevel@tonic-gate 	size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
12707c478bd9Sstevel@tonic-gate 	cred_t *cr)
12717c478bd9Sstevel@tonic-gate {
12727c478bd9Sstevel@tonic-gate 	femarg_t	farg;
12737c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
12747c478bd9Sstevel@tonic-gate 	int		(*func)();
12757c478bd9Sstevel@tonic-gate 	void		*arg0;
12767c478bd9Sstevel@tonic-gate 	int		errc;
12777c478bd9Sstevel@tonic-gate 
12787c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
12797c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_map);
12807c478bd9Sstevel@tonic-gate 		arg0 = vp;
12817c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
12827c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, as, addrp, len, prot, maxprot,
12837c478bd9Sstevel@tonic-gate 			flags, cr);
12847c478bd9Sstevel@tonic-gate 	} else {
12857c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
12867c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
12877c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
12887c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
12897c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_map, vsop_map);
12907c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, as, addrp, len, prot, maxprot,
12917c478bd9Sstevel@tonic-gate 			flags, cr);
12927c478bd9Sstevel@tonic-gate 		fem_release(femsp);
12937c478bd9Sstevel@tonic-gate 	}
12947c478bd9Sstevel@tonic-gate 	return (errc);
12957c478bd9Sstevel@tonic-gate }
12967c478bd9Sstevel@tonic-gate 
12977c478bd9Sstevel@tonic-gate static int
12987c478bd9Sstevel@tonic-gate vhead_addmap(vnode_t *vp, offset_t off, struct as *as, caddr_t addr,
12997c478bd9Sstevel@tonic-gate 	size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
13007c478bd9Sstevel@tonic-gate 	cred_t *cr)
13017c478bd9Sstevel@tonic-gate {
13027c478bd9Sstevel@tonic-gate 	femarg_t	farg;
13037c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
13047c478bd9Sstevel@tonic-gate 	int		(*func)();
13057c478bd9Sstevel@tonic-gate 	void		*arg0;
13067c478bd9Sstevel@tonic-gate 	int		errc;
13077c478bd9Sstevel@tonic-gate 
13087c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
13097c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_addmap);
13107c478bd9Sstevel@tonic-gate 		arg0 = vp;
13117c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
13127c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
13137c478bd9Sstevel@tonic-gate 			flags, cr);
13147c478bd9Sstevel@tonic-gate 	} else {
13157c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
13167c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
13177c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
13187c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
13197c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_addmap,
13207c478bd9Sstevel@tonic-gate 			vsop_addmap);
13217c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
13227c478bd9Sstevel@tonic-gate 			flags, cr);
13237c478bd9Sstevel@tonic-gate 		fem_release(femsp);
13247c478bd9Sstevel@tonic-gate 	}
13257c478bd9Sstevel@tonic-gate 	return (errc);
13267c478bd9Sstevel@tonic-gate }
13277c478bd9Sstevel@tonic-gate 
13287c478bd9Sstevel@tonic-gate static int
13297c478bd9Sstevel@tonic-gate vhead_delmap(vnode_t *vp, offset_t off, struct as *as, caddr_t addr,
13307c478bd9Sstevel@tonic-gate 	size_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cr)
13317c478bd9Sstevel@tonic-gate {
13327c478bd9Sstevel@tonic-gate 	femarg_t	farg;
13337c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
13347c478bd9Sstevel@tonic-gate 	int		(*func)();
13357c478bd9Sstevel@tonic-gate 	void		*arg0;
13367c478bd9Sstevel@tonic-gate 	int		errc;
13377c478bd9Sstevel@tonic-gate 
13387c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
13397c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_delmap);
13407c478bd9Sstevel@tonic-gate 		arg0 = vp;
13417c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
13427c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
13437c478bd9Sstevel@tonic-gate 			flags, cr);
13447c478bd9Sstevel@tonic-gate 	} else {
13457c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
13467c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
13477c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
13487c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
13497c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_delmap,
13507c478bd9Sstevel@tonic-gate 			vsop_delmap);
13517c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, off, as, addr, len, prot, maxprot,
13527c478bd9Sstevel@tonic-gate 			flags, cr);
13537c478bd9Sstevel@tonic-gate 		fem_release(femsp);
13547c478bd9Sstevel@tonic-gate 	}
13557c478bd9Sstevel@tonic-gate 	return (errc);
13567c478bd9Sstevel@tonic-gate }
13577c478bd9Sstevel@tonic-gate 
13587c478bd9Sstevel@tonic-gate static int
13597c478bd9Sstevel@tonic-gate vhead_poll(vnode_t *vp, short events, int anyyet, short *reventsp,
13607c478bd9Sstevel@tonic-gate 	struct pollhead **phpp)
13617c478bd9Sstevel@tonic-gate {
13627c478bd9Sstevel@tonic-gate 	femarg_t	farg;
13637c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
13647c478bd9Sstevel@tonic-gate 	int		(*func)();
13657c478bd9Sstevel@tonic-gate 	void		*arg0;
13667c478bd9Sstevel@tonic-gate 	int		errc;
13677c478bd9Sstevel@tonic-gate 
13687c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
13697c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_poll);
13707c478bd9Sstevel@tonic-gate 		arg0 = vp;
13717c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
13727c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, events, anyyet, reventsp, phpp);
13737c478bd9Sstevel@tonic-gate 	} else {
13747c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
13757c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
13767c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
13777c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
13787c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_poll, vsop_poll);
13797c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, events, anyyet, reventsp, phpp);
13807c478bd9Sstevel@tonic-gate 		fem_release(femsp);
13817c478bd9Sstevel@tonic-gate 	}
13827c478bd9Sstevel@tonic-gate 	return (errc);
13837c478bd9Sstevel@tonic-gate }
13847c478bd9Sstevel@tonic-gate 
13857c478bd9Sstevel@tonic-gate static int
13867c478bd9Sstevel@tonic-gate vhead_dump(vnode_t *vp, caddr_t addr, int lbdn, int dblks)
13877c478bd9Sstevel@tonic-gate {
13887c478bd9Sstevel@tonic-gate 	femarg_t	farg;
13897c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
13907c478bd9Sstevel@tonic-gate 	int		(*func)();
13917c478bd9Sstevel@tonic-gate 	void		*arg0;
13927c478bd9Sstevel@tonic-gate 	int		errc;
13937c478bd9Sstevel@tonic-gate 
13947c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
13957c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_dump);
13967c478bd9Sstevel@tonic-gate 		arg0 = vp;
13977c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
13987c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, addr, lbdn, dblks);
13997c478bd9Sstevel@tonic-gate 	} else {
14007c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
14017c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
14027c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
14037c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
14047c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_dump, vsop_dump);
14057c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, addr, lbdn, dblks);
14067c478bd9Sstevel@tonic-gate 		fem_release(femsp);
14077c478bd9Sstevel@tonic-gate 	}
14087c478bd9Sstevel@tonic-gate 	return (errc);
14097c478bd9Sstevel@tonic-gate }
14107c478bd9Sstevel@tonic-gate 
14117c478bd9Sstevel@tonic-gate static int
14127c478bd9Sstevel@tonic-gate vhead_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr)
14137c478bd9Sstevel@tonic-gate {
14147c478bd9Sstevel@tonic-gate 	femarg_t	farg;
14157c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
14167c478bd9Sstevel@tonic-gate 	int		(*func)();
14177c478bd9Sstevel@tonic-gate 	void		*arg0;
14187c478bd9Sstevel@tonic-gate 	int		errc;
14197c478bd9Sstevel@tonic-gate 
14207c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
14217c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_pathconf);
14227c478bd9Sstevel@tonic-gate 		arg0 = vp;
14237c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
14247c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, valp, cr);
14257c478bd9Sstevel@tonic-gate 	} else {
14267c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
14277c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
14287c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
14297c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
14307c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_pathconf,
14317c478bd9Sstevel@tonic-gate 			vsop_pathconf);
14327c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, valp, cr);
14337c478bd9Sstevel@tonic-gate 		fem_release(femsp);
14347c478bd9Sstevel@tonic-gate 	}
14357c478bd9Sstevel@tonic-gate 	return (errc);
14367c478bd9Sstevel@tonic-gate }
14377c478bd9Sstevel@tonic-gate 
14387c478bd9Sstevel@tonic-gate static int
14397c478bd9Sstevel@tonic-gate vhead_pageio(vnode_t *vp, struct page *pp, u_offset_t io_off,
14407c478bd9Sstevel@tonic-gate 	size_t io_len, int flags, cred_t *cr)
14417c478bd9Sstevel@tonic-gate {
14427c478bd9Sstevel@tonic-gate 	femarg_t	farg;
14437c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
14447c478bd9Sstevel@tonic-gate 	int		(*func)();
14457c478bd9Sstevel@tonic-gate 	void		*arg0;
14467c478bd9Sstevel@tonic-gate 	int		errc;
14477c478bd9Sstevel@tonic-gate 
14487c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
14497c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_pageio);
14507c478bd9Sstevel@tonic-gate 		arg0 = vp;
14517c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
14527c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, pp, io_off, io_len, flags, cr);
14537c478bd9Sstevel@tonic-gate 	} else {
14547c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
14557c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
14567c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
14577c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
14587c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_pageio,
14597c478bd9Sstevel@tonic-gate 			vsop_pageio);
14607c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, pp, io_off, io_len, flags, cr);
14617c478bd9Sstevel@tonic-gate 		fem_release(femsp);
14627c478bd9Sstevel@tonic-gate 	}
14637c478bd9Sstevel@tonic-gate 	return (errc);
14647c478bd9Sstevel@tonic-gate }
14657c478bd9Sstevel@tonic-gate 
14667c478bd9Sstevel@tonic-gate static int
14677c478bd9Sstevel@tonic-gate vhead_dumpctl(vnode_t *vp, int action, int *blkp)
14687c478bd9Sstevel@tonic-gate {
14697c478bd9Sstevel@tonic-gate 	femarg_t	farg;
14707c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
14717c478bd9Sstevel@tonic-gate 	int		(*func)();
14727c478bd9Sstevel@tonic-gate 	void		*arg0;
14737c478bd9Sstevel@tonic-gate 	int		errc;
14747c478bd9Sstevel@tonic-gate 
14757c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
14767c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_dumpctl);
14777c478bd9Sstevel@tonic-gate 		arg0 = vp;
14787c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
14797c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, action, blkp);
14807c478bd9Sstevel@tonic-gate 	} else {
14817c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
14827c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
14837c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
14847c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
14857c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_dumpctl,
14867c478bd9Sstevel@tonic-gate 			vsop_dumpctl);
14877c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, action, blkp);
14887c478bd9Sstevel@tonic-gate 		fem_release(femsp);
14897c478bd9Sstevel@tonic-gate 	}
14907c478bd9Sstevel@tonic-gate 	return (errc);
14917c478bd9Sstevel@tonic-gate }
14927c478bd9Sstevel@tonic-gate 
14937c478bd9Sstevel@tonic-gate static void
14947c478bd9Sstevel@tonic-gate vhead_dispose(vnode_t *vp, struct page *pp, int flag, int dn, cred_t *cr)
14957c478bd9Sstevel@tonic-gate {
14967c478bd9Sstevel@tonic-gate 	femarg_t	farg;
14977c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
14987c478bd9Sstevel@tonic-gate 	void		(*func)();
14997c478bd9Sstevel@tonic-gate 	void		*arg0;
15007c478bd9Sstevel@tonic-gate 
15017c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
15027c478bd9Sstevel@tonic-gate 		func = (void (*)()) (vp->v_op->vop_dispose);
15037c478bd9Sstevel@tonic-gate 		arg0 = vp;
15047c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15057c478bd9Sstevel@tonic-gate 		(*func)(arg0, pp, flag, dn, cr);
15067c478bd9Sstevel@tonic-gate 	} else {
15077c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
15087c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15097c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
15107c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15117c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, void, &arg0, vop_dispose,
15127c478bd9Sstevel@tonic-gate 			vsop_dispose);
15137c478bd9Sstevel@tonic-gate 		(*func)(arg0, pp, flag, dn, cr);
15147c478bd9Sstevel@tonic-gate 		fem_release(femsp);
15157c478bd9Sstevel@tonic-gate 	}
15167c478bd9Sstevel@tonic-gate }
15177c478bd9Sstevel@tonic-gate 
15187c478bd9Sstevel@tonic-gate static int
15197c478bd9Sstevel@tonic-gate vhead_setsecattr(vnode_t *vp, vsecattr_t *vsap, int flag, cred_t *cr)
15207c478bd9Sstevel@tonic-gate {
15217c478bd9Sstevel@tonic-gate 	femarg_t	farg;
15227c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
15237c478bd9Sstevel@tonic-gate 	int		(*func)();
15247c478bd9Sstevel@tonic-gate 	void		*arg0;
15257c478bd9Sstevel@tonic-gate 	int		errc;
15267c478bd9Sstevel@tonic-gate 
15277c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
15287c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_setsecattr);
15297c478bd9Sstevel@tonic-gate 		arg0 = vp;
15307c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15317c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vsap, flag, cr);
15327c478bd9Sstevel@tonic-gate 	} else {
15337c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
15347c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15357c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
15367c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15377c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_setsecattr,
15387c478bd9Sstevel@tonic-gate 			vsop_setsecattr);
15397c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vsap, flag, cr);
15407c478bd9Sstevel@tonic-gate 		fem_release(femsp);
15417c478bd9Sstevel@tonic-gate 	}
15427c478bd9Sstevel@tonic-gate 	return (errc);
15437c478bd9Sstevel@tonic-gate }
15447c478bd9Sstevel@tonic-gate 
15457c478bd9Sstevel@tonic-gate static int
15467c478bd9Sstevel@tonic-gate vhead_getsecattr(vnode_t *vp, vsecattr_t *vsap, int flag, cred_t *cr)
15477c478bd9Sstevel@tonic-gate {
15487c478bd9Sstevel@tonic-gate 	femarg_t	farg;
15497c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
15507c478bd9Sstevel@tonic-gate 	int		(*func)();
15517c478bd9Sstevel@tonic-gate 	void		*arg0;
15527c478bd9Sstevel@tonic-gate 	int		errc;
15537c478bd9Sstevel@tonic-gate 
15547c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
15557c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_getsecattr);
15567c478bd9Sstevel@tonic-gate 		arg0 = vp;
15577c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15587c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vsap, flag, cr);
15597c478bd9Sstevel@tonic-gate 	} else {
15607c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
15617c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15627c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
15637c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15647c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_getsecattr,
15657c478bd9Sstevel@tonic-gate 			vsop_getsecattr);
15667c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vsap, flag, cr);
15677c478bd9Sstevel@tonic-gate 		fem_release(femsp);
15687c478bd9Sstevel@tonic-gate 	}
15697c478bd9Sstevel@tonic-gate 	return (errc);
15707c478bd9Sstevel@tonic-gate }
15717c478bd9Sstevel@tonic-gate 
15727c478bd9Sstevel@tonic-gate static int
15737c478bd9Sstevel@tonic-gate vhead_shrlock(vnode_t *vp, int cmd, struct shrlock *shr, int flag,
15747c478bd9Sstevel@tonic-gate 	cred_t *cr)
15757c478bd9Sstevel@tonic-gate {
15767c478bd9Sstevel@tonic-gate 	femarg_t	farg;
15777c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
15787c478bd9Sstevel@tonic-gate 	int		(*func)();
15797c478bd9Sstevel@tonic-gate 	void		*arg0;
15807c478bd9Sstevel@tonic-gate 	int		errc;
15817c478bd9Sstevel@tonic-gate 
15827c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
15837c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_shrlock);
15847c478bd9Sstevel@tonic-gate 		arg0 = vp;
15857c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15867c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, shr, flag, cr);
15877c478bd9Sstevel@tonic-gate 	} else {
15887c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
15897c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
15907c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
15917c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
15927c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_shrlock,
15937c478bd9Sstevel@tonic-gate 			vsop_shrlock);
15947c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, cmd, shr, flag, cr);
15957c478bd9Sstevel@tonic-gate 		fem_release(femsp);
15967c478bd9Sstevel@tonic-gate 	}
15977c478bd9Sstevel@tonic-gate 	return (errc);
15987c478bd9Sstevel@tonic-gate }
15997c478bd9Sstevel@tonic-gate 
16007c478bd9Sstevel@tonic-gate static int
16017c478bd9Sstevel@tonic-gate vhead_vnevent(vnode_t *vp, vnevent_t vnevent)
16027c478bd9Sstevel@tonic-gate {
16037c478bd9Sstevel@tonic-gate 	femarg_t	farg;
16047c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
16057c478bd9Sstevel@tonic-gate 	int		(*func)();
16067c478bd9Sstevel@tonic-gate 	void		*arg0;
16077c478bd9Sstevel@tonic-gate 	int		errc;
16087c478bd9Sstevel@tonic-gate 
16097c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vp->v_femhead)) == NULL) {
16107c478bd9Sstevel@tonic-gate 		func = (int (*)()) (vp->v_op->vop_vnevent);
16117c478bd9Sstevel@tonic-gate 		arg0 = vp;
16127c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
16137c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vnevent);
16147c478bd9Sstevel@tonic-gate 	} else {
16157c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
16167c478bd9Sstevel@tonic-gate 		fem_unlock(vp->v_femhead);
16177c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vp = vp;
16187c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
16197c478bd9Sstevel@tonic-gate 		vsop_find(&farg, &func, int, &arg0, vop_vnevent,
16207c478bd9Sstevel@tonic-gate 			vsop_vnevent);
16217c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vnevent);
16227c478bd9Sstevel@tonic-gate 		fem_release(femsp);
16237c478bd9Sstevel@tonic-gate 	}
16247c478bd9Sstevel@tonic-gate 	return (errc);
16257c478bd9Sstevel@tonic-gate }
16267c478bd9Sstevel@tonic-gate 
16277c478bd9Sstevel@tonic-gate static int
16287c478bd9Sstevel@tonic-gate fshead_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
16297c478bd9Sstevel@tonic-gate {
16307c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
16317c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
16327c478bd9Sstevel@tonic-gate 	int		(*func)();
16337c478bd9Sstevel@tonic-gate 	void		*arg0;
16347c478bd9Sstevel@tonic-gate 	int		errc;
16357c478bd9Sstevel@tonic-gate 
16367c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
16377c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_mount;
16387c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
16397c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, mvp, uap, cr);
16407c478bd9Sstevel@tonic-gate 	} else {
16417c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
16427c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
16437c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
16447c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
16457c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_mount,
16467c478bd9Sstevel@tonic-gate 			vfsop_mount);
16477c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, mvp, uap, cr);
16487c478bd9Sstevel@tonic-gate 		fem_release(femsp);
16497c478bd9Sstevel@tonic-gate 	}
16507c478bd9Sstevel@tonic-gate 	return (errc);
16517c478bd9Sstevel@tonic-gate }
16527c478bd9Sstevel@tonic-gate 
16537c478bd9Sstevel@tonic-gate static int
16547c478bd9Sstevel@tonic-gate fshead_unmount(vfs_t *vfsp, int flag, cred_t *cr)
16557c478bd9Sstevel@tonic-gate {
16567c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
16577c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
16587c478bd9Sstevel@tonic-gate 	int		(*func)();
16597c478bd9Sstevel@tonic-gate 	void		*arg0;
16607c478bd9Sstevel@tonic-gate 	int		errc;
16617c478bd9Sstevel@tonic-gate 
16627c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
16637c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_unmount;
16647c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
16657c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, flag, cr);
16667c478bd9Sstevel@tonic-gate 	} else {
16677c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
16687c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
16697c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
16707c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
16717c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_unmount,
16727c478bd9Sstevel@tonic-gate 			vfsop_unmount);
16737c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, flag, cr);
16747c478bd9Sstevel@tonic-gate 		fem_release(femsp);
16757c478bd9Sstevel@tonic-gate 	}
16767c478bd9Sstevel@tonic-gate 	return (errc);
16777c478bd9Sstevel@tonic-gate }
16787c478bd9Sstevel@tonic-gate 
16797c478bd9Sstevel@tonic-gate static int
16807c478bd9Sstevel@tonic-gate fshead_root(vfs_t *vfsp, vnode_t **vpp)
16817c478bd9Sstevel@tonic-gate {
16827c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
16837c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
16847c478bd9Sstevel@tonic-gate 	int		(*func)();
16857c478bd9Sstevel@tonic-gate 	void		*arg0;
16867c478bd9Sstevel@tonic-gate 	int		errc;
16877c478bd9Sstevel@tonic-gate 
16887c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
16897c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_root;
16907c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
16917c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, vpp);
16927c478bd9Sstevel@tonic-gate 	} else {
16937c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
16947c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
16957c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
16967c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
16977c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_root, vfsop_root);
16987c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vpp);
16997c478bd9Sstevel@tonic-gate 		fem_release(femsp);
17007c478bd9Sstevel@tonic-gate 	}
17017c478bd9Sstevel@tonic-gate 	return (errc);
17027c478bd9Sstevel@tonic-gate }
17037c478bd9Sstevel@tonic-gate 
17047c478bd9Sstevel@tonic-gate static int
17057c478bd9Sstevel@tonic-gate fshead_statvfs(vfs_t *vfsp, statvfs64_t *sp)
17067c478bd9Sstevel@tonic-gate {
17077c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
17087c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
17097c478bd9Sstevel@tonic-gate 	int		(*func)();
17107c478bd9Sstevel@tonic-gate 	void		*arg0;
17117c478bd9Sstevel@tonic-gate 	int		errc;
17127c478bd9Sstevel@tonic-gate 
17137c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
17147c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_statvfs;
17157c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17167c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, sp);
17177c478bd9Sstevel@tonic-gate 	} else {
17187c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
17197c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17207c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
17217c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
17227c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_statvfs,
17237c478bd9Sstevel@tonic-gate 			vfsop_statvfs);
17247c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, sp);
17257c478bd9Sstevel@tonic-gate 		fem_release(femsp);
17267c478bd9Sstevel@tonic-gate 	}
17277c478bd9Sstevel@tonic-gate 	return (errc);
17287c478bd9Sstevel@tonic-gate }
17297c478bd9Sstevel@tonic-gate 
17307c478bd9Sstevel@tonic-gate static int
17317c478bd9Sstevel@tonic-gate fshead_sync(vfs_t *vfsp, short flag, cred_t *cr)
17327c478bd9Sstevel@tonic-gate {
17337c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
17347c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
17357c478bd9Sstevel@tonic-gate 	int		(*func)();
17367c478bd9Sstevel@tonic-gate 	void		*arg0;
17377c478bd9Sstevel@tonic-gate 	int		errc;
17387c478bd9Sstevel@tonic-gate 
17397c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
17407c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_sync;
17417c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17427c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, flag, cr);
17437c478bd9Sstevel@tonic-gate 	} else {
17447c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
17457c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17467c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
17477c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
17487c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_sync, vfsop_sync);
17497c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, flag, cr);
17507c478bd9Sstevel@tonic-gate 		fem_release(femsp);
17517c478bd9Sstevel@tonic-gate 	}
17527c478bd9Sstevel@tonic-gate 	return (errc);
17537c478bd9Sstevel@tonic-gate }
17547c478bd9Sstevel@tonic-gate 
17557c478bd9Sstevel@tonic-gate static int
17567c478bd9Sstevel@tonic-gate fshead_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
17577c478bd9Sstevel@tonic-gate {
17587c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
17597c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
17607c478bd9Sstevel@tonic-gate 	int		(*func)();
17617c478bd9Sstevel@tonic-gate 	void		*arg0;
17627c478bd9Sstevel@tonic-gate 	int		errc;
17637c478bd9Sstevel@tonic-gate 
17647c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
17657c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_vget;
17667c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17677c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, vpp, fidp);
17687c478bd9Sstevel@tonic-gate 	} else {
17697c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
17707c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17717c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
17727c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
17737c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_vget, vfsop_vget);
17747c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vpp, fidp);
17757c478bd9Sstevel@tonic-gate 		fem_release(femsp);
17767c478bd9Sstevel@tonic-gate 	}
17777c478bd9Sstevel@tonic-gate 	return (errc);
17787c478bd9Sstevel@tonic-gate }
17797c478bd9Sstevel@tonic-gate 
17807c478bd9Sstevel@tonic-gate static int
17817c478bd9Sstevel@tonic-gate fshead_mountroot(vfs_t *vfsp, enum whymountroot reason)
17827c478bd9Sstevel@tonic-gate {
17837c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
17847c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
17857c478bd9Sstevel@tonic-gate 	int		(*func)();
17867c478bd9Sstevel@tonic-gate 	void		*arg0;
17877c478bd9Sstevel@tonic-gate 	int		errc;
17887c478bd9Sstevel@tonic-gate 
17897c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
17907c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_mountroot;
17917c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17927c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, reason);
17937c478bd9Sstevel@tonic-gate 	} else {
17947c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
17957c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
17967c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
17977c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
17987c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_mountroot,
17997c478bd9Sstevel@tonic-gate 			vfsop_mountroot);
18007c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, reason);
18017c478bd9Sstevel@tonic-gate 		fem_release(femsp);
18027c478bd9Sstevel@tonic-gate 	}
18037c478bd9Sstevel@tonic-gate 	return (errc);
18047c478bd9Sstevel@tonic-gate }
18057c478bd9Sstevel@tonic-gate 
18067c478bd9Sstevel@tonic-gate static void
18077c478bd9Sstevel@tonic-gate fshead_freevfs(vfs_t *vfsp)
18087c478bd9Sstevel@tonic-gate {
18097c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
18107c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
18117c478bd9Sstevel@tonic-gate 	void		(*func)();
18127c478bd9Sstevel@tonic-gate 	void		*arg0;
18137c478bd9Sstevel@tonic-gate 
18147c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
18157c478bd9Sstevel@tonic-gate 		func = (void (*)()) vfsp->vfs_op->vfs_freevfs;
18167c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
18177c478bd9Sstevel@tonic-gate 		(*func)(vfsp);
18187c478bd9Sstevel@tonic-gate 	} else {
18197c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
18207c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
18217c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
18227c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
18237c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, void, &arg0, vfs_freevfs,
18247c478bd9Sstevel@tonic-gate 			vfsop_freevfs);
18257c478bd9Sstevel@tonic-gate 		(*func)(arg0);
18267c478bd9Sstevel@tonic-gate 		fem_release(femsp);
18277c478bd9Sstevel@tonic-gate 	}
18287c478bd9Sstevel@tonic-gate }
18297c478bd9Sstevel@tonic-gate 
18307c478bd9Sstevel@tonic-gate static int
18317c478bd9Sstevel@tonic-gate fshead_vnstate(vfs_t *vfsp, vnode_t *vp, vntrans_t nstate)
18327c478bd9Sstevel@tonic-gate {
18337c478bd9Sstevel@tonic-gate 	fsemarg_t	farg;
18347c478bd9Sstevel@tonic-gate 	struct fem_list	*femsp;
18357c478bd9Sstevel@tonic-gate 	int		(*func)();
18367c478bd9Sstevel@tonic-gate 	void		*arg0;
18377c478bd9Sstevel@tonic-gate 	int		errc;
18387c478bd9Sstevel@tonic-gate 
18397c478bd9Sstevel@tonic-gate 	if ((femsp = fem_lock(vfsp->vfs_femhead)) == NULL) {
18407c478bd9Sstevel@tonic-gate 		func = (int (*)()) vfsp->vfs_op->vfs_vnstate;
18417c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
18427c478bd9Sstevel@tonic-gate 		errc = (*func)(vfsp, vp, nstate);
18437c478bd9Sstevel@tonic-gate 	} else {
18447c478bd9Sstevel@tonic-gate 		fem_addref(femsp);
18457c478bd9Sstevel@tonic-gate 		fem_unlock(vfsp->vfs_femhead);
18467c478bd9Sstevel@tonic-gate 		farg.fa_vnode.vfsp = vfsp;
18477c478bd9Sstevel@tonic-gate 		farg.fa_fnode = femsp->feml_nodes + femsp->feml_tos;
18487c478bd9Sstevel@tonic-gate 		vfsop_find(&farg, &func, int, &arg0, vfs_vnstate,
18497c478bd9Sstevel@tonic-gate 			vfsop_vnstate);
18507c478bd9Sstevel@tonic-gate 		errc = (*func)(arg0, vp, nstate);
18517c478bd9Sstevel@tonic-gate 		fem_release(femsp);
18527c478bd9Sstevel@tonic-gate 	}
18537c478bd9Sstevel@tonic-gate 	return (errc);
18547c478bd9Sstevel@tonic-gate }
18557c478bd9Sstevel@tonic-gate 
18567c478bd9Sstevel@tonic-gate 
18577c478bd9Sstevel@tonic-gate /*
18587c478bd9Sstevel@tonic-gate  * specification table for the vhead vnode operations.
18597c478bd9Sstevel@tonic-gate  * It is an error for any operations to be missing.
18607c478bd9Sstevel@tonic-gate  */
18617c478bd9Sstevel@tonic-gate 
18627c478bd9Sstevel@tonic-gate static struct fs_operation_def fhead_vn_spec[] = {
18637c478bd9Sstevel@tonic-gate 	{ VOPNAME_OPEN, (femop_t *)vhead_open },
18647c478bd9Sstevel@tonic-gate 	{ VOPNAME_CLOSE, (femop_t *)vhead_close },
18657c478bd9Sstevel@tonic-gate 	{ VOPNAME_READ, (femop_t *)vhead_read },
18667c478bd9Sstevel@tonic-gate 	{ VOPNAME_WRITE, (femop_t *)vhead_write },
18677c478bd9Sstevel@tonic-gate 	{ VOPNAME_IOCTL, (femop_t *)vhead_ioctl },
18687c478bd9Sstevel@tonic-gate 	{ VOPNAME_SETFL, (femop_t *)vhead_setfl },
18697c478bd9Sstevel@tonic-gate 	{ VOPNAME_GETATTR, (femop_t *)vhead_getattr },
18707c478bd9Sstevel@tonic-gate 	{ VOPNAME_SETATTR, (femop_t *)vhead_setattr },
18717c478bd9Sstevel@tonic-gate 	{ VOPNAME_ACCESS, (femop_t *)vhead_access },
18727c478bd9Sstevel@tonic-gate 	{ VOPNAME_LOOKUP, (femop_t *)vhead_lookup },
18737c478bd9Sstevel@tonic-gate 	{ VOPNAME_CREATE, (femop_t *)vhead_create },
18747c478bd9Sstevel@tonic-gate 	{ VOPNAME_REMOVE, (femop_t *)vhead_remove },
18757c478bd9Sstevel@tonic-gate 	{ VOPNAME_LINK, (femop_t *)vhead_link },
18767c478bd9Sstevel@tonic-gate 	{ VOPNAME_RENAME, (femop_t *)vhead_rename },
18777c478bd9Sstevel@tonic-gate 	{ VOPNAME_MKDIR, (femop_t *)vhead_mkdir },
18787c478bd9Sstevel@tonic-gate 	{ VOPNAME_RMDIR, (femop_t *)vhead_rmdir },
18797c478bd9Sstevel@tonic-gate 	{ VOPNAME_READDIR, (femop_t *)vhead_readdir },
18807c478bd9Sstevel@tonic-gate 	{ VOPNAME_SYMLINK, (femop_t *)vhead_symlink },
18817c478bd9Sstevel@tonic-gate 	{ VOPNAME_READLINK, (femop_t *)vhead_readlink },
18827c478bd9Sstevel@tonic-gate 	{ VOPNAME_FSYNC, (femop_t *)vhead_fsync },
18837c478bd9Sstevel@tonic-gate 	{ VOPNAME_INACTIVE, (femop_t *)vhead_inactive },
18847c478bd9Sstevel@tonic-gate 	{ VOPNAME_FID, (femop_t *)vhead_fid },
18857c478bd9Sstevel@tonic-gate 	{ VOPNAME_RWLOCK, (femop_t *)vhead_rwlock },
18867c478bd9Sstevel@tonic-gate 	{ VOPNAME_RWUNLOCK, (femop_t *)vhead_rwunlock },
18877c478bd9Sstevel@tonic-gate 	{ VOPNAME_SEEK, (femop_t *)vhead_seek },
18887c478bd9Sstevel@tonic-gate 	{ VOPNAME_CMP, (femop_t *)vhead_cmp },
18897c478bd9Sstevel@tonic-gate 	{ VOPNAME_FRLOCK, (femop_t *)vhead_frlock },
18907c478bd9Sstevel@tonic-gate 	{ VOPNAME_SPACE, (femop_t *)vhead_space },
18917c478bd9Sstevel@tonic-gate 	{ VOPNAME_REALVP, (femop_t *)vhead_realvp },
18927c478bd9Sstevel@tonic-gate 	{ VOPNAME_GETPAGE, (femop_t *)vhead_getpage },
18937c478bd9Sstevel@tonic-gate 	{ VOPNAME_PUTPAGE, (femop_t *)vhead_putpage },
18947c478bd9Sstevel@tonic-gate 	{ VOPNAME_MAP, (femop_t *)vhead_map },
18957c478bd9Sstevel@tonic-gate 	{ VOPNAME_ADDMAP, (femop_t *)vhead_addmap },
18967c478bd9Sstevel@tonic-gate 	{ VOPNAME_DELMAP, (femop_t *)vhead_delmap },
18977c478bd9Sstevel@tonic-gate 	{ VOPNAME_POLL, (femop_t *)vhead_poll },
18987c478bd9Sstevel@tonic-gate 	{ VOPNAME_DUMP, (femop_t *)vhead_dump },
18997c478bd9Sstevel@tonic-gate 	{ VOPNAME_PATHCONF, (femop_t *)vhead_pathconf },
19007c478bd9Sstevel@tonic-gate 	{ VOPNAME_PAGEIO, (femop_t *)vhead_pageio },
19017c478bd9Sstevel@tonic-gate 	{ VOPNAME_DUMPCTL, (femop_t *)vhead_dumpctl },
19027c478bd9Sstevel@tonic-gate 	{ VOPNAME_DISPOSE, (femop_t *)vhead_dispose },
19037c478bd9Sstevel@tonic-gate 	{ VOPNAME_SETSECATTR, (femop_t *)vhead_setsecattr },
19047c478bd9Sstevel@tonic-gate 	{ VOPNAME_GETSECATTR, (femop_t *)vhead_getsecattr },
19057c478bd9Sstevel@tonic-gate 	{ VOPNAME_SHRLOCK, (femop_t *)vhead_shrlock },
19067c478bd9Sstevel@tonic-gate 	{ VOPNAME_VNEVENT, (femop_t *)vhead_vnevent },
19077c478bd9Sstevel@tonic-gate 	{	NULL,	NULL	}
19087c478bd9Sstevel@tonic-gate };
19097c478bd9Sstevel@tonic-gate 
19107c478bd9Sstevel@tonic-gate /*
19117c478bd9Sstevel@tonic-gate  * specification table for the vfshead vnode operations.
19127c478bd9Sstevel@tonic-gate  * It is an error for any operations to be missing.
19137c478bd9Sstevel@tonic-gate  */
19147c478bd9Sstevel@tonic-gate 
19157c478bd9Sstevel@tonic-gate static struct fs_operation_def fshead_vfs_spec[]  = {
19167c478bd9Sstevel@tonic-gate 	{ VFSNAME_MOUNT, (femop_t *)fshead_mount },
19177c478bd9Sstevel@tonic-gate 	{ VFSNAME_UNMOUNT, (femop_t *)fshead_unmount },
19187c478bd9Sstevel@tonic-gate 	{ VFSNAME_ROOT, (femop_t *)fshead_root },
19197c478bd9Sstevel@tonic-gate 	{ VFSNAME_STATVFS, (femop_t *)fshead_statvfs },
19207c478bd9Sstevel@tonic-gate 	{ VFSNAME_SYNC, (femop_t *)fshead_sync },
19217c478bd9Sstevel@tonic-gate 	{ VFSNAME_VGET, (femop_t *)fshead_vget },
19227c478bd9Sstevel@tonic-gate 	{ VFSNAME_MOUNTROOT, (femop_t *)fshead_mountroot },
19237c478bd9Sstevel@tonic-gate 	{ VFSNAME_FREEVFS, (femop_t *)fshead_freevfs },
19247c478bd9Sstevel@tonic-gate 	{ VFSNAME_VNSTATE, (femop_t *)fshead_vnstate },
19257c478bd9Sstevel@tonic-gate 	{	NULL,	NULL	}
19267c478bd9Sstevel@tonic-gate };
19277c478bd9Sstevel@tonic-gate 
19287c478bd9Sstevel@tonic-gate /*
19297c478bd9Sstevel@tonic-gate  * This set of routines transfer control to the next stacked monitor.
19307c478bd9Sstevel@tonic-gate  *
19317c478bd9Sstevel@tonic-gate  * Each routine is identical except for naming, types and arguments.
19327c478bd9Sstevel@tonic-gate  *
19337c478bd9Sstevel@tonic-gate  * The basic steps are:
19347c478bd9Sstevel@tonic-gate  * 1.  Decrease the stack pointer by one.
19357c478bd9Sstevel@tonic-gate  * 2.  If the current item is a base operation (vnode, vfs), goto 5.
19367c478bd9Sstevel@tonic-gate  * 3.  If the current item does not have a corresponding operation, goto 1
19377c478bd9Sstevel@tonic-gate  * 4.  Return by invoking the current item with the argument handle.
19387c478bd9Sstevel@tonic-gate  * 5.  Return by invoking the base operation with the base object.
19397c478bd9Sstevel@tonic-gate  *
19407c478bd9Sstevel@tonic-gate  * for each classification, there needs to be at least one "next" operation
19417c478bd9Sstevel@tonic-gate  * for each "head"operation.
19427c478bd9Sstevel@tonic-gate  *
19437c478bd9Sstevel@tonic-gate  */
19447c478bd9Sstevel@tonic-gate 
19457c478bd9Sstevel@tonic-gate int
19467c478bd9Sstevel@tonic-gate vnext_open(femarg_t *vf, int mode, cred_t *cr)
19477c478bd9Sstevel@tonic-gate {
19487c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
19497c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
19507c478bd9Sstevel@tonic-gate 
19517c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
19527c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
19537c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_open, vsop_open);
19547c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
19557c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
19567c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, mode, cr));
19577c478bd9Sstevel@tonic-gate }
19587c478bd9Sstevel@tonic-gate 
19597c478bd9Sstevel@tonic-gate int
19607c478bd9Sstevel@tonic-gate vnext_close(femarg_t *vf, int flag, int count, offset_t offset, cred_t *cr)
19617c478bd9Sstevel@tonic-gate {
19627c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
19637c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
19647c478bd9Sstevel@tonic-gate 
19657c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
19667c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
19677c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_close, vsop_close);
19687c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
19697c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
19707c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, flag, count, offset, cr));
19717c478bd9Sstevel@tonic-gate }
19727c478bd9Sstevel@tonic-gate 
19737c478bd9Sstevel@tonic-gate int
19747c478bd9Sstevel@tonic-gate vnext_read(femarg_t *vf, uio_t *uiop, int ioflag, cred_t *cr,
19757c478bd9Sstevel@tonic-gate 	struct caller_context *ct)
19767c478bd9Sstevel@tonic-gate {
19777c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
19787c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
19797c478bd9Sstevel@tonic-gate 
19807c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
19817c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
19827c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_read, vsop_read);
19837c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
19847c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
19857c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, uiop, ioflag, cr, ct));
19867c478bd9Sstevel@tonic-gate }
19877c478bd9Sstevel@tonic-gate 
19887c478bd9Sstevel@tonic-gate int
19897c478bd9Sstevel@tonic-gate vnext_write(femarg_t *vf, uio_t *uiop, int ioflag, cred_t *cr,
19907c478bd9Sstevel@tonic-gate 	struct caller_context *ct)
19917c478bd9Sstevel@tonic-gate {
19927c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
19937c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
19947c478bd9Sstevel@tonic-gate 
19957c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
19967c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
19977c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_write, vsop_write);
19987c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
19997c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
20007c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, uiop, ioflag, cr, ct));
20017c478bd9Sstevel@tonic-gate }
20027c478bd9Sstevel@tonic-gate 
20037c478bd9Sstevel@tonic-gate int
20047c478bd9Sstevel@tonic-gate vnext_ioctl(femarg_t *vf, int cmd, intptr_t arg, int flag, cred_t *cr,
20057c478bd9Sstevel@tonic-gate 	int *rvalp)
20067c478bd9Sstevel@tonic-gate {
20077c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
20087c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
20097c478bd9Sstevel@tonic-gate 
20107c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
20117c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
20127c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_ioctl, vsop_ioctl);
20137c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
20147c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
20157c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, cmd, arg, flag, cr, rvalp));
20167c478bd9Sstevel@tonic-gate }
20177c478bd9Sstevel@tonic-gate 
20187c478bd9Sstevel@tonic-gate int
20197c478bd9Sstevel@tonic-gate vnext_setfl(femarg_t *vf, int oflags, int nflags, cred_t *cr)
20207c478bd9Sstevel@tonic-gate {
20217c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
20227c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
20237c478bd9Sstevel@tonic-gate 
20247c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
20257c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
20267c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_setfl, vsop_setfl);
20277c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
20287c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
20297c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, oflags, nflags, cr));
20307c478bd9Sstevel@tonic-gate }
20317c478bd9Sstevel@tonic-gate 
20327c478bd9Sstevel@tonic-gate int
20337c478bd9Sstevel@tonic-gate vnext_getattr(femarg_t *vf, vattr_t *vap, int flags, cred_t *cr)
20347c478bd9Sstevel@tonic-gate {
20357c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
20367c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
20377c478bd9Sstevel@tonic-gate 
20387c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
20397c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
20407c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_getattr, vsop_getattr);
20417c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
20427c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
20437c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vap, flags, cr));
20447c478bd9Sstevel@tonic-gate }
20457c478bd9Sstevel@tonic-gate 
20467c478bd9Sstevel@tonic-gate int
20477c478bd9Sstevel@tonic-gate vnext_setattr(femarg_t *vf, vattr_t *vap, int flags, cred_t *cr,
20487c478bd9Sstevel@tonic-gate 	caller_context_t *ct)
20497c478bd9Sstevel@tonic-gate {
20507c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
20517c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
20527c478bd9Sstevel@tonic-gate 
20537c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
20547c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
20557c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_setattr, vsop_setattr);
20567c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
20577c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
20587c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vap, flags, cr, ct));
20597c478bd9Sstevel@tonic-gate }
20607c478bd9Sstevel@tonic-gate 
20617c478bd9Sstevel@tonic-gate int
20627c478bd9Sstevel@tonic-gate vnext_access(femarg_t *vf, int mode, int flags, cred_t *cr)
20637c478bd9Sstevel@tonic-gate {
20647c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
20657c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
20667c478bd9Sstevel@tonic-gate 
20677c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
20687c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
20697c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_access, vsop_access);
20707c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
20717c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
20727c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, mode, flags, cr));
20737c478bd9Sstevel@tonic-gate }
20747c478bd9Sstevel@tonic-gate 
20757c478bd9Sstevel@tonic-gate int
20767c478bd9Sstevel@tonic-gate vnext_lookup(femarg_t *vf, char *nm, vnode_t **vpp, pathname_t *pnp,
20777c478bd9Sstevel@tonic-gate 	int flags, vnode_t *rdir, cred_t *cr)
20787c478bd9Sstevel@tonic-gate {
20797c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
20807c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
20817c478bd9Sstevel@tonic-gate 
20827c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
20837c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
20847c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_lookup, vsop_lookup);
20857c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
20867c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
20877c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, nm, vpp, pnp, flags, rdir, cr));
20887c478bd9Sstevel@tonic-gate }
20897c478bd9Sstevel@tonic-gate 
20907c478bd9Sstevel@tonic-gate int
20917c478bd9Sstevel@tonic-gate vnext_create(femarg_t *vf, char *name, vattr_t *vap, vcexcl_t excl,
20927c478bd9Sstevel@tonic-gate 	int mode, vnode_t **vpp, cred_t *cr, int flag)
20937c478bd9Sstevel@tonic-gate {
20947c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
20957c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
20967c478bd9Sstevel@tonic-gate 
20977c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
20987c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
20997c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_create, vsop_create);
21007c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
21017c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
21027c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, name, vap, excl, mode, vpp, cr, flag));
21037c478bd9Sstevel@tonic-gate }
21047c478bd9Sstevel@tonic-gate 
21057c478bd9Sstevel@tonic-gate int
21067c478bd9Sstevel@tonic-gate vnext_remove(femarg_t *vf, char *nm, cred_t *cr)
21077c478bd9Sstevel@tonic-gate {
21087c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
21097c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
21107c478bd9Sstevel@tonic-gate 
21117c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
21127c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
21137c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_remove, vsop_remove);
21147c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
21157c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
21167c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, nm, cr));
21177c478bd9Sstevel@tonic-gate }
21187c478bd9Sstevel@tonic-gate 
21197c478bd9Sstevel@tonic-gate int
21207c478bd9Sstevel@tonic-gate vnext_link(femarg_t *vf, vnode_t *svp, char *tnm, cred_t *cr)
21217c478bd9Sstevel@tonic-gate {
21227c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
21237c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
21247c478bd9Sstevel@tonic-gate 
21257c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
21267c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
21277c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_link, vsop_link);
21287c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
21297c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
21307c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, svp, tnm, cr));
21317c478bd9Sstevel@tonic-gate }
21327c478bd9Sstevel@tonic-gate 
21337c478bd9Sstevel@tonic-gate int
21347c478bd9Sstevel@tonic-gate vnext_rename(femarg_t *vf, char *snm, vnode_t *tdvp, char *tnm, cred_t *cr)
21357c478bd9Sstevel@tonic-gate {
21367c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
21377c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
21387c478bd9Sstevel@tonic-gate 
21397c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
21407c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
21417c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_rename, vsop_rename);
21427c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
21437c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
21447c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, snm, tdvp, tnm, cr));
21457c478bd9Sstevel@tonic-gate }
21467c478bd9Sstevel@tonic-gate 
21477c478bd9Sstevel@tonic-gate int
21487c478bd9Sstevel@tonic-gate vnext_mkdir(femarg_t *vf, char *dirname, vattr_t *vap, vnode_t **vpp,
21497c478bd9Sstevel@tonic-gate 	cred_t *cr)
21507c478bd9Sstevel@tonic-gate {
21517c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
21527c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
21537c478bd9Sstevel@tonic-gate 
21547c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
21557c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
21567c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_mkdir, vsop_mkdir);
21577c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
21587c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
21597c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, dirname, vap, vpp, cr));
21607c478bd9Sstevel@tonic-gate }
21617c478bd9Sstevel@tonic-gate 
21627c478bd9Sstevel@tonic-gate int
21637c478bd9Sstevel@tonic-gate vnext_rmdir(femarg_t *vf, char *nm, vnode_t *cdir, cred_t *cr)
21647c478bd9Sstevel@tonic-gate {
21657c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
21667c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
21677c478bd9Sstevel@tonic-gate 
21687c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
21697c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
21707c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_rmdir, vsop_rmdir);
21717c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
21727c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
21737c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, nm, cdir, cr));
21747c478bd9Sstevel@tonic-gate }
21757c478bd9Sstevel@tonic-gate 
21767c478bd9Sstevel@tonic-gate int
21777c478bd9Sstevel@tonic-gate vnext_readdir(femarg_t *vf, uio_t *uiop, cred_t *cr, int *eofp)
21787c478bd9Sstevel@tonic-gate {
21797c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
21807c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
21817c478bd9Sstevel@tonic-gate 
21827c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
21837c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
21847c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_readdir, vsop_readdir);
21857c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
21867c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
21877c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, uiop, cr, eofp));
21887c478bd9Sstevel@tonic-gate }
21897c478bd9Sstevel@tonic-gate 
21907c478bd9Sstevel@tonic-gate int
21917c478bd9Sstevel@tonic-gate vnext_symlink(femarg_t *vf, char *linkname, vattr_t *vap, char *target,
21927c478bd9Sstevel@tonic-gate 	cred_t *cr)
21937c478bd9Sstevel@tonic-gate {
21947c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
21957c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
21967c478bd9Sstevel@tonic-gate 
21977c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
21987c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
21997c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_symlink, vsop_symlink);
22007c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22017c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
22027c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, linkname, vap, target, cr));
22037c478bd9Sstevel@tonic-gate }
22047c478bd9Sstevel@tonic-gate 
22057c478bd9Sstevel@tonic-gate int
22067c478bd9Sstevel@tonic-gate vnext_readlink(femarg_t *vf, uio_t *uiop, cred_t *cr)
22077c478bd9Sstevel@tonic-gate {
22087c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
22097c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
22107c478bd9Sstevel@tonic-gate 
22117c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
22127c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
22137c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_readlink, vsop_readlink);
22147c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22157c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
22167c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, uiop, cr));
22177c478bd9Sstevel@tonic-gate }
22187c478bd9Sstevel@tonic-gate 
22197c478bd9Sstevel@tonic-gate int
22207c478bd9Sstevel@tonic-gate vnext_fsync(femarg_t *vf, int syncflag, cred_t *cr)
22217c478bd9Sstevel@tonic-gate {
22227c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
22237c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
22247c478bd9Sstevel@tonic-gate 
22257c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
22267c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
22277c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_fsync, vsop_fsync);
22287c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22297c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
22307c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, syncflag, cr));
22317c478bd9Sstevel@tonic-gate }
22327c478bd9Sstevel@tonic-gate 
22337c478bd9Sstevel@tonic-gate void
22347c478bd9Sstevel@tonic-gate vnext_inactive(femarg_t *vf, cred_t *cr)
22357c478bd9Sstevel@tonic-gate {
22367c478bd9Sstevel@tonic-gate 	void (*func)() = NULL;
22377c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
22387c478bd9Sstevel@tonic-gate 
22397c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
22407c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
22417c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, void, &arg0, vop_inactive, vsop_inactive);
22427c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22437c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
22447c478bd9Sstevel@tonic-gate 	(*func)(arg0, cr);
22457c478bd9Sstevel@tonic-gate }
22467c478bd9Sstevel@tonic-gate 
22477c478bd9Sstevel@tonic-gate int
22487c478bd9Sstevel@tonic-gate vnext_fid(femarg_t *vf, fid_t *fidp)
22497c478bd9Sstevel@tonic-gate {
22507c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
22517c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
22527c478bd9Sstevel@tonic-gate 
22537c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
22547c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
22557c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_fid, vsop_fid);
22567c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22577c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
22587c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, fidp));
22597c478bd9Sstevel@tonic-gate }
22607c478bd9Sstevel@tonic-gate 
22617c478bd9Sstevel@tonic-gate int
22627c478bd9Sstevel@tonic-gate vnext_rwlock(femarg_t *vf, int write_lock, caller_context_t *ct)
22637c478bd9Sstevel@tonic-gate {
22647c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
22657c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
22667c478bd9Sstevel@tonic-gate 
22677c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
22687c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
22697c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_rwlock, vsop_rwlock);
22707c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22717c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
22727c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, write_lock, ct));
22737c478bd9Sstevel@tonic-gate }
22747c478bd9Sstevel@tonic-gate 
22757c478bd9Sstevel@tonic-gate void
22767c478bd9Sstevel@tonic-gate vnext_rwunlock(femarg_t *vf, int write_lock, caller_context_t *ct)
22777c478bd9Sstevel@tonic-gate {
22787c478bd9Sstevel@tonic-gate 	void (*func)() = NULL;
22797c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
22807c478bd9Sstevel@tonic-gate 
22817c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
22827c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
22837c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, void, &arg0, vop_rwunlock, vsop_rwunlock);
22847c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22857c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
22867c478bd9Sstevel@tonic-gate 	(*func)(arg0, write_lock, ct);
22877c478bd9Sstevel@tonic-gate }
22887c478bd9Sstevel@tonic-gate 
22897c478bd9Sstevel@tonic-gate int
22907c478bd9Sstevel@tonic-gate vnext_seek(femarg_t *vf, offset_t ooff, offset_t *noffp)
22917c478bd9Sstevel@tonic-gate {
22927c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
22937c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
22947c478bd9Sstevel@tonic-gate 
22957c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
22967c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
22977c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_seek, vsop_seek);
22987c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
22997c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
23007c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, ooff, noffp));
23017c478bd9Sstevel@tonic-gate }
23027c478bd9Sstevel@tonic-gate 
23037c478bd9Sstevel@tonic-gate int
23047c478bd9Sstevel@tonic-gate vnext_cmp(femarg_t *vf, vnode_t *vp2)
23057c478bd9Sstevel@tonic-gate {
23067c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
23077c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
23087c478bd9Sstevel@tonic-gate 
23097c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
23107c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
23117c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_cmp, vsop_cmp);
23127c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
23137c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
23147c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vp2));
23157c478bd9Sstevel@tonic-gate }
23167c478bd9Sstevel@tonic-gate 
23177c478bd9Sstevel@tonic-gate int
23187c478bd9Sstevel@tonic-gate vnext_frlock(femarg_t *vf, int cmd, struct flock64 *bfp, int flag,
23197c478bd9Sstevel@tonic-gate 	offset_t offset, struct flk_callback *flk_cbp, cred_t *cr)
23207c478bd9Sstevel@tonic-gate {
23217c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
23227c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
23237c478bd9Sstevel@tonic-gate 
23247c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
23257c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
23267c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_frlock, vsop_frlock);
23277c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
23287c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
23297c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, cmd, bfp, flag, offset, flk_cbp, cr));
23307c478bd9Sstevel@tonic-gate }
23317c478bd9Sstevel@tonic-gate 
23327c478bd9Sstevel@tonic-gate int
23337c478bd9Sstevel@tonic-gate vnext_space(femarg_t *vf, int cmd, struct flock64 *bfp, int flag,
23347c478bd9Sstevel@tonic-gate 	offset_t offset, cred_t *cr, caller_context_t *ct)
23357c478bd9Sstevel@tonic-gate {
23367c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
23377c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
23387c478bd9Sstevel@tonic-gate 
23397c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
23407c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
23417c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_space, vsop_space);
23427c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
23437c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
23447c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, cmd, bfp, flag, offset, cr, ct));
23457c478bd9Sstevel@tonic-gate }
23467c478bd9Sstevel@tonic-gate 
23477c478bd9Sstevel@tonic-gate int
23487c478bd9Sstevel@tonic-gate vnext_realvp(femarg_t *vf, vnode_t **vpp)
23497c478bd9Sstevel@tonic-gate {
23507c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
23517c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
23527c478bd9Sstevel@tonic-gate 
23537c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
23547c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
23557c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_realvp, vsop_realvp);
23567c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
23577c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
23587c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vpp));
23597c478bd9Sstevel@tonic-gate }
23607c478bd9Sstevel@tonic-gate 
23617c478bd9Sstevel@tonic-gate int
23627c478bd9Sstevel@tonic-gate vnext_getpage(femarg_t *vf, offset_t off, size_t len, uint_t *protp,
23637c478bd9Sstevel@tonic-gate 	struct page **plarr, size_t plsz, struct seg *seg, caddr_t addr,
23647c478bd9Sstevel@tonic-gate 	enum seg_rw rw, cred_t *cr)
23657c478bd9Sstevel@tonic-gate {
23667c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
23677c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
23687c478bd9Sstevel@tonic-gate 
23697c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
23707c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
23717c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_getpage, vsop_getpage);
23727c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
23737c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
23747c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, off, len, protp, plarr, plsz, seg, addr, rw,
23757c478bd9Sstevel@tonic-gate 			cr));
23767c478bd9Sstevel@tonic-gate }
23777c478bd9Sstevel@tonic-gate 
23787c478bd9Sstevel@tonic-gate int
23797c478bd9Sstevel@tonic-gate vnext_putpage(femarg_t *vf, offset_t off, size_t len, int flags,
23807c478bd9Sstevel@tonic-gate 	cred_t *cr)
23817c478bd9Sstevel@tonic-gate {
23827c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
23837c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
23847c478bd9Sstevel@tonic-gate 
23857c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
23867c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
23877c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_putpage, vsop_putpage);
23887c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
23897c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
23907c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, off, len, flags, cr));
23917c478bd9Sstevel@tonic-gate }
23927c478bd9Sstevel@tonic-gate 
23937c478bd9Sstevel@tonic-gate int
23947c478bd9Sstevel@tonic-gate vnext_map(femarg_t *vf, offset_t off, struct as *as, caddr_t *addrp,
23957c478bd9Sstevel@tonic-gate 	size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
23967c478bd9Sstevel@tonic-gate 	cred_t *cr)
23977c478bd9Sstevel@tonic-gate {
23987c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
23997c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
24007c478bd9Sstevel@tonic-gate 
24017c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
24027c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
24037c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_map, vsop_map);
24047c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
24057c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
24067c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, off, as, addrp, len, prot, maxprot, flags,
24077c478bd9Sstevel@tonic-gate 			cr));
24087c478bd9Sstevel@tonic-gate }
24097c478bd9Sstevel@tonic-gate 
24107c478bd9Sstevel@tonic-gate int
24117c478bd9Sstevel@tonic-gate vnext_addmap(femarg_t *vf, offset_t off, struct as *as, caddr_t addr,
24127c478bd9Sstevel@tonic-gate 	size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
24137c478bd9Sstevel@tonic-gate 	cred_t *cr)
24147c478bd9Sstevel@tonic-gate {
24157c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
24167c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
24177c478bd9Sstevel@tonic-gate 
24187c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
24197c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
24207c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_addmap, vsop_addmap);
24217c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
24227c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
24237c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, off, as, addr, len, prot, maxprot, flags, cr));
24247c478bd9Sstevel@tonic-gate }
24257c478bd9Sstevel@tonic-gate 
24267c478bd9Sstevel@tonic-gate int
24277c478bd9Sstevel@tonic-gate vnext_delmap(femarg_t *vf, offset_t off, struct as *as, caddr_t addr,
24287c478bd9Sstevel@tonic-gate 	size_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cr)
24297c478bd9Sstevel@tonic-gate {
24307c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
24317c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
24327c478bd9Sstevel@tonic-gate 
24337c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
24347c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
24357c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_delmap, vsop_delmap);
24367c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
24377c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
24387c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, off, as, addr, len, prot, maxprot, flags, cr));
24397c478bd9Sstevel@tonic-gate }
24407c478bd9Sstevel@tonic-gate 
24417c478bd9Sstevel@tonic-gate int
24427c478bd9Sstevel@tonic-gate vnext_poll(femarg_t *vf, short events, int anyyet, short *reventsp,
24437c478bd9Sstevel@tonic-gate 	struct pollhead **phpp)
24447c478bd9Sstevel@tonic-gate {
24457c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
24467c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
24477c478bd9Sstevel@tonic-gate 
24487c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
24497c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
24507c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_poll, vsop_poll);
24517c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
24527c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
24537c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, events, anyyet, reventsp, phpp));
24547c478bd9Sstevel@tonic-gate }
24557c478bd9Sstevel@tonic-gate 
24567c478bd9Sstevel@tonic-gate int
24577c478bd9Sstevel@tonic-gate vnext_dump(femarg_t *vf, caddr_t addr, int lbdn, int dblks)
24587c478bd9Sstevel@tonic-gate {
24597c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
24607c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
24617c478bd9Sstevel@tonic-gate 
24627c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
24637c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
24647c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_dump, vsop_dump);
24657c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
24667c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
24677c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, addr, lbdn, dblks));
24687c478bd9Sstevel@tonic-gate }
24697c478bd9Sstevel@tonic-gate 
24707c478bd9Sstevel@tonic-gate int
24717c478bd9Sstevel@tonic-gate vnext_pathconf(femarg_t *vf, int cmd, ulong_t *valp, cred_t *cr)
24727c478bd9Sstevel@tonic-gate {
24737c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
24747c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
24757c478bd9Sstevel@tonic-gate 
24767c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
24777c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
24787c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_pathconf, vsop_pathconf);
24797c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
24807c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
24817c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, cmd, valp, cr));
24827c478bd9Sstevel@tonic-gate }
24837c478bd9Sstevel@tonic-gate 
24847c478bd9Sstevel@tonic-gate int
24857c478bd9Sstevel@tonic-gate vnext_pageio(femarg_t *vf, struct page *pp, u_offset_t io_off,
24867c478bd9Sstevel@tonic-gate 	size_t io_len, int flags, cred_t *cr)
24877c478bd9Sstevel@tonic-gate {
24887c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
24897c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
24907c478bd9Sstevel@tonic-gate 
24917c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
24927c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
24937c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_pageio, vsop_pageio);
24947c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
24957c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
24967c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, pp, io_off, io_len, flags, cr));
24977c478bd9Sstevel@tonic-gate }
24987c478bd9Sstevel@tonic-gate 
24997c478bd9Sstevel@tonic-gate int
25007c478bd9Sstevel@tonic-gate vnext_dumpctl(femarg_t *vf, int action, int *blkp)
25017c478bd9Sstevel@tonic-gate {
25027c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
25037c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
25047c478bd9Sstevel@tonic-gate 
25057c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
25067c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
25077c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_dumpctl, vsop_dumpctl);
25087c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
25097c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
25107c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, action, blkp));
25117c478bd9Sstevel@tonic-gate }
25127c478bd9Sstevel@tonic-gate 
25137c478bd9Sstevel@tonic-gate void
25147c478bd9Sstevel@tonic-gate vnext_dispose(femarg_t *vf, struct page *pp, int flag, int dn, cred_t *cr)
25157c478bd9Sstevel@tonic-gate {
25167c478bd9Sstevel@tonic-gate 	void (*func)() = NULL;
25177c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
25187c478bd9Sstevel@tonic-gate 
25197c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
25207c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
25217c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, void, &arg0, vop_dispose, vsop_dispose);
25227c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
25237c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
25247c478bd9Sstevel@tonic-gate 	(*func)(arg0, pp, flag, dn, cr);
25257c478bd9Sstevel@tonic-gate }
25267c478bd9Sstevel@tonic-gate 
25277c478bd9Sstevel@tonic-gate int
25287c478bd9Sstevel@tonic-gate vnext_setsecattr(femarg_t *vf, vsecattr_t *vsap, int flag, cred_t *cr)
25297c478bd9Sstevel@tonic-gate {
25307c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
25317c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
25327c478bd9Sstevel@tonic-gate 
25337c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
25347c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
25357c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_setsecattr, vsop_setsecattr);
25367c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
25377c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
25387c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vsap, flag, cr));
25397c478bd9Sstevel@tonic-gate }
25407c478bd9Sstevel@tonic-gate 
25417c478bd9Sstevel@tonic-gate int
25427c478bd9Sstevel@tonic-gate vnext_getsecattr(femarg_t *vf, vsecattr_t *vsap, int flag, cred_t *cr)
25437c478bd9Sstevel@tonic-gate {
25447c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
25457c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
25467c478bd9Sstevel@tonic-gate 
25477c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
25487c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
25497c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_getsecattr, vsop_getsecattr);
25507c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
25517c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
25527c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vsap, flag, cr));
25537c478bd9Sstevel@tonic-gate }
25547c478bd9Sstevel@tonic-gate 
25557c478bd9Sstevel@tonic-gate int
25567c478bd9Sstevel@tonic-gate vnext_shrlock(femarg_t *vf, int cmd, struct shrlock *shr, int flag,
25577c478bd9Sstevel@tonic-gate 	cred_t *cr)
25587c478bd9Sstevel@tonic-gate {
25597c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
25607c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
25617c478bd9Sstevel@tonic-gate 
25627c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
25637c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
25647c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_shrlock, vsop_shrlock);
25657c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
25667c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
25677c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, cmd, shr, flag, cr));
25687c478bd9Sstevel@tonic-gate }
25697c478bd9Sstevel@tonic-gate 
25707c478bd9Sstevel@tonic-gate int
25717c478bd9Sstevel@tonic-gate vnext_vnevent(femarg_t *vf, vnevent_t vnevent)
25727c478bd9Sstevel@tonic-gate {
25737c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
25747c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
25757c478bd9Sstevel@tonic-gate 
25767c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
25777c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
25787c478bd9Sstevel@tonic-gate 	vsop_find(vf, &func, int, &arg0, vop_vnevent, vsop_vnevent);
25797c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
25807c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
25817c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vnevent));
25827c478bd9Sstevel@tonic-gate }
25837c478bd9Sstevel@tonic-gate 
25847c478bd9Sstevel@tonic-gate int
25857c478bd9Sstevel@tonic-gate vfsnext_mount(fsemarg_t *vf, vnode_t *mvp, struct mounta *uap, cred_t *cr)
25867c478bd9Sstevel@tonic-gate {
25877c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
25887c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
25897c478bd9Sstevel@tonic-gate 
25907c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
25917c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
25927c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_mount, vfsop_mount);
25937c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
25947c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
25957c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, mvp, uap, cr));
25967c478bd9Sstevel@tonic-gate }
25977c478bd9Sstevel@tonic-gate 
25987c478bd9Sstevel@tonic-gate int
25997c478bd9Sstevel@tonic-gate vfsnext_unmount(fsemarg_t *vf, int flag, cred_t *cr)
26007c478bd9Sstevel@tonic-gate {
26017c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
26027c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
26037c478bd9Sstevel@tonic-gate 
26047c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
26057c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
26067c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_unmount, vfsop_unmount);
26077c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
26087c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
26097c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, flag, cr));
26107c478bd9Sstevel@tonic-gate }
26117c478bd9Sstevel@tonic-gate 
26127c478bd9Sstevel@tonic-gate int
26137c478bd9Sstevel@tonic-gate vfsnext_root(fsemarg_t *vf, vnode_t **vpp)
26147c478bd9Sstevel@tonic-gate {
26157c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
26167c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
26177c478bd9Sstevel@tonic-gate 
26187c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
26197c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
26207c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_root, vfsop_root);
26217c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
26227c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
26237c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vpp));
26247c478bd9Sstevel@tonic-gate }
26257c478bd9Sstevel@tonic-gate 
26267c478bd9Sstevel@tonic-gate int
26277c478bd9Sstevel@tonic-gate vfsnext_statvfs(fsemarg_t *vf, statvfs64_t *sp)
26287c478bd9Sstevel@tonic-gate {
26297c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
26307c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
26317c478bd9Sstevel@tonic-gate 
26327c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
26337c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
26347c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_statvfs, vfsop_statvfs);
26357c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
26367c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
26377c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, sp));
26387c478bd9Sstevel@tonic-gate }
26397c478bd9Sstevel@tonic-gate 
26407c478bd9Sstevel@tonic-gate int
26417c478bd9Sstevel@tonic-gate vfsnext_sync(fsemarg_t *vf, short flag, cred_t *cr)
26427c478bd9Sstevel@tonic-gate {
26437c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
26447c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
26457c478bd9Sstevel@tonic-gate 
26467c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
26477c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
26487c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_sync, vfsop_sync);
26497c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
26507c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
26517c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, flag, cr));
26527c478bd9Sstevel@tonic-gate }
26537c478bd9Sstevel@tonic-gate 
26547c478bd9Sstevel@tonic-gate int
26557c478bd9Sstevel@tonic-gate vfsnext_vget(fsemarg_t *vf, vnode_t **vpp, fid_t *fidp)
26567c478bd9Sstevel@tonic-gate {
26577c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
26587c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
26597c478bd9Sstevel@tonic-gate 
26607c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
26617c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
26627c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_vget, vfsop_vget);
26637c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
26647c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
26657c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vpp, fidp));
26667c478bd9Sstevel@tonic-gate }
26677c478bd9Sstevel@tonic-gate 
26687c478bd9Sstevel@tonic-gate int
26697c478bd9Sstevel@tonic-gate vfsnext_mountroot(fsemarg_t *vf, enum whymountroot reason)
26707c478bd9Sstevel@tonic-gate {
26717c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
26727c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
26737c478bd9Sstevel@tonic-gate 
26747c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
26757c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
26767c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_mountroot, vfsop_mountroot);
26777c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
26787c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
26797c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, reason));
26807c478bd9Sstevel@tonic-gate }
26817c478bd9Sstevel@tonic-gate 
26827c478bd9Sstevel@tonic-gate void
26837c478bd9Sstevel@tonic-gate vfsnext_freevfs(fsemarg_t *vf)
26847c478bd9Sstevel@tonic-gate {
26857c478bd9Sstevel@tonic-gate 	void (*func)() = NULL;
26867c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
26877c478bd9Sstevel@tonic-gate 
26887c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
26897c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
26907c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, void, &arg0, vfs_freevfs, vfsop_freevfs);
26917c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
26927c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
26937c478bd9Sstevel@tonic-gate 	(*func)(arg0);
26947c478bd9Sstevel@tonic-gate }
26957c478bd9Sstevel@tonic-gate 
26967c478bd9Sstevel@tonic-gate int
26977c478bd9Sstevel@tonic-gate vfsnext_vnstate(fsemarg_t *vf, vnode_t *vp, vntrans_t nstate)
26987c478bd9Sstevel@tonic-gate {
26997c478bd9Sstevel@tonic-gate 	int (*func)() = NULL;
27007c478bd9Sstevel@tonic-gate 	void *arg0 = NULL;
27017c478bd9Sstevel@tonic-gate 
27027c478bd9Sstevel@tonic-gate 	ASSERT(vf != NULL);
27037c478bd9Sstevel@tonic-gate 	vf->fa_fnode--;
27047c478bd9Sstevel@tonic-gate 	vfsop_find(vf, &func, int, &arg0, vfs_vnstate, vfsop_vnstate);
27057c478bd9Sstevel@tonic-gate 	ASSERT(func != NULL);
27067c478bd9Sstevel@tonic-gate 	ASSERT(arg0 != NULL);
27077c478bd9Sstevel@tonic-gate 	return ((*func)(arg0, vp, nstate));
27087c478bd9Sstevel@tonic-gate }
27097c478bd9Sstevel@tonic-gate 
27107c478bd9Sstevel@tonic-gate 
27117c478bd9Sstevel@tonic-gate /*
27127c478bd9Sstevel@tonic-gate  * Create a new fem_head and associate with the vnode.
27137c478bd9Sstevel@tonic-gate  * To keep the unaugmented vnode access path lock free, we spin
27147c478bd9Sstevel@tonic-gate  * update this - create a new one, then try and install it. If
27157c478bd9Sstevel@tonic-gate  * we fail to install, release the old one and pretend we succeeded.
27167c478bd9Sstevel@tonic-gate  */
27177c478bd9Sstevel@tonic-gate 
27187c478bd9Sstevel@tonic-gate static struct fem_head *
27197c478bd9Sstevel@tonic-gate new_femhead(struct fem_head **hp)
27207c478bd9Sstevel@tonic-gate {
27217c478bd9Sstevel@tonic-gate 	struct fem_head	*head;
27227c478bd9Sstevel@tonic-gate 
27237c478bd9Sstevel@tonic-gate 	head = kmem_alloc(sizeof (*head), KM_SLEEP);
27247c478bd9Sstevel@tonic-gate 	mutex_init(&head->femh_lock, NULL, MUTEX_DEFAULT, NULL);
27257c478bd9Sstevel@tonic-gate 	head->femh_list = NULL;
27267c478bd9Sstevel@tonic-gate 	if (casptr(hp, NULL, head) != NULL) {
27277c478bd9Sstevel@tonic-gate 		kmem_free(head, sizeof (*head));
27287c478bd9Sstevel@tonic-gate 		head = *hp;
27297c478bd9Sstevel@tonic-gate 	}
27307c478bd9Sstevel@tonic-gate 	return (head);
27317c478bd9Sstevel@tonic-gate }
27327c478bd9Sstevel@tonic-gate 
27337c478bd9Sstevel@tonic-gate /*
27347c478bd9Sstevel@tonic-gate  * Create a fem_list.  The fem_list that gets returned is in a
27357c478bd9Sstevel@tonic-gate  * very rudimentary state and MUST NOT be used until it's initialized
27367c478bd9Sstevel@tonic-gate  * (usually by femlist_construct() or fem_dup_list()).  The refcount
27377c478bd9Sstevel@tonic-gate  * and size is set properly and top-of-stack is set to the "guard" node
27387c478bd9Sstevel@tonic-gate  * just to be consistent.
27397c478bd9Sstevel@tonic-gate  *
27407c478bd9Sstevel@tonic-gate  * If anyone were to accidentally trying to run on this fem_list before
27417c478bd9Sstevel@tonic-gate  * it's initialized then the system would likely panic trying to defererence
27427c478bd9Sstevel@tonic-gate  * the (NULL) fn_op pointer.
27437c478bd9Sstevel@tonic-gate  *
27447c478bd9Sstevel@tonic-gate  */
27457c478bd9Sstevel@tonic-gate static struct fem_list *
27467c478bd9Sstevel@tonic-gate femlist_create(int numnodes)
27477c478bd9Sstevel@tonic-gate {
27487c478bd9Sstevel@tonic-gate 	struct fem_list	*sp;
27497c478bd9Sstevel@tonic-gate 
27507c478bd9Sstevel@tonic-gate 	sp = kmem_alloc(fl_ntob(numnodes), KM_SLEEP);
27517c478bd9Sstevel@tonic-gate 	sp->feml_refc  = 1;
27527c478bd9Sstevel@tonic-gate 	sp->feml_ssize = numnodes;
27537c478bd9Sstevel@tonic-gate 	sp->feml_nodes[0] = FEM_GUARD(FEMTYPE_NULL);
27547c478bd9Sstevel@tonic-gate 	sp->feml_tos = 0;
27557c478bd9Sstevel@tonic-gate 	return (sp);
27567c478bd9Sstevel@tonic-gate }
27577c478bd9Sstevel@tonic-gate 
27587c478bd9Sstevel@tonic-gate /*
27597c478bd9Sstevel@tonic-gate  * Construct a new femlist.
27607c478bd9Sstevel@tonic-gate  * The list is constructed with the appropriate type of guard to
27617c478bd9Sstevel@tonic-gate  * anchor it, and inserts the original ops.
27627c478bd9Sstevel@tonic-gate  */
27637c478bd9Sstevel@tonic-gate 
27647c478bd9Sstevel@tonic-gate static struct fem_list *
27657c478bd9Sstevel@tonic-gate femlist_construct(void *baseops, int type, int numnodes)
27667c478bd9Sstevel@tonic-gate {
27677c478bd9Sstevel@tonic-gate 	struct fem_list	*sp;
27687c478bd9Sstevel@tonic-gate 
27697c478bd9Sstevel@tonic-gate 	sp = femlist_create(numnodes);
27707c478bd9Sstevel@tonic-gate 	sp->feml_nodes[0] = FEM_GUARD(type);
27717c478bd9Sstevel@tonic-gate 	sp->feml_nodes[1].fn_op.anon = baseops;
27727c478bd9Sstevel@tonic-gate 	sp->feml_nodes[1].fn_available = NULL;
27737c478bd9Sstevel@tonic-gate 	sp->feml_nodes[1].fn_av_hold = NULL;
27747c478bd9Sstevel@tonic-gate 	sp->feml_nodes[1].fn_av_rele = NULL;
27757c478bd9Sstevel@tonic-gate 	sp->feml_tos = 1;
27767c478bd9Sstevel@tonic-gate 	return (sp);
27777c478bd9Sstevel@tonic-gate }
27787c478bd9Sstevel@tonic-gate 
27797c478bd9Sstevel@tonic-gate /*
27807c478bd9Sstevel@tonic-gate  * Duplicate a list.  Copy the original list to the clone.
27817c478bd9Sstevel@tonic-gate  *
27827c478bd9Sstevel@tonic-gate  * NOTE: The caller must have the fem_head for the lists locked.
27837c478bd9Sstevel@tonic-gate  * Assuming the appropriate lock is held and the caller has done the
27847c478bd9Sstevel@tonic-gate  * math right, the clone list should be big enough to old the original.
27857c478bd9Sstevel@tonic-gate  */
27867c478bd9Sstevel@tonic-gate 
27877c478bd9Sstevel@tonic-gate static void
27887c478bd9Sstevel@tonic-gate fem_dup_list(struct fem_list *orig, struct fem_list *clone)
27897c478bd9Sstevel@tonic-gate {
27907c478bd9Sstevel@tonic-gate 	int		i;
27917c478bd9Sstevel@tonic-gate 
27927c478bd9Sstevel@tonic-gate 	ASSERT(clone->feml_ssize >= orig->feml_ssize);
27937c478bd9Sstevel@tonic-gate 
27947c478bd9Sstevel@tonic-gate 	bcopy(orig->feml_nodes, clone->feml_nodes,
27957c478bd9Sstevel@tonic-gate 		sizeof (orig->feml_nodes[0]) * orig->feml_ssize);
27967c478bd9Sstevel@tonic-gate 	clone->feml_tos = orig->feml_tos;
27977c478bd9Sstevel@tonic-gate 	/*
27987c478bd9Sstevel@tonic-gate 	 * Now that we've copied the old list (orig) to the new list (clone),
27997c478bd9Sstevel@tonic-gate 	 * we need to walk the new list and put another hold on fn_available.
28007c478bd9Sstevel@tonic-gate 	 */
28017c478bd9Sstevel@tonic-gate 	for (i = clone->feml_tos; i > 0; i--) {
28027c478bd9Sstevel@tonic-gate 		struct fem_node *fnp = &clone->feml_nodes[i];
28037c478bd9Sstevel@tonic-gate 
28047c478bd9Sstevel@tonic-gate 		if (fnp->fn_av_hold)
28057c478bd9Sstevel@tonic-gate 			(*(fnp->fn_av_hold))(fnp->fn_available);
28067c478bd9Sstevel@tonic-gate 	}
28077c478bd9Sstevel@tonic-gate }
28087c478bd9Sstevel@tonic-gate 
28097c478bd9Sstevel@tonic-gate 
28107c478bd9Sstevel@tonic-gate static int
28117c478bd9Sstevel@tonic-gate fem_push_node(
28127c478bd9Sstevel@tonic-gate 	struct fem_head **hp,
28137c478bd9Sstevel@tonic-gate 	void **baseops,
28147c478bd9Sstevel@tonic-gate 	int type,
28157c478bd9Sstevel@tonic-gate 	struct fem_node *nnode,
28167c478bd9Sstevel@tonic-gate 	femhow_t how)
28177c478bd9Sstevel@tonic-gate {
28187c478bd9Sstevel@tonic-gate 	struct fem_head	*hd;
28197c478bd9Sstevel@tonic-gate 	struct fem_list	*list;
28207c478bd9Sstevel@tonic-gate 	void		*oldops;
28217c478bd9Sstevel@tonic-gate 	int		retry;
28227c478bd9Sstevel@tonic-gate 	int		error = 0;
28237c478bd9Sstevel@tonic-gate 	int		i;
28247c478bd9Sstevel@tonic-gate 
28257c478bd9Sstevel@tonic-gate 	/* Validate the node */
28267c478bd9Sstevel@tonic-gate 	if ((nnode->fn_op.anon == NULL) || (nnode->fn_available == NULL)) {
28277c478bd9Sstevel@tonic-gate 		return (EINVAL);
28287c478bd9Sstevel@tonic-gate 	}
28297c478bd9Sstevel@tonic-gate 
28307c478bd9Sstevel@tonic-gate 	if ((hd = *hp) == NULL) { /* construct a proto-list */
28317c478bd9Sstevel@tonic-gate 		hd = new_femhead(hp);
28327c478bd9Sstevel@tonic-gate 	}
28337c478bd9Sstevel@tonic-gate 	/*
28347c478bd9Sstevel@tonic-gate 	 * RULE: once a femhead has been pushed onto a object, it cannot be
28357c478bd9Sstevel@tonic-gate 	 * removed until the object is destroyed.  It can be deactivated by
28367c478bd9Sstevel@tonic-gate 	 * placing the original 'object operations' onto the object, which
28377c478bd9Sstevel@tonic-gate 	 * will ignore the femhead.
28387c478bd9Sstevel@tonic-gate 	 * The loop will exist when the femh_list has space to push a monitor
28397c478bd9Sstevel@tonic-gate 	 * onto it.
28407c478bd9Sstevel@tonic-gate 	 */
28417c478bd9Sstevel@tonic-gate 	do {
28427c478bd9Sstevel@tonic-gate 		retry = 1;
28437c478bd9Sstevel@tonic-gate 		list = fem_lock(hd);
28447c478bd9Sstevel@tonic-gate 		oldops = *baseops;
28457c478bd9Sstevel@tonic-gate 
28467c478bd9Sstevel@tonic-gate 		if (list != NULL) {
28477c478bd9Sstevel@tonic-gate 			if (list->feml_tos+1 < list->feml_ssize) {
28487c478bd9Sstevel@tonic-gate 				retry = 0;
28497c478bd9Sstevel@tonic-gate 			} else {
28507c478bd9Sstevel@tonic-gate 				struct fem_list	*olist = list;
28517c478bd9Sstevel@tonic-gate 
28527c478bd9Sstevel@tonic-gate 				fem_addref(olist);
28537c478bd9Sstevel@tonic-gate 				fem_unlock(hd);
28547c478bd9Sstevel@tonic-gate 				list = femlist_create(olist->feml_ssize * 2);
28557c478bd9Sstevel@tonic-gate 				(void) fem_lock(hd);
28567c478bd9Sstevel@tonic-gate 				if (hd->femh_list == olist) {
28577c478bd9Sstevel@tonic-gate 					if (list->feml_ssize <=
28587c478bd9Sstevel@tonic-gate 							olist->feml_ssize) {
28597c478bd9Sstevel@tonic-gate 						/*
28607c478bd9Sstevel@tonic-gate 						 * We have a new list, but it
28617c478bd9Sstevel@tonic-gate 						 * is too small to hold the
28627c478bd9Sstevel@tonic-gate 						 * original contents plus the
28637c478bd9Sstevel@tonic-gate 						 * one to push.  Release the
28647c478bd9Sstevel@tonic-gate 						 * new list and start over.
28657c478bd9Sstevel@tonic-gate 						 */
28667c478bd9Sstevel@tonic-gate 						fem_release(list);
28677c478bd9Sstevel@tonic-gate 						fem_unlock(hd);
28687c478bd9Sstevel@tonic-gate 					} else {
28697c478bd9Sstevel@tonic-gate 						/*
28707c478bd9Sstevel@tonic-gate 						 * Life is good:  Our new list
28717c478bd9Sstevel@tonic-gate 						 * is big enough to hold the
28727c478bd9Sstevel@tonic-gate 						 * original list (olist) + 1.
28737c478bd9Sstevel@tonic-gate 						 */
28747c478bd9Sstevel@tonic-gate 						fem_dup_list(olist, list);
28757c478bd9Sstevel@tonic-gate 						/* orphan this list */
28767c478bd9Sstevel@tonic-gate 						hd->femh_list = list;
28777c478bd9Sstevel@tonic-gate 						fem_delref(olist);
28787c478bd9Sstevel@tonic-gate 						retry = 0;
28797c478bd9Sstevel@tonic-gate 					}
28807c478bd9Sstevel@tonic-gate 				} else {
28817c478bd9Sstevel@tonic-gate 					/* concurrent update, retry */
28827c478bd9Sstevel@tonic-gate 					fem_release(list);
28837c478bd9Sstevel@tonic-gate 					fem_unlock(hd);
28847c478bd9Sstevel@tonic-gate 				}
28857c478bd9Sstevel@tonic-gate 				/* remove the reference we added above */
28867c478bd9Sstevel@tonic-gate 				fem_release(olist);
28877c478bd9Sstevel@tonic-gate 			}
28887c478bd9Sstevel@tonic-gate 		} else {
28897c478bd9Sstevel@tonic-gate 			fem_unlock(hd);
28907c478bd9Sstevel@tonic-gate 			list = femlist_construct(oldops, type, NNODES_DEFAULT);
28917c478bd9Sstevel@tonic-gate 			(void) fem_lock(hd);
28927c478bd9Sstevel@tonic-gate 			if (hd->femh_list != NULL || *baseops != oldops) {
28937c478bd9Sstevel@tonic-gate 				/* concurrent update, retry */
28947c478bd9Sstevel@tonic-gate 				fem_release(list);
28957c478bd9Sstevel@tonic-gate 				fem_unlock(hd);
28967c478bd9Sstevel@tonic-gate 			} else {
28977c478bd9Sstevel@tonic-gate 				hd->femh_list = list;
28987c478bd9Sstevel@tonic-gate 				*baseops = FEM_HEAD(type);
28997c478bd9Sstevel@tonic-gate 				retry = 0;
29007c478bd9Sstevel@tonic-gate 			}
29017c478bd9Sstevel@tonic-gate 		}
29027c478bd9Sstevel@tonic-gate 	} while (retry);
29037c478bd9Sstevel@tonic-gate 
29047c478bd9Sstevel@tonic-gate 	ASSERT(mutex_owner(&hd->femh_lock) == curthread);
29057c478bd9Sstevel@tonic-gate 	ASSERT(list->feml_tos+1 < list->feml_ssize);
29067c478bd9Sstevel@tonic-gate 
29077c478bd9Sstevel@tonic-gate 	/*
29087c478bd9Sstevel@tonic-gate 	 * The presence of "how" will modify the behavior of how/if
29097c478bd9Sstevel@tonic-gate 	 * nodes are pushed.  If it's FORCE, then we can skip
29107c478bd9Sstevel@tonic-gate 	 * all the checks and push it on.
29117c478bd9Sstevel@tonic-gate 	 */
29127c478bd9Sstevel@tonic-gate 	if (how != FORCE) {
29137c478bd9Sstevel@tonic-gate 		/* Start at the top and work our way down */
29147c478bd9Sstevel@tonic-gate 		for (i = list->feml_tos; i > 0; i--) {
29157c478bd9Sstevel@tonic-gate 			void *fn_av = list->feml_nodes[i].fn_available;
29167c478bd9Sstevel@tonic-gate 			void *fn_op = list->feml_nodes[i].fn_op.anon;
29177c478bd9Sstevel@tonic-gate 
29187c478bd9Sstevel@tonic-gate 			/*
29197c478bd9Sstevel@tonic-gate 			 * OPARGUNIQ means that this node should not
29207c478bd9Sstevel@tonic-gate 			 * be pushed on if a node with the same op/avail
29217c478bd9Sstevel@tonic-gate 			 * combination exists.  This situation returns
29227c478bd9Sstevel@tonic-gate 			 * EBUSY.
29237c478bd9Sstevel@tonic-gate 			 *
29247c478bd9Sstevel@tonic-gate 			 * OPUNIQ means that this node should not be
29257c478bd9Sstevel@tonic-gate 			 * pushed on if a node with the same op exists.
29267c478bd9Sstevel@tonic-gate 			 * This situation also returns EBUSY.
29277c478bd9Sstevel@tonic-gate 			 */
29287c478bd9Sstevel@tonic-gate 			switch (how) {
29297c478bd9Sstevel@tonic-gate 
29307c478bd9Sstevel@tonic-gate 			case OPUNIQ:
29317c478bd9Sstevel@tonic-gate 				if (fn_op == nnode->fn_op.anon) {
29327c478bd9Sstevel@tonic-gate 					error = EBUSY;
29337c478bd9Sstevel@tonic-gate 				}
29347c478bd9Sstevel@tonic-gate 				break;
29357c478bd9Sstevel@tonic-gate 
29367c478bd9Sstevel@tonic-gate 			case OPARGUNIQ:
29377c478bd9Sstevel@tonic-gate 				if ((fn_op == nnode->fn_op.anon) &&
29387c478bd9Sstevel@tonic-gate 				    (fn_av == nnode->fn_available)) {
29397c478bd9Sstevel@tonic-gate 					error = EBUSY;
29407c478bd9Sstevel@tonic-gate 				}
29417c478bd9Sstevel@tonic-gate 				break;
29427c478bd9Sstevel@tonic-gate 
29437c478bd9Sstevel@tonic-gate 			default:
29447c478bd9Sstevel@tonic-gate 				error = EINVAL;	/* Unexpected value */
29457c478bd9Sstevel@tonic-gate 				break;
29467c478bd9Sstevel@tonic-gate 			}
29477c478bd9Sstevel@tonic-gate 
29487c478bd9Sstevel@tonic-gate 			if (error)
29497c478bd9Sstevel@tonic-gate 				break;
29507c478bd9Sstevel@tonic-gate 		}
29517c478bd9Sstevel@tonic-gate 	}
29527c478bd9Sstevel@tonic-gate 
29537c478bd9Sstevel@tonic-gate 	if (error == 0) {
29547c478bd9Sstevel@tonic-gate 		/*
29557c478bd9Sstevel@tonic-gate 		 * If no errors, slap the node on the list.
29567c478bd9Sstevel@tonic-gate 		 * Note: The following is a structure copy.
29577c478bd9Sstevel@tonic-gate 		 */
29587c478bd9Sstevel@tonic-gate 		list->feml_nodes[++(list->feml_tos)] = *nnode;
29597c478bd9Sstevel@tonic-gate 	}
29607c478bd9Sstevel@tonic-gate 
29617c478bd9Sstevel@tonic-gate 	fem_unlock(hd);
29627c478bd9Sstevel@tonic-gate 	return (error);
29637c478bd9Sstevel@tonic-gate }
29647c478bd9Sstevel@tonic-gate 
29657c478bd9Sstevel@tonic-gate /*
29667c478bd9Sstevel@tonic-gate  * Remove a node by copying the list above it down a notch.
29677c478bd9Sstevel@tonic-gate  * If the list is busy, replace it with an idle one and work
29687c478bd9Sstevel@tonic-gate  * upon it.
29697c478bd9Sstevel@tonic-gate  * A node matches if the opset matches and the datap matches or is
29707c478bd9Sstevel@tonic-gate  * null.
29717c478bd9Sstevel@tonic-gate  */
29727c478bd9Sstevel@tonic-gate 
29737c478bd9Sstevel@tonic-gate static int
29747c478bd9Sstevel@tonic-gate remove_node(struct fem_list *sp, void **baseops, void *opset, void *datap)
29757c478bd9Sstevel@tonic-gate {
29767c478bd9Sstevel@tonic-gate 	int	i;
29777c478bd9Sstevel@tonic-gate 	struct fem_node	*fn;
29787c478bd9Sstevel@tonic-gate 
29797c478bd9Sstevel@tonic-gate 	for (i = sp->feml_tos; i > 0; i--) {
29807c478bd9Sstevel@tonic-gate 		fn = sp->feml_nodes+i;
29817c478bd9Sstevel@tonic-gate 		if (fn->fn_op.anon == opset &&
29827c478bd9Sstevel@tonic-gate 		    (fn->fn_available == datap || datap == NULL)) {
29837c478bd9Sstevel@tonic-gate 			break;
29847c478bd9Sstevel@tonic-gate 		}
29857c478bd9Sstevel@tonic-gate 	}
29867c478bd9Sstevel@tonic-gate 	if (i == 0) {
29877c478bd9Sstevel@tonic-gate 		return (EINVAL);
29887c478bd9Sstevel@tonic-gate 	}
29897c478bd9Sstevel@tonic-gate 
29907c478bd9Sstevel@tonic-gate 	/*
29917c478bd9Sstevel@tonic-gate 	 * At this point we have a node in-hand (*fn) that we are about
29927c478bd9Sstevel@tonic-gate 	 * to remove by overwriting it and adjusting the stack.  This is
29937c478bd9Sstevel@tonic-gate 	 * our last chance to do anything with this node so we do the
29947c478bd9Sstevel@tonic-gate 	 * release on the arg.
29957c478bd9Sstevel@tonic-gate 	 */
29967c478bd9Sstevel@tonic-gate 	if (fn->fn_av_rele)
29977c478bd9Sstevel@tonic-gate 		(*(fn->fn_av_rele))(fn->fn_available);
29987c478bd9Sstevel@tonic-gate 
29997c478bd9Sstevel@tonic-gate 	while (i++ < sp->feml_tos) {
30007c478bd9Sstevel@tonic-gate 		sp->feml_nodes[i-1] = sp->feml_nodes[i];
30017c478bd9Sstevel@tonic-gate 	}
30027c478bd9Sstevel@tonic-gate 	if (--(sp->feml_tos) == 1) { /* Empty, restore ops */
30037c478bd9Sstevel@tonic-gate 		*baseops = sp->feml_nodes[1].fn_op.anon;
30047c478bd9Sstevel@tonic-gate 	}
30057c478bd9Sstevel@tonic-gate 	return (0);
30067c478bd9Sstevel@tonic-gate }
30077c478bd9Sstevel@tonic-gate 
30087c478bd9Sstevel@tonic-gate static int
30097c478bd9Sstevel@tonic-gate fem_remove_node(struct fem_head *fh, void **baseops, void *opset, void *datap)
30107c478bd9Sstevel@tonic-gate {
30117c478bd9Sstevel@tonic-gate 	struct fem_list *sp;
3012*de7d3445Sjwahlig 	int		error = 0;
30137c478bd9Sstevel@tonic-gate 	int		retry;
30147c478bd9Sstevel@tonic-gate 
30157c478bd9Sstevel@tonic-gate 	if (fh == NULL) {
30167c478bd9Sstevel@tonic-gate 		return (EINVAL);
30177c478bd9Sstevel@tonic-gate 	}
30187c478bd9Sstevel@tonic-gate 
30197c478bd9Sstevel@tonic-gate 	do {
30207c478bd9Sstevel@tonic-gate 		retry = 0;
30217c478bd9Sstevel@tonic-gate 		if ((sp = fem_lock(fh)) == NULL) {
30227c478bd9Sstevel@tonic-gate 			fem_unlock(fh);
30237c478bd9Sstevel@tonic-gate 			error = EINVAL;
30247c478bd9Sstevel@tonic-gate 		} else if (sp->feml_refc == 1) {
30257c478bd9Sstevel@tonic-gate 			error = remove_node(sp, baseops, opset, datap);
30267c478bd9Sstevel@tonic-gate 			if (sp->feml_tos == 1) {
30277c478bd9Sstevel@tonic-gate 				/*
30287c478bd9Sstevel@tonic-gate 				 * The top-of-stack was decremented by
30297c478bd9Sstevel@tonic-gate 				 * remove_node().  If it got down to 1,
30307c478bd9Sstevel@tonic-gate 				 * then the base ops were replaced and we
30317c478bd9Sstevel@tonic-gate 				 * call fem_release() which will free the
30327c478bd9Sstevel@tonic-gate 				 * fem_list.
30337c478bd9Sstevel@tonic-gate 				 */
30347c478bd9Sstevel@tonic-gate 				fem_release(sp);
30357c478bd9Sstevel@tonic-gate 				fh->femh_list = NULL;
30367c478bd9Sstevel@tonic-gate 				/* XXX - Do we need a membar_producer() call? */
30377c478bd9Sstevel@tonic-gate 			}
30387c478bd9Sstevel@tonic-gate 			fem_unlock(fh);
30397c478bd9Sstevel@tonic-gate 		} else {
30407c478bd9Sstevel@tonic-gate 			/* busy - install a new one without this monitor */
30417c478bd9Sstevel@tonic-gate 			struct fem_list *nsp;	/* New fem_list being cloned */
30427c478bd9Sstevel@tonic-gate 
30437c478bd9Sstevel@tonic-gate 			fem_addref(sp);
30447c478bd9Sstevel@tonic-gate 			fem_unlock(fh);
30457c478bd9Sstevel@tonic-gate 			nsp = femlist_create(sp->feml_ssize);
30467c478bd9Sstevel@tonic-gate 			if (fem_lock(fh) == sp) {
30477c478bd9Sstevel@tonic-gate 				/*
30487c478bd9Sstevel@tonic-gate 				 * We popped out of the lock, created a
30497c478bd9Sstevel@tonic-gate 				 * list, then relocked.  If we're in here
30507c478bd9Sstevel@tonic-gate 				 * then the fem_head points to the same list
30517c478bd9Sstevel@tonic-gate 				 * it started with.
30527c478bd9Sstevel@tonic-gate 				 */
30537c478bd9Sstevel@tonic-gate 				fem_dup_list(sp, nsp);
30547c478bd9Sstevel@tonic-gate 				error = remove_node(nsp, baseops, opset, datap);
30557c478bd9Sstevel@tonic-gate 				if (error != 0) {
30567c478bd9Sstevel@tonic-gate 					fem_release(nsp);
30577c478bd9Sstevel@tonic-gate 				} else if (nsp->feml_tos == 1) {
30587c478bd9Sstevel@tonic-gate 					/* New list now empty, tear it down */
30597c478bd9Sstevel@tonic-gate 					fem_release(nsp);
30607c478bd9Sstevel@tonic-gate 					fh->femh_list = NULL;
30617c478bd9Sstevel@tonic-gate 				} else {
30627c478bd9Sstevel@tonic-gate 					fh->femh_list = nsp;
30637c478bd9Sstevel@tonic-gate 				}
30647c478bd9Sstevel@tonic-gate 				fem_delref(sp);
30657c478bd9Sstevel@tonic-gate 			} else {
30667c478bd9Sstevel@tonic-gate 				/* List changed while locked, try again... */
30677c478bd9Sstevel@tonic-gate 				fem_release(nsp);
30687c478bd9Sstevel@tonic-gate 				retry = 1;
30697c478bd9Sstevel@tonic-gate 			}
3070*de7d3445Sjwahlig 			/*
3071*de7d3445Sjwahlig 			 * If error is set, then we tried to remove a node
3072*de7d3445Sjwahlig 			 * from the list, but failed.  This means that we
3073*de7d3445Sjwahlig 			 * will still be using this list so don't release it.
3074*de7d3445Sjwahlig 			 */
3075*de7d3445Sjwahlig 			if (error == 0)
30767c478bd9Sstevel@tonic-gate 				fem_release(sp);
30777c478bd9Sstevel@tonic-gate 			fem_unlock(fh);
30787c478bd9Sstevel@tonic-gate 		}
30797c478bd9Sstevel@tonic-gate 	} while (retry);
30807c478bd9Sstevel@tonic-gate 	return (error);
30817c478bd9Sstevel@tonic-gate }
30827c478bd9Sstevel@tonic-gate 
30837c478bd9Sstevel@tonic-gate 
30847c478bd9Sstevel@tonic-gate /*
30857c478bd9Sstevel@tonic-gate  * perform operation on each element until one returns non zero
30867c478bd9Sstevel@tonic-gate  */
30877c478bd9Sstevel@tonic-gate static int
30887c478bd9Sstevel@tonic-gate fem_walk_list(
30897c478bd9Sstevel@tonic-gate 	struct fem_list *sp,
30907c478bd9Sstevel@tonic-gate 	int (*f)(struct fem_node *, void *, void *),
30917c478bd9Sstevel@tonic-gate 	void *mon,
30927c478bd9Sstevel@tonic-gate 	void *arg)
30937c478bd9Sstevel@tonic-gate {
30947c478bd9Sstevel@tonic-gate 	int	i;
30957c478bd9Sstevel@tonic-gate 
30967c478bd9Sstevel@tonic-gate 	ASSERT(sp != NULL);
30977c478bd9Sstevel@tonic-gate 	for (i = sp->feml_tos; i > 0; i--) {
30987c478bd9Sstevel@tonic-gate 		if ((*f)(sp->feml_nodes+i, mon, arg) != 0) {
30997c478bd9Sstevel@tonic-gate 			break;
31007c478bd9Sstevel@tonic-gate 		}
31017c478bd9Sstevel@tonic-gate 	}
31027c478bd9Sstevel@tonic-gate 	return (i);
31037c478bd9Sstevel@tonic-gate }
31047c478bd9Sstevel@tonic-gate 
31057c478bd9Sstevel@tonic-gate /*
31067c478bd9Sstevel@tonic-gate  * companion comparison functions.
31077c478bd9Sstevel@tonic-gate  */
31087c478bd9Sstevel@tonic-gate static int
31097c478bd9Sstevel@tonic-gate fem_compare_mon(struct fem_node *n, void *mon, void *arg)
31107c478bd9Sstevel@tonic-gate {
31117c478bd9Sstevel@tonic-gate 	return ((n->fn_op.anon == mon) && (n->fn_available == arg));
31127c478bd9Sstevel@tonic-gate }
31137c478bd9Sstevel@tonic-gate 
31147c478bd9Sstevel@tonic-gate /*
31157c478bd9Sstevel@tonic-gate  * VNODE interposition.
31167c478bd9Sstevel@tonic-gate  */
31177c478bd9Sstevel@tonic-gate 
31187c478bd9Sstevel@tonic-gate int
31197c478bd9Sstevel@tonic-gate fem_create(char *name, const struct fs_operation_def *templ,
31207c478bd9Sstevel@tonic-gate     fem_t **actual)
31217c478bd9Sstevel@tonic-gate {
31227c478bd9Sstevel@tonic-gate 	int	unused_ops = 0;
31237c478bd9Sstevel@tonic-gate 	int	e;
31247c478bd9Sstevel@tonic-gate 	fem_t	*newf;
31257c478bd9Sstevel@tonic-gate 
31267c478bd9Sstevel@tonic-gate 	newf = fem_alloc();
31277c478bd9Sstevel@tonic-gate 	newf->name = name;
31287c478bd9Sstevel@tonic-gate 	newf->templ = templ;
31297c478bd9Sstevel@tonic-gate 
31307c478bd9Sstevel@tonic-gate 	e =  fs_build_vector(newf, &unused_ops, fem_opdef, templ);
31317c478bd9Sstevel@tonic-gate 	if (e != 0) {
31327c478bd9Sstevel@tonic-gate #ifdef DEBUG
31337c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "fem_create: error %d building vector", e);
31347c478bd9Sstevel@tonic-gate #endif
31357c478bd9Sstevel@tonic-gate 		fem_free(newf);
31367c478bd9Sstevel@tonic-gate 	} else {
31377c478bd9Sstevel@tonic-gate 		*actual = newf;
31387c478bd9Sstevel@tonic-gate 	}
31397c478bd9Sstevel@tonic-gate 	return (e);
31407c478bd9Sstevel@tonic-gate }
31417c478bd9Sstevel@tonic-gate 
31427c478bd9Sstevel@tonic-gate int
31437c478bd9Sstevel@tonic-gate fem_install(
31447c478bd9Sstevel@tonic-gate 	vnode_t *vp,		/* Vnode on which monitor is being installed */
31457c478bd9Sstevel@tonic-gate 	fem_t *mon,		/* Monitor operations being installed */
31467c478bd9Sstevel@tonic-gate 	void *arg,		/* Opaque data used by monitor */
31477c478bd9Sstevel@tonic-gate 	femhow_t how,		/* Installation control */
31487c478bd9Sstevel@tonic-gate 	void (*arg_hold)(void *),	/* Hold routine for "arg" */
31497c478bd9Sstevel@tonic-gate 	void (*arg_rele)(void *))	/* Release routine for "arg" */
31507c478bd9Sstevel@tonic-gate {
31517c478bd9Sstevel@tonic-gate 	int	error;
31527c478bd9Sstevel@tonic-gate 	struct fem_node	nnode;
31537c478bd9Sstevel@tonic-gate 
31547c478bd9Sstevel@tonic-gate 	nnode.fn_available = arg;
31557c478bd9Sstevel@tonic-gate 	nnode.fn_op.fem = mon;
31567c478bd9Sstevel@tonic-gate 	nnode.fn_av_hold = arg_hold;
31577c478bd9Sstevel@tonic-gate 	nnode.fn_av_rele = arg_rele;
31587c478bd9Sstevel@tonic-gate 	/*
31597c478bd9Sstevel@tonic-gate 	 * If we have a non-NULL hold function, do the hold right away.
31607c478bd9Sstevel@tonic-gate 	 * The release is done in remove_node().
31617c478bd9Sstevel@tonic-gate 	 */
31627c478bd9Sstevel@tonic-gate 	if (arg_hold)
31637c478bd9Sstevel@tonic-gate 		(*arg_hold)(arg);
31647c478bd9Sstevel@tonic-gate 
31657c478bd9Sstevel@tonic-gate 	error = fem_push_node(&vp->v_femhead, (void **)&vp->v_op, FEMTYPE_VNODE,
31667c478bd9Sstevel@tonic-gate 			&nnode, how);
31677c478bd9Sstevel@tonic-gate 
31687c478bd9Sstevel@tonic-gate 	/* If there was an error then the monitor wasn't pushed */
31697c478bd9Sstevel@tonic-gate 	if (error && arg_rele)
31707c478bd9Sstevel@tonic-gate 		(*arg_rele)(arg);
31717c478bd9Sstevel@tonic-gate 
31727c478bd9Sstevel@tonic-gate 	return (error);
31737c478bd9Sstevel@tonic-gate }
31747c478bd9Sstevel@tonic-gate 
31757c478bd9Sstevel@tonic-gate int
31767c478bd9Sstevel@tonic-gate fem_is_installed(vnode_t *v, fem_t *mon, void *arg)
31777c478bd9Sstevel@tonic-gate {
31787c478bd9Sstevel@tonic-gate 	int	e;
31797c478bd9Sstevel@tonic-gate 	struct fem_list	*fl;
31807c478bd9Sstevel@tonic-gate 
31817c478bd9Sstevel@tonic-gate 	fl = fem_get(v->v_femhead);
31827c478bd9Sstevel@tonic-gate 	if (fl != NULL) {
31837c478bd9Sstevel@tonic-gate 		e = fem_walk_list(fl, fem_compare_mon, (void *)mon, arg);
31847c478bd9Sstevel@tonic-gate 		fem_release(fl);
31857c478bd9Sstevel@tonic-gate 		return (e);
31867c478bd9Sstevel@tonic-gate 	}
31877c478bd9Sstevel@tonic-gate 	return (0);
31887c478bd9Sstevel@tonic-gate }
31897c478bd9Sstevel@tonic-gate 
31907c478bd9Sstevel@tonic-gate int
31917c478bd9Sstevel@tonic-gate fem_uninstall(vnode_t *v, fem_t *mon, void *arg)
31927c478bd9Sstevel@tonic-gate {
31937c478bd9Sstevel@tonic-gate 	int	e;
31947c478bd9Sstevel@tonic-gate 	e = fem_remove_node(v->v_femhead, (void **)&v->v_op,
31957c478bd9Sstevel@tonic-gate 			(void *)mon, arg);
31967c478bd9Sstevel@tonic-gate 	return (e);
31977c478bd9Sstevel@tonic-gate }
31987c478bd9Sstevel@tonic-gate 
31997c478bd9Sstevel@tonic-gate void
32007c478bd9Sstevel@tonic-gate fem_setvnops(vnode_t *v, vnodeops_t *newops)
32017c478bd9Sstevel@tonic-gate {
32027c478bd9Sstevel@tonic-gate 	vnodeops_t	*r;
32037c478bd9Sstevel@tonic-gate 
32047c478bd9Sstevel@tonic-gate 	ASSERT(v != NULL);
32057c478bd9Sstevel@tonic-gate 	ASSERT(newops != NULL);
32067c478bd9Sstevel@tonic-gate 
32077c478bd9Sstevel@tonic-gate 	do {
32087c478bd9Sstevel@tonic-gate 		r = v->v_op;
32097c478bd9Sstevel@tonic-gate 		membar_consumer();
32107c478bd9Sstevel@tonic-gate 		if (v->v_femhead != NULL) {
32117c478bd9Sstevel@tonic-gate 			struct fem_list	*fl;
32127c478bd9Sstevel@tonic-gate 			if ((fl = fem_lock(v->v_femhead)) != NULL) {
32137c478bd9Sstevel@tonic-gate 				fl->feml_nodes[1].fn_op.vnode = newops;
32147c478bd9Sstevel@tonic-gate 				fem_unlock(v->v_femhead);
32157c478bd9Sstevel@tonic-gate 				return;
32167c478bd9Sstevel@tonic-gate 			}
32177c478bd9Sstevel@tonic-gate 			fem_unlock(v->v_femhead);
32187c478bd9Sstevel@tonic-gate 		}
32197c478bd9Sstevel@tonic-gate 	} while (casptr(&v->v_op, r, newops) != r);
32207c478bd9Sstevel@tonic-gate }
32217c478bd9Sstevel@tonic-gate 
32227c478bd9Sstevel@tonic-gate vnodeops_t *
32237c478bd9Sstevel@tonic-gate fem_getvnops(vnode_t *v)
32247c478bd9Sstevel@tonic-gate {
32257c478bd9Sstevel@tonic-gate 	vnodeops_t	*r;
32267c478bd9Sstevel@tonic-gate 
32277c478bd9Sstevel@tonic-gate 	ASSERT(v != NULL);
32287c478bd9Sstevel@tonic-gate 
32297c478bd9Sstevel@tonic-gate 	r = v->v_op;
32307c478bd9Sstevel@tonic-gate 	membar_consumer();
32317c478bd9Sstevel@tonic-gate 	if (v->v_femhead != NULL) {
32327c478bd9Sstevel@tonic-gate 		struct fem_list	*fl;
32337c478bd9Sstevel@tonic-gate 		if ((fl = fem_lock(v->v_femhead)) != NULL) {
32347c478bd9Sstevel@tonic-gate 			r = fl->feml_nodes[1].fn_op.vnode;
32357c478bd9Sstevel@tonic-gate 		}
32367c478bd9Sstevel@tonic-gate 		fem_unlock(v->v_femhead);
32377c478bd9Sstevel@tonic-gate 	}
32387c478bd9Sstevel@tonic-gate 	return (r);
32397c478bd9Sstevel@tonic-gate }
32407c478bd9Sstevel@tonic-gate 
32417c478bd9Sstevel@tonic-gate 
32427c478bd9Sstevel@tonic-gate /*
32437c478bd9Sstevel@tonic-gate  * VFS interposition
32447c478bd9Sstevel@tonic-gate  */
32457c478bd9Sstevel@tonic-gate int
32467c478bd9Sstevel@tonic-gate fsem_create(char *name, const struct fs_operation_def *templ,
32477c478bd9Sstevel@tonic-gate     fsem_t **actual)
32487c478bd9Sstevel@tonic-gate {
32497c478bd9Sstevel@tonic-gate 	int	unused_ops = 0;
32507c478bd9Sstevel@tonic-gate 	int	e;
32517c478bd9Sstevel@tonic-gate 	fsem_t	*newv;
32527c478bd9Sstevel@tonic-gate 
32537c478bd9Sstevel@tonic-gate 	newv = fsem_alloc();
32547c478bd9Sstevel@tonic-gate 	newv->name = (const char *)name;
32557c478bd9Sstevel@tonic-gate 	newv->templ = templ;
32567c478bd9Sstevel@tonic-gate 
32577c478bd9Sstevel@tonic-gate 	e = fs_build_vector(newv, &unused_ops, fsem_opdef, templ);
32587c478bd9Sstevel@tonic-gate 	if (e != 0) {
32597c478bd9Sstevel@tonic-gate #ifdef DEBUG
32607c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "fsem_create: error %d building vector", e);
32617c478bd9Sstevel@tonic-gate #endif
32627c478bd9Sstevel@tonic-gate 		fsem_free(newv);
32637c478bd9Sstevel@tonic-gate 	} else {
32647c478bd9Sstevel@tonic-gate 		*actual = newv;
32657c478bd9Sstevel@tonic-gate 	}
32667c478bd9Sstevel@tonic-gate 	return (e);
32677c478bd9Sstevel@tonic-gate }
32687c478bd9Sstevel@tonic-gate 
32697c478bd9Sstevel@tonic-gate /*
32707c478bd9Sstevel@tonic-gate  * These need to be re-written, but there should be more common bits.
32717c478bd9Sstevel@tonic-gate  */
32727c478bd9Sstevel@tonic-gate 
32737c478bd9Sstevel@tonic-gate int
32747c478bd9Sstevel@tonic-gate fsem_is_installed(struct vfs *v, fsem_t *mon, void *arg)
32757c478bd9Sstevel@tonic-gate {
32767c478bd9Sstevel@tonic-gate 	struct fem_list	*fl;
32777c478bd9Sstevel@tonic-gate 
32787c478bd9Sstevel@tonic-gate 	fl = fem_get(v->vfs_femhead);
32797c478bd9Sstevel@tonic-gate 	if (fl != NULL) {
32807c478bd9Sstevel@tonic-gate 		int	e;
32817c478bd9Sstevel@tonic-gate 		e = fem_walk_list(fl, fem_compare_mon, (void *)mon, arg);
32827c478bd9Sstevel@tonic-gate 		fem_release(fl);
32837c478bd9Sstevel@tonic-gate 		return (e);
32847c478bd9Sstevel@tonic-gate 	}
32857c478bd9Sstevel@tonic-gate 	return (0);
32867c478bd9Sstevel@tonic-gate }
32877c478bd9Sstevel@tonic-gate 
32887c478bd9Sstevel@tonic-gate int
32897c478bd9Sstevel@tonic-gate fsem_install(
32907c478bd9Sstevel@tonic-gate 	struct vfs *vfsp,	/* VFS on which monitor is being installed */
32917c478bd9Sstevel@tonic-gate 	fsem_t *mon,		/* Monitor operations being installed */
32927c478bd9Sstevel@tonic-gate 	void *arg,		/* Opaque data used by monitor */
32937c478bd9Sstevel@tonic-gate 	femhow_t how,		/* Installation control */
32947c478bd9Sstevel@tonic-gate 	void (*arg_hold)(void *),	/* Hold routine for "arg" */
32957c478bd9Sstevel@tonic-gate 	void (*arg_rele)(void *))	/* Release routine for "arg" */
32967c478bd9Sstevel@tonic-gate {
32977c478bd9Sstevel@tonic-gate 	int	error;
32987c478bd9Sstevel@tonic-gate 	struct fem_node	nnode;
32997c478bd9Sstevel@tonic-gate 
33007c478bd9Sstevel@tonic-gate 	nnode.fn_available = arg;
33017c478bd9Sstevel@tonic-gate 	nnode.fn_op.fsem = mon;
33027c478bd9Sstevel@tonic-gate 	nnode.fn_av_hold = arg_hold;
33037c478bd9Sstevel@tonic-gate 	nnode.fn_av_rele = arg_rele;
33047c478bd9Sstevel@tonic-gate 	/*
33057c478bd9Sstevel@tonic-gate 	 * If we have a non-NULL hold function, do the hold right away.
33067c478bd9Sstevel@tonic-gate 	 * The release is done in remove_node().
33077c478bd9Sstevel@tonic-gate 	 */
33087c478bd9Sstevel@tonic-gate 	if (arg_hold)
33097c478bd9Sstevel@tonic-gate 		(*arg_hold)(arg);
33107c478bd9Sstevel@tonic-gate 
33117c478bd9Sstevel@tonic-gate 	error = fem_push_node(&vfsp->vfs_femhead, (void **)&vfsp->vfs_op,
33127c478bd9Sstevel@tonic-gate 			FEMTYPE_VFS, &nnode, how);
33137c478bd9Sstevel@tonic-gate 
33147c478bd9Sstevel@tonic-gate 	/* If there was an error then the monitor wasn't pushed */
33157c478bd9Sstevel@tonic-gate 	if (error && arg_rele)
33167c478bd9Sstevel@tonic-gate 		(*arg_rele)(arg);
33177c478bd9Sstevel@tonic-gate 
33187c478bd9Sstevel@tonic-gate 	return (error);
33197c478bd9Sstevel@tonic-gate }
33207c478bd9Sstevel@tonic-gate 
33217c478bd9Sstevel@tonic-gate int
33227c478bd9Sstevel@tonic-gate fsem_uninstall(struct vfs *v, fsem_t *mon, void *arg)
33237c478bd9Sstevel@tonic-gate {
33247c478bd9Sstevel@tonic-gate 	int	e;
33257c478bd9Sstevel@tonic-gate 	e = fem_remove_node(v->vfs_femhead, (void **)&v->vfs_op,
33267c478bd9Sstevel@tonic-gate 			(void *)mon, arg);
33277c478bd9Sstevel@tonic-gate 	return (e);
33287c478bd9Sstevel@tonic-gate }
33297c478bd9Sstevel@tonic-gate 
33307c478bd9Sstevel@tonic-gate void
33317c478bd9Sstevel@tonic-gate fsem_setvfsops(vfs_t *v, vfsops_t *newops)
33327c478bd9Sstevel@tonic-gate {
33337c478bd9Sstevel@tonic-gate 	vfsops_t	*r;
33347c478bd9Sstevel@tonic-gate 
33357c478bd9Sstevel@tonic-gate 	ASSERT(v != NULL);
33367c478bd9Sstevel@tonic-gate 	ASSERT(newops != NULL);
33377c478bd9Sstevel@tonic-gate 
33387c478bd9Sstevel@tonic-gate 	do {
33397c478bd9Sstevel@tonic-gate 		r = v->vfs_op;
33407c478bd9Sstevel@tonic-gate 		membar_consumer();
33417c478bd9Sstevel@tonic-gate 		if (v->vfs_femhead != NULL) {
33427c478bd9Sstevel@tonic-gate 			struct fem_list	*fl;
33437c478bd9Sstevel@tonic-gate 			if ((fl = fem_lock(v->vfs_femhead)) != NULL) {
33447c478bd9Sstevel@tonic-gate 				fl->feml_nodes[1].fn_op.vfs = newops;
33457c478bd9Sstevel@tonic-gate 				fem_unlock(v->vfs_femhead);
33467c478bd9Sstevel@tonic-gate 				return;
33477c478bd9Sstevel@tonic-gate 			}
33487c478bd9Sstevel@tonic-gate 			fem_unlock(v->vfs_femhead);
33497c478bd9Sstevel@tonic-gate 		}
33507c478bd9Sstevel@tonic-gate 	} while (casptr(&v->vfs_op, r, newops) != r);
33517c478bd9Sstevel@tonic-gate }
33527c478bd9Sstevel@tonic-gate 
33537c478bd9Sstevel@tonic-gate vfsops_t *
33547c478bd9Sstevel@tonic-gate fsem_getvfsops(vfs_t *v)
33557c478bd9Sstevel@tonic-gate {
33567c478bd9Sstevel@tonic-gate 	vfsops_t	*r;
33577c478bd9Sstevel@tonic-gate 
33587c478bd9Sstevel@tonic-gate 	ASSERT(v != NULL);
33597c478bd9Sstevel@tonic-gate 
33607c478bd9Sstevel@tonic-gate 	r = v->vfs_op;
33617c478bd9Sstevel@tonic-gate 	membar_consumer();
33627c478bd9Sstevel@tonic-gate 	if (v->vfs_femhead != NULL) {
33637c478bd9Sstevel@tonic-gate 		struct fem_list	*fl;
33647c478bd9Sstevel@tonic-gate 		if ((fl = fem_lock(v->vfs_femhead)) != NULL) {
33657c478bd9Sstevel@tonic-gate 			r = fl->feml_nodes[1].fn_op.vfs;
33667c478bd9Sstevel@tonic-gate 		}
33677c478bd9Sstevel@tonic-gate 		fem_unlock(v->vfs_femhead);
33687c478bd9Sstevel@tonic-gate 	}
33697c478bd9Sstevel@tonic-gate 	return (r);
33707c478bd9Sstevel@tonic-gate }
33717c478bd9Sstevel@tonic-gate 
33727c478bd9Sstevel@tonic-gate /*
33737c478bd9Sstevel@tonic-gate  * Setup FEM.
33747c478bd9Sstevel@tonic-gate  */
33757c478bd9Sstevel@tonic-gate void
33767c478bd9Sstevel@tonic-gate fem_init()
33777c478bd9Sstevel@tonic-gate {
33787c478bd9Sstevel@tonic-gate 	struct fem_type_info   *fi;
33797c478bd9Sstevel@tonic-gate 
33807c478bd9Sstevel@tonic-gate 	/*
33817c478bd9Sstevel@tonic-gate 	 * This femtype is only used for fem_list creation so we only
33827c478bd9Sstevel@tonic-gate 	 * need the "guard" to be initialized so that feml_tos has
33837c478bd9Sstevel@tonic-gate 	 * some rudimentary meaning.  A fem_list must not be used until
33847c478bd9Sstevel@tonic-gate 	 * it has been initialized (either via femlist_construct() or
33857c478bd9Sstevel@tonic-gate 	 * fem_dup_list()).  Anything that tries to use this fem_list
33867c478bd9Sstevel@tonic-gate 	 * before it's actually initialized would panic the system as
33877c478bd9Sstevel@tonic-gate 	 * soon as "fn_op" (NULL) is dereferenced.
33887c478bd9Sstevel@tonic-gate 	 */
33897c478bd9Sstevel@tonic-gate 	fi = femtype + FEMTYPE_NULL;
33907c478bd9Sstevel@tonic-gate 	fi->errf = fem_err;
33917c478bd9Sstevel@tonic-gate 	fi->guard.fn_available = (void *)&fi->guard;
33927c478bd9Sstevel@tonic-gate 	fi->guard.fn_av_hold = NULL;
33937c478bd9Sstevel@tonic-gate 	fi->guard.fn_av_rele = NULL;
33947c478bd9Sstevel@tonic-gate 	fi->guard.fn_op.anon = NULL;
33957c478bd9Sstevel@tonic-gate 
33967c478bd9Sstevel@tonic-gate 	fi = femtype + FEMTYPE_VNODE;
33977c478bd9Sstevel@tonic-gate 	fi->errf = fem_err;
33987c478bd9Sstevel@tonic-gate 	fi->head.fn_available = NULL;
33997c478bd9Sstevel@tonic-gate 	fi->head.fn_av_hold = NULL;
34007c478bd9Sstevel@tonic-gate 	fi->head.fn_av_rele = NULL;
34017c478bd9Sstevel@tonic-gate 	(void) vn_make_ops("fem-head", fhead_vn_spec, &fi->head.fn_op.vnode);
34027c478bd9Sstevel@tonic-gate 	fi->guard.fn_available = (void *)&fi->guard;
34037c478bd9Sstevel@tonic-gate 	fi->guard.fn_av_hold = NULL;
34047c478bd9Sstevel@tonic-gate 	fi->guard.fn_av_rele = NULL;
34057c478bd9Sstevel@tonic-gate 	(void) fem_create("fem-guard", fem_guard_ops, &fi->guard.fn_op.fem);
34067c478bd9Sstevel@tonic-gate 
34077c478bd9Sstevel@tonic-gate 	fi = femtype + FEMTYPE_VFS;
34087c478bd9Sstevel@tonic-gate 	fi->errf = fsem_err;
34097c478bd9Sstevel@tonic-gate 	fi->head.fn_available = NULL;
34107c478bd9Sstevel@tonic-gate 	fi->head.fn_av_hold = NULL;
34117c478bd9Sstevel@tonic-gate 	fi->head.fn_av_rele = NULL;
34127c478bd9Sstevel@tonic-gate 	(void) vfs_makefsops(fshead_vfs_spec, &fi->head.fn_op.vfs);
34137c478bd9Sstevel@tonic-gate 
34147c478bd9Sstevel@tonic-gate 	fi->guard.fn_available = (void *)&fi->guard;
34157c478bd9Sstevel@tonic-gate 	fi->guard.fn_av_hold = NULL;
34167c478bd9Sstevel@tonic-gate 	fi->guard.fn_av_rele = NULL;
34177c478bd9Sstevel@tonic-gate 	(void) fsem_create("fem-guard", fsem_guard_ops, &fi->guard.fn_op.fsem);
34187c478bd9Sstevel@tonic-gate }
34197c478bd9Sstevel@tonic-gate 
34207c478bd9Sstevel@tonic-gate 
34217c478bd9Sstevel@tonic-gate int
34227c478bd9Sstevel@tonic-gate fem_err()
34237c478bd9Sstevel@tonic-gate {
34247c478bd9Sstevel@tonic-gate 	cmn_err(CE_PANIC, "fem/vnode operations corrupt");
34257c478bd9Sstevel@tonic-gate 	return (0);
34267c478bd9Sstevel@tonic-gate }
34277c478bd9Sstevel@tonic-gate 
34287c478bd9Sstevel@tonic-gate int
34297c478bd9Sstevel@tonic-gate fsem_err()
34307c478bd9Sstevel@tonic-gate {
34317c478bd9Sstevel@tonic-gate 	cmn_err(CE_PANIC, "fem/vfs operations corrupt");
34327c478bd9Sstevel@tonic-gate 	return (0);
34337c478bd9Sstevel@tonic-gate }
3434