xref: /titanic_52/usr/src/uts/common/sys/vnode.h (revision 9b14cf1dc76dad8f2d9a74310e0a0200af96d217)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 /*
30  * University Copyright- Copyright (c) 1982, 1986, 1988
31  * The Regents of the University of California
32  * All Rights Reserved
33  *
34  * University Acknowledgment- Portions of this document are derived from
35  * software developed by the University of California, Berkeley, and its
36  * contributors.
37  */
38 
39 #ifndef _SYS_VNODE_H
40 #define	_SYS_VNODE_H
41 
42 #pragma ident	"%Z%%M%	%I%	%E% SMI"
43 
44 #include <sys/types.h>
45 #include <sys/t_lock.h>
46 #include <sys/rwstlock.h>
47 #include <sys/time_impl.h>
48 #include <sys/cred.h>
49 #include <sys/uio.h>
50 #include <sys/resource.h>
51 #include <vm/seg_enum.h>
52 #include <sys/kstat.h>
53 #include <sys/kmem.h>
54 #ifdef	_KERNEL
55 #include <sys/buf.h>
56 #endif	/* _KERNEL */
57 
58 #ifdef	__cplusplus
59 extern "C" {
60 #endif
61 
62 /*
63  * Statistics for all vnode operations.
64  * All operations record number of ops (since boot/mount/zero'ed).
65  * Certain I/O operations (read, write, readdir) also record number
66  * of bytes transferred.
67  * This appears in two places in the system: one is embedded in each
68  * vfs_t.  There is also an array of vopstats_t structures allocated
69  * on a per-fstype basis.
70  */
71 
72 #define	VOPSTATS_STR	"vopstats_"	/* Initial string for vopstat kstats */
73 
74 typedef struct vopstats {
75 	kstat_named_t	nopen;		/* VOP_OPEN */
76 	kstat_named_t	nclose;		/* VOP_CLOSE */
77 	kstat_named_t	nread;		/* VOP_READ */
78 	kstat_named_t	read_bytes;
79 	kstat_named_t	nwrite;		/* VOP_WRITE */
80 	kstat_named_t	write_bytes;
81 	kstat_named_t	nioctl;		/* VOP_IOCTL */
82 	kstat_named_t	nsetfl;		/* VOP_SETFL */
83 	kstat_named_t	ngetattr;	/* VOP_GETATTR */
84 	kstat_named_t	nsetattr;	/* VOP_SETATTR */
85 	kstat_named_t	naccess;	/* VOP_ACCESS */
86 	kstat_named_t	nlookup;	/* VOP_LOOKUP */
87 	kstat_named_t	ncreate;	/* VOP_CREATE */
88 	kstat_named_t	nremove;	/* VOP_REMOVE */
89 	kstat_named_t	nlink;		/* VOP_LINK */
90 	kstat_named_t	nrename;	/* VOP_RENAME */
91 	kstat_named_t	nmkdir;		/* VOP_MKDIR */
92 	kstat_named_t	nrmdir;		/* VOP_RMDIR */
93 	kstat_named_t	nreaddir;	/* VOP_READDIR */
94 	kstat_named_t	readdir_bytes;
95 	kstat_named_t	nsymlink;	/* VOP_SYMLINK */
96 	kstat_named_t	nreadlink;	/* VOP_READLINK */
97 	kstat_named_t	nfsync;		/* VOP_FSYNC */
98 	kstat_named_t	ninactive;	/* VOP_INACTIVE */
99 	kstat_named_t	nfid;		/* VOP_FID */
100 	kstat_named_t	nrwlock;	/* VOP_RWLOCK */
101 	kstat_named_t	nrwunlock;	/* VOP_RWUNLOCK */
102 	kstat_named_t	nseek;		/* VOP_SEEK */
103 	kstat_named_t	ncmp;		/* VOP_CMP */
104 	kstat_named_t	nfrlock;	/* VOP_FRLOCK */
105 	kstat_named_t	nspace;		/* VOP_SPACE */
106 	kstat_named_t	nrealvp;	/* VOP_REALVP */
107 	kstat_named_t	ngetpage;	/* VOP_GETPAGE */
108 	kstat_named_t	nputpage;	/* VOP_PUTPAGE */
109 	kstat_named_t	nmap;		/* VOP_MAP */
110 	kstat_named_t	naddmap;	/* VOP_ADDMAP */
111 	kstat_named_t	ndelmap;	/* VOP_DELMAP */
112 	kstat_named_t	npoll;		/* VOP_POLL */
113 	kstat_named_t	ndump;		/* VOP_DUMP */
114 	kstat_named_t	npathconf;	/* VOP_PATHCONF */
115 	kstat_named_t	npageio;	/* VOP_PAGEIO */
116 	kstat_named_t	ndumpctl;	/* VOP_DUMPCTL */
117 	kstat_named_t	ndispose;	/* VOP_DISPOSE */
118 	kstat_named_t	nsetsecattr;	/* VOP_SETSECATTR */
119 	kstat_named_t	ngetsecattr;	/* VOP_GETSECATTR */
120 	kstat_named_t	nshrlock;	/* VOP_SHRLOCK */
121 	kstat_named_t	nvnevent;	/* VOP_VNEVENT */
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  * Many of the fields in the vnode are read-only once they are initialized
173  * at vnode creation time.  Other fields are protected by locks.
174  *
175  * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc().  They
176  * may not be embedded into the file-system specific node (inode).  The
177  * size of vnodes may change.
178  *
179  * The v_lock protects:
180  *   v_flag
181  *   v_stream
182  *   v_count
183  *   v_shrlocks
184  *   v_path
185  *
186  * A special lock (implemented by vn_vfswlock in vnode.c) protects:
187  *   v_vfsmountedhere
188  *
189  * The global flock_lock mutex (in flock.c) protects:
190  *   v_filocks
191  *
192  * IMPORTANT NOTE:
193  *
194  *   The following vnode fields are considered public and may safely be
195  *   accessed by file systems or other consumers:
196  *
197  *     v_lock
198  *     v_flag
199  *     v_count
200  *     v_data
201  *     v_vfsp
202  *     v_stream
203  *     v_type
204  *     v_rdev
205  *
206  * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD.
207  * In particular, file systems should not access other fields; they may
208  * change or even be removed.  The functionality which was once provided
209  * by these fields is available through vn_* functions.
210  */
211 
212 struct fem_head;	/* from fem.h */
213 
214 typedef struct vnode {
215 	kmutex_t	v_lock;		/* protects vnode fields */
216 	uint_t		v_flag;		/* vnode flags (see below) */
217 	uint_t		v_count;	/* reference count */
218 	void		*v_data;	/* private data for fs */
219 	struct vfs	*v_vfsp;	/* ptr to containing VFS */
220 	struct stdata	*v_stream;	/* associated stream */
221 	enum vtype	v_type;		/* vnode type */
222 	dev_t		v_rdev;		/* device (VCHR, VBLK) */
223 
224 	/* PRIVATE FIELDS BELOW - DO NOT USE */
225 
226 	struct vfs	*v_vfsmountedhere; /* ptr to vfs mounted here */
227 	struct vnodeops	*v_op;		/* vnode operations */
228 	struct page	*v_pages;	/* vnode pages list */
229 	pgcnt_t		v_npages;	/* # pages on this vnode */
230 	pgcnt_t		v_msnpages;	/* # pages charged to v_mset */
231 	struct page	*v_scanfront;	/* scanner front hand */
232 	struct page	*v_scanback;	/* scanner back hand */
233 	struct filock	*v_filocks;	/* ptr to filock list */
234 	struct shrlocklist *v_shrlocks;	/* ptr to shrlock list */
235 	krwlock_t	v_nbllock;	/* sync for NBMAND locks */
236 	kcondvar_t	v_cv;		/* synchronize locking */
237 	void		*v_locality;	/* hook for locality info */
238 	struct fem_head	*v_femhead;	/* fs monitoring */
239 	char		*v_path;	/* cached path */
240 	uint_t		v_rdcnt;	/* open for read count  (VREG only) */
241 	uint_t		v_wrcnt;	/* open for write count (VREG only) */
242 	u_longlong_t	v_mmap_read;	/* mmap read count */
243 	u_longlong_t	v_mmap_write;	/* mmap write count */
244 	void		*v_mpssdata;	/* info for large page mappings */
245 	hrtime_t	v_scantime;	/* last time this vnode was scanned */
246 	ushort_t	v_mset;		/* memory set ID */
247 	uint_t		v_msflags;	/* memory set flags */
248 	struct vnode	*v_msnext;	/* list of vnodes on an mset */
249 	struct vnode	*v_msprev;	/* list of vnodes on an mset */
250 	krwlock_t	v_mslock;	/* protects v_mset */
251 } vnode_t;
252 
253 #define	IS_DEVVP(vp)	\
254 	((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
255 
256 /*
257  * vnode flags.
258  */
259 #define	VROOT		0x01	/* root of its file system */
260 #define	VNOCACHE	0x02	/* don't keep cache pages on vnode */
261 #define	VNOMAP		0x04	/* file cannot be mapped/faulted */
262 #define	VDUP		0x08	/* file should be dup'ed rather then opened */
263 #define	VNOSWAP		0x10	/* file cannot be used as virtual swap device */
264 #define	VNOMOUNT	0x20	/* file cannot be covered by mount */
265 #define	VISSWAP		0x40	/* vnode is being used for swap */
266 #define	VSWAPLIKE	0x80	/* vnode acts like swap (but may not be) */
267 
268 #define	IS_SWAPVP(vp)	(((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0)
269 
270 typedef struct vn_vfslocks_entry {
271 	rwstlock_t ve_lock;
272 	void *ve_vpvfs;
273 	struct vn_vfslocks_entry *ve_next;
274 	uint32_t ve_refcnt;
275 	char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \
276 	    sizeof (uint32_t)];
277 } vn_vfslocks_entry_t;
278 
279 /*
280  * The following two flags are used to lock the v_vfsmountedhere field
281  */
282 #define	VVFSLOCK	0x100
283 #define	VVFSWAIT	0x200
284 
285 /*
286  * Used to serialize VM operations on a vnode
287  */
288 #define	VVMLOCK		0x400
289 
290 /*
291  * Tell vn_open() not to fail a directory open for writing but
292  * to go ahead and call VOP_OPEN() to let the filesystem check.
293  */
294 #define	VDIROPEN	0x800
295 
296 /*
297  * Flag to let the VM system know that this file is most likely a binary
298  * or shared library since it has been mmap()ed EXEC at some time.
299  */
300 #define	VVMEXEC		0x1000
301 
302 #define	VPXFS		0x2000  /* clustering: global fs proxy vnode */
303 
304 #define	IS_PXFSVP(vp)	((vp)->v_flag & VPXFS)
305 
306 #define	V_XATTRDIR	0x4000	/* attribute unnamed directory */
307 
308 #define	V_LOCALITY	0x8000	/* whether locality aware */
309 
310 /*
311  * Flag that indicates the VM should maintain the v_pages list with all modified
312  * pages on one end and unmodified pages at the other. This makes finding dirty
313  * pages to write back to disk much faster at the expense of taking a minor
314  * fault on the first store instruction which touches a writable page.
315  */
316 #define	VMODSORT	(0x10000)
317 #define	IS_VMODSORT(vp) \
318 	(pvn_vmodsort_supported != 0 && ((vp)->v_flag  & VMODSORT) != 0)
319 
320 #define	VISSWAPFS	0x20000	/* vnode is being used for swapfs */
321 #define	IS_SWAPFSVP(vp)	(((vp)->v_flag & VISSWAPFS) != 0)
322 
323 /*
324  * Vnode attributes.  A bit-mask is supplied as part of the
325  * structure to indicate the attributes the caller wants to
326  * set (setattr) or extract (getattr).
327  */
328 
329 /*
330  * Note that va_nodeid and va_nblocks are 64bit data type.
331  * We support large files over NFSV3. With Solaris client and
332  * Server that generates 64bit ino's and sizes these fields
333  * will overflow if they are 32 bit sizes.
334  */
335 
336 typedef struct vattr {
337 	uint_t		va_mask;	/* bit-mask of attributes */
338 	vtype_t		va_type;	/* vnode type (for create) */
339 	mode_t		va_mode;	/* file access mode */
340 	uid_t		va_uid;		/* owner user id */
341 	gid_t		va_gid;		/* owner group id */
342 	dev_t		va_fsid;	/* file system id (dev for now) */
343 	u_longlong_t	va_nodeid;	/* node id */
344 	nlink_t		va_nlink;	/* number of references to file */
345 	u_offset_t	va_size;	/* file size in bytes */
346 	timestruc_t	va_atime;	/* time of last access */
347 	timestruc_t	va_mtime;	/* time of last modification */
348 	timestruc_t	va_ctime;	/* time of last status change */
349 	dev_t		va_rdev;	/* device the file represents */
350 	uint_t		va_blksize;	/* fundamental block size */
351 	u_longlong_t	va_nblocks;	/* # of blocks allocated */
352 	uint_t		va_seq;		/* sequence number */
353 } vattr_t;
354 
355 #ifdef _SYSCALL32
356 /*
357  * For bigtypes time_t changed to 64 bit on the 64-bit kernel.
358  * Define an old version for user/kernel interface
359  */
360 
361 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
362 #pragma pack(4)
363 #endif
364 
365 typedef struct vattr32 {
366 	uint32_t	va_mask;	/* bit-mask of attributes */
367 	vtype_t		va_type;	/* vnode type (for create) */
368 	mode32_t	va_mode;	/* file access mode */
369 	uid32_t		va_uid;		/* owner user id */
370 	gid32_t		va_gid;		/* owner group id */
371 	dev32_t		va_fsid;	/* file system id (dev for now) */
372 	u_longlong_t	va_nodeid;	/* node id */
373 	nlink_t		va_nlink;	/* number of references to file */
374 	u_offset_t	va_size;	/* file size in bytes */
375 	timestruc32_t	va_atime;	/* time of last access */
376 	timestruc32_t	va_mtime;	/* time of last modification */
377 	timestruc32_t	va_ctime;	/* time of last status change */
378 	dev32_t		va_rdev;	/* device the file represents */
379 	uint32_t	va_blksize;	/* fundamental block size */
380 	u_longlong_t	va_nblocks;	/* # of blocks allocated */
381 	uint32_t	va_seq;		/* sequence number */
382 } vattr32_t;
383 
384 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
385 #pragma pack()
386 #endif
387 
388 #else  /* not _SYSCALL32 */
389 #define	vattr32		vattr
390 typedef vattr_t		vattr32_t;
391 #endif /* _SYSCALL32 */
392 
393 /*
394  * Attributes of interest to the caller of setattr or getattr.
395  */
396 #define	AT_TYPE		0x0001
397 #define	AT_MODE		0x0002
398 #define	AT_UID		0x0004
399 #define	AT_GID		0x0008
400 #define	AT_FSID		0x0010
401 #define	AT_NODEID	0x0020
402 #define	AT_NLINK	0x0040
403 #define	AT_SIZE		0x0080
404 #define	AT_ATIME	0x0100
405 #define	AT_MTIME	0x0200
406 #define	AT_CTIME	0x0400
407 #define	AT_RDEV		0x0800
408 #define	AT_BLKSIZE	0x1000
409 #define	AT_NBLOCKS	0x2000
410 /*			0x4000 */	/* unused */
411 #define	AT_SEQ		0x8000
412 
413 #define	AT_ALL		(AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\
414 			AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\
415 			AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
416 
417 #define	AT_STAT		(AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
418 			AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE)
419 
420 #define	AT_TIMES	(AT_ATIME|AT_MTIME|AT_CTIME)
421 
422 #define	AT_NOSET	(AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
423 			AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
424 
425 /*
426  *  Modes.  Some values same as S_xxx entries from stat.h for convenience.
427  */
428 #define	VSUID		04000		/* set user id on execution */
429 #define	VSGID		02000		/* set group id on execution */
430 #define	VSVTX		01000		/* save swapped text even after use */
431 
432 /*
433  * Permissions.
434  */
435 #define	VREAD		00400
436 #define	VWRITE		00200
437 #define	VEXEC		00100
438 
439 #define	MODEMASK	07777		/* mode bits plus permission bits */
440 #define	PERMMASK	00777		/* permission bits */
441 
442 /*
443  * Check whether mandatory file locking is enabled.
444  */
445 
446 #define	MANDMODE(mode)		(((mode) & (VSGID|(VEXEC>>3))) == VSGID)
447 #define	MANDLOCK(vp, mode)	((vp)->v_type == VREG && MANDMODE(mode))
448 
449 /*
450  * Flags for vnode operations.
451  */
452 enum rm		{ RMFILE, RMDIRECTORY };	/* rm or rmdir (remove) */
453 enum symfollow	{ NO_FOLLOW, FOLLOW };		/* follow symlinks (or not) */
454 enum vcexcl	{ NONEXCL, EXCL };		/* (non)excl create */
455 enum create	{ CRCREAT, CRMKNOD, CRMKDIR };	/* reason for create */
456 
457 typedef enum rm		rm_t;
458 typedef enum symfollow	symfollow_t;
459 typedef enum vcexcl	vcexcl_t;
460 typedef enum create	create_t;
461 
462 /* Vnode Events - Used by VOP_VNEVENT */
463 typedef enum vnevent	{
464 	VE_SUPPORT	= 0,	/* Query */
465 	VE_RENAME_SRC	= 1,	/* Rename, with vnode as source */
466 	VE_RENAME_DEST	= 2,	/* Rename, with vnode as target/destination */
467 	VE_REMOVE	= 3,	/* Remove of vnode's name */
468 	VE_RMDIR	= 4	/* Remove of directory vnode's name */
469 } vnevent_t;
470 
471 /*
472  * Values for checking vnode open and map counts
473  */
474 enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR };
475 
476 typedef enum v_mode v_mode_t;
477 
478 #define	V_TRUE	1
479 #define	V_FALSE	0
480 
481 /*
482  * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations
483  */
484 
485 typedef struct vsecattr {
486 	uint_t		vsa_mask;	/* See below */
487 	int		vsa_aclcnt;	/* ACL entry count */
488 	void		*vsa_aclentp;	/* pointer to ACL entries */
489 	int		vsa_dfaclcnt;	/* default ACL entry count */
490 	void		*vsa_dfaclentp;	/* pointer to default ACL entries */
491 } vsecattr_t;
492 
493 /* vsa_mask values */
494 #define	VSA_ACL		0x0001
495 #define	VSA_ACLCNT	0x0002
496 #define	VSA_DFACL	0x0004
497 #define	VSA_DFACLCNT	0x0008
498 #define	VSA_ACE		0x0010
499 #define	VSA_ACECNT	0x0020
500 
501 /*
502  * Structure used by various vnode operations to determine
503  * the context (pid, host, identity) of a caller.
504  *
505  * The cc_caller_id is used to identify one or more callers who invoke
506  * operations, possibly on behalf of others.  For example, the NFS
507  * server could have it's own cc_caller_id which can be detected by
508  * vnode/vfs operations or (FEM) monitors on those operations.  New
509  * caller IDs are generated by fs_new_caller_id().
510  */
511 typedef struct caller_context {
512 	pid_t		cc_pid;		/* Process ID of the caller */
513 	int		cc_sysid;	/* System ID, used for remote calls */
514 	u_longlong_t	cc_caller_id;	/* Identifier for (set of) caller(s) */
515 } caller_context_t;
516 
517 /*
518  * Structure tags for function prototypes, defined elsewhere.
519  */
520 struct pathname;
521 struct fid;
522 struct flock64;
523 struct flk_callback;
524 struct shrlock;
525 struct page;
526 struct seg;
527 struct as;
528 struct pollhead;
529 
530 #ifdef	_KERNEL
531 
532 /*
533  * VNODE_OPS defines all the vnode operations.  It is used to define
534  * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h).
535  */
536 #define	VNODE_OPS							\
537 	int	(*vop_open)(vnode_t **, int, cred_t *);			\
538 	int	(*vop_close)(vnode_t *, int, int, offset_t, cred_t *);	\
539 	int	(*vop_read)(vnode_t *, uio_t *, int, cred_t *,		\
540 				caller_context_t *);			\
541 	int	(*vop_write)(vnode_t *, uio_t *, int, cred_t *,		\
542 				caller_context_t *);			\
543 	int	(*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *,	\
544 				int *);					\
545 	int	(*vop_setfl)(vnode_t *, int, int, cred_t *);		\
546 	int	(*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *);	\
547 	int	(*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *,	\
548 				caller_context_t *);			\
549 	int	(*vop_access)(vnode_t *, int, int, cred_t *);		\
550 	int	(*vop_lookup)(vnode_t *, char *, vnode_t **,		\
551 				struct pathname *,			\
552 				int, vnode_t *, cred_t *);		\
553 	int	(*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t,	\
554 				int, vnode_t **, cred_t *, int);	\
555 	int	(*vop_remove)(vnode_t *, char *, cred_t *);		\
556 	int	(*vop_link)(vnode_t *, vnode_t *, char *, cred_t *);	\
557 	int	(*vop_rename)(vnode_t *, char *, vnode_t *, char *,	\
558 				cred_t *);				\
559 	int	(*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **,	\
560 				cred_t *);				\
561 	int	(*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *);	\
562 	int	(*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *);	\
563 	int	(*vop_symlink)(vnode_t *, char *, vattr_t *, char *,	\
564 				cred_t *);				\
565 	int	(*vop_readlink)(vnode_t *, uio_t *, cred_t *);		\
566 	int	(*vop_fsync)(vnode_t *, int, cred_t *);			\
567 	void	(*vop_inactive)(vnode_t *, cred_t *);			\
568 	int	(*vop_fid)(vnode_t *, struct fid *);			\
569 	int	(*vop_rwlock)(vnode_t *, int, caller_context_t *);	\
570 	void	(*vop_rwunlock)(vnode_t *, int, caller_context_t *);	\
571 	int	(*vop_seek)(vnode_t *, offset_t, offset_t *);		\
572 	int	(*vop_cmp)(vnode_t *, vnode_t *);			\
573 	int	(*vop_frlock)(vnode_t *, int, struct flock64 *,		\
574 				int, offset_t,				\
575 				struct flk_callback *, cred_t *);	\
576 	int	(*vop_space)(vnode_t *, int, struct flock64 *,		\
577 				int, offset_t,				\
578 				cred_t *, caller_context_t *);		\
579 	int	(*vop_realvp)(vnode_t *, vnode_t **);			\
580 	int	(*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *,	\
581 				struct page **, size_t, struct seg *,	\
582 				caddr_t, enum seg_rw, cred_t *);	\
583 	int	(*vop_putpage)(vnode_t *, offset_t, size_t,		\
584 				int, cred_t *);				\
585 	int	(*vop_map)(vnode_t *, offset_t, struct as *,		\
586 				caddr_t *, size_t,			\
587 				uchar_t, uchar_t, uint_t, cred_t *);	\
588 	int	(*vop_addmap)(vnode_t *, offset_t, struct as *,		\
589 				caddr_t, size_t,			\
590 				uchar_t, uchar_t, uint_t, cred_t *);	\
591 	int	(*vop_delmap)(vnode_t *, offset_t, struct as *,		\
592 				caddr_t, size_t,			\
593 				uint_t, uint_t, uint_t, cred_t *);	\
594 	int	(*vop_poll)(vnode_t *, short, int, short *,		\
595 				struct pollhead **);			\
596 	int	(*vop_dump)(vnode_t *, caddr_t, int, int);		\
597 	int	(*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *);	\
598 	int	(*vop_pageio)(vnode_t *, struct page *,			\
599 				u_offset_t, size_t, int, cred_t *);	\
600 	int	(*vop_dumpctl)(vnode_t *, int, int *);			\
601 	void	(*vop_dispose)(vnode_t *, struct page *,		\
602 				int, int, cred_t *);			\
603 	int	(*vop_setsecattr)(vnode_t *, vsecattr_t *,		\
604 				int, cred_t *);				\
605 	int	(*vop_getsecattr)(vnode_t *, vsecattr_t *,		\
606 				int, cred_t *);				\
607 	int	(*vop_shrlock)(vnode_t *, int, struct shrlock *,	\
608 				int, cred_t *);				\
609 	int	(*vop_vnevent)(vnode_t *, vnevent_t)	/* NB: No ";" */
610 
611 /*
612  * Operations on vnodes.  Note: File systems must never operate directly
613  * on a 'vnodeops' structure -- it WILL change in future releases!  They
614  * must use vn_make_ops() to create the structure.
615  */
616 typedef struct vnodeops {
617 	const char *vnop_name;
618 	VNODE_OPS;	/* Signatures of all vnode operations (vops) */
619 } vnodeops_t;
620 
621 typedef int (*fs_generic_func_p) ();	/* Generic vop/vfsop/femop/fsemop ptr */
622 
623 extern int	fop_open(vnode_t **, int, cred_t *);
624 extern int	fop_close(vnode_t *, int, int, offset_t, cred_t *);
625 extern int	fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *);
626 extern int	fop_write(vnode_t *, uio_t *, int, cred_t *,
627 				caller_context_t *);
628 extern int	fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *);
629 extern int	fop_setfl(vnode_t *, int, int, cred_t *);
630 extern int	fop_getattr(vnode_t *, vattr_t *, int, cred_t *);
631 extern int	fop_setattr(vnode_t *, vattr_t *, int, cred_t *,
632 				caller_context_t *);
633 extern int	fop_access(vnode_t *, int, int, cred_t *);
634 extern int	fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *,
635 				int, vnode_t *, cred_t *);
636 extern int	fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int,
637 				vnode_t **, cred_t *, int);
638 extern int	fop_remove(vnode_t *vp, char *, cred_t *);
639 extern int	fop_link(vnode_t *, vnode_t *, char *, cred_t *);
640 extern int	fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *);
641 extern int	fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *);
642 extern int	fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *);
643 extern int	fop_readdir(vnode_t *, uio_t *, cred_t *, int *);
644 extern int	fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *);
645 extern int	fop_readlink(vnode_t *, uio_t *, cred_t *);
646 extern int	fop_fsync(vnode_t *, int, cred_t *);
647 extern void	fop_inactive(vnode_t *, cred_t *);
648 extern int	fop_fid(vnode_t *, struct fid *);
649 extern int	fop_rwlock(vnode_t *, int, caller_context_t *);
650 extern void	fop_rwunlock(vnode_t *, int, caller_context_t *);
651 extern int	fop_seek(vnode_t *, offset_t, offset_t *);
652 extern int	fop_cmp(vnode_t *, vnode_t *);
653 extern int	fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t,
654 				struct flk_callback *, cred_t *);
655 extern int	fop_space(vnode_t *, int, struct flock64 *, int, offset_t,
656 				cred_t *, caller_context_t *);
657 extern int	fop_realvp(vnode_t *, vnode_t **);
658 extern int	fop_getpage(vnode_t *, offset_t, size_t, uint_t *,
659 				struct page **, size_t, struct seg *,
660 				caddr_t, enum seg_rw, cred_t *);
661 extern int	fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *);
662 extern int	fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t,
663 				uchar_t, uchar_t, uint_t, cred_t *cr);
664 extern int	fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
665 				uchar_t, uchar_t, uint_t, cred_t *);
666 extern int	fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
667 				uint_t, uint_t, uint_t, cred_t *);
668 extern int	fop_poll(vnode_t *, short, int, short *, struct pollhead **);
669 extern int	fop_dump(vnode_t *, caddr_t, int, int);
670 extern int	fop_pathconf(vnode_t *, int, ulong_t *, cred_t *);
671 extern int	fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int,
672 				cred_t *);
673 extern int	fop_dumpctl(vnode_t *, int, int *);
674 extern void	fop_dispose(vnode_t *, struct page *, int, int, cred_t *);
675 extern int	fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *);
676 extern int	fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *);
677 extern int	fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *);
678 extern int	fop_vnevent(vnode_t *, vnevent_t);
679 
680 #endif	/* _KERNEL */
681 
682 #define	VOP_OPEN(vpp, mode, cr) \
683 	fop_open(vpp, mode, cr)
684 #define	VOP_CLOSE(vp, f, c, o, cr) \
685 	fop_close(vp, f, c, o, cr)
686 #define	VOP_READ(vp, uiop, iof, cr, ct) \
687 	fop_read(vp, uiop, iof, cr, ct)
688 #define	VOP_WRITE(vp, uiop, iof, cr, ct) \
689 	fop_write(vp, uiop, iof, cr, ct)
690 #define	VOP_IOCTL(vp, cmd, a, f, cr, rvp) \
691 	fop_ioctl(vp, cmd, a, f, cr, rvp)
692 #define	VOP_SETFL(vp, f, a, cr) \
693 	fop_setfl(vp, f, a, cr)
694 #define	VOP_GETATTR(vp, vap, f, cr) \
695 	fop_getattr(vp, vap, f, cr)
696 #define	VOP_SETATTR(vp, vap, f, cr, ct) \
697 	fop_setattr(vp, vap, f, cr, ct)
698 #define	VOP_ACCESS(vp, mode, f, cr) \
699 	fop_access(vp, mode, f, cr)
700 #define	VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr) \
701 	fop_lookup(vp, cp, vpp, pnp, f, rdir, cr)
702 #define	VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag) \
703 	fop_create(dvp, p, vap, ex, mode, vpp, cr, flag)
704 #define	VOP_REMOVE(dvp, p, cr) \
705 	fop_remove(dvp, p, cr)
706 #define	VOP_LINK(tdvp, fvp, p, cr) \
707 	fop_link(tdvp, fvp, p, cr)
708 #define	VOP_RENAME(fvp, fnm, tdvp, tnm, cr) \
709 	fop_rename(fvp, fnm, tdvp, tnm, cr)
710 #define	VOP_MKDIR(dp, p, vap, vpp, cr) \
711 	fop_mkdir(dp, p, vap, vpp, cr)
712 #define	VOP_RMDIR(dp, p, cdir, cr) \
713 	fop_rmdir(dp, p, cdir, cr)
714 #define	VOP_READDIR(vp, uiop, cr, eofp) \
715 	fop_readdir(vp, uiop, cr, eofp)
716 #define	VOP_SYMLINK(dvp, lnm, vap, tnm, cr) \
717 	fop_symlink(dvp, lnm, vap, tnm, cr)
718 #define	VOP_READLINK(vp, uiop, cr) \
719 	fop_readlink(vp, uiop, cr)
720 #define	VOP_FSYNC(vp, syncflag, cr) \
721 	fop_fsync(vp, syncflag, cr)
722 #define	VOP_INACTIVE(vp, cr) \
723 	fop_inactive(vp, cr)
724 #define	VOP_FID(vp, fidp) \
725 	fop_fid(vp, fidp)
726 #define	VOP_RWLOCK(vp, w, ct) \
727 	fop_rwlock(vp, w, ct)
728 #define	VOP_RWUNLOCK(vp, w, ct) \
729 	fop_rwunlock(vp, w, ct)
730 #define	VOP_SEEK(vp, ooff, noffp) \
731 	fop_seek(vp, ooff, noffp)
732 #define	VOP_CMP(vp1, vp2) \
733 	fop_cmp(vp1, vp2)
734 #define	VOP_FRLOCK(vp, cmd, a, f, o, cb, cr) \
735 	fop_frlock(vp, cmd, a, f, o, cb, cr)
736 #define	VOP_SPACE(vp, cmd, a, f, o, cr, ct) \
737 	fop_space(vp, cmd, a, f, o, cr, ct)
738 #define	VOP_REALVP(vp1, vp2) \
739 	fop_realvp(vp1, vp2)
740 #define	VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr) \
741 	fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr)
742 #define	VOP_PUTPAGE(vp, of, sz, fl, cr) \
743 	fop_putpage(vp, of, sz, fl, cr)
744 #define	VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr) \
745 	fop_map(vp, of, as, a, sz, p, mp, fl, cr)
746 #define	VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr) \
747 	fop_addmap(vp, of, as, a, sz, p, mp, fl, cr)
748 #define	VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr) \
749 	fop_delmap(vp, of, as, a, sz, p, mp, fl, cr)
750 #define	VOP_POLL(vp, events, anyyet, reventsp, phpp) \
751 	fop_poll(vp, events, anyyet, reventsp, phpp)
752 #define	VOP_DUMP(vp, addr, bn, count) \
753 	fop_dump(vp, addr, bn, count)
754 #define	VOP_PATHCONF(vp, cmd, valp, cr) \
755 	fop_pathconf(vp, cmd, valp, cr)
756 #define	VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr) \
757 	fop_pageio(vp, pp, io_off, io_len, flags, cr)
758 #define	VOP_DUMPCTL(vp, action, blkp) \
759 	fop_dumpctl(vp, action, blkp)
760 #define	VOP_DISPOSE(vp, pp, flag, dn, cr) \
761 	fop_dispose(vp, pp, flag, dn, cr)
762 #define	VOP_GETSECATTR(vp, vsap, f, cr) \
763 	fop_getsecattr(vp, vsap, f, cr)
764 #define	VOP_SETSECATTR(vp, vsap, f, cr) \
765 	fop_setsecattr(vp, vsap, f, cr)
766 #define	VOP_SHRLOCK(vp, cmd, shr, f, cr) \
767 	fop_shrlock(vp, cmd, shr, f, cr)
768 #define	VOP_VNEVENT(vp, vnevent) \
769 	fop_vnevent(vp, vnevent)
770 
771 #define	VOPNAME_OPEN		"open"
772 #define	VOPNAME_CLOSE		"close"
773 #define	VOPNAME_READ		"read"
774 #define	VOPNAME_WRITE		"write"
775 #define	VOPNAME_IOCTL		"ioctl"
776 #define	VOPNAME_SETFL		"setfl"
777 #define	VOPNAME_GETATTR		"getattr"
778 #define	VOPNAME_SETATTR		"setattr"
779 #define	VOPNAME_ACCESS		"access"
780 #define	VOPNAME_LOOKUP		"lookup"
781 #define	VOPNAME_CREATE		"create"
782 #define	VOPNAME_REMOVE		"remove"
783 #define	VOPNAME_LINK		"link"
784 #define	VOPNAME_RENAME		"rename"
785 #define	VOPNAME_MKDIR		"mkdir"
786 #define	VOPNAME_RMDIR		"rmdir"
787 #define	VOPNAME_READDIR		"readdir"
788 #define	VOPNAME_SYMLINK		"symlink"
789 #define	VOPNAME_READLINK	"readlink"
790 #define	VOPNAME_FSYNC		"fsync"
791 #define	VOPNAME_INACTIVE	"inactive"
792 #define	VOPNAME_FID		"fid"
793 #define	VOPNAME_RWLOCK		"rwlock"
794 #define	VOPNAME_RWUNLOCK	"rwunlock"
795 #define	VOPNAME_SEEK		"seek"
796 #define	VOPNAME_CMP		"cmp"
797 #define	VOPNAME_FRLOCK		"frlock"
798 #define	VOPNAME_SPACE		"space"
799 #define	VOPNAME_REALVP		"realvp"
800 #define	VOPNAME_GETPAGE		"getpage"
801 #define	VOPNAME_PUTPAGE		"putpage"
802 #define	VOPNAME_MAP		"map"
803 #define	VOPNAME_ADDMAP		"addmap"
804 #define	VOPNAME_DELMAP		"delmap"
805 #define	VOPNAME_POLL		"poll"
806 #define	VOPNAME_DUMP		"dump"
807 #define	VOPNAME_PATHCONF	"pathconf"
808 #define	VOPNAME_PAGEIO		"pageio"
809 #define	VOPNAME_DUMPCTL		"dumpctl"
810 #define	VOPNAME_DISPOSE		"dispose"
811 #define	VOPNAME_GETSECATTR	"getsecattr"
812 #define	VOPNAME_SETSECATTR	"setsecattr"
813 #define	VOPNAME_SHRLOCK		"shrlock"
814 #define	VOPNAME_VNEVENT		"vnevent"
815 
816 /*
817  * Flags for VOP_LOOKUP
818  */
819 #define	LOOKUP_DIR		0x01	/* want parent dir vp */
820 #define	LOOKUP_XATTR		0x02	/* lookup up extended attr dir */
821 #define	CREATE_XATTR_DIR	0x04	/* Create extended attr dir */
822 
823 /*
824  * Flags for VOP_RWLOCK/VOP_RWUNLOCK
825  * VOP_RWLOCK will return the flag that was actually set, or -1 if none.
826  */
827 #define	V_WRITELOCK_TRUE	(1)	/* Request write-lock on the vnode */
828 #define	V_WRITELOCK_FALSE	(0)	/* Request read-lock on the vnode */
829 
830 /*
831  * Flags for VOP_DUMPCTL
832  */
833 #define	DUMP_ALLOC	0
834 #define	DUMP_FREE	1
835 #define	DUMP_SCAN	2
836 
837 /*
838  * Public vnode manipulation functions.
839  */
840 #ifdef	_KERNEL
841 
842 vnode_t *vn_alloc(int);
843 void	vn_reinit(vnode_t *);
844 void	vn_recycle(vnode_t *);
845 void	vn_free(vnode_t *);
846 
847 int	vn_is_readonly(vnode_t *);
848 int   	vn_is_opened(vnode_t *, v_mode_t);
849 int   	vn_is_mapped(vnode_t *, v_mode_t);
850 
851 int	vn_can_change_zones(vnode_t *vp);
852 
853 int	vn_has_flocks(vnode_t *);
854 int	vn_has_mandatory_locks(vnode_t *, int);
855 int	vn_has_cached_data(vnode_t *);
856 
857 void	vn_setops(vnode_t *, vnodeops_t *);
858 vnodeops_t *vn_getops(vnode_t *);
859 int	vn_matchops(vnode_t *, vnodeops_t *);
860 int	vn_matchopval(vnode_t *, char *, fs_generic_func_p);
861 int	vn_ismntpt(vnode_t *);
862 
863 struct vfs *vn_mountedvfs(vnode_t *);
864 
865 void	vn_create_cache(void);
866 void	vn_destroy_cache(void);
867 
868 void	vn_freevnodeops(vnodeops_t *);
869 
870 int	vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode,
871 		struct vnode **vpp, enum create crwhy, mode_t umask);
872 int	vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode,
873 		struct vnode **vpp, enum create crwhy,
874 		mode_t umask, struct vnode *startvp);
875 int	vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap,
876 		enum vcexcl excl, int mode, struct vnode **vpp,
877 		enum create why, int flag, mode_t umask);
878 int	vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap,
879 		enum vcexcl excl, int mode, struct vnode **vpp,
880 		enum create why, int flag, mode_t umask, struct vnode *startvp);
881 int	vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len,
882 		offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit,
883 		cred_t *cr, ssize_t *residp);
884 void	vn_rele(struct vnode *vp);
885 void	vn_rele_stream(struct vnode *vp);
886 int	vn_link(char *from, char *to, enum uio_seg seg);
887 int	vn_rename(char *from, char *to, enum uio_seg seg);
888 int	vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname,
889 		enum uio_seg seg);
890 int	vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag);
891 int	vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg,
892 		enum rm dirflag);
893 int	vn_compare(vnode_t *vp1, vnode_t *vp2);
894 int	vn_vfswlock(struct vnode *vp);
895 int	vn_vfswlock_wait(struct vnode *vp);
896 int	vn_vfsrlock(struct vnode *vp);
897 int	vn_vfsrlock_wait(struct vnode *vp);
898 void	vn_vfsunlock(struct vnode *vp);
899 int	vn_vfswlock_held(struct vnode *vp);
900 vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr);
901 vnode_t *makespecvp(dev_t dev, vtype_t type);
902 vn_vfslocks_entry_t *vn_vfslocks_getlock(void *);
903 void	vn_vfslocks_rele(vn_vfslocks_entry_t *);
904 
905 void vn_copypath(struct vnode *src, struct vnode *dst);
906 void vn_setpath_str(struct vnode *vp, const char *str, size_t len);
907 void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp,
908     const char *path, size_t plen);
909 
910 /* Vnode event notification */
911 void	vnevent_rename_src(vnode_t *);
912 void	vnevent_rename_dest(vnode_t *);
913 void	vnevent_remove(vnode_t *);
914 void	vnevent_rmdir(vnode_t *);
915 int	vnevent_support(vnode_t *);
916 
917 /* Context identification */
918 u_longlong_t	fs_new_caller_id();
919 
920 int	vn_vmpss_usepageio(vnode_t *);
921 
922 /*
923  * Needed for use of IS_VMODSORT() in kernel.
924  */
925 extern uint_t pvn_vmodsort_supported;
926 
927 #define	VN_HOLD(vp)	{ \
928 	mutex_enter(&(vp)->v_lock); \
929 	(vp)->v_count++; \
930 	mutex_exit(&(vp)->v_lock); \
931 }
932 
933 #define	VN_RELE(vp)	{ \
934 	vn_rele(vp); \
935 }
936 
937 #define	VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev)	{ \
938 	(vp)->v_vfsp = (vfsp); \
939 	(vp)->v_type = (type); \
940 	(vp)->v_rdev = (dev); \
941 }
942 
943 /*
944  * Compare two vnodes for equality.  In general this macro should be used
945  * in preference to calling VOP_CMP directly.
946  */
947 #define	VN_CMP(VP1, VP2)	((VP1) == (VP2) ? 1 : 	\
948 	((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \
949 	VOP_CMP(VP1, VP2) : 0))
950 
951 extern struct vnode kvp;
952 extern struct vnode zvp;
953 
954 #define	VN_ISKAS(vp)		((vp) == &kvp || (vp) == &zvp)
955 
956 #endif	/* _KERNEL */
957 
958 /*
959  * Flags to VOP_SETATTR/VOP_GETATTR.
960  */
961 #define	ATTR_UTIME	0x01	/* non-default utime(2) request */
962 #define	ATTR_EXEC	0x02	/* invocation from exec(2) */
963 #define	ATTR_COMM	0x04	/* yield common vp attributes */
964 #define	ATTR_HINT	0x08	/* information returned will be `hint' */
965 #define	ATTR_REAL	0x10	/* yield attributes of the real vp */
966 
967 /*
968  * Generally useful macros.
969  */
970 #define	VBSIZE(vp)	((vp)->v_vfsp->vfs_bsize)
971 
972 #define	VTOZONE(vp)	((vp)->v_vfsp->vfs_zone)
973 
974 #define	NULLVP		((struct vnode *)0)
975 #define	NULLVPP		((struct vnode **)0)
976 
977 #ifdef	_KERNEL
978 
979 /*
980  * Structure used while handling asynchronous VOP_PUTPAGE operations.
981  */
982 struct async_reqs {
983 	struct async_reqs *a_next;	/* pointer to next arg struct */
984 	struct vnode *a_vp;		/* vnode pointer */
985 	u_offset_t a_off;			/* offset in file */
986 	uint_t a_len;			/* size of i/o request */
987 	int a_flags;			/* flags to indicate operation type */
988 	struct cred *a_cred;		/* cred pointer	*/
989 	ushort_t a_prealloced;		/* set if struct is pre-allocated */
990 };
991 
992 /*
993  * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE().
994  */
995 #define	VN_DISPOSE(pp, flag, dn, cr)	{ \
996 	extern struct vnode kvp; \
997 	if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \
998 		VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr)); \
999 	else if ((flag) == B_FREE) \
1000 		page_free((pp), (dn)); \
1001 	else \
1002 		page_destroy((pp), (dn)); \
1003 	}
1004 
1005 #endif	/* _KERNEL */
1006 
1007 #ifdef	__cplusplus
1008 }
1009 #endif
1010 
1011 #endif	/* _SYS_VNODE_H */
1012