xref: /onnv-gate/usr/src/uts/common/nfs/rnode.h (revision 11888:542e7ffc22d6)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51636Sthurlow  * Common Development and Distribution License (the "License").
61636Sthurlow  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*11888SPavel.Filipensky@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifndef	_NFS_RNODE_H
300Sstevel@tonic-gate #define	_NFS_RNODE_H
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/avl.h>
330Sstevel@tonic-gate #include <sys/list.h>
340Sstevel@tonic-gate #include <nfs/nfs.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
400Sstevel@tonic-gate typedef enum nfs_access_type {
410Sstevel@tonic-gate 	NFS_ACCESS_UNKNOWN,
420Sstevel@tonic-gate 	NFS_ACCESS_ALLOWED,
430Sstevel@tonic-gate 	NFS_ACCESS_DENIED
440Sstevel@tonic-gate } nfs_access_type_t;
450Sstevel@tonic-gate 
460Sstevel@tonic-gate typedef struct acache_hash {
470Sstevel@tonic-gate 	struct acache *next;	/* next and prev must be first */
480Sstevel@tonic-gate 	struct acache *prev;
490Sstevel@tonic-gate 	krwlock_t lock;
500Sstevel@tonic-gate } acache_hash_t;
510Sstevel@tonic-gate 
520Sstevel@tonic-gate typedef struct acache {
530Sstevel@tonic-gate 	struct acache *next;	/* next and prev must be first */
540Sstevel@tonic-gate 	struct acache *prev;
550Sstevel@tonic-gate 	uint32_t known;
560Sstevel@tonic-gate 	uint32_t allowed;
570Sstevel@tonic-gate 	struct rnode *rnode;
580Sstevel@tonic-gate 	cred_t *cred;
590Sstevel@tonic-gate 	struct acache *list;
600Sstevel@tonic-gate 	struct acache_hash *hashq;
610Sstevel@tonic-gate } acache_t;
620Sstevel@tonic-gate 
631636Sthurlow #define	NFS_FHANDLE_LEN	72
640Sstevel@tonic-gate 
650Sstevel@tonic-gate typedef struct nfs_fhandle {
660Sstevel@tonic-gate 	int fh_len;
670Sstevel@tonic-gate 	char fh_buf[NFS_FHANDLE_LEN];
680Sstevel@tonic-gate } nfs_fhandle;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate typedef struct rddir_cache {
710Sstevel@tonic-gate 	lloff_t _cookie;	/* cookie used to find this cache entry */
720Sstevel@tonic-gate 	lloff_t _ncookie;	/* cookie used to find the next cache entry */
730Sstevel@tonic-gate 	char *entries;		/* buffer containing dirent entries */
740Sstevel@tonic-gate 	int eof;		/* EOF reached after this request */
750Sstevel@tonic-gate 	int entlen;		/* size of dirent entries in buf */
760Sstevel@tonic-gate 	int buflen;		/* size of the buffer used to store entries */
770Sstevel@tonic-gate 	int flags;		/* control flags, see below */
780Sstevel@tonic-gate 	kcondvar_t cv;		/* cv for blocking */
790Sstevel@tonic-gate 	int error;		/* error from RPC operation */
800Sstevel@tonic-gate 	kmutex_t lock;
810Sstevel@tonic-gate 	uint_t count;		/* reference count */
820Sstevel@tonic-gate 	avl_node_t tree;	/* AVL tree links */
830Sstevel@tonic-gate } rddir_cache;
840Sstevel@tonic-gate 
850Sstevel@tonic-gate #define	nfs_cookie	_cookie._p._l
860Sstevel@tonic-gate #define	nfs_ncookie	_ncookie._p._l
870Sstevel@tonic-gate #define	nfs3_cookie	_cookie._f
880Sstevel@tonic-gate #define	nfs3_ncookie	_ncookie._f
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #define	RDDIR		0x1	/* readdir operation in progress */
910Sstevel@tonic-gate #define	RDDIRWAIT	0x2	/* waiting on readdir in progress */
920Sstevel@tonic-gate #define	RDDIRREQ	0x4	/* a new readdir is required */
930Sstevel@tonic-gate #define	RDDIRCACHED	0x8	/* entry is in the cache */
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #define	HAVE_RDDIR_CACHE(rp)	(avl_numnodes(&(rp)->r_dir) > 0)
960Sstevel@tonic-gate 
970Sstevel@tonic-gate typedef struct symlink_cache {
980Sstevel@tonic-gate 	char *contents;		/* contents of the symbolic link */
990Sstevel@tonic-gate 	int len;		/* length of the contents */
1000Sstevel@tonic-gate 	int size;		/* size of the allocated buffer */
1010Sstevel@tonic-gate } symlink_cache;
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate typedef struct commit {
1040Sstevel@tonic-gate 	page_t *c_pages;	/* list of pages to commit */
1050Sstevel@tonic-gate 	offset3 c_commbase;	/* base offset to do commit from */
1060Sstevel@tonic-gate 	count3 c_commlen;	/* len to commit */
1070Sstevel@tonic-gate 	kcondvar_t c_cv;	/* condvar for waiting for commit */
1080Sstevel@tonic-gate } commit_t;
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate /*
1110Sstevel@tonic-gate  * The various values for the commit states.  These are stored in
1120Sstevel@tonic-gate  * the p_fsdata byte in the page struct.
113*11888SPavel.Filipensky@Sun.COM  * NFSv3,4 can use asynchronous writes - the NFS server can send a response
114*11888SPavel.Filipensky@Sun.COM  * before storing the data to the stable store (disk). The response contains
115*11888SPavel.Filipensky@Sun.COM  * information if the data are on a disk or not. NFS client marks pages
116*11888SPavel.Filipensky@Sun.COM  * which are already on the stable store as C_NOCOMMIT. The pages which were
117*11888SPavel.Filipensky@Sun.COM  * sent but are not yet on the stable store are only partially 'safe' and are
118*11888SPavel.Filipensky@Sun.COM  * marked as C_DELAYCOMMIT, which can be later changed to C_COMMIT if the
119*11888SPavel.Filipensky@Sun.COM  * commit operation is in progress. If the NFS server is e.g. rebooted, the
120*11888SPavel.Filipensky@Sun.COM  * client needs to resend all the uncommitted data. The client walks all the
121*11888SPavel.Filipensky@Sun.COM  * vp->v_pages and if C_DELAYCOMMIT or C_COMMIT is set, the page is marked as
122*11888SPavel.Filipensky@Sun.COM  * dirty and thus will be written to the server again.
1230Sstevel@tonic-gate  */
1240Sstevel@tonic-gate #define	C_NOCOMMIT	0	/* no commit is required */
1250Sstevel@tonic-gate #define	C_COMMIT	1	/* a commit is required so do it now */
1260Sstevel@tonic-gate #define	C_DELAYCOMMIT	2	/* a commit is required, but can be delayed */
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate /*
1290Sstevel@tonic-gate  * The lock manager holds state making it possible for the client
1300Sstevel@tonic-gate  * and server to be out of sync.  For example, if the response from
1310Sstevel@tonic-gate  * the server granting a lock request is lost, the server will think
1320Sstevel@tonic-gate  * the lock is granted and the client will think the lock is lost.
1330Sstevel@tonic-gate  * To deal with this, a list of processes for which the client is
1340Sstevel@tonic-gate  * not sure if the server holds a lock is attached to the rnode.
1350Sstevel@tonic-gate  * When such a process closes the rnode, an unlock request is sent
1360Sstevel@tonic-gate  * to the server to unlock the entire file.
1370Sstevel@tonic-gate  *
1380Sstevel@tonic-gate  * The list is kept as a singularly linked NULL terminated list.
1390Sstevel@tonic-gate  * Because it is  only added to under extreme error conditions, the
1400Sstevel@tonic-gate  * list shouldn't get very big.  DEBUG kernels print a console warning
1410Sstevel@tonic-gate  * when the number of entries on a list go beyond nfs_lmpl_high_water
1420Sstevel@tonic-gate  * an  arbitrary number defined in nfs_add_locking_id()
1430Sstevel@tonic-gate  */
1440Sstevel@tonic-gate #define	RLMPL_PID	1
1450Sstevel@tonic-gate #define	RLMPL_OWNER	2
1460Sstevel@tonic-gate typedef struct lock_manager_pid_list {
1470Sstevel@tonic-gate 	int lmpl_type;
1480Sstevel@tonic-gate 	pid_t lmpl_pid;
1490Sstevel@tonic-gate 	union {
1500Sstevel@tonic-gate 		pid_t _pid;
1510Sstevel@tonic-gate 		struct {
1520Sstevel@tonic-gate 			int len;
1530Sstevel@tonic-gate 			char *owner;
1540Sstevel@tonic-gate 		} _own;
1550Sstevel@tonic-gate 	} un;
1560Sstevel@tonic-gate 	struct lock_manager_pid_list *lmpl_next;
1570Sstevel@tonic-gate } lmpl_t;
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate #define	lmpl_opid un._pid
1600Sstevel@tonic-gate #define	lmpl_own_len un._own.len
1610Sstevel@tonic-gate #define	lmpl_owner un._own.owner
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate /*
1640Sstevel@tonic-gate  * A homegrown reader/writer lock implementation.  It addresses
1650Sstevel@tonic-gate  * two requirements not addressed by the system primitives.  They
1660Sstevel@tonic-gate  * are that the `enter" operation is optionally interruptible and
1670Sstevel@tonic-gate  * that that they can be re`enter'ed by writers without deadlock.
1680Sstevel@tonic-gate  */
1690Sstevel@tonic-gate typedef struct nfs_rwlock {
1700Sstevel@tonic-gate 	int count;
1710Sstevel@tonic-gate 	int waiters;
1720Sstevel@tonic-gate 	kthread_t *owner;
1730Sstevel@tonic-gate 	kmutex_t lock;
1740Sstevel@tonic-gate 	kcondvar_t cv;
1750Sstevel@tonic-gate } nfs_rwlock_t;
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate /*
1780Sstevel@tonic-gate  * The format of the hash bucket used to lookup rnodes from a file handle.
1790Sstevel@tonic-gate  */
1800Sstevel@tonic-gate typedef struct rhashq {
1810Sstevel@tonic-gate 	struct rnode *r_hashf;
1820Sstevel@tonic-gate 	struct rnode *r_hashb;
1830Sstevel@tonic-gate 	krwlock_t r_lock;
1840Sstevel@tonic-gate } rhashq_t;
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /*
1870Sstevel@tonic-gate  * Remote file information structure.
1880Sstevel@tonic-gate  *
1890Sstevel@tonic-gate  * The rnode is the "inode" for remote files.  It contains all the
1900Sstevel@tonic-gate  * information necessary to handle remote file on the client side.
1910Sstevel@tonic-gate  *
1920Sstevel@tonic-gate  * Note on file sizes:  we keep two file sizes in the rnode: the size
1930Sstevel@tonic-gate  * according to the client (r_size) and the size according to the server
1940Sstevel@tonic-gate  * (r_attr.va_size).  They can differ because we modify r_size during a
1950Sstevel@tonic-gate  * write system call (nfs_rdwr), before the write request goes over the
1960Sstevel@tonic-gate  * wire (before the file is actually modified on the server).  If an OTW
1970Sstevel@tonic-gate  * request occurs before the cached data is written to the server the file
1980Sstevel@tonic-gate  * size returned from the server (r_attr.va_size) may not match r_size.
1990Sstevel@tonic-gate  * r_size is the one we use, in general.  r_attr.va_size is only used to
2000Sstevel@tonic-gate  * determine whether or not our cached data is valid.
2010Sstevel@tonic-gate  *
2020Sstevel@tonic-gate  * Each rnode has 3 locks associated with it (not including the rnode
2030Sstevel@tonic-gate  * hash table and free list locks):
2040Sstevel@tonic-gate  *
2050Sstevel@tonic-gate  *	r_rwlock:	Serializes nfs_write and nfs_setattr requests
2060Sstevel@tonic-gate  *			and allows nfs_read requests to proceed in parallel.
2070Sstevel@tonic-gate  *			Serializes reads/updates to directories.
2080Sstevel@tonic-gate  *
2090Sstevel@tonic-gate  *	r_lkserlock:	Serializes lock requests with map, write, and
2100Sstevel@tonic-gate  *			readahead operations.
2110Sstevel@tonic-gate  *
2120Sstevel@tonic-gate  *	r_statelock:	Protects all fields in the rnode except for
2130Sstevel@tonic-gate  *			those listed below.  This lock is intented
2140Sstevel@tonic-gate  *			to be held for relatively short periods of
2150Sstevel@tonic-gate  *			time (not accross entire putpage operations,
2160Sstevel@tonic-gate  *			for example).
2170Sstevel@tonic-gate  *
2180Sstevel@tonic-gate  * The following members are protected by the mutex rpfreelist_lock:
2190Sstevel@tonic-gate  *	r_freef
2200Sstevel@tonic-gate  *	r_freeb
2210Sstevel@tonic-gate  *
2220Sstevel@tonic-gate  * The following members are protected by the hash bucket rwlock:
2230Sstevel@tonic-gate  *	r_hashf
2240Sstevel@tonic-gate  *	r_hashb
2250Sstevel@tonic-gate  *
2260Sstevel@tonic-gate  * Note: r_modaddr is only accessed when the r_statelock mutex is held.
2270Sstevel@tonic-gate  *	Its value is also controlled via r_rwlock.  It is assumed that
2280Sstevel@tonic-gate  *	there will be only 1 writer active at a time, so it safe to
2290Sstevel@tonic-gate  *	set r_modaddr and release r_statelock as long as the r_rwlock
2300Sstevel@tonic-gate  *	writer lock is held.
2310Sstevel@tonic-gate  *
2327689SDeepak.Honnalli@Sun.COM  * r_inmap informs nfsX_read()/write() that there is a call to nfsX_map()
2337689SDeepak.Honnalli@Sun.COM  * in progress. nfsX_read()/write() check r_inmap to decide whether
2347689SDeepak.Honnalli@Sun.COM  * to perform directio on the file or not. r_inmap is atomically
2357689SDeepak.Honnalli@Sun.COM  * incremented in nfsX_map() before the address space routines are
2367689SDeepak.Honnalli@Sun.COM  * called and atomically decremented just before nfsX_map() exits.
2377689SDeepak.Honnalli@Sun.COM  * r_inmap is not protected by any lock.
2387689SDeepak.Honnalli@Sun.COM  *
2397689SDeepak.Honnalli@Sun.COM  * r_mapcnt tells that the rnode has mapped pages. r_inmap can be 0
2407689SDeepak.Honnalli@Sun.COM  * while the rnode has mapped pages.
2417689SDeepak.Honnalli@Sun.COM  *
2420Sstevel@tonic-gate  * 64-bit offsets: the code formerly assumed that atomic reads of
2430Sstevel@tonic-gate  * r_size were safe and reliable; on 32-bit architectures, this is
2440Sstevel@tonic-gate  * not true since an intervening bus cycle from another processor
2450Sstevel@tonic-gate  * could update half of the size field.  The r_statelock must now
2460Sstevel@tonic-gate  * be held whenever any kind of access of r_size is made.
2470Sstevel@tonic-gate  *
2480Sstevel@tonic-gate  * Lock ordering:
2490Sstevel@tonic-gate  * 	r_rwlock > r_lkserlock > r_statelock
2500Sstevel@tonic-gate  */
2510Sstevel@tonic-gate struct exportinfo;	/* defined in nfs/export.h */
2520Sstevel@tonic-gate struct servinfo;	/* defined in nfs/nfs_clnt.h */
2530Sstevel@tonic-gate struct failinfo;	/* defined in nfs/nfs_clnt.h */
2540Sstevel@tonic-gate struct mntinfo;		/* defined in nfs/nfs_clnt.h */
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate #ifdef _KERNEL
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate typedef struct rnode {
2590Sstevel@tonic-gate 	/* the hash fields must be first to match the rhashq_t */
2600Sstevel@tonic-gate 	struct rnode	*r_hashf;	/* hash queue forward pointer */
2610Sstevel@tonic-gate 	struct rnode	*r_hashb;	/* hash queue back pointer */
2620Sstevel@tonic-gate 	struct rnode	*r_freef;	/* free list forward pointer */
2630Sstevel@tonic-gate 	struct rnode	*r_freeb;	/* free list back pointer */
2640Sstevel@tonic-gate 	rhashq_t	*r_hashq;	/* pointer to the hash bucket */
2650Sstevel@tonic-gate 	vnode_t		*r_vnode;	/* vnode for remote file */
2660Sstevel@tonic-gate 	nfs_rwlock_t	r_rwlock;	/* serializes write/setattr requests */
2670Sstevel@tonic-gate 	nfs_rwlock_t	r_lkserlock;	/* serialize lock with other ops */
2680Sstevel@tonic-gate 	kmutex_t	r_statelock;	/* protects (most of) rnode contents */
2690Sstevel@tonic-gate 	nfs_fhandle	r_fh;		/* file handle */
2700Sstevel@tonic-gate 	struct servinfo	*r_server;	/* current server */
2710Sstevel@tonic-gate 	char		*r_path;	/* path to this rnode */
2720Sstevel@tonic-gate 	u_offset_t	r_nextr;	/* next byte read offset (read-ahead) */
2730Sstevel@tonic-gate 	cred_t		*r_cred;	/* current credentials */
2740Sstevel@tonic-gate 	cred_t		*r_unlcred;	/* unlinked credentials */
2750Sstevel@tonic-gate 	char		*r_unlname;	/* unlinked file name */
2760Sstevel@tonic-gate 	vnode_t		*r_unldvp;	/* parent dir of unlinked file */
2770Sstevel@tonic-gate 	len_t		r_size;		/* client's view of file size */
2780Sstevel@tonic-gate 	struct vattr	r_attr;		/* cached vnode attributes */
2790Sstevel@tonic-gate 	hrtime_t	r_attrtime;	/* time attributes become invalid */
2800Sstevel@tonic-gate 	hrtime_t	r_mtime;	/* client time file last modified */
2810Sstevel@tonic-gate 	long		r_mapcnt;	/* count of mmapped pages */
2820Sstevel@tonic-gate 	uint_t		r_count;	/* # of refs not reflect in v_count */
2830Sstevel@tonic-gate 	uint_t		r_awcount;	/* # of outstanding async write */
2840Sstevel@tonic-gate 	uint_t		r_gcount;	/* getattrs waiting to flush pages */
2850Sstevel@tonic-gate 	ushort_t	r_flags;	/* flags, see below */
2860Sstevel@tonic-gate 	short		r_error;	/* async write error */
2870Sstevel@tonic-gate 	kcondvar_t	r_cv;		/* condvar for blocked threads */
2880Sstevel@tonic-gate 	int		(*r_putapage)	/* address of putapage routine */
2890Sstevel@tonic-gate 		(vnode_t *, page_t *, u_offset_t *, size_t *, int, cred_t *);
2900Sstevel@tonic-gate 	avl_tree_t	r_dir;		/* cache of readdir responses */
2910Sstevel@tonic-gate 	rddir_cache	*r_direof;	/* pointer to the EOF entry */
2920Sstevel@tonic-gate 	symlink_cache	r_symlink;	/* cached readlink response */
2930Sstevel@tonic-gate 	writeverf3	r_verf;		/* version 3 write verifier */
2940Sstevel@tonic-gate 	u_offset_t	r_modaddr;	/* address for page in writerp */
2950Sstevel@tonic-gate 	commit_t	r_commit;	/* commit information */
2960Sstevel@tonic-gate 	u_offset_t	r_truncaddr;	/* base for truncate operation */
2970Sstevel@tonic-gate 	vsecattr_t	*r_secattr;	/* cached security attributes (acls) */
2980Sstevel@tonic-gate 	cookieverf3	r_cookieverf;	/* version 3 readdir cookie verifier */
2990Sstevel@tonic-gate 	lmpl_t		*r_lmpl;	/* pids that may be holding locks */
3000Sstevel@tonic-gate 	nfs3_pathconf_info *r_pathconf;	/* cached pathconf information */
3010Sstevel@tonic-gate 	acache_t	*r_acache;	/* list of access cache entries */
3020Sstevel@tonic-gate 	kthread_t	*r_serial;	/* id of purging thread */
3030Sstevel@tonic-gate 	list_t		r_indelmap;	/* list of delmap callers */
3047689SDeepak.Honnalli@Sun.COM 	uint_t		r_inmap;	/* to serialize read/write and mmap */
3050Sstevel@tonic-gate } rnode_t;
3060Sstevel@tonic-gate #endif /* _KERNEL */
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate /*
3090Sstevel@tonic-gate  * Flags
3100Sstevel@tonic-gate  */
3110Sstevel@tonic-gate #define	RREADDIRPLUS	0x1	/* issue a READDIRPLUS instead of READDIR */
3120Sstevel@tonic-gate #define	RDIRTY		0x2	/* dirty pages from write operation */
3130Sstevel@tonic-gate #define	RSTALE		0x4	/* file handle is stale */
3140Sstevel@tonic-gate #define	RMODINPROGRESS	0x8	/* page modification happening */
3150Sstevel@tonic-gate #define	RTRUNCATE	0x10	/* truncating, don't commit */
3160Sstevel@tonic-gate #define	RHAVEVERF	0x20	/* have a write verifier to compare against */
3170Sstevel@tonic-gate #define	RCOMMIT		0x40	/* commit in progress */
3180Sstevel@tonic-gate #define	RCOMMITWAIT	0x80	/* someone is waiting to do a commit */
3190Sstevel@tonic-gate #define	RHASHED		0x100	/* rnode is in hash queues */
3200Sstevel@tonic-gate #define	ROUTOFSPACE	0x200	/* an out of space error has happened */
3210Sstevel@tonic-gate #define	RDIRECTIO	0x400	/* bypass the buffer cache */
3220Sstevel@tonic-gate #define	RLOOKUP		0x800	/* a lookup has been performed */
3230Sstevel@tonic-gate #define	RWRITEATTR	0x1000	/* attributes came from WRITE */
3240Sstevel@tonic-gate #define	RINDNLCPURGE	0x2000	/* in the process of purging DNLC references */
3250Sstevel@tonic-gate #define	RDELMAPLIST	0x4000	/* delmap callers tracking for as callback */
3265486Svv149972 #define	RINCACHEPURGE	0x8000	/* purging caches due to file size change */
3270Sstevel@tonic-gate 
3280Sstevel@tonic-gate /*
3290Sstevel@tonic-gate  * Convert between vnode and rnode
3300Sstevel@tonic-gate  */
3310Sstevel@tonic-gate #define	RTOV(rp)	((rp)->r_vnode)
3320Sstevel@tonic-gate #define	VTOR(vp)	((rnode_t *)((vp)->v_data))
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate #define	VTOFH(vp)	(RTOFH(VTOR(vp)))
3350Sstevel@tonic-gate #define	RTOFH(rp)	((fhandle_t *)(&(rp)->r_fh.fh_buf))
3360Sstevel@tonic-gate #define	VTOFH3(vp)	(RTOFH3(VTOR(vp)))
3370Sstevel@tonic-gate #define	RTOFH3(rp)	((nfs_fh3 *)(&(rp)->r_fh))
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate #ifdef _KERNEL
3400Sstevel@tonic-gate extern int	nfs_async_readahead(vnode_t *, u_offset_t, caddr_t,
3410Sstevel@tonic-gate 				struct seg *, cred_t *,
3420Sstevel@tonic-gate 				void (*)(vnode_t *, u_offset_t,
3430Sstevel@tonic-gate 				caddr_t, struct seg *, cred_t *));
3440Sstevel@tonic-gate extern int	nfs_async_putapage(vnode_t *, page_t *, u_offset_t, size_t,
3450Sstevel@tonic-gate 				int, cred_t *, int (*)(vnode_t *, page_t *,
3460Sstevel@tonic-gate 				u_offset_t, size_t, int, cred_t *));
3470Sstevel@tonic-gate extern int	nfs_async_pageio(vnode_t *, page_t *, u_offset_t, size_t,
3480Sstevel@tonic-gate 				int, cred_t *, int (*)(vnode_t *, page_t *,
3490Sstevel@tonic-gate 				u_offset_t, size_t, int, cred_t *));
3500Sstevel@tonic-gate extern void	nfs_async_readdir(vnode_t *, rddir_cache *,
3510Sstevel@tonic-gate 				cred_t *, int (*)(vnode_t *,
3520Sstevel@tonic-gate 				rddir_cache *, cred_t *));
3530Sstevel@tonic-gate extern void	nfs_async_commit(vnode_t *, page_t *, offset3, count3,
3540Sstevel@tonic-gate 				cred_t *, void (*)(vnode_t *, page_t *,
3550Sstevel@tonic-gate 				offset3, count3, cred_t *));
3560Sstevel@tonic-gate extern void	nfs_async_inactive(vnode_t *, cred_t *, void (*)(vnode_t *,
3575331Samw 				cred_t *, caller_context_t *));
3580Sstevel@tonic-gate extern int	writerp(rnode_t *, caddr_t, int, struct uio *, int);
3590Sstevel@tonic-gate extern int	nfs_putpages(vnode_t *, u_offset_t, size_t, int, cred_t *);
3600Sstevel@tonic-gate extern void	nfs_invalidate_pages(vnode_t *, u_offset_t, cred_t *);
3610Sstevel@tonic-gate extern int	rfs2call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t,
3620Sstevel@tonic-gate 			xdrproc_t, caddr_t, cred_t *, int *, enum nfsstat *,
3630Sstevel@tonic-gate 			int, struct failinfo *);
3640Sstevel@tonic-gate extern int	rfs3call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t,
3650Sstevel@tonic-gate 			xdrproc_t, caddr_t, cred_t *, int *, nfsstat3 *,
3660Sstevel@tonic-gate 			int, struct failinfo *);
3670Sstevel@tonic-gate extern void	nfs_setswaplike(vnode_t *, vattr_t *);
3680Sstevel@tonic-gate extern vnode_t	*makenfsnode(fhandle_t *, struct nfsfattr *, struct vfs *,
3690Sstevel@tonic-gate 			hrtime_t, cred_t *, char *, char *);
3700Sstevel@tonic-gate extern vnode_t	*makenfs3node_va(nfs_fh3 *, vattr_t *, struct vfs *, hrtime_t,
3710Sstevel@tonic-gate 			cred_t *, char *, char *);
3720Sstevel@tonic-gate extern vnode_t	*makenfs3node(nfs_fh3 *, fattr3 *, struct vfs *, hrtime_t,
3730Sstevel@tonic-gate 			cred_t *, char *, char *);
3740Sstevel@tonic-gate extern void	rp_addfree(rnode_t *, cred_t *);
3750Sstevel@tonic-gate extern void	rp_rmhash(rnode_t *);
3760Sstevel@tonic-gate extern int	check_rtable(struct vfs *);
3770Sstevel@tonic-gate extern void	destroy_rtable(struct vfs *, cred_t *);
3780Sstevel@tonic-gate extern void	rflush(struct vfs *, cred_t *);
3790Sstevel@tonic-gate extern nfs_access_type_t nfs_access_check(rnode_t *, uint32_t, cred_t *);
3800Sstevel@tonic-gate extern void	nfs_access_cache(rnode_t *rp, uint32_t, uint32_t, cred_t *);
3810Sstevel@tonic-gate extern int	nfs_access_purge_rp(rnode_t *);
3820Sstevel@tonic-gate extern int	nfs_putapage(vnode_t *, page_t *, u_offset_t *, size_t *,
3830Sstevel@tonic-gate 			int, cred_t *);
3840Sstevel@tonic-gate extern int	nfs3_putapage(vnode_t *, page_t *, u_offset_t *, size_t *,
3850Sstevel@tonic-gate 			int, cred_t *);
3860Sstevel@tonic-gate extern void	nfs_printfhandle(nfs_fhandle *);
3870Sstevel@tonic-gate extern void	nfs_write_error(vnode_t *, int, cred_t *);
3880Sstevel@tonic-gate extern rddir_cache	*rddir_cache_alloc(int);
3890Sstevel@tonic-gate extern void		rddir_cache_hold(rddir_cache *);
3900Sstevel@tonic-gate extern void		rddir_cache_rele(rddir_cache *);
3910Sstevel@tonic-gate #ifdef DEBUG
3920Sstevel@tonic-gate extern char		*rddir_cache_buf_alloc(size_t, int);
3930Sstevel@tonic-gate extern void		rddir_cache_buf_free(void *, size_t);
3940Sstevel@tonic-gate #endif
3950Sstevel@tonic-gate extern int	nfs_rw_enter_sig(nfs_rwlock_t *, krw_t, int);
3960Sstevel@tonic-gate extern int	nfs_rw_tryenter(nfs_rwlock_t *, krw_t);
3970Sstevel@tonic-gate extern void	nfs_rw_exit(nfs_rwlock_t *);
3980Sstevel@tonic-gate extern int	nfs_rw_lock_held(nfs_rwlock_t *, krw_t);
3990Sstevel@tonic-gate extern void	nfs_rw_init(nfs_rwlock_t *, char *, krw_type_t, void *);
4000Sstevel@tonic-gate extern void	nfs_rw_destroy(nfs_rwlock_t *);
4010Sstevel@tonic-gate extern int	nfs_directio(vnode_t *, int, cred_t *);
4020Sstevel@tonic-gate extern int	nfs3_rddir_compar(const void *, const void *);
4030Sstevel@tonic-gate extern int	nfs_rddir_compar(const void *, const void *);
404766Scarlsonj extern struct zone *nfs_zone(void);
405766Scarlsonj extern zoneid_t nfs_zoneid(void);
4060Sstevel@tonic-gate 
4070Sstevel@tonic-gate #endif
4080Sstevel@tonic-gate 
4090Sstevel@tonic-gate #ifdef	__cplusplus
4100Sstevel@tonic-gate }
4110Sstevel@tonic-gate #endif
4120Sstevel@tonic-gate 
4130Sstevel@tonic-gate #endif	/* _NFS_RNODE_H */
414