xref: /onnv-gate/usr/src/uts/common/nfs/rnode.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #ifndef	_NFS_RNODE_H
31*0Sstevel@tonic-gate #define	_NFS_RNODE_H
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #include <sys/avl.h>
36*0Sstevel@tonic-gate #include <sys/list.h>
37*0Sstevel@tonic-gate #include <nfs/nfs.h>
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #ifdef	__cplusplus
40*0Sstevel@tonic-gate extern "C" {
41*0Sstevel@tonic-gate #endif
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate typedef enum nfs_access_type {
44*0Sstevel@tonic-gate 	NFS_ACCESS_UNKNOWN,
45*0Sstevel@tonic-gate 	NFS_ACCESS_ALLOWED,
46*0Sstevel@tonic-gate 	NFS_ACCESS_DENIED
47*0Sstevel@tonic-gate } nfs_access_type_t;
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate typedef struct acache_hash {
50*0Sstevel@tonic-gate 	struct acache *next;	/* next and prev must be first */
51*0Sstevel@tonic-gate 	struct acache *prev;
52*0Sstevel@tonic-gate 	krwlock_t lock;
53*0Sstevel@tonic-gate } acache_hash_t;
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate typedef struct acache {
56*0Sstevel@tonic-gate 	struct acache *next;	/* next and prev must be first */
57*0Sstevel@tonic-gate 	struct acache *prev;
58*0Sstevel@tonic-gate 	uint32_t known;
59*0Sstevel@tonic-gate 	uint32_t allowed;
60*0Sstevel@tonic-gate 	struct rnode *rnode;
61*0Sstevel@tonic-gate 	cred_t *cred;
62*0Sstevel@tonic-gate 	struct acache *list;
63*0Sstevel@tonic-gate 	struct acache_hash *hashq;
64*0Sstevel@tonic-gate } acache_t;
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate #define	NFS_FHANDLE_LEN	64
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate typedef struct nfs_fhandle {
69*0Sstevel@tonic-gate 	int fh_len;
70*0Sstevel@tonic-gate 	char fh_buf[NFS_FHANDLE_LEN];
71*0Sstevel@tonic-gate } nfs_fhandle;
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate typedef struct rddir_cache {
74*0Sstevel@tonic-gate 	lloff_t _cookie;	/* cookie used to find this cache entry */
75*0Sstevel@tonic-gate 	lloff_t _ncookie;	/* cookie used to find the next cache entry */
76*0Sstevel@tonic-gate 	char *entries;		/* buffer containing dirent entries */
77*0Sstevel@tonic-gate 	int eof;		/* EOF reached after this request */
78*0Sstevel@tonic-gate 	int entlen;		/* size of dirent entries in buf */
79*0Sstevel@tonic-gate 	int buflen;		/* size of the buffer used to store entries */
80*0Sstevel@tonic-gate 	int flags;		/* control flags, see below */
81*0Sstevel@tonic-gate 	kcondvar_t cv;		/* cv for blocking */
82*0Sstevel@tonic-gate 	int error;		/* error from RPC operation */
83*0Sstevel@tonic-gate 	kmutex_t lock;
84*0Sstevel@tonic-gate 	uint_t count;		/* reference count */
85*0Sstevel@tonic-gate 	avl_node_t tree;	/* AVL tree links */
86*0Sstevel@tonic-gate } rddir_cache;
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate #define	nfs_cookie	_cookie._p._l
89*0Sstevel@tonic-gate #define	nfs_ncookie	_ncookie._p._l
90*0Sstevel@tonic-gate #define	nfs3_cookie	_cookie._f
91*0Sstevel@tonic-gate #define	nfs3_ncookie	_ncookie._f
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate #define	RDDIR		0x1	/* readdir operation in progress */
94*0Sstevel@tonic-gate #define	RDDIRWAIT	0x2	/* waiting on readdir in progress */
95*0Sstevel@tonic-gate #define	RDDIRREQ	0x4	/* a new readdir is required */
96*0Sstevel@tonic-gate #define	RDDIRCACHED	0x8	/* entry is in the cache */
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate #define	HAVE_RDDIR_CACHE(rp)	(avl_numnodes(&(rp)->r_dir) > 0)
99*0Sstevel@tonic-gate 
100*0Sstevel@tonic-gate typedef struct symlink_cache {
101*0Sstevel@tonic-gate 	char *contents;		/* contents of the symbolic link */
102*0Sstevel@tonic-gate 	int len;		/* length of the contents */
103*0Sstevel@tonic-gate 	int size;		/* size of the allocated buffer */
104*0Sstevel@tonic-gate } symlink_cache;
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate typedef struct commit {
107*0Sstevel@tonic-gate 	page_t *c_pages;	/* list of pages to commit */
108*0Sstevel@tonic-gate 	offset3 c_commbase;	/* base offset to do commit from */
109*0Sstevel@tonic-gate 	count3 c_commlen;	/* len to commit */
110*0Sstevel@tonic-gate 	kcondvar_t c_cv;	/* condvar for waiting for commit */
111*0Sstevel@tonic-gate } commit_t;
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate /*
114*0Sstevel@tonic-gate  * The various values for the commit states.  These are stored in
115*0Sstevel@tonic-gate  * the p_fsdata byte in the page struct.
116*0Sstevel@tonic-gate  */
117*0Sstevel@tonic-gate #define	C_NOCOMMIT	0	/* no commit is required */
118*0Sstevel@tonic-gate #define	C_COMMIT	1	/* a commit is required so do it now */
119*0Sstevel@tonic-gate #define	C_DELAYCOMMIT	2	/* a commit is required, but can be delayed */
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate /*
122*0Sstevel@tonic-gate  * The lock manager holds state making it possible for the client
123*0Sstevel@tonic-gate  * and server to be out of sync.  For example, if the response from
124*0Sstevel@tonic-gate  * the server granting a lock request is lost, the server will think
125*0Sstevel@tonic-gate  * the lock is granted and the client will think the lock is lost.
126*0Sstevel@tonic-gate  * To deal with this, a list of processes for which the client is
127*0Sstevel@tonic-gate  * not sure if the server holds a lock is attached to the rnode.
128*0Sstevel@tonic-gate  * When such a process closes the rnode, an unlock request is sent
129*0Sstevel@tonic-gate  * to the server to unlock the entire file.
130*0Sstevel@tonic-gate  *
131*0Sstevel@tonic-gate  * The list is kept as a singularly linked NULL terminated list.
132*0Sstevel@tonic-gate  * Because it is  only added to under extreme error conditions, the
133*0Sstevel@tonic-gate  * list shouldn't get very big.  DEBUG kernels print a console warning
134*0Sstevel@tonic-gate  * when the number of entries on a list go beyond nfs_lmpl_high_water
135*0Sstevel@tonic-gate  * an  arbitrary number defined in nfs_add_locking_id()
136*0Sstevel@tonic-gate  */
137*0Sstevel@tonic-gate #define	RLMPL_PID	1
138*0Sstevel@tonic-gate #define	RLMPL_OWNER	2
139*0Sstevel@tonic-gate typedef struct lock_manager_pid_list {
140*0Sstevel@tonic-gate 	int lmpl_type;
141*0Sstevel@tonic-gate 	pid_t lmpl_pid;
142*0Sstevel@tonic-gate 	union {
143*0Sstevel@tonic-gate 		pid_t _pid;
144*0Sstevel@tonic-gate 		struct {
145*0Sstevel@tonic-gate 			int len;
146*0Sstevel@tonic-gate 			char *owner;
147*0Sstevel@tonic-gate 		} _own;
148*0Sstevel@tonic-gate 	} un;
149*0Sstevel@tonic-gate 	struct lock_manager_pid_list *lmpl_next;
150*0Sstevel@tonic-gate } lmpl_t;
151*0Sstevel@tonic-gate 
152*0Sstevel@tonic-gate #define	lmpl_opid un._pid
153*0Sstevel@tonic-gate #define	lmpl_own_len un._own.len
154*0Sstevel@tonic-gate #define	lmpl_owner un._own.owner
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate /*
157*0Sstevel@tonic-gate  * A homegrown reader/writer lock implementation.  It addresses
158*0Sstevel@tonic-gate  * two requirements not addressed by the system primitives.  They
159*0Sstevel@tonic-gate  * are that the `enter" operation is optionally interruptible and
160*0Sstevel@tonic-gate  * that that they can be re`enter'ed by writers without deadlock.
161*0Sstevel@tonic-gate  */
162*0Sstevel@tonic-gate typedef struct nfs_rwlock {
163*0Sstevel@tonic-gate 	int count;
164*0Sstevel@tonic-gate 	int waiters;
165*0Sstevel@tonic-gate 	kthread_t *owner;
166*0Sstevel@tonic-gate 	kmutex_t lock;
167*0Sstevel@tonic-gate 	kcondvar_t cv;
168*0Sstevel@tonic-gate } nfs_rwlock_t;
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate /*
171*0Sstevel@tonic-gate  * The format of the hash bucket used to lookup rnodes from a file handle.
172*0Sstevel@tonic-gate  */
173*0Sstevel@tonic-gate typedef struct rhashq {
174*0Sstevel@tonic-gate 	struct rnode *r_hashf;
175*0Sstevel@tonic-gate 	struct rnode *r_hashb;
176*0Sstevel@tonic-gate 	krwlock_t r_lock;
177*0Sstevel@tonic-gate } rhashq_t;
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate /*
180*0Sstevel@tonic-gate  * Remote file information structure.
181*0Sstevel@tonic-gate  *
182*0Sstevel@tonic-gate  * The rnode is the "inode" for remote files.  It contains all the
183*0Sstevel@tonic-gate  * information necessary to handle remote file on the client side.
184*0Sstevel@tonic-gate  *
185*0Sstevel@tonic-gate  * Note on file sizes:  we keep two file sizes in the rnode: the size
186*0Sstevel@tonic-gate  * according to the client (r_size) and the size according to the server
187*0Sstevel@tonic-gate  * (r_attr.va_size).  They can differ because we modify r_size during a
188*0Sstevel@tonic-gate  * write system call (nfs_rdwr), before the write request goes over the
189*0Sstevel@tonic-gate  * wire (before the file is actually modified on the server).  If an OTW
190*0Sstevel@tonic-gate  * request occurs before the cached data is written to the server the file
191*0Sstevel@tonic-gate  * size returned from the server (r_attr.va_size) may not match r_size.
192*0Sstevel@tonic-gate  * r_size is the one we use, in general.  r_attr.va_size is only used to
193*0Sstevel@tonic-gate  * determine whether or not our cached data is valid.
194*0Sstevel@tonic-gate  *
195*0Sstevel@tonic-gate  * Each rnode has 3 locks associated with it (not including the rnode
196*0Sstevel@tonic-gate  * hash table and free list locks):
197*0Sstevel@tonic-gate  *
198*0Sstevel@tonic-gate  *	r_rwlock:	Serializes nfs_write and nfs_setattr requests
199*0Sstevel@tonic-gate  *			and allows nfs_read requests to proceed in parallel.
200*0Sstevel@tonic-gate  *			Serializes reads/updates to directories.
201*0Sstevel@tonic-gate  *
202*0Sstevel@tonic-gate  *	r_lkserlock:	Serializes lock requests with map, write, and
203*0Sstevel@tonic-gate  *			readahead operations.
204*0Sstevel@tonic-gate  *
205*0Sstevel@tonic-gate  *	r_statelock:	Protects all fields in the rnode except for
206*0Sstevel@tonic-gate  *			those listed below.  This lock is intented
207*0Sstevel@tonic-gate  *			to be held for relatively short periods of
208*0Sstevel@tonic-gate  *			time (not accross entire putpage operations,
209*0Sstevel@tonic-gate  *			for example).
210*0Sstevel@tonic-gate  *
211*0Sstevel@tonic-gate  * The following members are protected by the mutex rpfreelist_lock:
212*0Sstevel@tonic-gate  *	r_freef
213*0Sstevel@tonic-gate  *	r_freeb
214*0Sstevel@tonic-gate  *
215*0Sstevel@tonic-gate  * The following members are protected by the hash bucket rwlock:
216*0Sstevel@tonic-gate  *	r_hashf
217*0Sstevel@tonic-gate  *	r_hashb
218*0Sstevel@tonic-gate  *
219*0Sstevel@tonic-gate  * Note: r_modaddr is only accessed when the r_statelock mutex is held.
220*0Sstevel@tonic-gate  *	Its value is also controlled via r_rwlock.  It is assumed that
221*0Sstevel@tonic-gate  *	there will be only 1 writer active at a time, so it safe to
222*0Sstevel@tonic-gate  *	set r_modaddr and release r_statelock as long as the r_rwlock
223*0Sstevel@tonic-gate  *	writer lock is held.
224*0Sstevel@tonic-gate  *
225*0Sstevel@tonic-gate  * 64-bit offsets: the code formerly assumed that atomic reads of
226*0Sstevel@tonic-gate  * r_size were safe and reliable; on 32-bit architectures, this is
227*0Sstevel@tonic-gate  * not true since an intervening bus cycle from another processor
228*0Sstevel@tonic-gate  * could update half of the size field.  The r_statelock must now
229*0Sstevel@tonic-gate  * be held whenever any kind of access of r_size is made.
230*0Sstevel@tonic-gate  *
231*0Sstevel@tonic-gate  * Lock ordering:
232*0Sstevel@tonic-gate  * 	r_rwlock > r_lkserlock > r_statelock
233*0Sstevel@tonic-gate  */
234*0Sstevel@tonic-gate struct exportinfo;	/* defined in nfs/export.h */
235*0Sstevel@tonic-gate struct servinfo;	/* defined in nfs/nfs_clnt.h */
236*0Sstevel@tonic-gate struct failinfo;	/* defined in nfs/nfs_clnt.h */
237*0Sstevel@tonic-gate struct mntinfo;		/* defined in nfs/nfs_clnt.h */
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate #ifdef _KERNEL
240*0Sstevel@tonic-gate 
241*0Sstevel@tonic-gate typedef struct rnode {
242*0Sstevel@tonic-gate 	/* the hash fields must be first to match the rhashq_t */
243*0Sstevel@tonic-gate 	struct rnode	*r_hashf;	/* hash queue forward pointer */
244*0Sstevel@tonic-gate 	struct rnode	*r_hashb;	/* hash queue back pointer */
245*0Sstevel@tonic-gate 	struct rnode	*r_freef;	/* free list forward pointer */
246*0Sstevel@tonic-gate 	struct rnode	*r_freeb;	/* free list back pointer */
247*0Sstevel@tonic-gate 	rhashq_t	*r_hashq;	/* pointer to the hash bucket */
248*0Sstevel@tonic-gate 	vnode_t		*r_vnode;	/* vnode for remote file */
249*0Sstevel@tonic-gate 	nfs_rwlock_t	r_rwlock;	/* serializes write/setattr requests */
250*0Sstevel@tonic-gate 	nfs_rwlock_t	r_lkserlock;	/* serialize lock with other ops */
251*0Sstevel@tonic-gate 	kmutex_t	r_statelock;	/* protects (most of) rnode contents */
252*0Sstevel@tonic-gate 	nfs_fhandle	r_fh;		/* file handle */
253*0Sstevel@tonic-gate 	struct servinfo	*r_server;	/* current server */
254*0Sstevel@tonic-gate 	char		*r_path;	/* path to this rnode */
255*0Sstevel@tonic-gate 	u_offset_t	r_nextr;	/* next byte read offset (read-ahead) */
256*0Sstevel@tonic-gate 	cred_t		*r_cred;	/* current credentials */
257*0Sstevel@tonic-gate 	cred_t		*r_unlcred;	/* unlinked credentials */
258*0Sstevel@tonic-gate 	char		*r_unlname;	/* unlinked file name */
259*0Sstevel@tonic-gate 	vnode_t		*r_unldvp;	/* parent dir of unlinked file */
260*0Sstevel@tonic-gate 	len_t		r_size;		/* client's view of file size */
261*0Sstevel@tonic-gate 	struct vattr	r_attr;		/* cached vnode attributes */
262*0Sstevel@tonic-gate 	hrtime_t	r_attrtime;	/* time attributes become invalid */
263*0Sstevel@tonic-gate 	hrtime_t	r_mtime;	/* client time file last modified */
264*0Sstevel@tonic-gate 	long		r_mapcnt;	/* count of mmapped pages */
265*0Sstevel@tonic-gate 	uint_t		r_count;	/* # of refs not reflect in v_count */
266*0Sstevel@tonic-gate 	uint_t		r_awcount;	/* # of outstanding async write */
267*0Sstevel@tonic-gate 	uint_t		r_gcount;	/* getattrs waiting to flush pages */
268*0Sstevel@tonic-gate 	ushort_t	r_flags;	/* flags, see below */
269*0Sstevel@tonic-gate 	short		r_error;	/* async write error */
270*0Sstevel@tonic-gate 	kcondvar_t	r_cv;		/* condvar for blocked threads */
271*0Sstevel@tonic-gate 	int		(*r_putapage)	/* address of putapage routine */
272*0Sstevel@tonic-gate 		(vnode_t *, page_t *, u_offset_t *, size_t *, int, cred_t *);
273*0Sstevel@tonic-gate 	avl_tree_t	r_dir;		/* cache of readdir responses */
274*0Sstevel@tonic-gate 	rddir_cache	*r_direof;	/* pointer to the EOF entry */
275*0Sstevel@tonic-gate 	symlink_cache	r_symlink;	/* cached readlink response */
276*0Sstevel@tonic-gate 	writeverf3	r_verf;		/* version 3 write verifier */
277*0Sstevel@tonic-gate 	u_offset_t	r_modaddr;	/* address for page in writerp */
278*0Sstevel@tonic-gate 	commit_t	r_commit;	/* commit information */
279*0Sstevel@tonic-gate 	u_offset_t	r_truncaddr;	/* base for truncate operation */
280*0Sstevel@tonic-gate 	vsecattr_t	*r_secattr;	/* cached security attributes (acls) */
281*0Sstevel@tonic-gate 	cookieverf3	r_cookieverf;	/* version 3 readdir cookie verifier */
282*0Sstevel@tonic-gate 	lmpl_t		*r_lmpl;	/* pids that may be holding locks */
283*0Sstevel@tonic-gate 	nfs3_pathconf_info *r_pathconf;	/* cached pathconf information */
284*0Sstevel@tonic-gate 	acache_t	*r_acache;	/* list of access cache entries */
285*0Sstevel@tonic-gate 	kthread_t	*r_serial;	/* id of purging thread */
286*0Sstevel@tonic-gate 	list_t		r_indelmap;	/* list of delmap callers */
287*0Sstevel@tonic-gate } rnode_t;
288*0Sstevel@tonic-gate #endif /* _KERNEL */
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate /*
291*0Sstevel@tonic-gate  * Flags
292*0Sstevel@tonic-gate  */
293*0Sstevel@tonic-gate #define	RREADDIRPLUS	0x1	/* issue a READDIRPLUS instead of READDIR */
294*0Sstevel@tonic-gate #define	RDIRTY		0x2	/* dirty pages from write operation */
295*0Sstevel@tonic-gate #define	RSTALE		0x4	/* file handle is stale */
296*0Sstevel@tonic-gate #define	RMODINPROGRESS	0x8	/* page modification happening */
297*0Sstevel@tonic-gate #define	RTRUNCATE	0x10	/* truncating, don't commit */
298*0Sstevel@tonic-gate #define	RHAVEVERF	0x20	/* have a write verifier to compare against */
299*0Sstevel@tonic-gate #define	RCOMMIT		0x40	/* commit in progress */
300*0Sstevel@tonic-gate #define	RCOMMITWAIT	0x80	/* someone is waiting to do a commit */
301*0Sstevel@tonic-gate #define	RHASHED		0x100	/* rnode is in hash queues */
302*0Sstevel@tonic-gate #define	ROUTOFSPACE	0x200	/* an out of space error has happened */
303*0Sstevel@tonic-gate #define	RDIRECTIO	0x400	/* bypass the buffer cache */
304*0Sstevel@tonic-gate #define	RLOOKUP		0x800	/* a lookup has been performed */
305*0Sstevel@tonic-gate #define	RWRITEATTR	0x1000	/* attributes came from WRITE */
306*0Sstevel@tonic-gate #define	RINDNLCPURGE	0x2000	/* in the process of purging DNLC references */
307*0Sstevel@tonic-gate #define	RDELMAPLIST	0x4000	/* delmap callers tracking for as callback */
308*0Sstevel@tonic-gate 
309*0Sstevel@tonic-gate /*
310*0Sstevel@tonic-gate  * Convert between vnode and rnode
311*0Sstevel@tonic-gate  */
312*0Sstevel@tonic-gate #define	RTOV(rp)	((rp)->r_vnode)
313*0Sstevel@tonic-gate #define	VTOR(vp)	((rnode_t *)((vp)->v_data))
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate #define	VTOFH(vp)	(RTOFH(VTOR(vp)))
316*0Sstevel@tonic-gate #define	RTOFH(rp)	((fhandle_t *)(&(rp)->r_fh.fh_buf))
317*0Sstevel@tonic-gate #define	VTOFH3(vp)	(RTOFH3(VTOR(vp)))
318*0Sstevel@tonic-gate #define	RTOFH3(rp)	((nfs_fh3 *)(&(rp)->r_fh))
319*0Sstevel@tonic-gate 
320*0Sstevel@tonic-gate #ifdef _KERNEL
321*0Sstevel@tonic-gate extern int	nfs_async_readahead(vnode_t *, u_offset_t, caddr_t,
322*0Sstevel@tonic-gate 				struct seg *, cred_t *,
323*0Sstevel@tonic-gate 				void (*)(vnode_t *, u_offset_t,
324*0Sstevel@tonic-gate 				caddr_t, struct seg *, cred_t *));
325*0Sstevel@tonic-gate extern int	nfs_async_putapage(vnode_t *, page_t *, u_offset_t, size_t,
326*0Sstevel@tonic-gate 				int, cred_t *, int (*)(vnode_t *, page_t *,
327*0Sstevel@tonic-gate 				u_offset_t, size_t, int, cred_t *));
328*0Sstevel@tonic-gate extern int	nfs_async_pageio(vnode_t *, page_t *, u_offset_t, size_t,
329*0Sstevel@tonic-gate 				int, cred_t *, int (*)(vnode_t *, page_t *,
330*0Sstevel@tonic-gate 				u_offset_t, size_t, int, cred_t *));
331*0Sstevel@tonic-gate extern void	nfs_async_readdir(vnode_t *, rddir_cache *,
332*0Sstevel@tonic-gate 				cred_t *, int (*)(vnode_t *,
333*0Sstevel@tonic-gate 				rddir_cache *, cred_t *));
334*0Sstevel@tonic-gate extern void	nfs_async_commit(vnode_t *, page_t *, offset3, count3,
335*0Sstevel@tonic-gate 				cred_t *, void (*)(vnode_t *, page_t *,
336*0Sstevel@tonic-gate 				offset3, count3, cred_t *));
337*0Sstevel@tonic-gate extern void	nfs_async_inactive(vnode_t *, cred_t *, void (*)(vnode_t *,
338*0Sstevel@tonic-gate 				cred_t *));
339*0Sstevel@tonic-gate extern int	writerp(rnode_t *, caddr_t, int, struct uio *, int);
340*0Sstevel@tonic-gate extern int	nfs_putpages(vnode_t *, u_offset_t, size_t, int, cred_t *);
341*0Sstevel@tonic-gate extern void	nfs_invalidate_pages(vnode_t *, u_offset_t, cred_t *);
342*0Sstevel@tonic-gate extern int	rfs2call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t,
343*0Sstevel@tonic-gate 			xdrproc_t, caddr_t, cred_t *, int *, enum nfsstat *,
344*0Sstevel@tonic-gate 			int, struct failinfo *);
345*0Sstevel@tonic-gate extern int	rfs3call(struct mntinfo *, rpcproc_t, xdrproc_t, caddr_t,
346*0Sstevel@tonic-gate 			xdrproc_t, caddr_t, cred_t *, int *, nfsstat3 *,
347*0Sstevel@tonic-gate 			int, struct failinfo *);
348*0Sstevel@tonic-gate extern void	nfs_setswaplike(vnode_t *, vattr_t *);
349*0Sstevel@tonic-gate extern vnode_t	*makenfsnode(fhandle_t *, struct nfsfattr *, struct vfs *,
350*0Sstevel@tonic-gate 			hrtime_t, cred_t *, char *, char *);
351*0Sstevel@tonic-gate extern vnode_t	*makenfs3node_va(nfs_fh3 *, vattr_t *, struct vfs *, hrtime_t,
352*0Sstevel@tonic-gate 			cred_t *, char *, char *);
353*0Sstevel@tonic-gate extern vnode_t	*makenfs3node(nfs_fh3 *, fattr3 *, struct vfs *, hrtime_t,
354*0Sstevel@tonic-gate 			cred_t *, char *, char *);
355*0Sstevel@tonic-gate extern void	rp_addfree(rnode_t *, cred_t *);
356*0Sstevel@tonic-gate extern void	rp_rmhash(rnode_t *);
357*0Sstevel@tonic-gate extern int	check_rtable(struct vfs *);
358*0Sstevel@tonic-gate extern void	destroy_rtable(struct vfs *, cred_t *);
359*0Sstevel@tonic-gate extern void	rflush(struct vfs *, cred_t *);
360*0Sstevel@tonic-gate extern nfs_access_type_t nfs_access_check(rnode_t *, uint32_t, cred_t *);
361*0Sstevel@tonic-gate extern void	nfs_access_cache(rnode_t *rp, uint32_t, uint32_t, cred_t *);
362*0Sstevel@tonic-gate extern int	nfs_access_purge_rp(rnode_t *);
363*0Sstevel@tonic-gate extern int	nfs_putapage(vnode_t *, page_t *, u_offset_t *, size_t *,
364*0Sstevel@tonic-gate 			int, cred_t *);
365*0Sstevel@tonic-gate extern int	nfs3_putapage(vnode_t *, page_t *, u_offset_t *, size_t *,
366*0Sstevel@tonic-gate 			int, cred_t *);
367*0Sstevel@tonic-gate extern void	nfs_printfhandle(nfs_fhandle *);
368*0Sstevel@tonic-gate extern void	nfs_write_error(vnode_t *, int, cred_t *);
369*0Sstevel@tonic-gate extern rddir_cache	*rddir_cache_alloc(int);
370*0Sstevel@tonic-gate extern void		rddir_cache_hold(rddir_cache *);
371*0Sstevel@tonic-gate extern void		rddir_cache_rele(rddir_cache *);
372*0Sstevel@tonic-gate #ifdef DEBUG
373*0Sstevel@tonic-gate extern char		*rddir_cache_buf_alloc(size_t, int);
374*0Sstevel@tonic-gate extern void		rddir_cache_buf_free(void *, size_t);
375*0Sstevel@tonic-gate #endif
376*0Sstevel@tonic-gate extern int	nfs_rw_enter_sig(nfs_rwlock_t *, krw_t, int);
377*0Sstevel@tonic-gate extern int	nfs_rw_tryenter(nfs_rwlock_t *, krw_t);
378*0Sstevel@tonic-gate extern void	nfs_rw_exit(nfs_rwlock_t *);
379*0Sstevel@tonic-gate extern int	nfs_rw_lock_held(nfs_rwlock_t *, krw_t);
380*0Sstevel@tonic-gate extern void	nfs_rw_init(nfs_rwlock_t *, char *, krw_type_t, void *);
381*0Sstevel@tonic-gate extern void	nfs_rw_destroy(nfs_rwlock_t *);
382*0Sstevel@tonic-gate extern int	nfs_directio(vnode_t *, int, cred_t *);
383*0Sstevel@tonic-gate extern int	nfs3_rddir_compar(const void *, const void *);
384*0Sstevel@tonic-gate extern int	nfs_rddir_compar(const void *, const void *);
385*0Sstevel@tonic-gate 
386*0Sstevel@tonic-gate #endif
387*0Sstevel@tonic-gate 
388*0Sstevel@tonic-gate #ifdef	__cplusplus
389*0Sstevel@tonic-gate }
390*0Sstevel@tonic-gate #endif
391*0Sstevel@tonic-gate 
392*0Sstevel@tonic-gate #endif	/* _NFS_RNODE_H */
393