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