xref: /titanic_52/usr/src/uts/common/sys/vnode.h (revision a69cdccdf9a647a09c204a49f998caff672138e5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
26 /*	  All Rights Reserved  	*/
27 
28 /*
29  * University Copyright- Copyright (c) 1982, 1986, 1988
30  * The Regents of the University of California
31  * All Rights Reserved
32  *
33  * University Acknowledgment- Portions of this document are derived from
34  * software developed by the University of California, Berkeley, and its
35  * contributors.
36  */
37 
38 #ifndef _SYS_VNODE_H
39 #define	_SYS_VNODE_H
40 
41 #include <sys/types.h>
42 #include <sys/t_lock.h>
43 #include <sys/rwstlock.h>
44 #include <sys/time_impl.h>
45 #include <sys/cred.h>
46 #include <sys/uio.h>
47 #include <sys/resource.h>
48 #include <vm/seg_enum.h>
49 #include <sys/kstat.h>
50 #include <sys/kmem.h>
51 #include <sys/list.h>
52 #ifdef	_KERNEL
53 #include <sys/buf.h>
54 #endif	/* _KERNEL */
55 
56 #ifdef	__cplusplus
57 extern "C" {
58 #endif
59 
60 /*
61  * Statistics for all vnode operations.
62  * All operations record number of ops (since boot/mount/zero'ed).
63  * Certain I/O operations (read, write, readdir) also record number
64  * of bytes transferred.
65  * This appears in two places in the system: one is embedded in each
66  * vfs_t.  There is also an array of vopstats_t structures allocated
67  * on a per-fstype basis.
68  */
69 
70 #define	VOPSTATS_STR	"vopstats_"	/* Initial string for vopstat kstats */
71 
72 typedef struct vopstats {
73 	kstat_named_t	nopen;		/* VOP_OPEN */
74 	kstat_named_t	nclose;		/* VOP_CLOSE */
75 	kstat_named_t	nread;		/* VOP_READ */
76 	kstat_named_t	read_bytes;
77 	kstat_named_t	nwrite;		/* VOP_WRITE */
78 	kstat_named_t	write_bytes;
79 	kstat_named_t	nioctl;		/* VOP_IOCTL */
80 	kstat_named_t	nsetfl;		/* VOP_SETFL */
81 	kstat_named_t	ngetattr;	/* VOP_GETATTR */
82 	kstat_named_t	nsetattr;	/* VOP_SETATTR */
83 	kstat_named_t	naccess;	/* VOP_ACCESS */
84 	kstat_named_t	nlookup;	/* VOP_LOOKUP */
85 	kstat_named_t	ncreate;	/* VOP_CREATE */
86 	kstat_named_t	nremove;	/* VOP_REMOVE */
87 	kstat_named_t	nlink;		/* VOP_LINK */
88 	kstat_named_t	nrename;	/* VOP_RENAME */
89 	kstat_named_t	nmkdir;		/* VOP_MKDIR */
90 	kstat_named_t	nrmdir;		/* VOP_RMDIR */
91 	kstat_named_t	nreaddir;	/* VOP_READDIR */
92 	kstat_named_t	readdir_bytes;
93 	kstat_named_t	nsymlink;	/* VOP_SYMLINK */
94 	kstat_named_t	nreadlink;	/* VOP_READLINK */
95 	kstat_named_t	nfsync;		/* VOP_FSYNC */
96 	kstat_named_t	ninactive;	/* VOP_INACTIVE */
97 	kstat_named_t	nfid;		/* VOP_FID */
98 	kstat_named_t	nrwlock;	/* VOP_RWLOCK */
99 	kstat_named_t	nrwunlock;	/* VOP_RWUNLOCK */
100 	kstat_named_t	nseek;		/* VOP_SEEK */
101 	kstat_named_t	ncmp;		/* VOP_CMP */
102 	kstat_named_t	nfrlock;	/* VOP_FRLOCK */
103 	kstat_named_t	nspace;		/* VOP_SPACE */
104 	kstat_named_t	nrealvp;	/* VOP_REALVP */
105 	kstat_named_t	ngetpage;	/* VOP_GETPAGE */
106 	kstat_named_t	nputpage;	/* VOP_PUTPAGE */
107 	kstat_named_t	nmap;		/* VOP_MAP */
108 	kstat_named_t	naddmap;	/* VOP_ADDMAP */
109 	kstat_named_t	ndelmap;	/* VOP_DELMAP */
110 	kstat_named_t	npoll;		/* VOP_POLL */
111 	kstat_named_t	ndump;		/* VOP_DUMP */
112 	kstat_named_t	npathconf;	/* VOP_PATHCONF */
113 	kstat_named_t	npageio;	/* VOP_PAGEIO */
114 	kstat_named_t	ndumpctl;	/* VOP_DUMPCTL */
115 	kstat_named_t	ndispose;	/* VOP_DISPOSE */
116 	kstat_named_t	nsetsecattr;	/* VOP_SETSECATTR */
117 	kstat_named_t	ngetsecattr;	/* VOP_GETSECATTR */
118 	kstat_named_t	nshrlock;	/* VOP_SHRLOCK */
119 	kstat_named_t	nvnevent;	/* VOP_VNEVENT */
120 	kstat_named_t	nreqzcbuf;	/* VOP_REQZCBUF */
121 	kstat_named_t	nretzcbuf;	/* VOP_RETZCBUF */
122 } vopstats_t;
123 
124 /*
125  * The vnode is the focus of all file activity in UNIX.
126  * A vnode is allocated for each active file, each current
127  * directory, each mounted-on file, and the root.
128  *
129  * Each vnode is usually associated with a file-system-specific node (for
130  * UFS, this is the in-memory inode).  Generally, a vnode and an fs-node
131  * should be created and destroyed together as a pair.
132  *
133  * If a vnode is reused for a new file, it should be reinitialized by calling
134  * either vn_reinit() or vn_recycle().
135  *
136  * vn_reinit() resets the entire vnode as if it was returned by vn_alloc().
137  * The caller is responsible for setting up the entire vnode after calling
138  * vn_reinit().  This is important when using kmem caching where the vnode is
139  * allocated by a constructor, for instance.
140  *
141  * vn_recycle() is used when the file system keeps some state around in both
142  * the vnode and the associated FS-node.  In UFS, for example, the inode of
143  * a deleted file can be reused immediately.  The v_data, v_vfsp, v_op, etc.
144  * remains the same but certain fields related to the previous instance need
145  * to be reset.  In particular:
146  *	v_femhead
147  *	v_path
148  *	v_rdcnt, v_wrcnt
149  *	v_mmap_read, v_mmap_write
150  */
151 
152 /*
153  * vnode types.  VNON means no type.  These values are unrelated to
154  * values in on-disk inodes.
155  */
156 typedef enum vtype {
157 	VNON	= 0,
158 	VREG	= 1,
159 	VDIR	= 2,
160 	VBLK	= 3,
161 	VCHR	= 4,
162 	VLNK	= 5,
163 	VFIFO	= 6,
164 	VDOOR	= 7,
165 	VPROC	= 8,
166 	VSOCK	= 9,
167 	VPORT	= 10,
168 	VBAD	= 11
169 } vtype_t;
170 
171 /*
172  * VSD - Vnode Specific Data
173  * Used to associate additional private data with a vnode.
174  */
175 struct vsd_node {
176 	list_node_t vs_nodes;		/* list of all VSD nodes */
177 	uint_t vs_nkeys;		/* entries in value array */
178 	void **vs_value;		/* array of value/key */
179 };
180 
181 /*
182  * Many of the fields in the vnode are read-only once they are initialized
183  * at vnode creation time.  Other fields are protected by locks.
184  *
185  * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc().  They
186  * may not be embedded into the file-system specific node (inode).  The
187  * size of vnodes may change.
188  *
189  * The v_lock protects:
190  *   v_flag
191  *   v_stream
192  *   v_count
193  *   v_shrlocks
194  *   v_path
195  *   v_vsd
196  *   v_xattrdir
197  *
198  * A special lock (implemented by vn_vfswlock in vnode.c) protects:
199  *   v_vfsmountedhere
200  *
201  * The global flock_lock mutex (in flock.c) protects:
202  *   v_filocks
203  *
204  * IMPORTANT NOTE:
205  *
206  *   The following vnode fields are considered public and may safely be
207  *   accessed by file systems or other consumers:
208  *
209  *     v_lock
210  *     v_flag
211  *     v_count
212  *     v_data
213  *     v_vfsp
214  *     v_stream
215  *     v_type
216  *     v_rdev
217  *
218  * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD.
219  * In particular, file systems should not access other fields; they may
220  * change or even be removed.  The functionality which was once provided
221  * by these fields is available through vn_* functions.
222  */
223 
224 struct fem_head;	/* from fem.h */
225 
226 typedef struct vnode {
227 	kmutex_t	v_lock;		/* protects vnode fields */
228 	uint_t		v_flag;		/* vnode flags (see below) */
229 	uint_t		v_count;	/* reference count */
230 	void		*v_data;	/* private data for fs */
231 	struct vfs	*v_vfsp;	/* ptr to containing VFS */
232 	struct stdata	*v_stream;	/* associated stream */
233 	enum vtype	v_type;		/* vnode type */
234 	dev_t		v_rdev;		/* device (VCHR, VBLK) */
235 
236 	/* PRIVATE FIELDS BELOW - DO NOT USE */
237 
238 	struct vfs	*v_vfsmountedhere; /* ptr to vfs mounted here */
239 	struct vnodeops	*v_op;		/* vnode operations */
240 	struct page	*v_pages;	/* vnode pages list */
241 	struct filock	*v_filocks;	/* ptr to filock list */
242 	struct shrlocklist *v_shrlocks;	/* ptr to shrlock list */
243 	krwlock_t	v_nbllock;	/* sync for NBMAND locks */
244 	kcondvar_t	v_cv;		/* synchronize locking */
245 	void		*v_locality;	/* hook for locality info */
246 	struct fem_head	*v_femhead;	/* fs monitoring */
247 	char		*v_path;	/* cached path */
248 	uint_t		v_rdcnt;	/* open for read count  (VREG only) */
249 	uint_t		v_wrcnt;	/* open for write count (VREG only) */
250 	u_longlong_t	v_mmap_read;	/* mmap read count */
251 	u_longlong_t	v_mmap_write;	/* mmap write count */
252 	void		*v_mpssdata;	/* info for large page mappings */
253 	void		*v_fopdata;	/* list of file ops event watches */
254 	kmutex_t	v_vsd_lock;	/* protects v_vsd field */
255 	struct vsd_node *v_vsd;		/* vnode specific data */
256 	struct vnode	*v_xattrdir;	/* unnamed extended attr dir (GFS) */
257 	uint_t		v_count_dnlc;	/* dnlc reference count */
258 } vnode_t;
259 
260 #define	IS_DEVVP(vp)	\
261 	((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
262 
263 #define	VNODE_ALIGN	64
264 /* Count of low-order 0 bits in a vnode *, based on size and alignment. */
265 #if defined(_LP64)
266 #define	VNODE_ALIGN_LOG2	8
267 #else
268 #define	VNODE_ALIGN_LOG2	7
269 #endif
270 
271 /*
272  * vnode flags.
273  */
274 #define	VROOT		0x01	/* root of its file system */
275 #define	VNOCACHE	0x02	/* don't keep cache pages on vnode */
276 #define	VNOMAP		0x04	/* file cannot be mapped/faulted */
277 #define	VDUP		0x08	/* file should be dup'ed rather then opened */
278 #define	VNOSWAP		0x10	/* file cannot be used as virtual swap device */
279 #define	VNOMOUNT	0x20	/* file cannot be covered by mount */
280 #define	VISSWAP		0x40	/* vnode is being used for swap */
281 #define	VSWAPLIKE	0x80	/* vnode acts like swap (but may not be) */
282 
283 #define	IS_SWAPVP(vp)	(((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0)
284 
285 typedef struct vn_vfslocks_entry {
286 	rwstlock_t ve_lock;
287 	void *ve_vpvfs;
288 	struct vn_vfslocks_entry *ve_next;
289 	uint32_t ve_refcnt;
290 	char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \
291 	    sizeof (uint32_t)];
292 } vn_vfslocks_entry_t;
293 
294 /*
295  * The following two flags are used to lock the v_vfsmountedhere field
296  */
297 #define	VVFSLOCK	0x100
298 #define	VVFSWAIT	0x200
299 
300 /*
301  * Used to serialize VM operations on a vnode
302  */
303 #define	VVMLOCK		0x400
304 
305 /*
306  * Tell vn_open() not to fail a directory open for writing but
307  * to go ahead and call VOP_OPEN() to let the filesystem check.
308  */
309 #define	VDIROPEN	0x800
310 
311 /*
312  * Flag to let the VM system know that this file is most likely a binary
313  * or shared library since it has been mmap()ed EXEC at some time.
314  */
315 #define	VVMEXEC		0x1000
316 
317 #define	VPXFS		0x2000  /* clustering: global fs proxy vnode */
318 
319 #define	IS_PXFSVP(vp)	((vp)->v_flag & VPXFS)
320 
321 #define	V_XATTRDIR	0x4000	/* attribute unnamed directory */
322 
323 #define	IS_XATTRDIR(vp)	((vp)->v_flag & V_XATTRDIR)
324 
325 #define	V_LOCALITY	0x8000	/* whether locality aware */
326 
327 /*
328  * Flag that indicates the VM should maintain the v_pages list with all modified
329  * pages on one end and unmodified pages at the other. This makes finding dirty
330  * pages to write back to disk much faster at the expense of taking a minor
331  * fault on the first store instruction which touches a writable page.
332  */
333 #define	VMODSORT	(0x10000)
334 #define	IS_VMODSORT(vp) \
335 	(pvn_vmodsort_supported != 0 && ((vp)->v_flag  & VMODSORT) != 0)
336 
337 #define	VISSWAPFS	0x20000	/* vnode is being used for swapfs */
338 
339 /*
340  * The mdb memstat command assumes that IS_SWAPFSVP only uses the
341  * vnode's v_flag field.  If this changes, cache the additional
342  * fields in mdb; see vn_get in mdb/common/modules/genunix/memory.c
343  */
344 #define	IS_SWAPFSVP(vp)	(((vp)->v_flag & VISSWAPFS) != 0)
345 
346 #define	V_SYSATTR	0x40000	/* vnode is a GFS system attribute */
347 
348 /*
349  * Vnode attributes.  A bit-mask is supplied as part of the
350  * structure to indicate the attributes the caller wants to
351  * set (setattr) or extract (getattr).
352  */
353 
354 /*
355  * Note that va_nodeid and va_nblocks are 64bit data type.
356  * We support large files over NFSV3. With Solaris client and
357  * Server that generates 64bit ino's and sizes these fields
358  * will overflow if they are 32 bit sizes.
359  */
360 
361 typedef struct vattr {
362 	uint_t		va_mask;	/* bit-mask of attributes */
363 	vtype_t		va_type;	/* vnode type (for create) */
364 	mode_t		va_mode;	/* file access mode */
365 	uid_t		va_uid;		/* owner user id */
366 	gid_t		va_gid;		/* owner group id */
367 	dev_t		va_fsid;	/* file system id (dev for now) */
368 	u_longlong_t	va_nodeid;	/* node id */
369 	nlink_t		va_nlink;	/* number of references to file */
370 	u_offset_t	va_size;	/* file size in bytes */
371 	timestruc_t	va_atime;	/* time of last access */
372 	timestruc_t	va_mtime;	/* time of last modification */
373 	timestruc_t	va_ctime;	/* time of last status change */
374 	dev_t		va_rdev;	/* device the file represents */
375 	uint_t		va_blksize;	/* fundamental block size */
376 	u_longlong_t	va_nblocks;	/* # of blocks allocated */
377 	uint_t		va_seq;		/* sequence number */
378 } vattr_t;
379 
380 #define	AV_SCANSTAMP_SZ	32		/* length of anti-virus scanstamp */
381 
382 /*
383  * Structure of all optional attributes.
384  */
385 typedef struct xoptattr {
386 	timestruc_t	xoa_createtime;	/* Create time of file */
387 	uint8_t		xoa_archive;
388 	uint8_t		xoa_system;
389 	uint8_t		xoa_readonly;
390 	uint8_t		xoa_hidden;
391 	uint8_t		xoa_nounlink;
392 	uint8_t		xoa_immutable;
393 	uint8_t		xoa_appendonly;
394 	uint8_t		xoa_nodump;
395 	uint8_t		xoa_opaque;
396 	uint8_t		xoa_av_quarantined;
397 	uint8_t		xoa_av_modified;
398 	uint8_t		xoa_av_scanstamp[AV_SCANSTAMP_SZ];
399 	uint8_t		xoa_reparse;
400 } xoptattr_t;
401 
402 /*
403  * The xvattr structure is really a variable length structure that
404  * is made up of:
405  * - The classic vattr_t (xva_vattr)
406  * - a 32 bit quantity (xva_mapsize) that specifies the size of the
407  *   attribute bitmaps in 32 bit words.
408  * - A pointer to the returned attribute bitmap (needed because the
409  *   previous element, the requested attribute bitmap) is variable lenth.
410  * - The requested attribute bitmap, which is an array of 32 bit words.
411  *   Callers use the XVA_SET_REQ() macro to set the bits corresponding to
412  *   the attributes that are being requested.
413  * - The returned attribute bitmap, which is an array of 32 bit words.
414  *   File systems that support optional attributes use the XVA_SET_RTN()
415  *   macro to set the bits corresponding to the attributes that are being
416  *   returned.
417  * - The xoptattr_t structure which contains the attribute values
418  *
419  * xva_mapsize determines how many words in the attribute bitmaps.
420  * Immediately following the attribute bitmaps is the xoptattr_t.
421  * xva_getxoptattr() is used to get the pointer to the xoptattr_t
422  * section.
423  */
424 
425 #define	XVA_MAPSIZE	3		/* Size of attr bitmaps */
426 #define	XVA_MAGIC	0x78766174	/* Magic # for verification */
427 
428 /*
429  * The xvattr structure is an extensible structure which permits optional
430  * attributes to be requested/returned.  File systems may or may not support
431  * optional attributes.  They do so at their own discretion but if they do
432  * support optional attributes, they must register the VFSFT_XVATTR feature
433  * so that the optional attributes can be set/retrived.
434  *
435  * The fields of the xvattr structure are:
436  *
437  * xva_vattr - The first element of an xvattr is a legacy vattr structure
438  * which includes the common attributes.  If AT_XVATTR is set in the va_mask
439  * then the entire structure is treated as an xvattr.  If AT_XVATTR is not
440  * set, then only the xva_vattr structure can be used.
441  *
442  * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification.
443  *
444  * xva_mapsize - Size of requested and returned attribute bitmaps.
445  *
446  * xva_rtnattrmapp - Pointer to xva_rtnattrmap[].  We need this since the
447  * size of the array before it, xva_reqattrmap[], could change which means
448  * the location of xva_rtnattrmap[] could change.  This will allow unbundled
449  * file systems to find the location of xva_rtnattrmap[] when the sizes change.
450  *
451  * xva_reqattrmap[] - Array of requested attributes.  Attributes are
452  * represented by a specific bit in a specific element of the attribute
453  * map array.  Callers set the bits corresponding to the attributes
454  * that the caller wants to get/set.
455  *
456  * xva_rtnattrmap[] - Array of attributes that the file system was able to
457  * process.  Not all file systems support all optional attributes.  This map
458  * informs the caller which attributes the underlying file system was able
459  * to set/get.  (Same structure as the requested attributes array in terms
460  * of each attribute  corresponding to specific bits and array elements.)
461  *
462  * xva_xoptattrs - Structure containing values of optional attributes.
463  * These values are only valid if the corresponding bits in xva_reqattrmap
464  * are set and the underlying file system supports those attributes.
465  */
466 typedef struct xvattr {
467 	vattr_t		xva_vattr;	/* Embedded vattr structure */
468 	uint32_t	xva_magic;	/* Magic Number */
469 	uint32_t	xva_mapsize;	/* Size of attr bitmap (32-bit words) */
470 	uint32_t	*xva_rtnattrmapp;	/* Ptr to xva_rtnattrmap[] */
471 	uint32_t	xva_reqattrmap[XVA_MAPSIZE];	/* Requested attrs */
472 	uint32_t	xva_rtnattrmap[XVA_MAPSIZE];	/* Returned attrs */
473 	xoptattr_t	xva_xoptattrs;	/* Optional attributes */
474 } xvattr_t;
475 
476 #ifdef _SYSCALL32
477 /*
478  * For bigtypes time_t changed to 64 bit on the 64-bit kernel.
479  * Define an old version for user/kernel interface
480  */
481 
482 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
483 #pragma pack(4)
484 #endif
485 
486 typedef struct vattr32 {
487 	uint32_t	va_mask;	/* bit-mask of attributes */
488 	vtype_t		va_type;	/* vnode type (for create) */
489 	mode32_t	va_mode;	/* file access mode */
490 	uid32_t		va_uid;		/* owner user id */
491 	gid32_t		va_gid;		/* owner group id */
492 	dev32_t		va_fsid;	/* file system id (dev for now) */
493 	u_longlong_t	va_nodeid;	/* node id */
494 	nlink_t		va_nlink;	/* number of references to file */
495 	u_offset_t	va_size;	/* file size in bytes */
496 	timestruc32_t	va_atime;	/* time of last access */
497 	timestruc32_t	va_mtime;	/* time of last modification */
498 	timestruc32_t	va_ctime;	/* time of last status change */
499 	dev32_t		va_rdev;	/* device the file represents */
500 	uint32_t	va_blksize;	/* fundamental block size */
501 	u_longlong_t	va_nblocks;	/* # of blocks allocated */
502 	uint32_t	va_seq;		/* sequence number */
503 } vattr32_t;
504 
505 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
506 #pragma pack()
507 #endif
508 
509 #else  /* not _SYSCALL32 */
510 #define	vattr32		vattr
511 typedef vattr_t		vattr32_t;
512 #endif /* _SYSCALL32 */
513 
514 /*
515  * Attributes of interest to the caller of setattr or getattr.
516  */
517 #define	AT_TYPE		0x00001
518 #define	AT_MODE		0x00002
519 #define	AT_UID		0x00004
520 #define	AT_GID		0x00008
521 #define	AT_FSID		0x00010
522 #define	AT_NODEID	0x00020
523 #define	AT_NLINK	0x00040
524 #define	AT_SIZE		0x00080
525 #define	AT_ATIME	0x00100
526 #define	AT_MTIME	0x00200
527 #define	AT_CTIME	0x00400
528 #define	AT_RDEV		0x00800
529 #define	AT_BLKSIZE	0x01000
530 #define	AT_NBLOCKS	0x02000
531 /*			0x04000 */	/* unused */
532 #define	AT_SEQ		0x08000
533 /*
534  * If AT_XVATTR is set then there are additional bits to process in
535  * the xvattr_t's attribute bitmap.  If this is not set then the bitmap
536  * MUST be ignored.  Note that this bit must be set/cleared explicitly.
537  * That is, setting AT_ALL will NOT set AT_XVATTR.
538  */
539 #define	AT_XVATTR	0x10000
540 
541 #define	AT_ALL		(AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\
542 			AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\
543 			AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
544 
545 #define	AT_STAT		(AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
546 			AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE)
547 
548 #define	AT_TIMES	(AT_ATIME|AT_MTIME|AT_CTIME)
549 
550 #define	AT_NOSET	(AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
551 			AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
552 
553 /*
554  * Attribute bits used in the extensible attribute's (xva's) attribute
555  * bitmaps.  Note that the bitmaps are made up of a variable length number
556  * of 32-bit words.  The convention is to use XAT{n}_{attrname} where "n"
557  * is the element in the bitmap (starting at 1).  This convention is for
558  * the convenience of the maintainer to keep track of which element each
559  * attribute belongs to.
560  *
561  * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY.  CONSUMERS
562  * MUST USE THE XAT_* DEFINES.
563  */
564 #define	XAT0_INDEX	0LL		/* Index into bitmap for XAT0 attrs */
565 #define	XAT0_CREATETIME	0x00000001	/* Create time of file */
566 #define	XAT0_ARCHIVE	0x00000002	/* Archive */
567 #define	XAT0_SYSTEM	0x00000004	/* System */
568 #define	XAT0_READONLY	0x00000008	/* Readonly */
569 #define	XAT0_HIDDEN	0x00000010	/* Hidden */
570 #define	XAT0_NOUNLINK	0x00000020	/* Nounlink */
571 #define	XAT0_IMMUTABLE	0x00000040	/* immutable */
572 #define	XAT0_APPENDONLY	0x00000080	/* appendonly */
573 #define	XAT0_NODUMP	0x00000100	/* nodump */
574 #define	XAT0_OPAQUE	0x00000200	/* opaque */
575 #define	XAT0_AV_QUARANTINED	0x00000400	/* anti-virus quarantine */
576 #define	XAT0_AV_MODIFIED	0x00000800	/* anti-virus modified */
577 #define	XAT0_AV_SCANSTAMP	0x00001000	/* anti-virus scanstamp */
578 #define	XAT0_REPARSE	0x00002000	/* FS reparse point */
579 
580 #define	XAT0_ALL_ATTRS	(XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \
581     XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \
582     XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| \
583     XAT0_AV_MODIFIED|XAT0_AV_SCANSTAMP|XAT0_REPARSE)
584 
585 /* Support for XAT_* optional attributes */
586 #define	XVA_MASK		0xffffffff	/* Used to mask off 32 bits */
587 #define	XVA_SHFT		32		/* Used to shift index */
588 
589 /*
590  * Used to pry out the index and attribute bits from the XAT_* attributes
591  * defined below.  Note that we're masking things down to 32 bits then
592  * casting to uint32_t.
593  */
594 #define	XVA_INDEX(attr)		((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK))
595 #define	XVA_ATTRBIT(attr)	((uint32_t)((attr) & XVA_MASK))
596 
597 /*
598  * The following defines present a "flat namespace" so that consumers don't
599  * need to keep track of which element belongs to which bitmap entry.
600  *
601  * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER
602  */
603 #define	XAT_CREATETIME		((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME)
604 #define	XAT_ARCHIVE		((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE)
605 #define	XAT_SYSTEM		((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM)
606 #define	XAT_READONLY		((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY)
607 #define	XAT_HIDDEN		((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN)
608 #define	XAT_NOUNLINK		((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK)
609 #define	XAT_IMMUTABLE		((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE)
610 #define	XAT_APPENDONLY		((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY)
611 #define	XAT_NODUMP		((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP)
612 #define	XAT_OPAQUE		((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE)
613 #define	XAT_AV_QUARANTINED	((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED)
614 #define	XAT_AV_MODIFIED		((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED)
615 #define	XAT_AV_SCANSTAMP	((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP)
616 #define	XAT_REPARSE		((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE)
617 
618 /*
619  * The returned attribute map array (xva_rtnattrmap[]) is located past the
620  * requested attribute map array (xva_reqattrmap[]).  Its location changes
621  * when the array sizes change.  We use a separate pointer in a known location
622  * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[].  This is
623  * set in xva_init()
624  */
625 #define	XVA_RTNATTRMAP(xvap)	((xvap)->xva_rtnattrmapp)
626 
627 /*
628  * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap
629  * of requested attributes (xva_reqattrmap[]).
630  */
631 #define	XVA_SET_REQ(xvap, attr)					\
632 	ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR);		\
633 	ASSERT((xvap)->xva_magic == XVA_MAGIC);			\
634 	(xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
635 /*
636  * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap
637  * of requested attributes (xva_reqattrmap[]).
638  */
639 #define	XVA_CLR_REQ(xvap, attr)					\
640 	ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR);		\
641 	ASSERT((xvap)->xva_magic == XVA_MAGIC);			\
642 	(xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr)
643 
644 /*
645  * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap
646  * of returned attributes (xva_rtnattrmap[]).
647  */
648 #define	XVA_SET_RTN(xvap, attr)					\
649 	ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR);		\
650 	ASSERT((xvap)->xva_magic == XVA_MAGIC);			\
651 	(XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
652 
653 /*
654  * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[])
655  * to see of the corresponding attribute bit is set.  If so, returns non-zero.
656  */
657 #define	XVA_ISSET_REQ(xvap, attr)					\
658 	((((xvap)->xva_vattr.va_mask | AT_XVATTR) &&			\
659 		((xvap)->xva_magic == XVA_MAGIC) &&			\
660 		((xvap)->xva_mapsize > XVA_INDEX(attr))) ?		\
661 	((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) :	0)
662 
663 /*
664  * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[])
665  * to see of the corresponding attribute bit is set.  If so, returns non-zero.
666  */
667 #define	XVA_ISSET_RTN(xvap, attr)					\
668 	((((xvap)->xva_vattr.va_mask | AT_XVATTR) &&			\
669 		((xvap)->xva_magic == XVA_MAGIC) &&			\
670 		((xvap)->xva_mapsize > XVA_INDEX(attr))) ?		\
671 	((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
672 
673 /*
674  *  Modes.  Some values same as S_xxx entries from stat.h for convenience.
675  */
676 #define	VSUID		04000		/* set user id on execution */
677 #define	VSGID		02000		/* set group id on execution */
678 #define	VSVTX		01000		/* save swapped text even after use */
679 
680 /*
681  * Permissions.
682  */
683 #define	VREAD		00400
684 #define	VWRITE		00200
685 #define	VEXEC		00100
686 
687 #define	MODEMASK	07777		/* mode bits plus permission bits */
688 #define	PERMMASK	00777		/* permission bits */
689 
690 /*
691  * VOP_ACCESS flags
692  */
693 #define	V_ACE_MASK	0x1	/* mask represents  NFSv4 ACE permissions */
694 #define	V_APPEND	0x2	/* want to do append only check */
695 
696 /*
697  * Check whether mandatory file locking is enabled.
698  */
699 
700 #define	MANDMODE(mode)		(((mode) & (VSGID|(VEXEC>>3))) == VSGID)
701 #define	MANDLOCK(vp, mode)	((vp)->v_type == VREG && MANDMODE(mode))
702 
703 /*
704  * Flags for vnode operations.
705  */
706 enum rm		{ RMFILE, RMDIRECTORY };	/* rm or rmdir (remove) */
707 enum symfollow	{ NO_FOLLOW, FOLLOW };		/* follow symlinks (or not) */
708 enum vcexcl	{ NONEXCL, EXCL };		/* (non)excl create */
709 enum create	{ CRCREAT, CRMKNOD, CRMKDIR };	/* reason for create */
710 
711 typedef enum rm		rm_t;
712 typedef enum symfollow	symfollow_t;
713 typedef enum vcexcl	vcexcl_t;
714 typedef enum create	create_t;
715 
716 /* Vnode Events - Used by VOP_VNEVENT */
717 typedef enum vnevent	{
718 	VE_SUPPORT	= 0,	/* Query */
719 	VE_RENAME_SRC	= 1,	/* Rename, with vnode as source */
720 	VE_RENAME_DEST	= 2,	/* Rename, with vnode as target/destination */
721 	VE_REMOVE	= 3,	/* Remove of vnode's name */
722 	VE_RMDIR	= 4,	/* Remove of directory vnode's name */
723 	VE_CREATE	= 5,	/* Create with vnode's name which exists */
724 	VE_LINK		= 6, 	/* Link with vnode's name as source */
725 	VE_RENAME_DEST_DIR	= 7, 	/* Rename with vnode as target dir */
726 	VE_MOUNTEDOVER	= 8 	/* File or Filesystem got mounted over vnode */
727 } vnevent_t;
728 
729 /*
730  * Values for checking vnode open and map counts
731  */
732 enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR };
733 
734 typedef enum v_mode v_mode_t;
735 
736 #define	V_TRUE	1
737 #define	V_FALSE	0
738 
739 /*
740  * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations
741  */
742 
743 typedef struct vsecattr {
744 	uint_t		vsa_mask;	/* See below */
745 	int		vsa_aclcnt;	/* ACL entry count */
746 	void		*vsa_aclentp;	/* pointer to ACL entries */
747 	int		vsa_dfaclcnt;	/* default ACL entry count */
748 	void		*vsa_dfaclentp;	/* pointer to default ACL entries */
749 	size_t		vsa_aclentsz;	/* ACE size in bytes of vsa_aclentp */
750 	uint_t		vsa_aclflags;	/* ACE ACL flags */
751 } vsecattr_t;
752 
753 /* vsa_mask values */
754 #define	VSA_ACL			0x0001
755 #define	VSA_ACLCNT		0x0002
756 #define	VSA_DFACL		0x0004
757 #define	VSA_DFACLCNT		0x0008
758 #define	VSA_ACE			0x0010
759 #define	VSA_ACECNT		0x0020
760 #define	VSA_ACE_ALLTYPES	0x0040
761 #define	VSA_ACE_ACLFLAGS	0x0080	/* get/set ACE ACL flags */
762 
763 /*
764  * Structure used by various vnode operations to determine
765  * the context (pid, host, identity) of a caller.
766  *
767  * The cc_caller_id is used to identify one or more callers who invoke
768  * operations, possibly on behalf of others.  For example, the NFS
769  * server could have it's own cc_caller_id which can be detected by
770  * vnode/vfs operations or (FEM) monitors on those operations.  New
771  * caller IDs are generated by fs_new_caller_id().
772  */
773 typedef struct caller_context {
774 	pid_t		cc_pid;		/* Process ID of the caller */
775 	int		cc_sysid;	/* System ID, used for remote calls */
776 	u_longlong_t	cc_caller_id;	/* Identifier for (set of) caller(s) */
777 	ulong_t		cc_flags;
778 } caller_context_t;
779 
780 /*
781  * Flags for caller context.  The caller sets CC_DONTBLOCK if it does not
782  * want to block inside of a FEM monitor.  The monitor will set CC_WOULDBLOCK
783  * and return EAGAIN if the operation would have blocked.
784  */
785 #define	CC_WOULDBLOCK	0x01
786 #define	CC_DONTBLOCK	0x02
787 
788 /*
789  * Structure tags for function prototypes, defined elsewhere.
790  */
791 struct pathname;
792 struct fid;
793 struct flock64;
794 struct flk_callback;
795 struct shrlock;
796 struct page;
797 struct seg;
798 struct as;
799 struct pollhead;
800 struct taskq;
801 
802 #ifdef	_KERNEL
803 
804 /*
805  * VNODE_OPS defines all the vnode operations.  It is used to define
806  * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h).
807  */
808 #define	VNODE_OPS							\
809 	int	(*vop_open)(vnode_t **, int, cred_t *,			\
810 				caller_context_t *);			\
811 	int	(*vop_close)(vnode_t *, int, int, offset_t, cred_t *,	\
812 				caller_context_t *);			\
813 	int	(*vop_read)(vnode_t *, uio_t *, int, cred_t *,		\
814 				caller_context_t *);			\
815 	int	(*vop_write)(vnode_t *, uio_t *, int, cred_t *,		\
816 				caller_context_t *);			\
817 	int	(*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *,	\
818 				int *, caller_context_t *);		\
819 	int	(*vop_setfl)(vnode_t *, int, int, cred_t *,		\
820 				caller_context_t *);			\
821 	int	(*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *,	\
822 				caller_context_t *);			\
823 	int	(*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *,	\
824 				caller_context_t *);			\
825 	int	(*vop_access)(vnode_t *, int, int, cred_t *,		\
826 				caller_context_t *);			\
827 	int	(*vop_lookup)(vnode_t *, char *, vnode_t **,		\
828 				struct pathname *,			\
829 				int, vnode_t *, cred_t *,		\
830 				caller_context_t *, int *,		\
831 				struct pathname *);			\
832 	int	(*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t,	\
833 				int, vnode_t **, cred_t *, int,		\
834 				caller_context_t *, vsecattr_t *);	\
835 	int	(*vop_remove)(vnode_t *, char *, cred_t *,		\
836 				caller_context_t *, int);		\
837 	int	(*vop_link)(vnode_t *, vnode_t *, char *, cred_t *,	\
838 				caller_context_t *, int);		\
839 	int	(*vop_rename)(vnode_t *, char *, vnode_t *, char *,	\
840 				cred_t *, caller_context_t *, int);	\
841 	int	(*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **,	\
842 				cred_t *, caller_context_t *, int,	\
843 				vsecattr_t *);				\
844 	int	(*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *,	\
845 				caller_context_t *, int);		\
846 	int	(*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *,	\
847 				caller_context_t *, int);		\
848 	int	(*vop_symlink)(vnode_t *, char *, vattr_t *, char *,	\
849 				cred_t *, caller_context_t *, int);	\
850 	int	(*vop_readlink)(vnode_t *, uio_t *, cred_t *,		\
851 				caller_context_t *);			\
852 	int	(*vop_fsync)(vnode_t *, int, cred_t *,			\
853 				caller_context_t *);			\
854 	void	(*vop_inactive)(vnode_t *, cred_t *,			\
855 				caller_context_t *);			\
856 	int	(*vop_fid)(vnode_t *, struct fid *,			\
857 				caller_context_t *);			\
858 	int	(*vop_rwlock)(vnode_t *, int, caller_context_t *);	\
859 	void	(*vop_rwunlock)(vnode_t *, int, caller_context_t *);	\
860 	int	(*vop_seek)(vnode_t *, offset_t, offset_t *,		\
861 				caller_context_t *);			\
862 	int	(*vop_cmp)(vnode_t *, vnode_t *, caller_context_t *);	\
863 	int	(*vop_frlock)(vnode_t *, int, struct flock64 *,		\
864 				int, offset_t,				\
865 				struct flk_callback *, cred_t *,	\
866 				caller_context_t *);			\
867 	int	(*vop_space)(vnode_t *, int, struct flock64 *,		\
868 				int, offset_t,				\
869 				cred_t *, caller_context_t *);		\
870 	int	(*vop_realvp)(vnode_t *, vnode_t **,			\
871 				caller_context_t *);			\
872 	int	(*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *,	\
873 				struct page **, size_t, struct seg *,	\
874 				caddr_t, enum seg_rw, cred_t *,		\
875 				caller_context_t *);			\
876 	int	(*vop_putpage)(vnode_t *, offset_t, size_t,		\
877 				int, cred_t *, caller_context_t *);	\
878 	int	(*vop_map)(vnode_t *, offset_t, struct as *,		\
879 				caddr_t *, size_t,			\
880 				uchar_t, uchar_t, uint_t, cred_t *,	\
881 				caller_context_t *);			\
882 	int	(*vop_addmap)(vnode_t *, offset_t, struct as *,		\
883 				caddr_t, size_t,			\
884 				uchar_t, uchar_t, uint_t, cred_t *,	\
885 				caller_context_t *);			\
886 	int	(*vop_delmap)(vnode_t *, offset_t, struct as *,		\
887 				caddr_t, size_t,			\
888 				uint_t, uint_t, uint_t, cred_t *,	\
889 				caller_context_t *);			\
890 	int	(*vop_poll)(vnode_t *, short, int, short *,		\
891 				struct pollhead **,			\
892 				caller_context_t *);			\
893 	int	(*vop_dump)(vnode_t *, caddr_t, offset_t, offset_t,	\
894 				caller_context_t *);			\
895 	int	(*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *,	\
896 				caller_context_t *);			\
897 	int	(*vop_pageio)(vnode_t *, struct page *,			\
898 				u_offset_t, size_t, int, cred_t *,	\
899 				caller_context_t *);			\
900 	int	(*vop_dumpctl)(vnode_t *, int, offset_t *,		\
901 				caller_context_t *);			\
902 	void	(*vop_dispose)(vnode_t *, struct page *,		\
903 				int, int, cred_t *,			\
904 				caller_context_t *);			\
905 	int	(*vop_setsecattr)(vnode_t *, vsecattr_t *,		\
906 				int, cred_t *, caller_context_t *);	\
907 	int	(*vop_getsecattr)(vnode_t *, vsecattr_t *,		\
908 				int, cred_t *, caller_context_t *);	\
909 	int	(*vop_shrlock)(vnode_t *, int, struct shrlock *,	\
910 				int, cred_t *, caller_context_t *);	\
911 	int	(*vop_vnevent)(vnode_t *, vnevent_t, vnode_t *,		\
912 				char *, caller_context_t *);		\
913 	int	(*vop_reqzcbuf)(vnode_t *, enum uio_rw, xuio_t *,	\
914 				cred_t *, caller_context_t *);		\
915 	int	(*vop_retzcbuf)(vnode_t *, xuio_t *, cred_t *,		\
916 				caller_context_t *)
917 	/* NB: No ";" */
918 
919 /*
920  * Operations on vnodes.  Note: File systems must never operate directly
921  * on a 'vnodeops' structure -- it WILL change in future releases!  They
922  * must use vn_make_ops() to create the structure.
923  */
924 typedef struct vnodeops {
925 	const char *vnop_name;
926 	VNODE_OPS;	/* Signatures of all vnode operations (vops) */
927 } vnodeops_t;
928 
929 typedef int (*fs_generic_func_p) ();	/* Generic vop/vfsop/femop/fsemop ptr */
930 
931 extern int	fop_open(vnode_t **, int, cred_t *, caller_context_t *);
932 extern int	fop_close(vnode_t *, int, int, offset_t, cred_t *,
933 				caller_context_t *);
934 extern int	fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *);
935 extern int	fop_write(vnode_t *, uio_t *, int, cred_t *,
936 				caller_context_t *);
937 extern int	fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *,
938 				caller_context_t *);
939 extern int	fop_setfl(vnode_t *, int, int, cred_t *, caller_context_t *);
940 extern int	fop_getattr(vnode_t *, vattr_t *, int, cred_t *,
941 				caller_context_t *);
942 extern int	fop_setattr(vnode_t *, vattr_t *, int, cred_t *,
943 				caller_context_t *);
944 extern int	fop_access(vnode_t *, int, int, cred_t *, caller_context_t *);
945 extern int	fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *,
946 				int, vnode_t *, cred_t *, caller_context_t *,
947 				int *, struct pathname *);
948 extern int	fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int,
949 				vnode_t **, cred_t *, int, caller_context_t *,
950 				vsecattr_t *);
951 extern int	fop_remove(vnode_t *vp, char *, cred_t *, caller_context_t *,
952 				int);
953 extern int	fop_link(vnode_t *, vnode_t *, char *, cred_t *,
954 				caller_context_t *, int);
955 extern int	fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *,
956 				caller_context_t *, int);
957 extern int	fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *,
958 				caller_context_t *, int, vsecattr_t *);
959 extern int	fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *,
960 				caller_context_t *, int);
961 extern int	fop_readdir(vnode_t *, uio_t *, cred_t *, int *,
962 				caller_context_t *, int);
963 extern int	fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *,
964 				caller_context_t *, int);
965 extern int	fop_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *);
966 extern int	fop_fsync(vnode_t *, int, cred_t *, caller_context_t *);
967 extern void	fop_inactive(vnode_t *, cred_t *, caller_context_t *);
968 extern int	fop_fid(vnode_t *, struct fid *, caller_context_t *);
969 extern int	fop_rwlock(vnode_t *, int, caller_context_t *);
970 extern void	fop_rwunlock(vnode_t *, int, caller_context_t *);
971 extern int	fop_seek(vnode_t *, offset_t, offset_t *, caller_context_t *);
972 extern int	fop_cmp(vnode_t *, vnode_t *, caller_context_t *);
973 extern int	fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t,
974 				struct flk_callback *, cred_t *,
975 				caller_context_t *);
976 extern int	fop_space(vnode_t *, int, struct flock64 *, int, offset_t,
977 				cred_t *, caller_context_t *);
978 extern int	fop_realvp(vnode_t *, vnode_t **, caller_context_t *);
979 extern int	fop_getpage(vnode_t *, offset_t, size_t, uint_t *,
980 				struct page **, size_t, struct seg *,
981 				caddr_t, enum seg_rw, cred_t *,
982 				caller_context_t *);
983 extern int	fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *,
984 				caller_context_t *);
985 extern int	fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t,
986 				uchar_t, uchar_t, uint_t, cred_t *cr,
987 				caller_context_t *);
988 extern int	fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
989 				uchar_t, uchar_t, uint_t, cred_t *,
990 				caller_context_t *);
991 extern int	fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
992 				uint_t, uint_t, uint_t, cred_t *,
993 				caller_context_t *);
994 extern int	fop_poll(vnode_t *, short, int, short *, struct pollhead **,
995 				caller_context_t *);
996 extern int	fop_dump(vnode_t *, caddr_t, offset_t, offset_t,
997     caller_context_t *);
998 extern int	fop_pathconf(vnode_t *, int, ulong_t *, cred_t *,
999 				caller_context_t *);
1000 extern int	fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int,
1001 				cred_t *, caller_context_t *);
1002 extern int	fop_dumpctl(vnode_t *, int, offset_t *, caller_context_t *);
1003 extern void	fop_dispose(vnode_t *, struct page *, int, int, cred_t *,
1004 				caller_context_t *);
1005 extern int	fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *,
1006 				caller_context_t *);
1007 extern int	fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *,
1008 				caller_context_t *);
1009 extern int	fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *,
1010 				caller_context_t *);
1011 extern int	fop_vnevent(vnode_t *, vnevent_t, vnode_t *, char *,
1012 				caller_context_t *);
1013 extern int	fop_reqzcbuf(vnode_t *, enum uio_rw, xuio_t *, cred_t *,
1014 				caller_context_t *);
1015 extern int	fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *);
1016 
1017 #endif	/* _KERNEL */
1018 
1019 #define	VOP_OPEN(vpp, mode, cr, ct) \
1020 	fop_open(vpp, mode, cr, ct)
1021 #define	VOP_CLOSE(vp, f, c, o, cr, ct) \
1022 	fop_close(vp, f, c, o, cr, ct)
1023 #define	VOP_READ(vp, uiop, iof, cr, ct) \
1024 	fop_read(vp, uiop, iof, cr, ct)
1025 #define	VOP_WRITE(vp, uiop, iof, cr, ct) \
1026 	fop_write(vp, uiop, iof, cr, ct)
1027 #define	VOP_IOCTL(vp, cmd, a, f, cr, rvp, ct) \
1028 	fop_ioctl(vp, cmd, a, f, cr, rvp, ct)
1029 #define	VOP_SETFL(vp, f, a, cr, ct) \
1030 	fop_setfl(vp, f, a, cr, ct)
1031 #define	VOP_GETATTR(vp, vap, f, cr, ct) \
1032 	fop_getattr(vp, vap, f, cr, ct)
1033 #define	VOP_SETATTR(vp, vap, f, cr, ct) \
1034 	fop_setattr(vp, vap, f, cr, ct)
1035 #define	VOP_ACCESS(vp, mode, f, cr, ct) \
1036 	fop_access(vp, mode, f, cr, ct)
1037 #define	VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) \
1038 	fop_lookup(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp)
1039 #define	VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) \
1040 	fop_create(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap)
1041 #define	VOP_REMOVE(dvp, p, cr, ct, f) \
1042 	fop_remove(dvp, p, cr, ct, f)
1043 #define	VOP_LINK(tdvp, fvp, p, cr, ct, f) \
1044 	fop_link(tdvp, fvp, p, cr, ct, f)
1045 #define	VOP_RENAME(fvp, fnm, tdvp, tnm, cr, ct, f) \
1046 	fop_rename(fvp, fnm, tdvp, tnm, cr, ct, f)
1047 #define	VOP_MKDIR(dp, p, vap, vpp, cr, ct, f, vsap) \
1048 	fop_mkdir(dp, p, vap, vpp, cr, ct, f, vsap)
1049 #define	VOP_RMDIR(dp, p, cdir, cr, ct, f) \
1050 	fop_rmdir(dp, p, cdir, cr, ct, f)
1051 #define	VOP_READDIR(vp, uiop, cr, eofp, ct, f) \
1052 	fop_readdir(vp, uiop, cr, eofp, ct, f)
1053 #define	VOP_SYMLINK(dvp, lnm, vap, tnm, cr, ct, f) \
1054 	fop_symlink(dvp, lnm, vap, tnm, cr, ct, f)
1055 #define	VOP_READLINK(vp, uiop, cr, ct) \
1056 	fop_readlink(vp, uiop, cr, ct)
1057 #define	VOP_FSYNC(vp, syncflag, cr, ct) \
1058 	fop_fsync(vp, syncflag, cr, ct)
1059 #define	VOP_INACTIVE(vp, cr, ct) \
1060 	fop_inactive(vp, cr, ct)
1061 #define	VOP_FID(vp, fidp, ct) \
1062 	fop_fid(vp, fidp, ct)
1063 #define	VOP_RWLOCK(vp, w, ct) \
1064 	fop_rwlock(vp, w, ct)
1065 #define	VOP_RWUNLOCK(vp, w, ct) \
1066 	fop_rwunlock(vp, w, ct)
1067 #define	VOP_SEEK(vp, ooff, noffp, ct) \
1068 	fop_seek(vp, ooff, noffp, ct)
1069 #define	VOP_CMP(vp1, vp2, ct) \
1070 	fop_cmp(vp1, vp2, ct)
1071 #define	VOP_FRLOCK(vp, cmd, a, f, o, cb, cr, ct) \
1072 	fop_frlock(vp, cmd, a, f, o, cb, cr, ct)
1073 #define	VOP_SPACE(vp, cmd, a, f, o, cr, ct) \
1074 	fop_space(vp, cmd, a, f, o, cr, ct)
1075 #define	VOP_REALVP(vp1, vp2, ct) \
1076 	fop_realvp(vp1, vp2, ct)
1077 #define	VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) \
1078 	fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct)
1079 #define	VOP_PUTPAGE(vp, of, sz, fl, cr, ct) \
1080 	fop_putpage(vp, of, sz, fl, cr, ct)
1081 #define	VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1082 	fop_map(vp, of, as, a, sz, p, mp, fl, cr, ct)
1083 #define	VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1084 	fop_addmap(vp, of, as, a, sz, p, mp, fl, cr, ct)
1085 #define	VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1086 	fop_delmap(vp, of, as, a, sz, p, mp, fl, cr, ct)
1087 #define	VOP_POLL(vp, events, anyyet, reventsp, phpp, ct) \
1088 	fop_poll(vp, events, anyyet, reventsp, phpp, ct)
1089 #define	VOP_DUMP(vp, addr, bn, count, ct) \
1090 	fop_dump(vp, addr, bn, count, ct)
1091 #define	VOP_PATHCONF(vp, cmd, valp, cr, ct) \
1092 	fop_pathconf(vp, cmd, valp, cr, ct)
1093 #define	VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr, ct) \
1094 	fop_pageio(vp, pp, io_off, io_len, flags, cr, ct)
1095 #define	VOP_DUMPCTL(vp, action, blkp, ct) \
1096 	fop_dumpctl(vp, action, blkp, ct)
1097 #define	VOP_DISPOSE(vp, pp, flag, dn, cr, ct) \
1098 	fop_dispose(vp, pp, flag, dn, cr, ct)
1099 #define	VOP_GETSECATTR(vp, vsap, f, cr, ct) \
1100 	fop_getsecattr(vp, vsap, f, cr, ct)
1101 #define	VOP_SETSECATTR(vp, vsap, f, cr, ct) \
1102 	fop_setsecattr(vp, vsap, f, cr, ct)
1103 #define	VOP_SHRLOCK(vp, cmd, shr, f, cr, ct) \
1104 	fop_shrlock(vp, cmd, shr, f, cr, ct)
1105 #define	VOP_VNEVENT(vp, vnevent, dvp, fnm, ct) \
1106 	fop_vnevent(vp, vnevent, dvp, fnm, ct)
1107 #define	VOP_REQZCBUF(vp, rwflag, xuiop, cr, ct) \
1108 	fop_reqzcbuf(vp, rwflag, xuiop, cr, ct)
1109 #define	VOP_RETZCBUF(vp, xuiop, cr, ct) \
1110 	fop_retzcbuf(vp, xuiop, cr, ct)
1111 
1112 #define	VOPNAME_OPEN		"open"
1113 #define	VOPNAME_CLOSE		"close"
1114 #define	VOPNAME_READ		"read"
1115 #define	VOPNAME_WRITE		"write"
1116 #define	VOPNAME_IOCTL		"ioctl"
1117 #define	VOPNAME_SETFL		"setfl"
1118 #define	VOPNAME_GETATTR		"getattr"
1119 #define	VOPNAME_SETATTR		"setattr"
1120 #define	VOPNAME_ACCESS		"access"
1121 #define	VOPNAME_LOOKUP		"lookup"
1122 #define	VOPNAME_CREATE		"create"
1123 #define	VOPNAME_REMOVE		"remove"
1124 #define	VOPNAME_LINK		"link"
1125 #define	VOPNAME_RENAME		"rename"
1126 #define	VOPNAME_MKDIR		"mkdir"
1127 #define	VOPNAME_RMDIR		"rmdir"
1128 #define	VOPNAME_READDIR		"readdir"
1129 #define	VOPNAME_SYMLINK		"symlink"
1130 #define	VOPNAME_READLINK	"readlink"
1131 #define	VOPNAME_FSYNC		"fsync"
1132 #define	VOPNAME_INACTIVE	"inactive"
1133 #define	VOPNAME_FID		"fid"
1134 #define	VOPNAME_RWLOCK		"rwlock"
1135 #define	VOPNAME_RWUNLOCK	"rwunlock"
1136 #define	VOPNAME_SEEK		"seek"
1137 #define	VOPNAME_CMP		"cmp"
1138 #define	VOPNAME_FRLOCK		"frlock"
1139 #define	VOPNAME_SPACE		"space"
1140 #define	VOPNAME_REALVP		"realvp"
1141 #define	VOPNAME_GETPAGE		"getpage"
1142 #define	VOPNAME_PUTPAGE		"putpage"
1143 #define	VOPNAME_MAP		"map"
1144 #define	VOPNAME_ADDMAP		"addmap"
1145 #define	VOPNAME_DELMAP		"delmap"
1146 #define	VOPNAME_POLL		"poll"
1147 #define	VOPNAME_DUMP		"dump"
1148 #define	VOPNAME_PATHCONF	"pathconf"
1149 #define	VOPNAME_PAGEIO		"pageio"
1150 #define	VOPNAME_DUMPCTL		"dumpctl"
1151 #define	VOPNAME_DISPOSE		"dispose"
1152 #define	VOPNAME_GETSECATTR	"getsecattr"
1153 #define	VOPNAME_SETSECATTR	"setsecattr"
1154 #define	VOPNAME_SHRLOCK		"shrlock"
1155 #define	VOPNAME_VNEVENT		"vnevent"
1156 #define	VOPNAME_REQZCBUF	"reqzcbuf"
1157 #define	VOPNAME_RETZCBUF	"retzcbuf"
1158 
1159 /*
1160  * Flags for VOP_LOOKUP
1161  *
1162  * Defined in file.h, but also possible, FIGNORECASE
1163  *
1164  */
1165 #define	LOOKUP_DIR		0x01	/* want parent dir vp */
1166 #define	LOOKUP_XATTR		0x02	/* lookup up extended attr dir */
1167 #define	CREATE_XATTR_DIR	0x04	/* Create extended attr dir */
1168 #define	LOOKUP_HAVE_SYSATTR_DIR	0x08	/* Already created virtual GFS dir */
1169 
1170 /*
1171  * Flags for VOP_READDIR
1172  */
1173 #define	V_RDDIR_ENTFLAGS	0x01	/* request dirent flags */
1174 #define	V_RDDIR_ACCFILTER	0x02	/* filter out inaccessible dirents */
1175 
1176 /*
1177  * Flags for VOP_RWLOCK/VOP_RWUNLOCK
1178  * VOP_RWLOCK will return the flag that was actually set, or -1 if none.
1179  */
1180 #define	V_WRITELOCK_TRUE	(1)	/* Request write-lock on the vnode */
1181 #define	V_WRITELOCK_FALSE	(0)	/* Request read-lock on the vnode */
1182 
1183 /*
1184  * Flags for VOP_DUMPCTL
1185  */
1186 #define	DUMP_ALLOC	0
1187 #define	DUMP_FREE	1
1188 #define	DUMP_SCAN	2
1189 
1190 /*
1191  * Public vnode manipulation functions.
1192  */
1193 #ifdef	_KERNEL
1194 
1195 vnode_t *vn_alloc(int);
1196 void	vn_reinit(vnode_t *);
1197 void	vn_recycle(vnode_t *);
1198 void	vn_free(vnode_t *);
1199 
1200 int	vn_is_readonly(vnode_t *);
1201 int   	vn_is_opened(vnode_t *, v_mode_t);
1202 int   	vn_is_mapped(vnode_t *, v_mode_t);
1203 int   	vn_has_other_opens(vnode_t *, v_mode_t);
1204 void	vn_open_upgrade(vnode_t *, int);
1205 void	vn_open_downgrade(vnode_t *, int);
1206 
1207 int	vn_can_change_zones(vnode_t *vp);
1208 
1209 int	vn_has_flocks(vnode_t *);
1210 int	vn_has_mandatory_locks(vnode_t *, int);
1211 int	vn_has_cached_data(vnode_t *);
1212 
1213 void	vn_setops(vnode_t *, vnodeops_t *);
1214 vnodeops_t *vn_getops(vnode_t *);
1215 int	vn_matchops(vnode_t *, vnodeops_t *);
1216 int	vn_matchopval(vnode_t *, char *, fs_generic_func_p);
1217 int	vn_ismntpt(vnode_t *);
1218 
1219 struct vfs *vn_mountedvfs(vnode_t *);
1220 
1221 int	vn_in_dnlc(vnode_t *);
1222 
1223 void	vn_create_cache(void);
1224 void	vn_destroy_cache(void);
1225 
1226 void	vn_freevnodeops(vnodeops_t *);
1227 
1228 int	vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode,
1229 		struct vnode **vpp, enum create crwhy, mode_t umask);
1230 int	vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode,
1231 		struct vnode **vpp, enum create crwhy,
1232 		mode_t umask, struct vnode *startvp, int fd);
1233 int	vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap,
1234 		enum vcexcl excl, int mode, struct vnode **vpp,
1235 		enum create why, int flag, mode_t umask);
1236 int	vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap,
1237 		enum vcexcl excl, int mode, struct vnode **vpp,
1238 		enum create why, int flag, mode_t umask, struct vnode *startvp);
1239 int	vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len,
1240 		offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit,
1241 		cred_t *cr, ssize_t *residp);
1242 void	vn_rele(struct vnode *vp);
1243 void	vn_rele_async(struct vnode *vp, struct taskq *taskq);
1244 void	vn_rele_dnlc(struct vnode *vp);
1245 void	vn_rele_stream(struct vnode *vp);
1246 int	vn_link(char *from, char *to, enum uio_seg seg);
1247 int	vn_rename(char *from, char *to, enum uio_seg seg);
1248 int	vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname,
1249 		enum uio_seg seg);
1250 int	vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag);
1251 int	vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg,
1252 		enum rm dirflag);
1253 int	vn_compare(vnode_t *vp1, vnode_t *vp2);
1254 int	vn_vfswlock(struct vnode *vp);
1255 int	vn_vfswlock_wait(struct vnode *vp);
1256 int	vn_vfsrlock(struct vnode *vp);
1257 int	vn_vfsrlock_wait(struct vnode *vp);
1258 void	vn_vfsunlock(struct vnode *vp);
1259 int	vn_vfswlock_held(struct vnode *vp);
1260 vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr);
1261 vnode_t *makespecvp(dev_t dev, vtype_t type);
1262 vn_vfslocks_entry_t *vn_vfslocks_getlock(void *);
1263 void	vn_vfslocks_rele(vn_vfslocks_entry_t *);
1264 boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *);
1265 
1266 void vn_copypath(struct vnode *src, struct vnode *dst);
1267 void vn_setpath_str(struct vnode *vp, const char *str, size_t len);
1268 void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp,
1269     const char *path, size_t plen);
1270 void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len);
1271 
1272 /* Vnode event notification */
1273 void	vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *);
1274 void	vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *);
1275 void	vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *);
1276 void	vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *);
1277 void	vnevent_create(vnode_t *, caller_context_t *);
1278 void	vnevent_link(vnode_t *, caller_context_t *);
1279 void	vnevent_rename_dest_dir(vnode_t *, caller_context_t *ct);
1280 void	vnevent_mountedover(vnode_t *, caller_context_t *);
1281 int	vnevent_support(vnode_t *, caller_context_t *);
1282 
1283 /* Vnode specific data */
1284 void vsd_create(uint_t *, void (*)(void *));
1285 void vsd_destroy(uint_t *);
1286 void *vsd_get(vnode_t *, uint_t);
1287 int vsd_set(vnode_t *, uint_t, void *);
1288 void vsd_free(vnode_t *);
1289 
1290 /*
1291  * Extensible vnode attribute (xva) routines:
1292  * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR)
1293  * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t
1294  */
1295 void		xva_init(xvattr_t *);
1296 xoptattr_t	*xva_getxoptattr(xvattr_t *);	/* Get ptr to xoptattr_t */
1297 
1298 void xattr_init(void);		/* Initialize vnodeops for xattrs */
1299 
1300 /* GFS tunnel for xattrs */
1301 int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *);
1302 
1303 /* Reparse Point */
1304 void reparse_point_init(void);
1305 
1306 /* Context identification */
1307 u_longlong_t	fs_new_caller_id();
1308 
1309 int	vn_vmpss_usepageio(vnode_t *);
1310 
1311 /*
1312  * Needed for use of IS_VMODSORT() in kernel.
1313  */
1314 extern uint_t pvn_vmodsort_supported;
1315 
1316 #define	VN_HOLD(vp)	{ \
1317 	mutex_enter(&(vp)->v_lock); \
1318 	(vp)->v_count++; \
1319 	mutex_exit(&(vp)->v_lock); \
1320 }
1321 
1322 #define	VN_RELE(vp)	{ \
1323 	vn_rele(vp); \
1324 }
1325 
1326 #define	VN_RELE_ASYNC(vp, taskq)	{ \
1327 	vn_rele_async(vp, taskq); \
1328 }
1329 
1330 #define	VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev)	{ \
1331 	(vp)->v_vfsp = (vfsp); \
1332 	(vp)->v_type = (type); \
1333 	(vp)->v_rdev = (dev); \
1334 }
1335 
1336 /*
1337  * Compare two vnodes for equality.  In general this macro should be used
1338  * in preference to calling VOP_CMP directly.
1339  */
1340 #define	VN_CMP(VP1, VP2)	((VP1) == (VP2) ? 1 : 	\
1341 	((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \
1342 	VOP_CMP(VP1, VP2, NULL) : 0))
1343 
1344 /*
1345  * Some well-known global vnodes used by the VM system to name pages.
1346  */
1347 extern struct vnode kvps[];
1348 
1349 typedef enum {
1350 	KV_KVP,		/* vnode for all segkmem pages */
1351 	KV_ZVP,		/* vnode for all ZFS pages */
1352 #if defined(__sparc)
1353 	KV_MPVP,	/* vnode for all page_t meta-pages */
1354 	KV_PROMVP,	/* vnode for all PROM pages */
1355 #endif	/* __sparc */
1356 	KV_MAX		/* total number of vnodes in kvps[] */
1357 } kvps_index_t;
1358 
1359 #define	VN_ISKAS(vp)	((vp) >= &kvps[0] && (vp) < &kvps[KV_MAX])
1360 
1361 #endif	/* _KERNEL */
1362 
1363 /*
1364  * Flags to VOP_SETATTR/VOP_GETATTR.
1365  */
1366 #define	ATTR_UTIME	0x01	/* non-default utime(2) request */
1367 #define	ATTR_EXEC	0x02	/* invocation from exec(2) */
1368 #define	ATTR_COMM	0x04	/* yield common vp attributes */
1369 #define	ATTR_HINT	0x08	/* information returned will be `hint' */
1370 #define	ATTR_REAL	0x10	/* yield attributes of the real vp */
1371 #define	ATTR_NOACLCHECK	0x20	/* Don't check ACL when checking permissions */
1372 #define	ATTR_TRIGGER	0x40	/* Mount first if vnode is a trigger mount */
1373 /*
1374  * Generally useful macros.
1375  */
1376 #define	VBSIZE(vp)	((vp)->v_vfsp->vfs_bsize)
1377 
1378 #define	VTOZONE(vp)	((vp)->v_vfsp->vfs_zone)
1379 
1380 #define	NULLVP		((struct vnode *)0)
1381 #define	NULLVPP		((struct vnode **)0)
1382 
1383 #ifdef	_KERNEL
1384 
1385 /*
1386  * Structure used while handling asynchronous VOP_PUTPAGE operations.
1387  */
1388 struct async_reqs {
1389 	struct async_reqs *a_next;	/* pointer to next arg struct */
1390 	struct vnode *a_vp;		/* vnode pointer */
1391 	u_offset_t a_off;			/* offset in file */
1392 	uint_t a_len;			/* size of i/o request */
1393 	int a_flags;			/* flags to indicate operation type */
1394 	struct cred *a_cred;		/* cred pointer	*/
1395 	ushort_t a_prealloced;		/* set if struct is pre-allocated */
1396 };
1397 
1398 /*
1399  * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE().
1400  * Note that there is no guarantee that the page passed in will be
1401  * freed.  If that is required, then a check after calling VN_DISPOSE would
1402  * be necessary to ensure the page was freed.
1403  */
1404 #define	VN_DISPOSE(pp, flag, dn, cr)	{ \
1405 	if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \
1406 		VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr), NULL); \
1407 	else if ((flag) == B_FREE) \
1408 		page_free((pp), (dn)); \
1409 	else \
1410 		page_destroy((pp), (dn)); \
1411 	}
1412 
1413 #endif	/* _KERNEL */
1414 
1415 #ifdef	__cplusplus
1416 }
1417 #endif
1418 
1419 #endif	/* _SYS_VNODE_H */
1420