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