xref: /onnv-gate/usr/src/uts/common/nfs/nfs4_clnt.h (revision 13096:b02331b7b26d)
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
51649Sdm120769  * Common Development and Distribution License (the "License").
61649Sdm120769  * 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*13096SJordan.Vaughan@Sun.com  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
260Sstevel@tonic-gate /*	All Rights Reserved   */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
300Sstevel@tonic-gate  * under license from the Regents of the University of California.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifndef _NFS4_CLNT_H
340Sstevel@tonic-gate #define	_NFS4_CLNT_H
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <sys/errno.h>
370Sstevel@tonic-gate #include <sys/types.h>
380Sstevel@tonic-gate #include <sys/kstat.h>
390Sstevel@tonic-gate #include <sys/time.h>
400Sstevel@tonic-gate #include <sys/flock.h>
410Sstevel@tonic-gate #include <vm/page.h>
420Sstevel@tonic-gate #include <nfs/nfs4_kprot.h>
430Sstevel@tonic-gate #include <nfs/nfs4.h>
440Sstevel@tonic-gate #include <nfs/rnode.h>
450Sstevel@tonic-gate #include <sys/avl.h>
460Sstevel@tonic-gate #include <sys/list.h>
475302Sth199096 #include <rpc/auth.h>
4811291SRobert.Thurlow@Sun.COM #include <sys/door.h>
4911507SVallish.Vaidyeshwara@Sun.COM #include <sys/condvar_impl.h>
50*13096SJordan.Vaughan@Sun.com #include <sys/zone.h>
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #ifdef	__cplusplus
530Sstevel@tonic-gate extern "C" {
540Sstevel@tonic-gate #endif
550Sstevel@tonic-gate 
560Sstevel@tonic-gate #define	NFS4_SIZE_OK(size)	((size) <= MAXOFFSET_T)
570Sstevel@tonic-gate 
580Sstevel@tonic-gate /* Four states of nfs4_server's lease_valid */
590Sstevel@tonic-gate #define	NFS4_LEASE_INVALID		0
600Sstevel@tonic-gate #define	NFS4_LEASE_VALID		1
610Sstevel@tonic-gate #define	NFS4_LEASE_UNINITIALIZED	2
620Sstevel@tonic-gate #define	NFS4_LEASE_NOT_STARTED		3
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /* flag to tell the renew thread it should exit */
650Sstevel@tonic-gate #define	NFS4_THREAD_EXIT	1
660Sstevel@tonic-gate 
670Sstevel@tonic-gate /* Default number of seconds to wait on GRACE and DELAY errors */
680Sstevel@tonic-gate #define	NFS4ERR_DELAY_TIME	10
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /* Number of hash buckets for open owners for each nfs4_server */
710Sstevel@tonic-gate #define	NFS4_NUM_OO_BUCKETS	53
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /* Number of freed open owners (per mntinfo4_t) to keep around */
740Sstevel@tonic-gate #define	NFS4_NUM_FREED_OPEN_OWNERS	8
750Sstevel@tonic-gate 
760Sstevel@tonic-gate /* Number of seconds to wait before retrying a SETCLIENTID(_CONFIRM) op */
770Sstevel@tonic-gate #define	NFS4_RETRY_SCLID_DELAY	10
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /* Number of times we should retry a SETCLIENTID(_CONFIRM) op */
800Sstevel@tonic-gate #define	NFS4_NUM_SCLID_RETRIES	3
810Sstevel@tonic-gate 
820Sstevel@tonic-gate /* Number of times we should retry on open after getting NFS4ERR_BAD_SEQID */
830Sstevel@tonic-gate #define	NFS4_NUM_RETRY_BAD_SEQID	3
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /*
8611507SVallish.Vaidyeshwara@Sun.COM  * Macro to wakeup sleeping async worker threads.
8711507SVallish.Vaidyeshwara@Sun.COM  */
8811507SVallish.Vaidyeshwara@Sun.COM #define	NFS4_WAKE_ASYNC_WORKER(work_cv)	{				\
8911507SVallish.Vaidyeshwara@Sun.COM 	if (CV_HAS_WAITERS(&work_cv[NFS4_ASYNC_QUEUE])) 		\
9011507SVallish.Vaidyeshwara@Sun.COM 		cv_signal(&work_cv[NFS4_ASYNC_QUEUE]);			\
9111507SVallish.Vaidyeshwara@Sun.COM 	else if (CV_HAS_WAITERS(&work_cv[NFS4_ASYNC_PGOPS_QUEUE])) 	\
9211507SVallish.Vaidyeshwara@Sun.COM 		cv_signal(&work_cv[NFS4_ASYNC_PGOPS_QUEUE]);		\
9311507SVallish.Vaidyeshwara@Sun.COM }
9411507SVallish.Vaidyeshwara@Sun.COM 
9511507SVallish.Vaidyeshwara@Sun.COM #define	NFS4_WAKEALL_ASYNC_WORKERS(work_cv) {				\
9611507SVallish.Vaidyeshwara@Sun.COM 		cv_broadcast(&work_cv[NFS4_ASYNC_QUEUE]);		\
9711507SVallish.Vaidyeshwara@Sun.COM 		cv_broadcast(&work_cv[NFS4_ASYNC_PGOPS_QUEUE]);		\
9811507SVallish.Vaidyeshwara@Sun.COM }
9911507SVallish.Vaidyeshwara@Sun.COM 
10011507SVallish.Vaidyeshwara@Sun.COM /*
1010Sstevel@tonic-gate  * Is the attribute cache valid?  If client holds a delegation, then attrs
1020Sstevel@tonic-gate  * are by definition valid.  If not, then check to see if attrs have timed out.
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate #define	ATTRCACHE4_VALID(vp) (VTOR4(vp)->r_deleg_type != OPEN_DELEGATE_NONE || \
1050Sstevel@tonic-gate 	gethrtime() < VTOR4(vp)->r_time_attr_inval)
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate /*
1080Sstevel@tonic-gate  * Flags to indicate whether to purge the DNLC for non-directory vnodes
1090Sstevel@tonic-gate  * in a call to nfs_purge_caches.
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate #define	NFS4_NOPURGE_DNLC	0
1120Sstevel@tonic-gate #define	NFS4_PURGE_DNLC		1
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate /*
1150Sstevel@tonic-gate  * Is cache valid?
1160Sstevel@tonic-gate  * Swap is always valid, if no attributes (attrtime == 0) or
1170Sstevel@tonic-gate  * if mtime matches cached mtime it is valid
1180Sstevel@tonic-gate  * NOTE: mtime is now a timestruc_t.
1190Sstevel@tonic-gate  * Caller should be holding the rnode r_statelock mutex.
1200Sstevel@tonic-gate  */
1210Sstevel@tonic-gate #define	CACHE4_VALID(rp, mtime, fsize)				\
1220Sstevel@tonic-gate 	((RTOV4(rp)->v_flag & VISSWAP) == VISSWAP ||		\
1230Sstevel@tonic-gate 	(((mtime).tv_sec == (rp)->r_attr.va_mtime.tv_sec &&	\
1240Sstevel@tonic-gate 	(mtime).tv_nsec == (rp)->r_attr.va_mtime.tv_nsec) &&	\
1250Sstevel@tonic-gate 	((fsize) == (rp)->r_attr.va_size)))
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate /*
1280Sstevel@tonic-gate  * Macro to detect forced unmount or a zone shutdown.
1290Sstevel@tonic-gate  */
1300Sstevel@tonic-gate #define	FS_OR_ZONE_GONE4(vfsp) \
1310Sstevel@tonic-gate 	(((vfsp)->vfs_flag & VFS_UNMOUNTED) || \
1320Sstevel@tonic-gate 	zone_status_get(curproc->p_zone) >= ZONE_IS_SHUTTING_DOWN)
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate /*
1350Sstevel@tonic-gate  * Macro to help determine whether a request failed because the underlying
1360Sstevel@tonic-gate  * filesystem has been forcibly unmounted or because of zone shutdown.
1370Sstevel@tonic-gate  */
1380Sstevel@tonic-gate #define	NFS4_FRC_UNMT_ERR(err, vfsp) \
1390Sstevel@tonic-gate 	((err) == EIO && FS_OR_ZONE_GONE4((vfsp)))
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate /*
1420Sstevel@tonic-gate  * Due to the way the address space callbacks are used to execute a delmap,
1430Sstevel@tonic-gate  * we must keep track of how many times the same thread has called
1440Sstevel@tonic-gate  * VOP_DELMAP()->nfs4_delmap().  This is done by having a list of
1450Sstevel@tonic-gate  * nfs4_delmapcall_t's associated with each rnode4_t.  This list is protected
1460Sstevel@tonic-gate  * by the rnode4_t's r_statelock.  The individual elements do not need to be
1470Sstevel@tonic-gate  * protected as they will only ever be created, modified and destroyed by
1480Sstevel@tonic-gate  * one thread (the call_id).
1490Sstevel@tonic-gate  * See nfs4_delmap() for further explanation.
1500Sstevel@tonic-gate  */
1510Sstevel@tonic-gate typedef struct nfs4_delmapcall {
1520Sstevel@tonic-gate 	kthread_t	*call_id;
1530Sstevel@tonic-gate 	int		error;	/* error from delmap */
1540Sstevel@tonic-gate 	list_node_t	call_node;
1550Sstevel@tonic-gate } nfs4_delmapcall_t;
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1580Sstevel@tonic-gate  * delmap address space callback args
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate typedef struct nfs4_delmap_args {
1610Sstevel@tonic-gate 	vnode_t			*vp;
1620Sstevel@tonic-gate 	offset_t		off;
1630Sstevel@tonic-gate 	caddr_t			addr;
1640Sstevel@tonic-gate 	size_t			len;
1650Sstevel@tonic-gate 	uint_t			prot;
1660Sstevel@tonic-gate 	uint_t			maxprot;
1670Sstevel@tonic-gate 	uint_t			flags;
1680Sstevel@tonic-gate 	cred_t			*cr;
1690Sstevel@tonic-gate 	nfs4_delmapcall_t	*caller; /* to retrieve errors from the cb */
1700Sstevel@tonic-gate } nfs4_delmap_args_t;
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate /*
1730Sstevel@tonic-gate  * client side statistics
1740Sstevel@tonic-gate  */
1750Sstevel@tonic-gate /*
1760Sstevel@tonic-gate  * Per-zone counters
1770Sstevel@tonic-gate  */
1780Sstevel@tonic-gate struct clstat4 {
1790Sstevel@tonic-gate 	kstat_named_t	calls;			/* client requests */
1800Sstevel@tonic-gate 	kstat_named_t	badcalls;		/* rpc failures */
18111291SRobert.Thurlow@Sun.COM 	kstat_named_t	referrals;		/* referrals */
18211291SRobert.Thurlow@Sun.COM 	kstat_named_t	referlinks;		/* referrals as symlinks */
1830Sstevel@tonic-gate 	kstat_named_t	clgets;			/* client handle gets */
1840Sstevel@tonic-gate 	kstat_named_t	cltoomany;		/* client handle cache misses */
1850Sstevel@tonic-gate #ifdef DEBUG
1860Sstevel@tonic-gate 	kstat_named_t	clalloc;		/* number of client handles */
1870Sstevel@tonic-gate 	kstat_named_t	noresponse;		/* server not responding cnt */
1880Sstevel@tonic-gate 	kstat_named_t	failover;		/* server failover count */
1890Sstevel@tonic-gate 	kstat_named_t	remap;			/* server remap count */
1900Sstevel@tonic-gate #endif
1910Sstevel@tonic-gate };
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate #ifdef DEBUG
1940Sstevel@tonic-gate /*
1950Sstevel@tonic-gate  * The following are statistics that describe the behavior of the system as a
1960Sstevel@tonic-gate  * whole and don't correspond to any particular zone.
1970Sstevel@tonic-gate  */
1980Sstevel@tonic-gate struct clstat4_debug {
1990Sstevel@tonic-gate 	kstat_named_t	nrnode;			/* number of allocated rnodes */
2000Sstevel@tonic-gate 	kstat_named_t	access;			/* size of access cache */
2010Sstevel@tonic-gate 	kstat_named_t	dirent;			/* size of readdir cache */
2020Sstevel@tonic-gate 	kstat_named_t	dirents;		/* size of readdir buf cache */
2030Sstevel@tonic-gate 	kstat_named_t	reclaim;		/* number of reclaims */
2040Sstevel@tonic-gate 	kstat_named_t	clreclaim;		/* number of cl reclaims */
2050Sstevel@tonic-gate 	kstat_named_t	f_reclaim;		/* number of free reclaims */
2060Sstevel@tonic-gate 	kstat_named_t	a_reclaim;		/* number of active reclaims */
2070Sstevel@tonic-gate 	kstat_named_t	r_reclaim;		/* number of rnode reclaims */
2080Sstevel@tonic-gate 	kstat_named_t	rpath;			/* bytes used to store rpaths */
2090Sstevel@tonic-gate };
2100Sstevel@tonic-gate extern struct clstat4_debug clstat4_debug;
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate #endif
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate /*
21511507SVallish.Vaidyeshwara@Sun.COM  * The NFS specific async_reqs structure. iotype4 is grouped to support two
21611507SVallish.Vaidyeshwara@Sun.COM  * types of async thread pools, please read comments section of mntinfo4_t
21711507SVallish.Vaidyeshwara@Sun.COM  * definition for more information. Care should be taken while adding new
21811507SVallish.Vaidyeshwara@Sun.COM  * members to this group.
2190Sstevel@tonic-gate  */
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate enum iotype4 {
2220Sstevel@tonic-gate 	NFS4_PUTAPAGE,
2230Sstevel@tonic-gate 	NFS4_PAGEIO,
22411507SVallish.Vaidyeshwara@Sun.COM 	NFS4_COMMIT,
22511507SVallish.Vaidyeshwara@Sun.COM 	NFS4_READ_AHEAD,
2260Sstevel@tonic-gate 	NFS4_READDIR,
2270Sstevel@tonic-gate 	NFS4_INACTIVE,
22811507SVallish.Vaidyeshwara@Sun.COM 	NFS4_ASYNC_TYPES
2290Sstevel@tonic-gate };
23011507SVallish.Vaidyeshwara@Sun.COM #define	NFS4_ASYNC_PGOPS_TYPES	(NFS4_COMMIT + 1)
23111507SVallish.Vaidyeshwara@Sun.COM 
23211507SVallish.Vaidyeshwara@Sun.COM /*
23311507SVallish.Vaidyeshwara@Sun.COM  * NFS async requests queue type.
23411507SVallish.Vaidyeshwara@Sun.COM  */
23511507SVallish.Vaidyeshwara@Sun.COM enum ioqtype4 {
23611507SVallish.Vaidyeshwara@Sun.COM 	NFS4_ASYNC_QUEUE,
23711507SVallish.Vaidyeshwara@Sun.COM 	NFS4_ASYNC_PGOPS_QUEUE,
23811507SVallish.Vaidyeshwara@Sun.COM 	NFS4_MAX_ASYNC_QUEUES
23911507SVallish.Vaidyeshwara@Sun.COM };
24011507SVallish.Vaidyeshwara@Sun.COM 
24111507SVallish.Vaidyeshwara@Sun.COM /*
24211507SVallish.Vaidyeshwara@Sun.COM  * Number of NFS async threads operating exclusively on page op requests.
24311507SVallish.Vaidyeshwara@Sun.COM  */
24411507SVallish.Vaidyeshwara@Sun.COM #define	NUM_ASYNC_PGOPS_THREADS	0x2
2450Sstevel@tonic-gate 
2460Sstevel@tonic-gate struct nfs4_async_read_req {
2470Sstevel@tonic-gate 	void (*readahead)();		/* pointer to readahead function */
2480Sstevel@tonic-gate 	u_offset_t blkoff;		/* offset in file */
2490Sstevel@tonic-gate 	struct seg *seg;		/* segment to do i/o to */
2500Sstevel@tonic-gate 	caddr_t addr;			/* address to do i/o to */
2510Sstevel@tonic-gate };
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate struct nfs4_pageio_req {
2540Sstevel@tonic-gate 	int (*pageio)();		/* pointer to pageio function */
2550Sstevel@tonic-gate 	page_t *pp;			/* page list */
2560Sstevel@tonic-gate 	u_offset_t io_off;		/* offset in file */
2570Sstevel@tonic-gate 	uint_t io_len;			/* size of request */
2580Sstevel@tonic-gate 	int flags;
2590Sstevel@tonic-gate };
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate struct nfs4_readdir_req {
2620Sstevel@tonic-gate 	int (*readdir)();		/* pointer to readdir function */
2630Sstevel@tonic-gate 	struct rddir4_cache *rdc;	/* pointer to cache entry to fill */
2640Sstevel@tonic-gate };
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate struct nfs4_commit_req {
2670Sstevel@tonic-gate 	void (*commit)();		/* pointer to commit function */
2680Sstevel@tonic-gate 	page_t *plist;			/* page list */
2690Sstevel@tonic-gate 	offset4 offset;			/* starting offset */
2700Sstevel@tonic-gate 	count4 count;			/* size of range to be commited */
2710Sstevel@tonic-gate };
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate struct nfs4_async_reqs {
2740Sstevel@tonic-gate 	struct nfs4_async_reqs *a_next;	/* pointer to next arg struct */
2750Sstevel@tonic-gate #ifdef DEBUG
2760Sstevel@tonic-gate 	kthread_t *a_queuer;		/* thread id of queueing thread */
2770Sstevel@tonic-gate #endif
2780Sstevel@tonic-gate 	struct vnode *a_vp;		/* vnode pointer */
2790Sstevel@tonic-gate 	struct cred *a_cred;		/* cred pointer */
2800Sstevel@tonic-gate 	enum iotype4 a_io;		/* i/o type */
2810Sstevel@tonic-gate 	union {
2820Sstevel@tonic-gate 		struct nfs4_async_read_req a_read_args;
2830Sstevel@tonic-gate 		struct nfs4_pageio_req a_pageio_args;
2840Sstevel@tonic-gate 		struct nfs4_readdir_req a_readdir_args;
2850Sstevel@tonic-gate 		struct nfs4_commit_req a_commit_args;
2860Sstevel@tonic-gate 	} a_args;
2870Sstevel@tonic-gate };
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate #define	a_nfs4_readahead a_args.a_read_args.readahead
2900Sstevel@tonic-gate #define	a_nfs4_blkoff a_args.a_read_args.blkoff
2910Sstevel@tonic-gate #define	a_nfs4_seg a_args.a_read_args.seg
2920Sstevel@tonic-gate #define	a_nfs4_addr a_args.a_read_args.addr
2930Sstevel@tonic-gate 
2940Sstevel@tonic-gate #define	a_nfs4_putapage a_args.a_pageio_args.pageio
2950Sstevel@tonic-gate #define	a_nfs4_pageio a_args.a_pageio_args.pageio
2960Sstevel@tonic-gate #define	a_nfs4_pp a_args.a_pageio_args.pp
2970Sstevel@tonic-gate #define	a_nfs4_off a_args.a_pageio_args.io_off
2980Sstevel@tonic-gate #define	a_nfs4_len a_args.a_pageio_args.io_len
2990Sstevel@tonic-gate #define	a_nfs4_flags a_args.a_pageio_args.flags
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate #define	a_nfs4_readdir a_args.a_readdir_args.readdir
3020Sstevel@tonic-gate #define	a_nfs4_rdc a_args.a_readdir_args.rdc
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate #define	a_nfs4_commit a_args.a_commit_args.commit
3050Sstevel@tonic-gate #define	a_nfs4_plist a_args.a_commit_args.plist
3060Sstevel@tonic-gate #define	a_nfs4_offset a_args.a_commit_args.offset
3070Sstevel@tonic-gate #define	a_nfs4_count a_args.a_commit_args.count
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate /*
3100Sstevel@tonic-gate  * Security information
3110Sstevel@tonic-gate  */
3120Sstevel@tonic-gate typedef struct sv_secinfo {
3130Sstevel@tonic-gate 	uint_t		count;	/* how many sdata there are */
3140Sstevel@tonic-gate 	uint_t		index;	/* which sdata[index] */
3150Sstevel@tonic-gate 	struct sec_data	*sdata;
3160Sstevel@tonic-gate } sv_secinfo_t;
3170Sstevel@tonic-gate 
3180Sstevel@tonic-gate /*
3190Sstevel@tonic-gate  * Hash bucket for the mi's open owner list (mi_oo_list).
3200Sstevel@tonic-gate  */
3210Sstevel@tonic-gate typedef struct nfs4_oo_hash_bucket {
3220Sstevel@tonic-gate 	list_t			b_oo_hash_list;
3230Sstevel@tonic-gate 	kmutex_t		b_lock;
3240Sstevel@tonic-gate } nfs4_oo_hash_bucket_t;
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate /*
3270Sstevel@tonic-gate  * Global array of ctags.
3280Sstevel@tonic-gate  */
3290Sstevel@tonic-gate extern ctag_t nfs4_ctags[];
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate typedef enum nfs4_tag_type {
3320Sstevel@tonic-gate 	TAG_NONE,
3330Sstevel@tonic-gate 	TAG_ACCESS,
3340Sstevel@tonic-gate 	TAG_CLOSE,
3350Sstevel@tonic-gate 	TAG_CLOSE_LOST,
3360Sstevel@tonic-gate 	TAG_CLOSE_UNDO,
3370Sstevel@tonic-gate 	TAG_COMMIT,
3380Sstevel@tonic-gate 	TAG_DELEGRETURN,
3390Sstevel@tonic-gate 	TAG_FSINFO,
3400Sstevel@tonic-gate 	TAG_GET_SYMLINK,
3410Sstevel@tonic-gate 	TAG_GETATTR,
34211291SRobert.Thurlow@Sun.COM 	TAG_GETATTR_FSLOCATION,
3430Sstevel@tonic-gate 	TAG_INACTIVE,
3440Sstevel@tonic-gate 	TAG_LINK,
3450Sstevel@tonic-gate 	TAG_LOCK,
3460Sstevel@tonic-gate 	TAG_LOCK_RECLAIM,
3470Sstevel@tonic-gate 	TAG_LOCK_RESEND,
3480Sstevel@tonic-gate 	TAG_LOCK_REINSTATE,
3490Sstevel@tonic-gate 	TAG_LOCK_UNKNOWN,
3500Sstevel@tonic-gate 	TAG_LOCKT,
3510Sstevel@tonic-gate 	TAG_LOCKU,
3520Sstevel@tonic-gate 	TAG_LOCKU_RESEND,
3530Sstevel@tonic-gate 	TAG_LOCKU_REINSTATE,
3540Sstevel@tonic-gate 	TAG_LOOKUP,
3550Sstevel@tonic-gate 	TAG_LOOKUP_PARENT,
3560Sstevel@tonic-gate 	TAG_LOOKUP_VALID,
3570Sstevel@tonic-gate 	TAG_LOOKUP_VPARENT,
3580Sstevel@tonic-gate 	TAG_MKDIR,
3590Sstevel@tonic-gate 	TAG_MKNOD,
3600Sstevel@tonic-gate 	TAG_MOUNT,
3610Sstevel@tonic-gate 	TAG_OPEN,
3620Sstevel@tonic-gate 	TAG_OPEN_CONFIRM,
3630Sstevel@tonic-gate 	TAG_OPEN_CONFIRM_LOST,
3640Sstevel@tonic-gate 	TAG_OPEN_DG,
3650Sstevel@tonic-gate 	TAG_OPEN_DG_LOST,
3660Sstevel@tonic-gate 	TAG_OPEN_LOST,
3670Sstevel@tonic-gate 	TAG_OPENATTR,
3680Sstevel@tonic-gate 	TAG_PATHCONF,
3690Sstevel@tonic-gate 	TAG_PUTROOTFH,
3700Sstevel@tonic-gate 	TAG_READ,
3710Sstevel@tonic-gate 	TAG_READAHEAD,
3720Sstevel@tonic-gate 	TAG_READDIR,
3730Sstevel@tonic-gate 	TAG_READLINK,
3740Sstevel@tonic-gate 	TAG_RELOCK,
3750Sstevel@tonic-gate 	TAG_REMAP_LOOKUP,
3760Sstevel@tonic-gate 	TAG_REMAP_LOOKUP_AD,
3770Sstevel@tonic-gate 	TAG_REMAP_LOOKUP_NA,
3780Sstevel@tonic-gate 	TAG_REMAP_MOUNT,
3790Sstevel@tonic-gate 	TAG_RMDIR,
3800Sstevel@tonic-gate 	TAG_REMOVE,
3810Sstevel@tonic-gate 	TAG_RENAME,
3820Sstevel@tonic-gate 	TAG_RENAME_VFH,
3830Sstevel@tonic-gate 	TAG_RENEW,
3840Sstevel@tonic-gate 	TAG_REOPEN,
3850Sstevel@tonic-gate 	TAG_REOPEN_LOST,
3860Sstevel@tonic-gate 	TAG_SECINFO,
3870Sstevel@tonic-gate 	TAG_SETATTR,
3880Sstevel@tonic-gate 	TAG_SETCLIENTID,
3890Sstevel@tonic-gate 	TAG_SETCLIENTID_CF,
3900Sstevel@tonic-gate 	TAG_SYMLINK,
3910Sstevel@tonic-gate 	TAG_WRITE
3920Sstevel@tonic-gate } nfs4_tag_type_t;
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate #define	NFS4_TAG_INITIALIZER	{				\
3950Sstevel@tonic-gate 		{TAG_NONE,		"",			\
3960Sstevel@tonic-gate 			{0x20202020, 0x20202020, 0x20202020}},	\
3970Sstevel@tonic-gate 		{TAG_ACCESS,		"access",		\
3980Sstevel@tonic-gate 			{0x61636365, 0x73732020, 0x20202020}},	\
3990Sstevel@tonic-gate 		{TAG_CLOSE,		"close",		\
4000Sstevel@tonic-gate 			{0x636c6f73, 0x65202020, 0x20202020}},	\
4010Sstevel@tonic-gate 		{TAG_CLOSE_LOST,	"lost close",		\
4020Sstevel@tonic-gate 			{0x6c6f7374, 0x20636c6f, 0x73652020}},	\
4030Sstevel@tonic-gate 		{TAG_CLOSE_UNDO,	"undo close",		\
4040Sstevel@tonic-gate 			{0x756e646f, 0x20636c6f, 0x73652020}},	\
4050Sstevel@tonic-gate 		{TAG_COMMIT,		"commit",		\
4060Sstevel@tonic-gate 			{0x636f6d6d, 0x69742020, 0x20202020}},	\
4070Sstevel@tonic-gate 		{TAG_DELEGRETURN,	"delegreturn",		\
4080Sstevel@tonic-gate 			{0x64656c65, 0x67726574, 0x75726e20}},	\
4090Sstevel@tonic-gate 		{TAG_FSINFO,		"fsinfo",		\
4100Sstevel@tonic-gate 			{0x6673696e, 0x666f2020, 0x20202020}},	\
4110Sstevel@tonic-gate 		{TAG_GET_SYMLINK,	"get symlink text",	\
4120Sstevel@tonic-gate 			{0x67657420, 0x736c6e6b, 0x20747874}},	\
4130Sstevel@tonic-gate 		{TAG_GETATTR,		"getattr",		\
4140Sstevel@tonic-gate 			{0x67657461, 0x74747220, 0x20202020}},	\
41511291SRobert.Thurlow@Sun.COM 		{TAG_GETATTR_FSLOCATION, "getattr fslocation",	\
41611291SRobert.Thurlow@Sun.COM 			{0x67657461, 0x74747220, 0x66736c6f}},	\
4170Sstevel@tonic-gate 		{TAG_INACTIVE,		"inactive",		\
4180Sstevel@tonic-gate 			{0x696e6163, 0x74697665, 0x20202020}},	\
4190Sstevel@tonic-gate 		{TAG_LINK,		"link",			\
4200Sstevel@tonic-gate 			{0x6c696e6b, 0x20202020, 0x20202020}},	\
4210Sstevel@tonic-gate 		{TAG_LOCK,		"lock",			\
4220Sstevel@tonic-gate 			{0x6c6f636b, 0x20202020, 0x20202020}},	\
4230Sstevel@tonic-gate 		{TAG_LOCK_RECLAIM,	"reclaim lock",		\
4240Sstevel@tonic-gate 			{0x7265636c, 0x61696d20, 0x6c6f636b}},	\
4250Sstevel@tonic-gate 		{TAG_LOCK_RESEND,	"resend lock",		\
4260Sstevel@tonic-gate 			{0x72657365, 0x6e64206c, 0x6f636b20}},	\
4270Sstevel@tonic-gate 		{TAG_LOCK_REINSTATE,	"reinstate lock",	\
4280Sstevel@tonic-gate 			{0x7265696e, 0x7374206c, 0x6f636b20}},	\
4290Sstevel@tonic-gate 		{TAG_LOCK_UNKNOWN,	"unknown lock",		\
4300Sstevel@tonic-gate 			{0x756e6b6e, 0x6f776e20, 0x6c6f636b}},	\
4310Sstevel@tonic-gate 		{TAG_LOCKT,		"lock test",		\
4320Sstevel@tonic-gate 			{0x6c6f636b, 0x5f746573, 0x74202020}},	\
4330Sstevel@tonic-gate 		{TAG_LOCKU,		"unlock",		\
4340Sstevel@tonic-gate 			{0x756e6c6f, 0x636b2020, 0x20202020}},	\
4350Sstevel@tonic-gate 		{TAG_LOCKU_RESEND,	"resend locku",		\
4360Sstevel@tonic-gate 			{0x72657365, 0x6e64206c, 0x6f636b75}},	\
4370Sstevel@tonic-gate 		{TAG_LOCKU_REINSTATE,	"reinstate unlock",	\
4380Sstevel@tonic-gate 			{0x7265696e, 0x73742075, 0x6e6c636b}},	\
4390Sstevel@tonic-gate 		{TAG_LOOKUP,		"lookup",		\
4400Sstevel@tonic-gate 			{0x6c6f6f6b, 0x75702020, 0x20202020}},	\
4410Sstevel@tonic-gate 		{TAG_LOOKUP_PARENT,	"lookup parent",	\
4420Sstevel@tonic-gate 			{0x6c6f6f6b, 0x75702070, 0x6172656e}},	\
4430Sstevel@tonic-gate 		{TAG_LOOKUP_VALID,	"lookup valid",		\
4440Sstevel@tonic-gate 			{0x6c6f6f6b, 0x75702076, 0x616c6964}},	\
4450Sstevel@tonic-gate 		{TAG_LOOKUP_VPARENT,	"lookup valid parent",	\
4460Sstevel@tonic-gate 			{0x6c6f6f6b, 0x766c6420, 0x7061726e}},	\
4470Sstevel@tonic-gate 		{TAG_MKDIR,		"mkdir",		\
4480Sstevel@tonic-gate 			{0x6d6b6469, 0x72202020, 0x20202020}},	\
4490Sstevel@tonic-gate 		{TAG_MKNOD,		"mknod",		\
4500Sstevel@tonic-gate 			{0x6d6b6e6f, 0x64202020, 0x20202020}},	\
4510Sstevel@tonic-gate 		{TAG_MOUNT,		"mount",		\
4520Sstevel@tonic-gate 			{0x6d6f756e, 0x74202020, 0x20202020}},	\
4530Sstevel@tonic-gate 		{TAG_OPEN,		"open",			\
4540Sstevel@tonic-gate 			{0x6f70656e, 0x20202020, 0x20202020}},	\
4550Sstevel@tonic-gate 		{TAG_OPEN_CONFIRM,	"open confirm",		\
4560Sstevel@tonic-gate 			{0x6f70656e, 0x5f636f6e, 0x6669726d}},	\
4570Sstevel@tonic-gate 		{TAG_OPEN_CONFIRM_LOST,	"lost open confirm",	\
4580Sstevel@tonic-gate 			{0x6c6f7374, 0x206f7065, 0x6e5f636f}},	\
4590Sstevel@tonic-gate 		{TAG_OPEN_DG,		"open downgrade",	\
4600Sstevel@tonic-gate 			{0x6f70656e, 0x20646772, 0x61646520}},	\
4610Sstevel@tonic-gate 		{TAG_OPEN_DG_LOST,	"lost open downgrade",	\
4620Sstevel@tonic-gate 			{0x6c737420, 0x6f70656e, 0x20646772}},	\
4630Sstevel@tonic-gate 		{TAG_OPEN_LOST,		"lost open",		\
4640Sstevel@tonic-gate 			{0x6c6f7374, 0x206f7065, 0x6e202020}},	\
4650Sstevel@tonic-gate 		{TAG_OPENATTR,		"openattr",		\
4660Sstevel@tonic-gate 			{0x6f70656e, 0x61747472, 0x20202020}},	\
4670Sstevel@tonic-gate 		{TAG_PATHCONF,		"pathhconf",		\
4680Sstevel@tonic-gate 			{0x70617468, 0x636f6e66, 0x20202020}},	\
4690Sstevel@tonic-gate 		{TAG_PUTROOTFH,		"putrootfh",		\
4700Sstevel@tonic-gate 			{0x70757472, 0x6f6f7466, 0x68202020}},	\
4710Sstevel@tonic-gate 		{TAG_READ,		"read",			\
4720Sstevel@tonic-gate 			{0x72656164, 0x20202020, 0x20202020}},	\
4730Sstevel@tonic-gate 		{TAG_READAHEAD,		"readahead",		\
4740Sstevel@tonic-gate 			{0x72656164, 0x61686561, 0x64202020}},	\
4750Sstevel@tonic-gate 		{TAG_READDIR,		"readdir",		\
4760Sstevel@tonic-gate 			{0x72656164, 0x64697220, 0x20202020}},	\
4770Sstevel@tonic-gate 		{TAG_READLINK,		"readlink",		\
4780Sstevel@tonic-gate 			{0x72656164, 0x6c696e6b, 0x20202020}},	\
4790Sstevel@tonic-gate 		{TAG_RELOCK,		"relock",		\
4800Sstevel@tonic-gate 			{0x72656c6f, 0x636b2020, 0x20202020}},	\
4810Sstevel@tonic-gate 		{TAG_REMAP_LOOKUP,	"remap lookup",		\
4820Sstevel@tonic-gate 			{0x72656d61, 0x70206c6f, 0x6f6b7570}},	\
4830Sstevel@tonic-gate 		{TAG_REMAP_LOOKUP_AD,	"remap lookup attr dir",	\
4840Sstevel@tonic-gate 			{0x72656d70, 0x206c6b75, 0x70206164}},	\
4850Sstevel@tonic-gate 		{TAG_REMAP_LOOKUP_NA,	"remap lookup named attrs",	\
4860Sstevel@tonic-gate 			{0x72656d70, 0x206c6b75, 0x70206e61}},	\
4870Sstevel@tonic-gate 		{TAG_REMAP_MOUNT,	"remap mount",		\
4880Sstevel@tonic-gate 			{0x72656d61, 0x70206d6f, 0x756e7420}},	\
4890Sstevel@tonic-gate 		{TAG_RMDIR,		"rmdir",		\
4900Sstevel@tonic-gate 			{0x726d6469, 0x72202020, 0x20202020}},	\
4910Sstevel@tonic-gate 		{TAG_REMOVE,		"remove",		\
4920Sstevel@tonic-gate 			{0x72656d6f, 0x76652020, 0x20202020}},	\
4930Sstevel@tonic-gate 		{TAG_RENAME,		"rename",		\
4940Sstevel@tonic-gate 			{0x72656e61, 0x6d652020, 0x20202020}},	\
4950Sstevel@tonic-gate 		{TAG_RENAME_VFH,	"rename volatile fh",	\
4960Sstevel@tonic-gate 			{0x72656e61, 0x6d652028, 0x76666829}},	\
4970Sstevel@tonic-gate 		{TAG_RENEW,		"renew",		\
4980Sstevel@tonic-gate 			{0x72656e65, 0x77202020, 0x20202020}},	\
4990Sstevel@tonic-gate 		{TAG_REOPEN,		"reopen",		\
5000Sstevel@tonic-gate 			{0x72656f70, 0x656e2020, 0x20202020}},	\
5010Sstevel@tonic-gate 		{TAG_REOPEN_LOST,	"lost reopen",		\
5020Sstevel@tonic-gate 			{0x6c6f7374, 0x2072656f, 0x70656e20}},	\
5030Sstevel@tonic-gate 		{TAG_SECINFO,		"secinfo",		\
5040Sstevel@tonic-gate 			{0x73656369, 0x6e666f20, 0x20202020}},	\
5050Sstevel@tonic-gate 		{TAG_SETATTR,		"setattr",		\
5060Sstevel@tonic-gate 			{0x73657461, 0x74747220, 0x20202020}},	\
5070Sstevel@tonic-gate 		{TAG_SETCLIENTID,	"setclientid",		\
5080Sstevel@tonic-gate 			{0x73657463, 0x6c69656e, 0x74696420}},	\
5090Sstevel@tonic-gate 		{TAG_SETCLIENTID_CF,	"setclientid_confirm",	\
5100Sstevel@tonic-gate 			{0x73636c6e, 0x7469645f, 0x636f6e66}},	\
5110Sstevel@tonic-gate 		{TAG_SYMLINK,		"symlink",		\
5120Sstevel@tonic-gate 			{0x73796d6c, 0x696e6b20, 0x20202020}},	\
5130Sstevel@tonic-gate 		{TAG_WRITE,		"write",		\
5140Sstevel@tonic-gate 			{0x77726974, 0x65202020, 0x20202020}}	\
5150Sstevel@tonic-gate 	}
5160Sstevel@tonic-gate 
5170Sstevel@tonic-gate /*
5180Sstevel@tonic-gate  * These flags are for differentiating the search criterian for
5190Sstevel@tonic-gate  * find_open_owner().  The comparison is done with the open_owners's
5200Sstevel@tonic-gate  * 'oo_just_created' flag.
5210Sstevel@tonic-gate  */
5220Sstevel@tonic-gate #define	NFS4_PERM_CREATED	0x0
5230Sstevel@tonic-gate #define	NFS4_JUST_CREATED	0x1
5240Sstevel@tonic-gate 
5250Sstevel@tonic-gate /*
5260Sstevel@tonic-gate  * Hashed by the cr_uid and cr_ruid of credential 'oo_cred'. 'oo_cred_otw'
5270Sstevel@tonic-gate  * is stored upon a successful OPEN.  This is needed when the user's effective
5280Sstevel@tonic-gate  * and real uid's don't match.  The 'oo_cred_otw' overrides the credential
5290Sstevel@tonic-gate  * passed down by VFS for async read/write, commit, lock, and close operations.
5300Sstevel@tonic-gate  *
5310Sstevel@tonic-gate  * The oo_ref_count keeps track the number of active references on this
5320Sstevel@tonic-gate  * data structure + number of nfs4_open_streams point to this structure.
5330Sstevel@tonic-gate  *
5340Sstevel@tonic-gate  * 'oo_valid' tells whether this stuct is about to be freed or not.
5350Sstevel@tonic-gate  *
5360Sstevel@tonic-gate  * 'oo_just_created' tells us whether this struct has just been created but
5370Sstevel@tonic-gate  * not been fully finalized (that is created upon an OPEN request and
5380Sstevel@tonic-gate  * finalized upon the OPEN success).
5390Sstevel@tonic-gate  *
5400Sstevel@tonic-gate  * The 'oo_seqid_inuse' is for the open seqid synchronization.  If a thread
5410Sstevel@tonic-gate  * is currently using the open owner and it's open_seqid, then it sets the
5420Sstevel@tonic-gate  * oo_seqid_inuse to true if it currently is not set.  If it is set then it
5430Sstevel@tonic-gate  * does a cv_wait on the oo_cv_seqid_sync condition variable.  When the thread
5440Sstevel@tonic-gate  * is done it unsets the oo_seqid_inuse and does a cv_signal to wake a process
5450Sstevel@tonic-gate  * waiting on the condition variable.
5460Sstevel@tonic-gate  *
5470Sstevel@tonic-gate  * 'oo_last_good_seqid' is the last valid seqid this open owner sent OTW,
5480Sstevel@tonic-gate  * and 'oo_last_good_op' is the operation that issued the last valid seqid.
5490Sstevel@tonic-gate  *
5500Sstevel@tonic-gate  * Lock ordering:
5510Sstevel@tonic-gate  *	mntinfo4_t::mi_lock > oo_lock (for searching mi_oo_list)
5520Sstevel@tonic-gate  *
5530Sstevel@tonic-gate  *	oo_seqid_inuse > mntinfo4_t::mi_lock
5540Sstevel@tonic-gate  *	oo_seqid_inuse > rnode4_t::r_statelock
5550Sstevel@tonic-gate  *	oo_seqid_inuse > rnode4_t::r_statev4_lock
5560Sstevel@tonic-gate  *	oo_seqid_inuse > nfs4_open_stream_t::os_sync_lock
5570Sstevel@tonic-gate  *
5580Sstevel@tonic-gate  * The 'oo_seqid_inuse'/'oo_cv_seqid_sync' protects:
5590Sstevel@tonic-gate  *	oo_last_good_op
5600Sstevel@tonic-gate  *	oo_last_good_seqid
5610Sstevel@tonic-gate  *	oo_name
5620Sstevel@tonic-gate  *	oo_seqid
5630Sstevel@tonic-gate  *
5640Sstevel@tonic-gate  * The 'oo_lock' protects:
5650Sstevel@tonic-gate  *	oo_cred
5660Sstevel@tonic-gate  *	oo_cred_otw
5670Sstevel@tonic-gate  *	oo_foo_node
5680Sstevel@tonic-gate  *	oo_hash_node
5690Sstevel@tonic-gate  *	oo_just_created
5700Sstevel@tonic-gate  *	oo_ref_count
5710Sstevel@tonic-gate  *	oo_valid
5720Sstevel@tonic-gate  */
5730Sstevel@tonic-gate 
5740Sstevel@tonic-gate typedef struct nfs4_open_owner {
5750Sstevel@tonic-gate 	cred_t			*oo_cred;
5760Sstevel@tonic-gate 	int			oo_ref_count;
5770Sstevel@tonic-gate 	int			oo_valid;
5780Sstevel@tonic-gate 	int			oo_just_created;
5790Sstevel@tonic-gate 	seqid4			oo_seqid;
5800Sstevel@tonic-gate 	seqid4			oo_last_good_seqid;
5810Sstevel@tonic-gate 	nfs4_tag_type_t		oo_last_good_op;
5820Sstevel@tonic-gate 	unsigned		oo_seqid_inuse:1;
5830Sstevel@tonic-gate 	cred_t			*oo_cred_otw;
5840Sstevel@tonic-gate 	kcondvar_t		oo_cv_seqid_sync;
5850Sstevel@tonic-gate 	/*
5860Sstevel@tonic-gate 	 * Fix this to always be 8 bytes
5870Sstevel@tonic-gate 	 */
5880Sstevel@tonic-gate 	uint64_t		oo_name;
5890Sstevel@tonic-gate 	list_node_t		oo_hash_node;
5900Sstevel@tonic-gate 	list_node_t		oo_foo_node;
5910Sstevel@tonic-gate 	kmutex_t		oo_lock;
5920Sstevel@tonic-gate } nfs4_open_owner_t;
5930Sstevel@tonic-gate 
5940Sstevel@tonic-gate /*
5950Sstevel@tonic-gate  * Static server information.
59611291SRobert.Thurlow@Sun.COM  * These fields are read-only once they are initialized; sv_lock
59711291SRobert.Thurlow@Sun.COM  * should be held as writer if they are changed during mount:
5980Sstevel@tonic-gate  *	sv_addr
5990Sstevel@tonic-gate  *	sv_dhsec
6000Sstevel@tonic-gate  *	sv_hostname
6010Sstevel@tonic-gate  *	sv_hostnamelen
6020Sstevel@tonic-gate  *	sv_knconf
6030Sstevel@tonic-gate  *	sv_next
6040Sstevel@tonic-gate  *	sv_origknconf
6050Sstevel@tonic-gate  *
6060Sstevel@tonic-gate  * These fields are protected by sv_lock:
6070Sstevel@tonic-gate  *	sv_currsec
6080Sstevel@tonic-gate  *	sv_fhandle
6090Sstevel@tonic-gate  *	sv_flags
6100Sstevel@tonic-gate  *	sv_fsid
6110Sstevel@tonic-gate  *	sv_path
6120Sstevel@tonic-gate  *	sv_pathlen
6130Sstevel@tonic-gate  *	sv_pfhandle
6140Sstevel@tonic-gate  *	sv_save_secinfo
6150Sstevel@tonic-gate  *	sv_savesec
6160Sstevel@tonic-gate  *	sv_secdata
6170Sstevel@tonic-gate  *	sv_secinfo
6180Sstevel@tonic-gate  *	sv_supp_attrs
6190Sstevel@tonic-gate  *
6200Sstevel@tonic-gate  * Lock ordering:
6210Sstevel@tonic-gate  * nfs_rtable4_lock > sv_lock
6220Sstevel@tonic-gate  * rnode4_t::r_statelock > sv_lock
6230Sstevel@tonic-gate  */
6240Sstevel@tonic-gate typedef struct servinfo4 {
6250Sstevel@tonic-gate 	struct knetconfig *sv_knconf;   /* bound TLI fd */
6260Sstevel@tonic-gate 	struct knetconfig *sv_origknconf;	/* For RDMA save orig knconf */
6270Sstevel@tonic-gate 	struct netbuf	   sv_addr;	/* server's address */
6280Sstevel@tonic-gate 	nfs4_fhandle_t	   sv_fhandle;	/* this server's filehandle */
6290Sstevel@tonic-gate 	nfs4_fhandle_t	   sv_pfhandle; /* parent dir filehandle */
6300Sstevel@tonic-gate 	int		   sv_pathlen;	/* Length of server path */
6310Sstevel@tonic-gate 	char		  *sv_path;	/* Path name on server */
6320Sstevel@tonic-gate 	uint32_t	   sv_flags;	/* flags for this server */
6330Sstevel@tonic-gate 	sec_data_t	  *sv_secdata;	/* client initiated security data */
6340Sstevel@tonic-gate 	sv_secinfo_t	  *sv_secinfo;	/* server security information */
6350Sstevel@tonic-gate 	sec_data_t	  *sv_currsec;	/* security data currently used; */
6360Sstevel@tonic-gate 					/* points to one of the sec_data */
6370Sstevel@tonic-gate 					/* entries in sv_secinfo */
6380Sstevel@tonic-gate 	sv_secinfo_t	  *sv_save_secinfo; /* saved secinfo */
6390Sstevel@tonic-gate 	sec_data_t	  *sv_savesec;	/* saved security data */
6400Sstevel@tonic-gate 	sec_data_t	  *sv_dhsec;    /* AUTH_DH data from the user land */
6410Sstevel@tonic-gate 	char		  *sv_hostname;	/* server's hostname */
6420Sstevel@tonic-gate 	int		   sv_hostnamelen;  /* server's hostname length */
6430Sstevel@tonic-gate 	fattr4_fsid		sv_fsid;    /* fsid of shared obj	*/
6440Sstevel@tonic-gate 	fattr4_supported_attrs	sv_supp_attrs;
6450Sstevel@tonic-gate 	struct servinfo4  *sv_next;	/* next in list */
6460Sstevel@tonic-gate 	nfs_rwlock_t	   sv_lock;
6470Sstevel@tonic-gate } servinfo4_t;
6480Sstevel@tonic-gate 
6490Sstevel@tonic-gate /* sv_flags fields */
6500Sstevel@tonic-gate #define	SV4_TRYSECINFO		0x001	/* try secinfo data from the server */
6510Sstevel@tonic-gate #define	SV4_TRYSECDEFAULT	0x002	/* try a default flavor */
6520Sstevel@tonic-gate #define	SV4_NOTINUSE		0x004	/* servinfo4_t had fatal errors */
6530Sstevel@tonic-gate #define	SV4_ROOT_STALE		0x008	/* root vnode got ESTALE */
6540Sstevel@tonic-gate 
6550Sstevel@tonic-gate /*
6560Sstevel@tonic-gate  * Lock call types.  See nfs4frlock().
6570Sstevel@tonic-gate  */
6580Sstevel@tonic-gate typedef enum nfs4_lock_call_type {
6590Sstevel@tonic-gate 	NFS4_LCK_CTYPE_NORM,
6600Sstevel@tonic-gate 	NFS4_LCK_CTYPE_RECLAIM,
6610Sstevel@tonic-gate 	NFS4_LCK_CTYPE_RESEND,
6620Sstevel@tonic-gate 	NFS4_LCK_CTYPE_REINSTATE
6630Sstevel@tonic-gate } nfs4_lock_call_type_t;
6640Sstevel@tonic-gate 
6650Sstevel@tonic-gate /*
6660Sstevel@tonic-gate  * This structure holds the information for a lost open/close/open downgrade/
6670Sstevel@tonic-gate  * lock/locku request.  It is also used for requests that are queued up so
6680Sstevel@tonic-gate  * that the recovery thread can release server state after a forced
6690Sstevel@tonic-gate  * unmount.
6700Sstevel@tonic-gate  * "lr_op" is 0 if the struct is uninitialized.  Otherwise, it is set to
6710Sstevel@tonic-gate  * the proper OP_* nfs_opnum4 number.  The other fields contain information
6720Sstevel@tonic-gate  * to reconstruct the call.
6730Sstevel@tonic-gate  *
6740Sstevel@tonic-gate  * lr_dvp is used for OPENs with CREATE, so that we can do a PUTFH of the
6750Sstevel@tonic-gate  * parent directroy without relying on vtodv (since we may not have a vp
6760Sstevel@tonic-gate  * for the file we wish to create).
6770Sstevel@tonic-gate  *
6780Sstevel@tonic-gate  * lr_putfirst means that the request should go to the front of the resend
6790Sstevel@tonic-gate  * queue, rather than the end.
6800Sstevel@tonic-gate  */
6810Sstevel@tonic-gate typedef struct nfs4_lost_rqst {
6820Sstevel@tonic-gate 	list_node_t			lr_node;
6830Sstevel@tonic-gate 	nfs_opnum4			lr_op;
6840Sstevel@tonic-gate 	vnode_t				*lr_vp;
6850Sstevel@tonic-gate 	vnode_t				*lr_dvp;
6860Sstevel@tonic-gate 	nfs4_open_owner_t		*lr_oop;
6870Sstevel@tonic-gate 	struct nfs4_open_stream		*lr_osp;
6880Sstevel@tonic-gate 	struct nfs4_lock_owner		*lr_lop;
6890Sstevel@tonic-gate 	cred_t				*lr_cr;
6900Sstevel@tonic-gate 	flock64_t			*lr_flk;
6910Sstevel@tonic-gate 	bool_t				lr_putfirst;
6920Sstevel@tonic-gate 	union {
6930Sstevel@tonic-gate 		struct {
6940Sstevel@tonic-gate 			nfs4_lock_call_type_t lru_ctype;
6950Sstevel@tonic-gate 			nfs_lock_type4	lru_locktype;
6960Sstevel@tonic-gate 		} lru_lockargs;		/* LOCK, LOCKU */
6970Sstevel@tonic-gate 		struct {
6980Sstevel@tonic-gate 			uint32_t		lru_oaccess;
6990Sstevel@tonic-gate 			uint32_t		lru_odeny;
7000Sstevel@tonic-gate 			enum open_claim_type4	lru_oclaim;
7010Sstevel@tonic-gate 			stateid4		lru_ostateid; /* reopen only */
7020Sstevel@tonic-gate 			component4		lru_ofile;
7030Sstevel@tonic-gate 		} lru_open_args;
7040Sstevel@tonic-gate 		struct {
7050Sstevel@tonic-gate 			uint32_t	lru_dg_access;
7060Sstevel@tonic-gate 			uint32_t	lru_dg_deny;
7070Sstevel@tonic-gate 		} lru_open_dg_args;
7080Sstevel@tonic-gate 	} nfs4_lr_u;
7090Sstevel@tonic-gate } nfs4_lost_rqst_t;
7100Sstevel@tonic-gate 
7110Sstevel@tonic-gate #define	lr_oacc		nfs4_lr_u.lru_open_args.lru_oaccess
7120Sstevel@tonic-gate #define	lr_odeny	nfs4_lr_u.lru_open_args.lru_odeny
7130Sstevel@tonic-gate #define	lr_oclaim	nfs4_lr_u.lru_open_args.lru_oclaim
7140Sstevel@tonic-gate #define	lr_ostateid	nfs4_lr_u.lru_open_args.lru_ostateid
7150Sstevel@tonic-gate #define	lr_ofile	nfs4_lr_u.lru_open_args.lru_ofile
7160Sstevel@tonic-gate #define	lr_dg_acc	nfs4_lr_u.lru_open_dg_args.lru_dg_access
7170Sstevel@tonic-gate #define	lr_dg_deny	nfs4_lr_u.lru_open_dg_args.lru_dg_deny
7180Sstevel@tonic-gate #define	lr_ctype	nfs4_lr_u.lru_lockargs.lru_ctype
7190Sstevel@tonic-gate #define	lr_locktype	nfs4_lr_u.lru_lockargs.lru_locktype
7200Sstevel@tonic-gate 
7210Sstevel@tonic-gate /*
7220Sstevel@tonic-gate  * Recovery actions.  Some actions can imply further recovery using a
7230Sstevel@tonic-gate  * different recovery action (e.g., recovering the clientid leads to
7240Sstevel@tonic-gate  * recovering open files and locks).
7250Sstevel@tonic-gate  */
7260Sstevel@tonic-gate 
7270Sstevel@tonic-gate typedef enum {
7280Sstevel@tonic-gate 	NR_UNUSED,
7290Sstevel@tonic-gate 	NR_CLIENTID,
7300Sstevel@tonic-gate 	NR_OPENFILES,
7310Sstevel@tonic-gate 	NR_FHEXPIRED,
7320Sstevel@tonic-gate 	NR_FAILOVER,
7330Sstevel@tonic-gate 	NR_WRONGSEC,
7340Sstevel@tonic-gate 	NR_EXPIRED,
7350Sstevel@tonic-gate 	NR_BAD_STATEID,
7360Sstevel@tonic-gate 	NR_BADHANDLE,
7370Sstevel@tonic-gate 	NR_BAD_SEQID,
7380Sstevel@tonic-gate 	NR_OLDSTATEID,
7390Sstevel@tonic-gate 	NR_GRACE,
7400Sstevel@tonic-gate 	NR_DELAY,
7410Sstevel@tonic-gate 	NR_LOST_LOCK,
7420Sstevel@tonic-gate 	NR_LOST_STATE_RQST,
74311291SRobert.Thurlow@Sun.COM 	NR_STALE,
74411291SRobert.Thurlow@Sun.COM 	NR_MOVED
7450Sstevel@tonic-gate } nfs4_recov_t;
7460Sstevel@tonic-gate 
7470Sstevel@tonic-gate /*
7480Sstevel@tonic-gate  * Administrative and debug message framework.
7490Sstevel@tonic-gate  */
7500Sstevel@tonic-gate 
7510Sstevel@tonic-gate #define	NFS4_MSG_MAX	100
7520Sstevel@tonic-gate extern int nfs4_msg_max;
7530Sstevel@tonic-gate 
75411291SRobert.Thurlow@Sun.COM #define	NFS4_REFERRAL_LOOP_MAX	20
75511291SRobert.Thurlow@Sun.COM 
7560Sstevel@tonic-gate typedef enum {
7570Sstevel@tonic-gate 	RE_BAD_SEQID,
7580Sstevel@tonic-gate 	RE_BADHANDLE,
7590Sstevel@tonic-gate 	RE_CLIENTID,
7600Sstevel@tonic-gate 	RE_DEAD_FILE,
7610Sstevel@tonic-gate 	RE_END,
7620Sstevel@tonic-gate 	RE_FAIL_RELOCK,
7630Sstevel@tonic-gate 	RE_FAIL_REMAP_LEN,
7640Sstevel@tonic-gate 	RE_FAIL_REMAP_OP,
7650Sstevel@tonic-gate 	RE_FAILOVER,
7660Sstevel@tonic-gate 	RE_FILE_DIFF,
7670Sstevel@tonic-gate 	RE_LOST_STATE,
7680Sstevel@tonic-gate 	RE_OPENS_CHANGED,
7690Sstevel@tonic-gate 	RE_SIGLOST,
7700Sstevel@tonic-gate 	RE_SIGLOST_NO_DUMP,
7710Sstevel@tonic-gate 	RE_START,
7720Sstevel@tonic-gate 	RE_UNEXPECTED_ACTION,
7730Sstevel@tonic-gate 	RE_UNEXPECTED_ERRNO,
7740Sstevel@tonic-gate 	RE_UNEXPECTED_STATUS,
7750Sstevel@tonic-gate 	RE_WRONGSEC,
77611291SRobert.Thurlow@Sun.COM 	RE_LOST_STATE_BAD_OP,
77711291SRobert.Thurlow@Sun.COM 	RE_REFERRAL
7780Sstevel@tonic-gate } nfs4_event_type_t;
7790Sstevel@tonic-gate 
7800Sstevel@tonic-gate typedef enum {
7810Sstevel@tonic-gate 	RFS_NO_INSPECT,
7820Sstevel@tonic-gate 	RFS_INSPECT
7830Sstevel@tonic-gate } nfs4_fact_status_t;
7840Sstevel@tonic-gate 
7850Sstevel@tonic-gate typedef enum {
7860Sstevel@tonic-gate 	RF_BADOWNER,
7870Sstevel@tonic-gate 	RF_ERR,
7880Sstevel@tonic-gate 	RF_RENEW_EXPIRED,
7890Sstevel@tonic-gate 	RF_SRV_NOT_RESPOND,
7900Sstevel@tonic-gate 	RF_SRV_OK,
7910Sstevel@tonic-gate 	RF_SRVS_NOT_RESPOND,
7920Sstevel@tonic-gate 	RF_SRVS_OK,
7939675Sdai.ngo@sun.com 	RF_DELMAP_CB_ERR,
7949675Sdai.ngo@sun.com 	RF_SENDQ_FULL
7950Sstevel@tonic-gate } nfs4_fact_type_t;
7960Sstevel@tonic-gate 
7970Sstevel@tonic-gate typedef enum {
7980Sstevel@tonic-gate 	NFS4_MS_DUMP,
7990Sstevel@tonic-gate 	NFS4_MS_NO_DUMP
8000Sstevel@tonic-gate } nfs4_msg_status_t;
8010Sstevel@tonic-gate 
8020Sstevel@tonic-gate typedef struct nfs4_rfact {
8030Sstevel@tonic-gate 	nfs4_fact_type_t	rf_type;
8040Sstevel@tonic-gate 	nfs4_fact_status_t	rf_status;
8050Sstevel@tonic-gate 	bool_t			rf_reboot;
8060Sstevel@tonic-gate 	nfs4_recov_t		rf_action;
8070Sstevel@tonic-gate 	nfs_opnum4		rf_op;
8080Sstevel@tonic-gate 	nfsstat4		rf_stat4;
8090Sstevel@tonic-gate 	timespec_t		rf_time;
8100Sstevel@tonic-gate 	int			rf_error;
8110Sstevel@tonic-gate 	struct rnode4		*rf_rp1;
8120Sstevel@tonic-gate 	char			*rf_char1;
8130Sstevel@tonic-gate } nfs4_rfact_t;
8140Sstevel@tonic-gate 
8150Sstevel@tonic-gate typedef struct nfs4_revent {
8160Sstevel@tonic-gate 	nfs4_event_type_t	re_type;
8170Sstevel@tonic-gate 	nfsstat4		re_stat4;
8180Sstevel@tonic-gate 	uint_t			re_uint;
8190Sstevel@tonic-gate 	pid_t			re_pid;
8200Sstevel@tonic-gate 	struct mntinfo4		*re_mi;
8210Sstevel@tonic-gate 	struct rnode4		*re_rp1;
8220Sstevel@tonic-gate 	struct rnode4		*re_rp2;
8230Sstevel@tonic-gate 	char			*re_char1;
8240Sstevel@tonic-gate 	char			*re_char2;
8250Sstevel@tonic-gate 	nfs4_tag_type_t		re_tag1;
8260Sstevel@tonic-gate 	nfs4_tag_type_t		re_tag2;
8270Sstevel@tonic-gate 	seqid4			re_seqid1;
8280Sstevel@tonic-gate 	seqid4			re_seqid2;
8290Sstevel@tonic-gate } nfs4_revent_t;
8300Sstevel@tonic-gate 
8310Sstevel@tonic-gate typedef enum {
8320Sstevel@tonic-gate 	RM_EVENT,
8330Sstevel@tonic-gate 	RM_FACT
8340Sstevel@tonic-gate } nfs4_msg_type_t;
8350Sstevel@tonic-gate 
8360Sstevel@tonic-gate typedef struct nfs4_debug_msg {
8370Sstevel@tonic-gate 	timespec_t		msg_time;
8380Sstevel@tonic-gate 	nfs4_msg_type_t		msg_type;
8390Sstevel@tonic-gate 	char			*msg_srv;
8400Sstevel@tonic-gate 	char			*msg_mntpt;
8410Sstevel@tonic-gate 	union {
8420Sstevel@tonic-gate 		nfs4_rfact_t	msg_fact;
8430Sstevel@tonic-gate 		nfs4_revent_t	msg_event;
8440Sstevel@tonic-gate 	} rmsg_u;
8450Sstevel@tonic-gate 	nfs4_msg_status_t	msg_status;
8460Sstevel@tonic-gate 	list_node_t		msg_node;
8470Sstevel@tonic-gate } nfs4_debug_msg_t;
8480Sstevel@tonic-gate 
8490Sstevel@tonic-gate /*
8500Sstevel@tonic-gate  * NFS private data per mounted file system
8510Sstevel@tonic-gate  *	The mi_lock mutex protects the following fields:
8520Sstevel@tonic-gate  *		mi_flags
8530Sstevel@tonic-gate  *		mi_in_recovery
8540Sstevel@tonic-gate  *		mi_recovflags
8550Sstevel@tonic-gate  *		mi_recovthread
8560Sstevel@tonic-gate  *		mi_error
8570Sstevel@tonic-gate  *		mi_printed
8580Sstevel@tonic-gate  *		mi_down
8590Sstevel@tonic-gate  *		mi_stsize
8600Sstevel@tonic-gate  *		mi_curread
8610Sstevel@tonic-gate  *		mi_curwrite
8620Sstevel@tonic-gate  *		mi_timers
8630Sstevel@tonic-gate  *		mi_curr_serv
8640Sstevel@tonic-gate  *		mi_klmconfig
8650Sstevel@tonic-gate  *		mi_oo_list
8660Sstevel@tonic-gate  *		mi_foo_list
8670Sstevel@tonic-gate  *		mi_foo_num
8680Sstevel@tonic-gate  *		mi_foo_max
8690Sstevel@tonic-gate  *		mi_lost_state
8700Sstevel@tonic-gate  *		mi_bseqid_list
8715302Sth199096  *		mi_ephemeral
8725302Sth199096  *		mi_ephemeral_tree
8730Sstevel@tonic-gate  *
8740Sstevel@tonic-gate  *	Normally the netconfig information for the mount comes from
8750Sstevel@tonic-gate  *	mi_curr_serv and mi_klmconfig is NULL.  If NLM calls need to use a
8760Sstevel@tonic-gate  *	different transport, mi_klmconfig contains the necessary netconfig
8770Sstevel@tonic-gate  *	information.
8780Sstevel@tonic-gate  *
8790Sstevel@tonic-gate  *	The mi_async_lock mutex protects the following fields:
8800Sstevel@tonic-gate  *		mi_async_reqs
8810Sstevel@tonic-gate  *		mi_async_req_count
8829858SPavel.Filipensky@Sun.COM  *		mi_async_tail
88311507SVallish.Vaidyeshwara@Sun.COM  *		mi_async_curr[NFS4_MAX_ASYNC_QUEUES]
8840Sstevel@tonic-gate  *		mi_async_clusters
8850Sstevel@tonic-gate  *		mi_async_init_clusters
88611507SVallish.Vaidyeshwara@Sun.COM  *		mi_threads[NFS4_MAX_ASYNC_QUEUES]
8870Sstevel@tonic-gate  *		mi_inactive_thread
8880Sstevel@tonic-gate  *		mi_manager_thread
8890Sstevel@tonic-gate  *
8900Sstevel@tonic-gate  *	The nfs4_server_t::s_lock protects the following fields:
8910Sstevel@tonic-gate  *		mi_clientid
8920Sstevel@tonic-gate  *		mi_clientid_next
8930Sstevel@tonic-gate  *		mi_clientid_prev
8940Sstevel@tonic-gate  *		mi_open_files
8950Sstevel@tonic-gate  *
896163Sek110237  *	The mntinfo4_t::mi_recovlock protects the following fields:
897163Sek110237  *		mi_srvsettime
8989858SPavel.Filipensky@Sun.COM  *		mi_srvset_cnt
8999858SPavel.Filipensky@Sun.COM  *		mi_srv
9009858SPavel.Filipensky@Sun.COM  *
9019858SPavel.Filipensky@Sun.COM  * Changing mi_srv from one nfs4_server_t to a different one requires
9029858SPavel.Filipensky@Sun.COM  * holding the mi_recovlock as RW_WRITER.
9039858SPavel.Filipensky@Sun.COM  * Exception: setting mi_srv the first time in mount/mountroot is done
9049858SPavel.Filipensky@Sun.COM  * holding the mi_recovlock as RW_READER.
905163Sek110237  *
9060Sstevel@tonic-gate  *	Locking order:
9070Sstevel@tonic-gate  *	  mi4_globals::mig_lock > mi_async_lock
9080Sstevel@tonic-gate  *	  mi_async_lock > nfs4_server_t::s_lock > mi_lock
9090Sstevel@tonic-gate  *	  mi_recovlock > mi_rename_lock > nfs_rtable4_lock
9100Sstevel@tonic-gate  *	  nfs4_server_t::s_recovlock > mi_recovlock
9110Sstevel@tonic-gate  *	  rnode4_t::r_rwlock > mi_rename_lock
9120Sstevel@tonic-gate  *	  nfs_rtable4_lock > mi_lock
9130Sstevel@tonic-gate  *	  nfs4_server_t::s_lock > mi_msg_list_lock
914163Sek110237  *	  mi_recovlock > nfs4_server_t::s_lock
915163Sek110237  *	  mi_recovlock > nfs4_server_lst_lock
9160Sstevel@tonic-gate  *
9170Sstevel@tonic-gate  * The 'mi_oo_list' represents the hash buckets that contain the
9180Sstevel@tonic-gate  * nfs4_open_owenrs for this particular mntinfo4.
9190Sstevel@tonic-gate  *
9200Sstevel@tonic-gate  * The 'mi_foo_list' represents the freed nfs4_open_owners for this mntinfo4.
9210Sstevel@tonic-gate  * 'mi_foo_num' is the current number of freed open owners on the list,
9220Sstevel@tonic-gate  * 'mi_foo_max' is the maximum number of freed open owners that are allowable
9230Sstevel@tonic-gate  * on the list.
9240Sstevel@tonic-gate  *
9250Sstevel@tonic-gate  * mi_rootfh and mi_srvparentfh are read-only once created, but that just
9260Sstevel@tonic-gate  * refers to the pointer.  The contents must be updated to keep in sync
9270Sstevel@tonic-gate  * with mi_curr_serv.
9280Sstevel@tonic-gate  *
9290Sstevel@tonic-gate  * The mi_msg_list_lock protects against adding/deleting entries to the
9300Sstevel@tonic-gate  * mi_msg_list, and also the updating/retrieving of mi_lease_period;
9310Sstevel@tonic-gate  *
9320Sstevel@tonic-gate  * 'mi_zone' is initialized at structure creation time, and never
9330Sstevel@tonic-gate  * changes; it may be read without a lock.
9340Sstevel@tonic-gate  *
9350Sstevel@tonic-gate  * mi_zone_node is linkage into the mi4_globals.mig_list, and is
9360Sstevel@tonic-gate  * protected by mi4_globals.mig_list_lock.
9375302Sth199096  *
9385302Sth199096  * If MI4_EPHEMERAL is set in mi_flags, then mi_ephemeral points to an
9395302Sth199096  * ephemeral structure for this ephemeral mount point. It can not be
9405302Sth199096  * NULL. Also, mi_ephemeral_tree points to the root of the ephemeral
9415302Sth199096  * tree.
9425302Sth199096  *
9435302Sth199096  * If MI4_EPHEMERAL is not set in mi_flags, then mi_ephemeral has
9445302Sth199096  * to be NULL. If mi_ephemeral_tree is non-NULL, then this node
9455302Sth199096  * is the enclosing mntinfo4 for the ephemeral tree.
9460Sstevel@tonic-gate  */
9470Sstevel@tonic-gate struct zone;
9485302Sth199096 struct nfs4_ephemeral;
9495302Sth199096 struct nfs4_ephemeral_tree;
9509858SPavel.Filipensky@Sun.COM struct nfs4_server;
9510Sstevel@tonic-gate typedef struct mntinfo4 {
9520Sstevel@tonic-gate 	kmutex_t	mi_lock;	/* protects mntinfo4 fields */
9530Sstevel@tonic-gate 	struct servinfo4 *mi_servers;   /* server list */
9540Sstevel@tonic-gate 	struct servinfo4 *mi_curr_serv; /* current server */
9550Sstevel@tonic-gate 	struct nfs4_sharedfh *mi_rootfh; /* root filehandle */
9560Sstevel@tonic-gate 	struct nfs4_sharedfh *mi_srvparentfh; /* root's parent on server */
9570Sstevel@tonic-gate 	kcondvar_t	mi_failover_cv;	/* failover synchronization */
9580Sstevel@tonic-gate 	struct vfs	*mi_vfsp;	/* back pointer to vfs */
9590Sstevel@tonic-gate 	enum vtype	mi_type;	/* file type of the root vnode */
9600Sstevel@tonic-gate 	uint_t		mi_flags;	/* see below */
9610Sstevel@tonic-gate 	uint_t		mi_recovflags;	/* if recovery active; see below */
9620Sstevel@tonic-gate 	kthread_t	*mi_recovthread; /* active recov thread or NULL */
9630Sstevel@tonic-gate 	uint_t		mi_error;	/* only set/valid when MI4_RECOV_FAIL */
9640Sstevel@tonic-gate 					/* is set in mi_flags */
9650Sstevel@tonic-gate 	int		mi_tsize;	/* transfer size (bytes) */
9660Sstevel@tonic-gate 					/* really read size */
9670Sstevel@tonic-gate 	int		mi_stsize;	/* server's max transfer size (bytes) */
9680Sstevel@tonic-gate 					/* really write size */
9690Sstevel@tonic-gate 	int		mi_timeo;	/* inital timeout in 10th sec */
9700Sstevel@tonic-gate 	int		mi_retrans;	/* times to retry request */
9710Sstevel@tonic-gate 	hrtime_t	mi_acregmin;	/* min time to hold cached file attr */
9720Sstevel@tonic-gate 	hrtime_t	mi_acregmax;	/* max time to hold cached file attr */
9730Sstevel@tonic-gate 	hrtime_t	mi_acdirmin;	/* min time to hold cached dir attr */
9740Sstevel@tonic-gate 	hrtime_t	mi_acdirmax;	/* max time to hold cached dir attr */
9750Sstevel@tonic-gate 	len_t		mi_maxfilesize; /* for pathconf _PC_FILESIZEBITS */
9760Sstevel@tonic-gate 	int		mi_curread;	/* current read size */
9770Sstevel@tonic-gate 	int		mi_curwrite;	/* current write size */
9781705Sjwahlig 	uint_t 		mi_count; 	/* ref count */
9790Sstevel@tonic-gate 	/*
98011507SVallish.Vaidyeshwara@Sun.COM 	 * Async I/O management
98111507SVallish.Vaidyeshwara@Sun.COM 	 * We have 2 pools of threads working on async I/O:
98211507SVallish.Vaidyeshwara@Sun.COM 	 * 	(1) Threads which work on all async queues. Default number of
98311507SVallish.Vaidyeshwara@Sun.COM 	 *	threads in this queue is 8. Threads in this pool work on async
98411507SVallish.Vaidyeshwara@Sun.COM 	 *	queue pointed by mi_async_curr[NFS4_ASYNC_QUEUE]. Number of
98511507SVallish.Vaidyeshwara@Sun.COM 	 *	active threads in this pool is tracked by
98611507SVallish.Vaidyeshwara@Sun.COM 	 *	mi_threads[NFS4_ASYNC_QUEUE].
98711507SVallish.Vaidyeshwara@Sun.COM 	 * 	(ii)Threads which work only on page op async queues.
98811507SVallish.Vaidyeshwara@Sun.COM 	 *	Page ops queue comprises of NFS4_PUTAPAGE, NFS4_PAGEIO &
98911507SVallish.Vaidyeshwara@Sun.COM 	 *	NFS4_COMMIT. Default number of threads in this queue is 2
99011507SVallish.Vaidyeshwara@Sun.COM 	 *	(NUM_ASYNC_PGOPS_THREADS). Threads in this pool work on async
99111507SVallish.Vaidyeshwara@Sun.COM 	 *	queue pointed by mi_async_curr[NFS4_ASYNC_PGOPS_QUEUE]. Number
99211507SVallish.Vaidyeshwara@Sun.COM 	 *	of active threads in this pool is tracked by
99311507SVallish.Vaidyeshwara@Sun.COM 	 *	mi_threads[NFS4_ASYNC_PGOPS_QUEUE].
99411507SVallish.Vaidyeshwara@Sun.COM 	 *
99511507SVallish.Vaidyeshwara@Sun.COM 	 * In addition to above two pools, there is always one thread that
99611507SVallish.Vaidyeshwara@Sun.COM 	 * handles over-the-wire requests for VOP_INACTIVE.
9970Sstevel@tonic-gate 	 */
9980Sstevel@tonic-gate 	struct nfs4_async_reqs *mi_async_reqs[NFS4_ASYNC_TYPES];
9990Sstevel@tonic-gate 	struct nfs4_async_reqs *mi_async_tail[NFS4_ASYNC_TYPES];
100011507SVallish.Vaidyeshwara@Sun.COM 	struct nfs4_async_reqs **mi_async_curr[NFS4_MAX_ASYNC_QUEUES];
100111507SVallish.Vaidyeshwara@Sun.COM 						/* current async queue */
10020Sstevel@tonic-gate 	uint_t		mi_async_clusters[NFS4_ASYNC_TYPES];
10030Sstevel@tonic-gate 	uint_t		mi_async_init_clusters;
10040Sstevel@tonic-gate 	uint_t		mi_async_req_count; /* # outstanding work requests */
10050Sstevel@tonic-gate 	kcondvar_t	mi_async_reqs_cv; /* signaled when there's work */
100611507SVallish.Vaidyeshwara@Sun.COM 	ushort_t	mi_threads[NFS4_MAX_ASYNC_QUEUES];
100711507SVallish.Vaidyeshwara@Sun.COM 					/* number of active async threads */
10080Sstevel@tonic-gate 	ushort_t	mi_max_threads;	/* max number of async threads */
10090Sstevel@tonic-gate 	kthread_t	*mi_manager_thread; /* async manager thread id */
10100Sstevel@tonic-gate 	kthread_t	*mi_inactive_thread; /* inactive thread id */
10110Sstevel@tonic-gate 	kcondvar_t	mi_inact_req_cv; /* notify VOP_INACTIVE thread */
101211507SVallish.Vaidyeshwara@Sun.COM 	kcondvar_t	mi_async_work_cv[NFS4_MAX_ASYNC_QUEUES];
101311507SVallish.Vaidyeshwara@Sun.COM 					/* tell workers to work */
10140Sstevel@tonic-gate 	kcondvar_t	mi_async_cv;	/* all pool threads exited */
10150Sstevel@tonic-gate 	kmutex_t	mi_async_lock;
10160Sstevel@tonic-gate 	/*
10170Sstevel@tonic-gate 	 * Other stuff
10180Sstevel@tonic-gate 	 */
10190Sstevel@tonic-gate 	struct pathcnf	*mi_pathconf;	/* static pathconf kludge */
10200Sstevel@tonic-gate 	rpcprog_t	mi_prog;	/* RPC program number */
10210Sstevel@tonic-gate 	rpcvers_t	mi_vers;	/* RPC program version number */
10220Sstevel@tonic-gate 	char		**mi_rfsnames;	/* mapping to proc names */
10230Sstevel@tonic-gate 	kstat_named_t	*mi_reqs;	/* count of requests */
10240Sstevel@tonic-gate 	clock_t		mi_printftime;	/* last error printf time */
10250Sstevel@tonic-gate 	nfs_rwlock_t	mi_recovlock;	/* separate ops from recovery (v4) */
10260Sstevel@tonic-gate 	time_t		mi_grace_wait;	/* non-zero represents time to wait */
10279858SPavel.Filipensky@Sun.COM 	/* when we switched nfs4_server_t - only for observability purposes */
10289858SPavel.Filipensky@Sun.COM 	time_t		mi_srvsettime;
10290Sstevel@tonic-gate 	nfs_rwlock_t	mi_rename_lock;	/* atomic volfh rename  */
10300Sstevel@tonic-gate 	struct nfs4_fname *mi_fname;	/* root fname */
10310Sstevel@tonic-gate 	list_t		mi_lost_state;	/* resend list */
10320Sstevel@tonic-gate 	list_t		mi_bseqid_list; /* bad seqid list */
10330Sstevel@tonic-gate 	/*
10340Sstevel@tonic-gate 	 * Client Side Failover stats
10350Sstevel@tonic-gate 	 */
10360Sstevel@tonic-gate 	uint_t		mi_noresponse;	/* server not responding count */
10370Sstevel@tonic-gate 	uint_t		mi_failover; 	/* failover to new server count */
10380Sstevel@tonic-gate 	uint_t		mi_remap;	/* remap to new server count */
10390Sstevel@tonic-gate 	/*
10400Sstevel@tonic-gate 	 * Kstat statistics
10410Sstevel@tonic-gate 	 */
10420Sstevel@tonic-gate 	struct kstat	*mi_io_kstats;
10430Sstevel@tonic-gate 	struct kstat	*mi_ro_kstats;
10440Sstevel@tonic-gate 	kstat_t		*mi_recov_ksp;	/* ptr to the recovery kstat */
10450Sstevel@tonic-gate 
10460Sstevel@tonic-gate 	/*
10470Sstevel@tonic-gate 	 * Volatile fh flags (nfsv4)
10480Sstevel@tonic-gate 	 */
10490Sstevel@tonic-gate 	uint32_t	mi_fh_expire_type;
10500Sstevel@tonic-gate 	/*
10510Sstevel@tonic-gate 	 * Lease Management
10520Sstevel@tonic-gate 	 */
10530Sstevel@tonic-gate 	struct mntinfo4	*mi_clientid_next;
10540Sstevel@tonic-gate 	struct mntinfo4	*mi_clientid_prev;
10550Sstevel@tonic-gate 	clientid4	mi_clientid; /* redundant info found in nfs4_server */
10560Sstevel@tonic-gate 	int		mi_open_files;	/* count of open files */
10570Sstevel@tonic-gate 	int		mi_in_recovery;	/* count of recovery instances */
10580Sstevel@tonic-gate 	kcondvar_t	mi_cv_in_recov; /* cv for recovery threads */
10590Sstevel@tonic-gate 	/*
10600Sstevel@tonic-gate 	 * Open owner stuff.
10610Sstevel@tonic-gate 	 */
10620Sstevel@tonic-gate 	struct nfs4_oo_hash_bucket	mi_oo_list[NFS4_NUM_OO_BUCKETS];
10630Sstevel@tonic-gate 	list_t				mi_foo_list;
10640Sstevel@tonic-gate 	int				mi_foo_num;
10650Sstevel@tonic-gate 	int				mi_foo_max;
10660Sstevel@tonic-gate 	/*
10670Sstevel@tonic-gate 	 * Shared filehandle pool.
10680Sstevel@tonic-gate 	 */
10690Sstevel@tonic-gate 	nfs_rwlock_t			mi_fh_lock;
10700Sstevel@tonic-gate 	avl_tree_t			mi_filehandles;
10710Sstevel@tonic-gate 
10720Sstevel@tonic-gate 	/*
10730Sstevel@tonic-gate 	 * Debug message queue.
10740Sstevel@tonic-gate 	 */
10750Sstevel@tonic-gate 	list_t			mi_msg_list;
10760Sstevel@tonic-gate 	int			mi_msg_count;
10770Sstevel@tonic-gate 	time_t			mi_lease_period;
10780Sstevel@tonic-gate 					/*
10790Sstevel@tonic-gate 					 * not guaranteed to be accurate.
10800Sstevel@tonic-gate 					 * only should be used by debug queue.
10810Sstevel@tonic-gate 					 */
10820Sstevel@tonic-gate 	kmutex_t		mi_msg_list_lock;
10830Sstevel@tonic-gate 	/*
10840Sstevel@tonic-gate 	 * Zones support.
10850Sstevel@tonic-gate 	 */
1086*13096SJordan.Vaughan@Sun.com 	struct zone	*mi_zone;	/* Zone in which FS is mounted */
1087*13096SJordan.Vaughan@Sun.com 	zone_ref_t	mi_zone_ref;	/* Reference to aforementioned zone */
10880Sstevel@tonic-gate 	list_node_t	mi_zone_node;  /* linkage into per-zone mi list */
10895302Sth199096 
10905302Sth199096 	/*
10915302Sth199096 	 * Links for unmounting ephemeral mounts.
10925302Sth199096 	 */
10935302Sth199096 	struct nfs4_ephemeral		*mi_ephemeral;
10945302Sth199096 	struct nfs4_ephemeral_tree	*mi_ephemeral_tree;
10959858SPavel.Filipensky@Sun.COM 
10969858SPavel.Filipensky@Sun.COM 	uint_t mi_srvset_cnt; /* increment when changing the nfs4_server_t */
10979858SPavel.Filipensky@Sun.COM 	struct nfs4_server *mi_srv; /* backpointer to nfs4_server_t */
109811291SRobert.Thurlow@Sun.COM 	/*
109911291SRobert.Thurlow@Sun.COM 	 * Referral related info.
110011291SRobert.Thurlow@Sun.COM 	 */
110111291SRobert.Thurlow@Sun.COM 	int		mi_vfs_referral_loop_cnt;
11020Sstevel@tonic-gate } mntinfo4_t;
11030Sstevel@tonic-gate 
11040Sstevel@tonic-gate /*
11050Sstevel@tonic-gate  * The values for mi_flags.
11060Sstevel@tonic-gate  *
11070Sstevel@tonic-gate  *	MI4_HARD		 hard or soft mount
11080Sstevel@tonic-gate  *	MI4_PRINTED		 responding message printed
11090Sstevel@tonic-gate  *	MI4_INT			 allow INTR on hard mount
11100Sstevel@tonic-gate  * 	MI4_DOWN		 server is down
11110Sstevel@tonic-gate  *	MI4_NOAC		 don't cache attributes
11120Sstevel@tonic-gate  *	MI4_NOCTO		 no close-to-open consistency
11130Sstevel@tonic-gate  *	MI4_LLOCK		 local locking only (no lockmgr)
11140Sstevel@tonic-gate  *	MI4_GRPID		 System V group id inheritance
11150Sstevel@tonic-gate  *	MI4_SHUTDOWN		 System is rebooting or shutting down
11160Sstevel@tonic-gate  *	MI4_LINK		 server supports link
11170Sstevel@tonic-gate  *	MI4_SYMLINK		 server supports symlink
11185302Sth199096  *	MI4_EPHEMERAL_RECURSED	 an ephemeral mount being unmounted
11195302Sth199096  *				 due to a recursive call - no need
11205302Sth199096  *				 for additional recursion
11210Sstevel@tonic-gate  *	MI4_ACL			 server supports NFSv4 ACLs
11225302Sth199096  *	MI4_MIRRORMOUNT		 is a mirrormount
11230Sstevel@tonic-gate  *	MI4_NOPRINT		 don't print messages
11240Sstevel@tonic-gate  *	MI4_DIRECTIO		 do direct I/O
11250Sstevel@tonic-gate  *	MI4_RECOV_ACTIV		 filesystem has recovery a thread
11260Sstevel@tonic-gate  *	MI4_REMOVE_ON_LAST_CLOSE remove from server's list
11270Sstevel@tonic-gate  *	MI4_RECOV_FAIL		 client recovery failed
11280Sstevel@tonic-gate  *	MI4_PUBLIC		 public/url option used
11290Sstevel@tonic-gate  *	MI4_MOUNTING		 mount in progress, don't failover
11300Sstevel@tonic-gate  *	MI4_POSIX_LOCK		 if server is using POSIX locking
11310Sstevel@tonic-gate  *	MI4_LOCK_DEBUG		 cmn_err'd posix lock err msg
11321705Sjwahlig  *	MI4_DEAD		 zone has released it
11330Sstevel@tonic-gate  *	MI4_INACTIVE_IDLE	 inactive thread idle
11340Sstevel@tonic-gate  *	MI4_BADOWNER_DEBUG	 badowner error msg per mount
11350Sstevel@tonic-gate  *	MI4_ASYNC_MGR_STOP	 tell async manager to die
11360Sstevel@tonic-gate  *	MI4_TIMEDOUT		 saw a timeout during zone shutdown
11375302Sth199096  *	MI4_EPHEMERAL		 is an ephemeral mount
11380Sstevel@tonic-gate  */
11390Sstevel@tonic-gate #define	MI4_HARD		 0x1
11400Sstevel@tonic-gate #define	MI4_PRINTED		 0x2
11410Sstevel@tonic-gate #define	MI4_INT			 0x4
11420Sstevel@tonic-gate #define	MI4_DOWN		 0x8
11430Sstevel@tonic-gate #define	MI4_NOAC		 0x10
11440Sstevel@tonic-gate #define	MI4_NOCTO		 0x20
11450Sstevel@tonic-gate #define	MI4_LLOCK		 0x80
11460Sstevel@tonic-gate #define	MI4_GRPID		 0x100
11470Sstevel@tonic-gate #define	MI4_SHUTDOWN		 0x200
11480Sstevel@tonic-gate #define	MI4_LINK		 0x400
11490Sstevel@tonic-gate #define	MI4_SYMLINK		 0x800
11505302Sth199096 #define	MI4_EPHEMERAL_RECURSED	 0x1000
11510Sstevel@tonic-gate #define	MI4_ACL			 0x2000
11525302Sth199096 /* MI4_MIRRORMOUNT is also defined in nfsstat.c */
11535302Sth199096 #define	MI4_MIRRORMOUNT		 0x4000
115411291SRobert.Thurlow@Sun.COM #define	MI4_REFERRAL		 0x8000
11550Sstevel@tonic-gate /* 0x10000 is available */
11560Sstevel@tonic-gate #define	MI4_NOPRINT		 0x20000
11570Sstevel@tonic-gate #define	MI4_DIRECTIO		 0x40000
11580Sstevel@tonic-gate /* 0x80000 is available */
11590Sstevel@tonic-gate #define	MI4_RECOV_ACTIV		 0x100000
11600Sstevel@tonic-gate #define	MI4_REMOVE_ON_LAST_CLOSE 0x200000
11610Sstevel@tonic-gate #define	MI4_RECOV_FAIL		 0x400000
11620Sstevel@tonic-gate #define	MI4_PUBLIC		 0x800000
11630Sstevel@tonic-gate #define	MI4_MOUNTING		 0x1000000
11640Sstevel@tonic-gate #define	MI4_POSIX_LOCK		 0x2000000
11650Sstevel@tonic-gate #define	MI4_LOCK_DEBUG		 0x4000000
11660Sstevel@tonic-gate #define	MI4_DEAD		 0x8000000
11670Sstevel@tonic-gate #define	MI4_INACTIVE_IDLE	 0x10000000
11680Sstevel@tonic-gate #define	MI4_BADOWNER_DEBUG	 0x20000000
11690Sstevel@tonic-gate #define	MI4_ASYNC_MGR_STOP	 0x40000000
11700Sstevel@tonic-gate #define	MI4_TIMEDOUT		 0x80000000
11710Sstevel@tonic-gate 
117211291SRobert.Thurlow@Sun.COM #define	MI4_EPHEMERAL		(MI4_MIRRORMOUNT | MI4_REFERRAL)
11735302Sth199096 
11740Sstevel@tonic-gate #define	INTR4(vp)	(VTOMI4(vp)->mi_flags & MI4_INT)
11750Sstevel@tonic-gate 
11760Sstevel@tonic-gate #define	FAILOVER_MOUNT4(mi)	(mi->mi_servers->sv_next)
11770Sstevel@tonic-gate 
11780Sstevel@tonic-gate /*
11790Sstevel@tonic-gate  * Recovery flags.
11800Sstevel@tonic-gate  *
11810Sstevel@tonic-gate  * MI4R_NEED_CLIENTID is sort of redundant (it's the nfs4_server_t flag
11820Sstevel@tonic-gate  * that's important), but some flag is needed to indicate that recovery is
11830Sstevel@tonic-gate  * going on for the filesystem.
11840Sstevel@tonic-gate  */
11850Sstevel@tonic-gate #define	MI4R_NEED_CLIENTID	0x1
11860Sstevel@tonic-gate #define	MI4R_REOPEN_FILES	0x2
11870Sstevel@tonic-gate #define	MI4R_NEED_SECINFO	0x4
11880Sstevel@tonic-gate #define	MI4R_NEED_NEW_SERVER	0x8
11890Sstevel@tonic-gate #define	MI4R_REMAP_FILES	0x10
11900Sstevel@tonic-gate #define	MI4R_SRV_REBOOT		0x20	/* server has rebooted */
11910Sstevel@tonic-gate #define	MI4R_LOST_STATE		0x40
11920Sstevel@tonic-gate #define	MI4R_BAD_SEQID		0x80
119311291SRobert.Thurlow@Sun.COM #define	MI4R_MOVED		0x100
11940Sstevel@tonic-gate 
11951705Sjwahlig #define	MI4_HOLD(mi) {		\
11961705Sjwahlig 	mi_hold(mi);		\
11971705Sjwahlig }
11981705Sjwahlig 
11991705Sjwahlig #define	MI4_RELE(mi) {		\
12001705Sjwahlig 	mi_rele(mi);		\
12011705Sjwahlig }
12021705Sjwahlig 
12030Sstevel@tonic-gate /*
12040Sstevel@tonic-gate  * vfs pointer to mount info
12050Sstevel@tonic-gate  */
12060Sstevel@tonic-gate #define	VFTOMI4(vfsp)	((mntinfo4_t *)((vfsp)->vfs_data))
12070Sstevel@tonic-gate 
12080Sstevel@tonic-gate /*
12090Sstevel@tonic-gate  * vnode pointer to mount info
12100Sstevel@tonic-gate  */
12110Sstevel@tonic-gate #define	VTOMI4(vp)	((mntinfo4_t *)(((vp)->v_vfsp)->vfs_data))
12120Sstevel@tonic-gate 
12130Sstevel@tonic-gate /*
12140Sstevel@tonic-gate  * Lease Management
12150Sstevel@tonic-gate  *
12160Sstevel@tonic-gate  * lease_valid is initially set to NFS4_LEASE_NOT_STARTED.  This is when the
12170Sstevel@tonic-gate  * nfs4_server is first created.  lease_valid is then set to
12180Sstevel@tonic-gate  * NFS4_LEASE_UNITIALIZED when the renew thread is started.  The extra state of
12190Sstevel@tonic-gate  * NFS4_LEASE_NOT_STARTED is needed for client recovery (so we know if a thread
12200Sstevel@tonic-gate  * already exists when we do SETCLIENTID).  lease_valid is then set to
12210Sstevel@tonic-gate  * NFS4_LEASE_VALID (if it is at NFS4_LEASE_UNITIALIZED) when a state creating
12220Sstevel@tonic-gate  * operation (OPEN) is done. lease_valid stays at NFS4_LEASE_VALID as long as
12230Sstevel@tonic-gate  * the lease is renewed.  It is set to NFS4_LEASE_INVALID when the lease
12240Sstevel@tonic-gate  * expires.  Client recovery is needed to set the lease back to
12250Sstevel@tonic-gate  * NFS4_LEASE_VALID from NFS4_LEASE_INVALID.
12260Sstevel@tonic-gate  *
12270Sstevel@tonic-gate  * The s_cred is the credential used to mount the first file system for this
12280Sstevel@tonic-gate  * server.  It used as the credential for the renew thread's calls to the
12290Sstevel@tonic-gate  * server.
12300Sstevel@tonic-gate  *
12310Sstevel@tonic-gate  * The renew thread waits on the condition variable cv_thread_exit.  If the cv
12320Sstevel@tonic-gate  * is signalled, then the thread knows it must check s_thread_exit to see if
12330Sstevel@tonic-gate  * it should exit.  The cv is signaled when the last file system is unmounted
12340Sstevel@tonic-gate  * from a particular server.  s_thread_exit is set to 0 upon thread startup,
12350Sstevel@tonic-gate  * and set to NFS4_THREAD_EXIT, when the last file system is unmounted thereby
12360Sstevel@tonic-gate  * telling the thread to exit.  s_thread_exit is needed to avoid spurious
12370Sstevel@tonic-gate  * wakeups.
12380Sstevel@tonic-gate  *
12390Sstevel@tonic-gate  * state_ref_count is incremented every time a new file is opened and
12400Sstevel@tonic-gate  * decremented every time a file is closed otw.  This keeps track of whether
12410Sstevel@tonic-gate  * the nfs4_server has state associated with it or not.
12420Sstevel@tonic-gate  *
12430Sstevel@tonic-gate  * s_refcnt is the reference count for storage management of the struct
12440Sstevel@tonic-gate  * itself.
12450Sstevel@tonic-gate  *
12460Sstevel@tonic-gate  * mntinfo4_list points to the doubly linked list of mntinfo4s that share
12470Sstevel@tonic-gate  * this nfs4_server (ie: <clientid, saddr> pair) in the current zone.  This is
12480Sstevel@tonic-gate  * needed for a nfs4_server to get a mntinfo4 for use in rfs4call.
12490Sstevel@tonic-gate  *
12500Sstevel@tonic-gate  * s_recovlock is used to synchronize recovery operations.  The thread
12510Sstevel@tonic-gate  * that is recovering the client must acquire it as a writer.  If the
12520Sstevel@tonic-gate  * thread is using the clientid (including recovery operations on other
12530Sstevel@tonic-gate  * state), acquire it as a reader.
12540Sstevel@tonic-gate  *
12550Sstevel@tonic-gate  * The 's_otw_call_count' keeps track of the number of outstanding over the
12560Sstevel@tonic-gate  * wire requests for this structure.  The struct will not go away as long
12570Sstevel@tonic-gate  * as this is non-zero (or s_refcnt is non-zero).
12580Sstevel@tonic-gate  *
12590Sstevel@tonic-gate  * The 's_cv_otw_count' is used in conjuntion with the 's_otw_call_count'
12600Sstevel@tonic-gate  * variable to let the renew thread when an outstanding otw request has
12610Sstevel@tonic-gate  * finished.
12620Sstevel@tonic-gate  *
12630Sstevel@tonic-gate  * 'zoneid' and 'zone_globals' are set at creation of this structure
12640Sstevel@tonic-gate  * and are read-only after that; no lock is required to read them.
12650Sstevel@tonic-gate  *
12660Sstevel@tonic-gate  * s_lock protects: everything except cv_thread_exit and s_recovlock.
12670Sstevel@tonic-gate  *
12680Sstevel@tonic-gate  * s_program is used as the index into the nfs4_callback_globals's
12690Sstevel@tonic-gate  * nfs4prog2server table.  When a callback request comes in, we can
12700Sstevel@tonic-gate  * use that request's program number (minus NFS4_CALLBACK) as an index
12710Sstevel@tonic-gate  * into the nfs4prog2server.  That entry will hold the nfs4_server_t ptr.
12720Sstevel@tonic-gate  * We can then access that nfs4_server_t and its 's_deleg_list' (its list of
12730Sstevel@tonic-gate  * delegated rnode4_ts).
12740Sstevel@tonic-gate  *
12750Sstevel@tonic-gate  * Lock order:
12760Sstevel@tonic-gate  * nfs4_server::s_lock > mntinfo4::mi_lock
12770Sstevel@tonic-gate  * nfs_rtable4_lock > s_lock
12780Sstevel@tonic-gate  * nfs4_server_lst_lock > s_lock
12790Sstevel@tonic-gate  * s_recovlock > s_lock
12800Sstevel@tonic-gate  */
12810Sstevel@tonic-gate struct nfs4_callback_globals;
12820Sstevel@tonic-gate 
12830Sstevel@tonic-gate typedef struct nfs4_server {
12840Sstevel@tonic-gate 	struct nfs4_server	*forw;
12850Sstevel@tonic-gate 	struct nfs4_server	*back;
12860Sstevel@tonic-gate 	struct netbuf		saddr;
12870Sstevel@tonic-gate 	uint_t			s_flags; /* see below */
12880Sstevel@tonic-gate 	uint_t			s_refcnt;
12890Sstevel@tonic-gate 	clientid4		clientid;	/* what we get from server */
12900Sstevel@tonic-gate 	nfs_client_id4		clidtosend;	/* what we send to server */
12910Sstevel@tonic-gate 	mntinfo4_t		*mntinfo4_list;
12920Sstevel@tonic-gate 	int			lease_valid;
12930Sstevel@tonic-gate 	time_t			s_lease_time;
12940Sstevel@tonic-gate 	time_t			last_renewal_time;
12950Sstevel@tonic-gate 	timespec_t		propagation_delay;
12960Sstevel@tonic-gate 	cred_t			*s_cred;
12970Sstevel@tonic-gate 	kcondvar_t		cv_thread_exit;
12980Sstevel@tonic-gate 	int			s_thread_exit;
12990Sstevel@tonic-gate 	int			state_ref_count;
13000Sstevel@tonic-gate 	int			s_otw_call_count;
13010Sstevel@tonic-gate 	kcondvar_t		s_cv_otw_count;
13021649Sdm120769 	kcondvar_t		s_clientid_pend;
13030Sstevel@tonic-gate 	kmutex_t		s_lock;
13040Sstevel@tonic-gate 	list_t			s_deleg_list;
13050Sstevel@tonic-gate 	rpcprog_t		s_program;
13060Sstevel@tonic-gate 	nfs_rwlock_t		s_recovlock;
13070Sstevel@tonic-gate 	kcondvar_t		wait_cb_null; /* used to wait for CB_NULL */
13080Sstevel@tonic-gate 	zoneid_t		zoneid;	/* zone using this nfs4_server_t */
13090Sstevel@tonic-gate 	struct nfs4_callback_globals *zone_globals;	/* globals */
13100Sstevel@tonic-gate } nfs4_server_t;
13110Sstevel@tonic-gate 
13120Sstevel@tonic-gate /* nfs4_server flags */
13130Sstevel@tonic-gate #define	N4S_CLIENTID_SET	1	/* server has our clientid */
13141649Sdm120769 #define	N4S_CLIENTID_PEND	0x2	/* server doesn't have clientid */
13150Sstevel@tonic-gate #define	N4S_CB_PINGED		0x4	/* server has sent us a CB_NULL */
13160Sstevel@tonic-gate #define	N4S_CB_WAITER		0x8	/* is/has wait{ing/ed} for cb_null */
13171849Sdm120769 #define	N4S_INSERTED		0x10	/* list has reference for server */
13181849Sdm120769 #define	N4S_BADOWNER_DEBUG	0x20	/* bad owner err msg per client */
13190Sstevel@tonic-gate 
13200Sstevel@tonic-gate #define	N4S_CB_PAUSE_TIME	10000	/* Amount of time to pause (10ms) */
13210Sstevel@tonic-gate 
13220Sstevel@tonic-gate struct lease_time_arg {
13230Sstevel@tonic-gate 	time_t	lease_time;
13240Sstevel@tonic-gate };
13250Sstevel@tonic-gate 
13260Sstevel@tonic-gate enum nfs4_delegreturn_policy {
13270Sstevel@tonic-gate 	IMMEDIATE,
13280Sstevel@tonic-gate 	FIRSTCLOSE,
13290Sstevel@tonic-gate 	LASTCLOSE,
13300Sstevel@tonic-gate 	INACTIVE
13310Sstevel@tonic-gate };
13320Sstevel@tonic-gate 
13330Sstevel@tonic-gate /*
13340Sstevel@tonic-gate  * Operation hints for the recovery framework (mostly).
13350Sstevel@tonic-gate  *
13360Sstevel@tonic-gate  * EXCEPTIONS:
13370Sstevel@tonic-gate  * OH_ACCESS, OH_GETACL, OH_GETATTR, OH_LOOKUP, OH_READDIR
13380Sstevel@tonic-gate  *	These hints exist to allow user visit/readdir a R4SRVSTUB dir.
13390Sstevel@tonic-gate  *	(dir represents the root of a server fs that has not yet been
13400Sstevel@tonic-gate  *	mounted at client)
13410Sstevel@tonic-gate  */
13420Sstevel@tonic-gate typedef enum {
13430Sstevel@tonic-gate 	OH_OTHER,
13440Sstevel@tonic-gate 	OH_READ,
13450Sstevel@tonic-gate 	OH_WRITE,
13460Sstevel@tonic-gate 	OH_COMMIT,
13470Sstevel@tonic-gate 	OH_VFH_RENAME,
13480Sstevel@tonic-gate 	OH_MOUNT,
13490Sstevel@tonic-gate 	OH_CLOSE,
13500Sstevel@tonic-gate 	OH_LOCKU,
13510Sstevel@tonic-gate 	OH_DELEGRETURN,
13520Sstevel@tonic-gate 	OH_ACCESS,
13530Sstevel@tonic-gate 	OH_GETACL,
13540Sstevel@tonic-gate 	OH_GETATTR,
13550Sstevel@tonic-gate 	OH_LOOKUP,
13560Sstevel@tonic-gate 	OH_READDIR
13570Sstevel@tonic-gate } nfs4_op_hint_t;
13580Sstevel@tonic-gate 
13590Sstevel@tonic-gate /*
13605302Sth199096  * This data structure is used to track ephemeral mounts for both
13615302Sth199096  * mirror mounts and referrals.
13625302Sth199096  *
13635302Sth199096  * Note that each nfs4_ephemeral can only have one other nfs4_ephemeral
13645302Sth199096  * pointing at it. So we don't need two backpointers to walk
13655302Sth199096  * back up the tree.
13665302Sth199096  *
13675302Sth199096  * An ephemeral tree is pointed to by an enclosing non-ephemeral
13685302Sth199096  * mntinfo4. The root is also pointed to by its ephemeral
13695302Sth199096  * mntinfo4. ne_child will get us back to it, while ne_prior
13705302Sth199096  * will get us back to the non-ephemeral mntinfo4. This is an
13715302Sth199096  * edge case we will need to be wary of when walking back up the
13725302Sth199096  * tree.
13735302Sth199096  *
13745302Sth199096  * The way we handle this edge case is to have ne_prior be NULL
13755302Sth199096  * for the root nfs4_ephemeral node.
13765302Sth199096  */
13775302Sth199096 typedef struct nfs4_ephemeral {
13785302Sth199096 	mntinfo4_t		*ne_mount;	/* who encloses us */
13795302Sth199096 	struct nfs4_ephemeral	*ne_child;	/* first child node */
13805302Sth199096 	struct nfs4_ephemeral	*ne_peer;	/* next sibling */
13815302Sth199096 	struct nfs4_ephemeral	*ne_prior;	/* who points at us */
13825302Sth199096 	time_t			ne_ref_time;	/* time last referenced */
13835302Sth199096 	uint_t			ne_mount_to;	/* timeout at */
13845302Sth199096 	int			ne_state;	/* used to traverse */
13855302Sth199096 } nfs4_ephemeral_t;
13865302Sth199096 
13875302Sth199096 /*
13885302Sth199096  * State for the node (set in ne_state):
13895302Sth199096  */
13905302Sth199096 #define	NFS4_EPHEMERAL_OK		0x0
13915302Sth199096 #define	NFS4_EPHEMERAL_VISIT_CHILD	0x1
13925302Sth199096 #define	NFS4_EPHEMERAL_VISIT_SIBLING	0x2
13935302Sth199096 #define	NFS4_EPHEMERAL_PROCESS_ME	0x4
13945302Sth199096 #define	NFS4_EPHEMERAL_CHILD_ERROR	0x8
13955302Sth199096 #define	NFS4_EPHEMERAL_PEER_ERROR	0x10
13965302Sth199096 
13975302Sth199096 /*
13985302Sth199096  * These are the locks used in processing ephemeral data:
13995302Sth199096  *
14005302Sth199096  * mi->mi_lock
14015302Sth199096  *
14025302Sth199096  * net->net_tree_lock
14035302Sth199096  *     This lock is used to gate all tree operations.
14045302Sth199096  *     If it is held, then no other process may
14055302Sth199096  *     traverse the tree. This allows us to not
14065302Sth199096  *     throw a hold on each vfs_t in the tree.
14075302Sth199096  *     Can be held for a "long" time.
14085302Sth199096  *
14095302Sth199096  * net->net_cnt_lock
14105302Sth199096  *     Used to protect refcnt and status.
14115302Sth199096  *     Must be held for a really short time.
14125302Sth199096  *
14135302Sth199096  * nfs4_ephemeral_thread_lock
14145302Sth199096  *     Is only held to create the harvester for the zone.
14155302Sth199096  *     There is no ordering imposed on it.
14165302Sth199096  *     Held for a really short time.
14175302Sth199096  *
14185302Sth199096  * Some further detail on the interactions:
14195302Sth199096  *
14205302Sth199096  * net_tree_lock controls access to net_root. Access needs to first be
14215302Sth199096  * attempted in a non-blocking check.
14225302Sth199096  *
14235302Sth199096  * net_cnt_lock controls access to net_refcnt and net_status. It must only be
14245302Sth199096  * held for very short periods of time, unless the refcnt is 0 and the status
14255302Sth199096  * is INVALID.
14265302Sth199096  *
14275302Sth199096  * Before a caller can grab net_tree_lock, it must first grab net_cnt_lock
14285302Sth199096  * to bump the net_refcnt. It then releases it and does the action specific
14295302Sth199096  * algorithm to get the net_tree_lock. Once it has that, then it is okay to
14305302Sth199096  * grab the net_cnt_lock and change the status. The status can only be
14315302Sth199096  * changed if the caller has the net_tree_lock held as well.
14325302Sth199096  *
14336218Sth199096  * Note that the initial grab of net_cnt_lock must occur whilst
14346218Sth199096  * mi_lock is being held. This prevents stale data in that if the
14356218Sth199096  * ephemeral tree is non-NULL, then the harvester can not remove
14366218Sth199096  * the tree from the mntinfo node until it grabs that lock. I.e.,
14376218Sth199096  * we get the pointer to the tree and hold the lock atomically
14386218Sth199096  * with respect to being in mi_lock.
14396218Sth199096  *
14405302Sth199096  * When a caller is done with net_tree_lock, it can decrement the net_refcnt
14415302Sth199096  * either before it releases net_tree_lock or after.
14425302Sth199096  *
14435302Sth199096  * In either event, to decrement net_refcnt, it must hold net_cnt_lock.
14445302Sth199096  *
14455302Sth199096  * Note that the overall locking scheme for the nodes is to control access
14465302Sth199096  * via the tree. The current scheme could easily be extended such that
14475302Sth199096  * the enclosing root referenced a "forest" of trees. The underlying trees
14485302Sth199096  * would be autonomous with respect to locks.
14495302Sth199096  *
14505302Sth199096  * Note that net_next is controlled by external locks
14515302Sth199096  * particular to the data structure that the tree is being added to.
14525302Sth199096  */
14535302Sth199096 typedef struct nfs4_ephemeral_tree {
14545302Sth199096 	mntinfo4_t			*net_mount;
14555302Sth199096 	nfs4_ephemeral_t		*net_root;
14565302Sth199096 	struct nfs4_ephemeral_tree	*net_next;
14575302Sth199096 	kmutex_t			net_tree_lock;
14585302Sth199096 	kmutex_t			net_cnt_lock;
14595302Sth199096 	uint_t				net_status;
14605302Sth199096 	uint_t				net_refcnt;
14615302Sth199096 } nfs4_ephemeral_tree_t;
14625302Sth199096 
14635302Sth199096 /*
14645302Sth199096  * State for the tree (set in net_status):
14655302Sth199096  */
14665302Sth199096 #define	NFS4_EPHEMERAL_TREE_OK		0x0
14675302Sth199096 #define	NFS4_EPHEMERAL_TREE_BUILDING	0x1
14685302Sth199096 #define	NFS4_EPHEMERAL_TREE_DEROOTING	0x2
14695302Sth199096 #define	NFS4_EPHEMERAL_TREE_INVALID	0x4
14705302Sth199096 #define	NFS4_EPHEMERAL_TREE_MOUNTING	0x8
14715302Sth199096 #define	NFS4_EPHEMERAL_TREE_UMOUNTING	0x10
14725302Sth199096 #define	NFS4_EPHEMERAL_TREE_LOCKED	0x20
14735302Sth199096 
14747318SThomas.Haynes@Sun.COM #define	NFS4_EPHEMERAL_TREE_PROCESSING	(NFS4_EPHEMERAL_TREE_DEROOTING | \
14757318SThomas.Haynes@Sun.COM 	NFS4_EPHEMERAL_TREE_INVALID | NFS4_EPHEMERAL_TREE_UMOUNTING | \
14767318SThomas.Haynes@Sun.COM 	NFS4_EPHEMERAL_TREE_LOCKED)
14777318SThomas.Haynes@Sun.COM 
14785302Sth199096 /*
14790Sstevel@tonic-gate  * This macro evaluates to non-zero if the given op releases state at the
14800Sstevel@tonic-gate  * server.
14810Sstevel@tonic-gate  */
14820Sstevel@tonic-gate #define	OH_IS_STATE_RELE(op)	((op) == OH_CLOSE || (op) == OH_LOCKU || \
14830Sstevel@tonic-gate 				(op) == OH_DELEGRETURN)
14840Sstevel@tonic-gate 
14850Sstevel@tonic-gate #ifdef _KERNEL
14860Sstevel@tonic-gate 
14870Sstevel@tonic-gate extern void	nfs4_async_manager(struct vfs *);
14880Sstevel@tonic-gate extern void	nfs4_async_manager_stop(struct vfs *);
14890Sstevel@tonic-gate extern void	nfs4_async_stop(struct vfs *);
14900Sstevel@tonic-gate extern int	nfs4_async_stop_sig(struct vfs *);
14910Sstevel@tonic-gate extern int	nfs4_async_readahead(vnode_t *, u_offset_t, caddr_t,
14920Sstevel@tonic-gate 				struct seg *, cred_t *,
14930Sstevel@tonic-gate 				void (*)(vnode_t *, u_offset_t,
14940Sstevel@tonic-gate 				caddr_t, struct seg *, cred_t *));
14950Sstevel@tonic-gate extern int	nfs4_async_putapage(vnode_t *, page_t *, u_offset_t, size_t,
14960Sstevel@tonic-gate 				int, cred_t *, int (*)(vnode_t *, page_t *,
14970Sstevel@tonic-gate 				u_offset_t, size_t, int, cred_t *));
14980Sstevel@tonic-gate extern int	nfs4_async_pageio(vnode_t *, page_t *, u_offset_t, size_t,
14990Sstevel@tonic-gate 				int, cred_t *, int (*)(vnode_t *, page_t *,
15000Sstevel@tonic-gate 				u_offset_t, size_t, int, cred_t *));
15010Sstevel@tonic-gate extern void	nfs4_async_commit(vnode_t *, page_t *, offset3, count3,
15020Sstevel@tonic-gate 				cred_t *, void (*)(vnode_t *, page_t *,
15030Sstevel@tonic-gate 				offset3, count3, cred_t *));
15040Sstevel@tonic-gate extern void	nfs4_async_inactive(vnode_t *, cred_t *);
15050Sstevel@tonic-gate extern void	nfs4_inactive_thread(mntinfo4_t *mi);
15060Sstevel@tonic-gate extern void	nfs4_inactive_otw(vnode_t *, cred_t *);
15070Sstevel@tonic-gate extern int	nfs4_putpages(vnode_t *, u_offset_t, size_t, int, cred_t *);
15080Sstevel@tonic-gate 
15090Sstevel@tonic-gate extern int	nfs4_setopts(vnode_t *, model_t, struct nfs_args *);
15100Sstevel@tonic-gate extern void	nfs4_mnt_kstat_init(struct vfs *);
15110Sstevel@tonic-gate 
15120Sstevel@tonic-gate extern void	rfs4call(struct mntinfo4 *, struct COMPOUND4args_clnt *,
15130Sstevel@tonic-gate 			struct COMPOUND4res_clnt *, cred_t *, int *, int,
15140Sstevel@tonic-gate 			nfs4_error_t *);
15150Sstevel@tonic-gate extern void	nfs4_acl_fill_cache(struct rnode4 *, vsecattr_t *);
15160Sstevel@tonic-gate extern int	nfs4_attr_otw(vnode_t *, nfs4_tag_type_t,
15170Sstevel@tonic-gate 				nfs4_ga_res_t *, bitmap4, cred_t *);
15180Sstevel@tonic-gate 
15190Sstevel@tonic-gate extern void	nfs4_attrcache_noinval(vnode_t *, nfs4_ga_res_t *, hrtime_t);
15200Sstevel@tonic-gate extern void	nfs4_attr_cache(vnode_t *, nfs4_ga_res_t *,
15210Sstevel@tonic-gate 				hrtime_t, cred_t *, int,
15220Sstevel@tonic-gate 				change_info4 *);
15230Sstevel@tonic-gate extern void	nfs4_purge_rddir_cache(vnode_t *);
15240Sstevel@tonic-gate extern void	nfs4_invalidate_pages(vnode_t *, u_offset_t, cred_t *);
15250Sstevel@tonic-gate extern void	nfs4_purge_caches(vnode_t *, int, cred_t *, int);
15260Sstevel@tonic-gate extern void	nfs4_purge_stale_fh(int, vnode_t *, cred_t *);
152710276SPavel.Filipensky@Sun.COM extern void	nfs4_flush_pages(vnode_t *vp, cred_t *cr);
15280Sstevel@tonic-gate 
15290Sstevel@tonic-gate extern void	nfs4rename_update(vnode_t *, vnode_t *, nfs_fh4 *, char *);
15300Sstevel@tonic-gate extern void	nfs4_update_paths(vnode_t *, char *, vnode_t *, char *,
15310Sstevel@tonic-gate 			vnode_t *);
15320Sstevel@tonic-gate 
15330Sstevel@tonic-gate extern void	nfs4args_lookup_free(nfs_argop4 *, int);
15340Sstevel@tonic-gate extern void	nfs4args_copen_free(OPEN4cargs *);
15350Sstevel@tonic-gate 
15360Sstevel@tonic-gate extern void	nfs4_printfhandle(nfs4_fhandle_t *);
15370Sstevel@tonic-gate 
15380Sstevel@tonic-gate extern void	nfs_free_mi4(mntinfo4_t *);
15390Sstevel@tonic-gate extern void	sv4_free(servinfo4_t *);
15400Sstevel@tonic-gate extern void	nfs4_mi_zonelist_add(mntinfo4_t *);
15411705Sjwahlig extern int	nfs4_mi_zonelist_remove(mntinfo4_t *);
15420Sstevel@tonic-gate extern int 	nfs4_secinfo_recov(mntinfo4_t *, vnode_t *, vnode_t *);
15430Sstevel@tonic-gate extern void	nfs4_secinfo_init(void);
15440Sstevel@tonic-gate extern void	nfs4_secinfo_fini(void);
15450Sstevel@tonic-gate extern int	nfs4_secinfo_path(mntinfo4_t *, cred_t *, int);
15460Sstevel@tonic-gate extern int 	nfs4_secinfo_vnode_otw(vnode_t *, char *, cred_t *);
15470Sstevel@tonic-gate extern void	secinfo_free(sv_secinfo_t *);
15480Sstevel@tonic-gate extern void	save_mnt_secinfo(servinfo4_t *);
15490Sstevel@tonic-gate extern void	check_mnt_secinfo(servinfo4_t *, vnode_t *);
15500Sstevel@tonic-gate extern int	vattr_to_fattr4(vattr_t *, vsecattr_t *, fattr4 *, int,
15510Sstevel@tonic-gate 				enum nfs_opnum4, bitmap4 supp_mask);
15520Sstevel@tonic-gate extern int	nfs4_putapage(vnode_t *, page_t *, u_offset_t *, size_t *,
15530Sstevel@tonic-gate 			int, cred_t *);
15540Sstevel@tonic-gate extern void	nfs4_write_error(vnode_t *, int, cred_t *);
15550Sstevel@tonic-gate extern void	nfs4_lockcompletion(vnode_t *, int);
15560Sstevel@tonic-gate extern bool_t	nfs4_map_lost_lock_conflict(vnode_t *);
15570Sstevel@tonic-gate extern int	vtodv(vnode_t *, vnode_t **, cred_t *, bool_t);
155811291SRobert.Thurlow@Sun.COM extern int	vtoname(vnode_t *, char *, ssize_t);
15590Sstevel@tonic-gate extern void	nfs4open_confirm(vnode_t *, seqid4*, stateid4 *, cred_t *,
15600Sstevel@tonic-gate 		    bool_t, bool_t *, nfs4_open_owner_t *, bool_t,
15610Sstevel@tonic-gate 		    nfs4_error_t *, int *);
15620Sstevel@tonic-gate extern void	nfs4_error_zinit(nfs4_error_t *);
15630Sstevel@tonic-gate extern void	nfs4_error_init(nfs4_error_t *, int);
15645302Sth199096 extern void	nfs4_free_args(struct nfs_args *);
15651705Sjwahlig 
15661705Sjwahlig extern void 	mi_hold(mntinfo4_t *);
15671705Sjwahlig extern void	mi_rele(mntinfo4_t *);
15681705Sjwahlig 
156911291SRobert.Thurlow@Sun.COM extern vnode_t	*find_referral_stubvp(vnode_t *, char *, cred_t *);
157011291SRobert.Thurlow@Sun.COM extern int	 nfs4_setup_referral(vnode_t *, char *, vnode_t **, cred_t *);
157111291SRobert.Thurlow@Sun.COM 
15725302Sth199096 extern sec_data_t	*copy_sec_data(sec_data_t *);
15735302Sth199096 extern gss_clntdata_t	*copy_sec_data_gss(gss_clntdata_t *);
15745302Sth199096 
15750Sstevel@tonic-gate #ifdef DEBUG
15760Sstevel@tonic-gate extern int	nfs4_consistent_type(vnode_t *);
15770Sstevel@tonic-gate #endif
15780Sstevel@tonic-gate 
15790Sstevel@tonic-gate extern void	nfs4_init_dot_entries(void);
15800Sstevel@tonic-gate extern void	nfs4_destroy_dot_entries(void);
15810Sstevel@tonic-gate extern struct nfs4_callback_globals	*nfs4_get_callback_globals(void);
15820Sstevel@tonic-gate 
15830Sstevel@tonic-gate extern struct nfs4_server nfs4_server_lst;
15840Sstevel@tonic-gate 
15850Sstevel@tonic-gate extern clock_t nfs_write_error_interval;
15860Sstevel@tonic-gate 
15870Sstevel@tonic-gate #endif /* _KERNEL */
15880Sstevel@tonic-gate 
15890Sstevel@tonic-gate /*
15900Sstevel@tonic-gate  * Flags for nfs4getfh_otw.
15910Sstevel@tonic-gate  */
15920Sstevel@tonic-gate 
15930Sstevel@tonic-gate #define	NFS4_GETFH_PUBLIC	0x01
15940Sstevel@tonic-gate #define	NFS4_GETFH_NEEDSOP	0x02
15950Sstevel@tonic-gate 
15960Sstevel@tonic-gate /*
15970Sstevel@tonic-gate  * Found through rnodes.
15980Sstevel@tonic-gate  *
15990Sstevel@tonic-gate  * The os_open_ref_count keeps track the number of open file descriptor
16000Sstevel@tonic-gate  * refernces on this data structure.  It will be bumped for any successful
16010Sstevel@tonic-gate  * OTW OPEN call and any OPEN call that determines the OTW call is not
16020Sstevel@tonic-gate  * necessary and the open stream hasn't just been created (see
16030Sstevel@tonic-gate  * nfs4_is_otw_open_necessary).
16040Sstevel@tonic-gate  *
16050Sstevel@tonic-gate  * os_mapcnt is a count of the number of mmapped pages for a particular
16060Sstevel@tonic-gate  * open stream; this in conjunction w/ os_open_ref_count is used to
16070Sstevel@tonic-gate  * determine when to do a close to the server.  This is necessary because
16080Sstevel@tonic-gate  * of the semantics of doing open, mmap, close; the OTW close must be wait
16090Sstevel@tonic-gate  * until all open and mmap references have vanished.
16100Sstevel@tonic-gate  *
16110Sstevel@tonic-gate  * 'os_valid' tells us whether this structure is about to be freed or not,
16120Sstevel@tonic-gate  * if it is then don't return it in find_open_stream().
16130Sstevel@tonic-gate  *
16140Sstevel@tonic-gate  * 'os_final_close' is set when a CLOSE OTW was attempted.  This is needed
16150Sstevel@tonic-gate  * so we can properly count the os_open_ref_count in cases where we VOP_CLOSE
16160Sstevel@tonic-gate  * without a VOP_OPEN, and have nfs4_inactive() drive the OTW CLOSE.  It
16170Sstevel@tonic-gate  * also helps differentiate the VOP_OPEN/VN_RELE case from the VOP_CLOSE
16180Sstevel@tonic-gate  * that tried to close OTW but failed, and left the state cleanup to
16190Sstevel@tonic-gate  * nfs4_inactive/CLOSE_FORCE.
16200Sstevel@tonic-gate  *
16210Sstevel@tonic-gate  * 'os_force_close' is used to let us know if an intervening thread came
16220Sstevel@tonic-gate  * and reopened the open stream after we decided to issue a CLOSE_FORCE,
16230Sstevel@tonic-gate  * but before we could actually process the CLOSE_FORCE.
16240Sstevel@tonic-gate  *
16250Sstevel@tonic-gate  * 'os_pending_close' is set when an over-the-wire CLOSE is deferred to the
16260Sstevel@tonic-gate  * lost state queue.
16270Sstevel@tonic-gate  *
16280Sstevel@tonic-gate  * 'open_stateid' is set the last open stateid returned by the server unless
16290Sstevel@tonic-gate  * 'os_delegation' is 1, in which case 'open_stateid' refers to the
16300Sstevel@tonic-gate  * delegation stateid returned by the server.  This is used in cases where the
16310Sstevel@tonic-gate  * client tries to OPEN a file but already has a suitable delegation, so we
16320Sstevel@tonic-gate  * just stick the delegation stateid in the open stream.
16330Sstevel@tonic-gate  *
16340Sstevel@tonic-gate  * os_dc_openacc are open access bits which have been granted to the
16350Sstevel@tonic-gate  * open stream by virtue of a delegation, but which have not been seen
16360Sstevel@tonic-gate  * by the server.  This applies even if the open stream does not have
16370Sstevel@tonic-gate  * os_delegation set.  These bits are used when setting file locks to
16380Sstevel@tonic-gate  * determine whether an open with CLAIM_DELEGATE_CUR needs to be done
16390Sstevel@tonic-gate  * before the lock request can be sent to the server.  See
16400Sstevel@tonic-gate  * nfs4frlock_check_deleg().
16410Sstevel@tonic-gate  *
16420Sstevel@tonic-gate  * 'os_mmap_read/write' keep track of the read and write access our memory
16430Sstevel@tonic-gate  * maps require.  We need to keep track of this so we can provide the proper
16440Sstevel@tonic-gate  * access bits in the open/mmap/close/reboot/reopen case.
16450Sstevel@tonic-gate  *
16460Sstevel@tonic-gate  * 'os_failed_reopen' tells us that we failed to successfully reopen this
16470Sstevel@tonic-gate  * open stream; therefore, we should not use this open stateid as it is
16480Sstevel@tonic-gate  * not valid anymore. This flag is also used to indicate an unsuccessful
16490Sstevel@tonic-gate  * attempt to reopen a delegation open stream with CLAIM_DELEGATE_CUR.
16500Sstevel@tonic-gate  *
16510Sstevel@tonic-gate  * If 'os_orig_oo_name' is different than os_open_owner's oo_name
16520Sstevel@tonic-gate  * then this tells us that this open stream's open owner used a
16530Sstevel@tonic-gate  * bad seqid (that is, got NFS4ERR_BAD_SEQID).  If different, this open
16540Sstevel@tonic-gate  * stream will no longer be used for future OTW state releasing calls.
16550Sstevel@tonic-gate  *
16560Sstevel@tonic-gate  * Lock ordering:
16570Sstevel@tonic-gate  * rnode4_t::r_os_lock > os_sync_lock
16580Sstevel@tonic-gate  * os_sync_lock > rnode4_t::r_statelock
16590Sstevel@tonic-gate  * os_sync_lock > rnode4_t::r_statev4_lock
16600Sstevel@tonic-gate  * os_sync_lock > mntinfo4_t::mi_lock (via hold over rfs4call)
16610Sstevel@tonic-gate  *
16620Sstevel@tonic-gate  * The 'os_sync_lock' protects:
16630Sstevel@tonic-gate  *	open_stateid
16640Sstevel@tonic-gate  *	os_dc_openacc
16650Sstevel@tonic-gate  *	os_delegation
16660Sstevel@tonic-gate  *	os_failed_reopen
16670Sstevel@tonic-gate  *	os_final_close
16680Sstevel@tonic-gate  *	os_force_close
16690Sstevel@tonic-gate  *	os_mapcnt
16700Sstevel@tonic-gate  *	os_mmap_read
16710Sstevel@tonic-gate  *	os_mmap_write
16720Sstevel@tonic-gate  *	os_open_ref_count
16730Sstevel@tonic-gate  *	os_pending_close
16740Sstevel@tonic-gate  *	os_share_acc_read
16750Sstevel@tonic-gate  *	os_share_acc_write
16760Sstevel@tonic-gate  *	os_share_deny_none
16770Sstevel@tonic-gate  *	os_share_deny_read
16780Sstevel@tonic-gate  *	os_share_deny_write
16790Sstevel@tonic-gate  *	os_ref_count
16800Sstevel@tonic-gate  *	os_valid
16810Sstevel@tonic-gate  *
16820Sstevel@tonic-gate  * The rnode4_t::r_os_lock protects:
16830Sstevel@tonic-gate  *	os_node
16840Sstevel@tonic-gate  *
16850Sstevel@tonic-gate  * These fields are set at creation time and
16860Sstevel@tonic-gate  * read only after that:
16870Sstevel@tonic-gate  *	os_open_owner
16880Sstevel@tonic-gate  *	os_orig_oo_name
16890Sstevel@tonic-gate  */
16900Sstevel@tonic-gate typedef struct nfs4_open_stream {
16910Sstevel@tonic-gate 	uint64_t		os_share_acc_read;
16920Sstevel@tonic-gate 	uint64_t		os_share_acc_write;
16930Sstevel@tonic-gate 	uint64_t		os_mmap_read;
16940Sstevel@tonic-gate 	uint64_t		os_mmap_write;
16950Sstevel@tonic-gate 	uint32_t		os_share_deny_none;
16960Sstevel@tonic-gate 	uint32_t		os_share_deny_read;
16970Sstevel@tonic-gate 	uint32_t		os_share_deny_write;
16980Sstevel@tonic-gate 	stateid4		open_stateid;
16990Sstevel@tonic-gate 	int			os_dc_openacc;
17000Sstevel@tonic-gate 	int			os_ref_count;
17010Sstevel@tonic-gate 	unsigned		os_valid:1;
17020Sstevel@tonic-gate 	unsigned 		os_delegation:1;
17030Sstevel@tonic-gate 	unsigned		os_final_close:1;
17040Sstevel@tonic-gate 	unsigned 		os_pending_close:1;
17050Sstevel@tonic-gate 	unsigned 		os_failed_reopen:1;
17060Sstevel@tonic-gate 	unsigned		os_force_close:1;
17070Sstevel@tonic-gate 	int			os_open_ref_count;
17080Sstevel@tonic-gate 	long			os_mapcnt;
17090Sstevel@tonic-gate 	list_node_t		os_node;
17100Sstevel@tonic-gate 	struct nfs4_open_owner	*os_open_owner;
17110Sstevel@tonic-gate 	uint64_t		os_orig_oo_name;
17120Sstevel@tonic-gate 	kmutex_t		os_sync_lock;
17130Sstevel@tonic-gate } nfs4_open_stream_t;
17140Sstevel@tonic-gate 
17150Sstevel@tonic-gate /*
17160Sstevel@tonic-gate  * This structure describes the format of the lock_owner_name
17170Sstevel@tonic-gate  * field of the lock owner.
17180Sstevel@tonic-gate  */
17190Sstevel@tonic-gate 
17200Sstevel@tonic-gate typedef struct nfs4_lo_name {
17210Sstevel@tonic-gate 	uint64_t	ln_seq_num;
17220Sstevel@tonic-gate 	pid_t		ln_pid;
17230Sstevel@tonic-gate } nfs4_lo_name_t;
17240Sstevel@tonic-gate 
17250Sstevel@tonic-gate /*
17260Sstevel@tonic-gate  * Flags for lo_flags.
17270Sstevel@tonic-gate  */
17280Sstevel@tonic-gate #define	NFS4_LOCK_SEQID_INUSE	0x1
17290Sstevel@tonic-gate #define	NFS4_BAD_SEQID_LOCK	0x2
17300Sstevel@tonic-gate 
17310Sstevel@tonic-gate /*
17320Sstevel@tonic-gate  * The lo_prev_rnode and lo_next_rnode are for a circular list that hangs
17330Sstevel@tonic-gate  * off the rnode.  If the links are NULL it means this object is not on the
17340Sstevel@tonic-gate  * list.
17350Sstevel@tonic-gate  *
17360Sstevel@tonic-gate  * 'lo_pending_rqsts' is non-zero if we ever tried to send a request and
17370Sstevel@tonic-gate  * didn't get a response back.  This is used to figure out if we have
17380Sstevel@tonic-gate  * possible remote v4 locks, so that we can clean up at process exit.  In
17390Sstevel@tonic-gate  * theory, the client should be able to figure out if the server received
17400Sstevel@tonic-gate  * the request (based on what seqid works), so maybe we can get rid of this
17410Sstevel@tonic-gate  * flag someday.
17420Sstevel@tonic-gate  *
17430Sstevel@tonic-gate  * 'lo_ref_count' tells us how many processes/threads are using this data
17440Sstevel@tonic-gate  * structure.  The rnode's list accounts for one reference.
17450Sstevel@tonic-gate  *
17460Sstevel@tonic-gate  * 'lo_just_created' is set to NFS4_JUST_CREATED when we first create the
17470Sstevel@tonic-gate  * data structure.  It is then set to NFS4_PERM_CREATED when a lock request
17480Sstevel@tonic-gate  * is successful using this lock owner structure.  We need to keep 'temporary'
17490Sstevel@tonic-gate  * lock owners around so we can properly keep the lock seqid synchronization
17500Sstevel@tonic-gate  * when multiple processes/threads are trying to create the lock owner for the
17510Sstevel@tonic-gate  * first time (especially with the DENIED error case).  Once
17520Sstevel@tonic-gate  * 'lo_just_created' is set to NFS4_PERM_CREATED, it doesn't change.
17530Sstevel@tonic-gate  *
17540Sstevel@tonic-gate  * 'lo_valid' tells us whether this structure is about to be freed or not,
17550Sstevel@tonic-gate  * if it is then don't return it from find_lock_owner().
17560Sstevel@tonic-gate  *
17570Sstevel@tonic-gate  * Retrieving and setting of 'lock_seqid' is protected by the
17580Sstevel@tonic-gate  * NFS4_LOCK_SEQID_INUSE flag.  Waiters for NFS4_LOCK_SEQID_INUSE should
17590Sstevel@tonic-gate  * use 'lo_cv_seqid_sync'.
17600Sstevel@tonic-gate  *
17610Sstevel@tonic-gate  * The setting of 'lock_stateid' is protected by the
17620Sstevel@tonic-gate  * NFS4_LOCK_SEQID_INUSE flag and 'lo_lock'.  The retrieving of the
17630Sstevel@tonic-gate  * 'lock_stateid' is protected by 'lo_lock', with the additional
17640Sstevel@tonic-gate  * requirement that the calling function can handle NFS4ERR_OLD_STATEID and
17650Sstevel@tonic-gate  * NFS4ERR_BAD_STATEID as appropiate.
17660Sstevel@tonic-gate  *
17670Sstevel@tonic-gate  * The setting of NFS4_BAD_SEQID_LOCK to lo_flags tells us whether this lock
17680Sstevel@tonic-gate  * owner used a bad seqid (that is, got NFS4ERR_BAD_SEQID).  With this set,
17690Sstevel@tonic-gate  * this lock owner will no longer be used for future OTW calls.  Once set,
17700Sstevel@tonic-gate  * it is never unset.
17710Sstevel@tonic-gate  *
17720Sstevel@tonic-gate  * Lock ordering:
17730Sstevel@tonic-gate  * rnode4_t::r_statev4_lock > lo_lock
17740Sstevel@tonic-gate  */
17750Sstevel@tonic-gate typedef struct nfs4_lock_owner {
17760Sstevel@tonic-gate 	struct nfs4_lock_owner	*lo_next_rnode;
17770Sstevel@tonic-gate 	struct nfs4_lock_owner	*lo_prev_rnode;
17780Sstevel@tonic-gate 	int			lo_pid;
17790Sstevel@tonic-gate 	stateid4		lock_stateid;
17800Sstevel@tonic-gate 	seqid4			lock_seqid;
17810Sstevel@tonic-gate 	/*
17820Sstevel@tonic-gate 	 * Fix this to always be 12 bytes
17830Sstevel@tonic-gate 	 */
17840Sstevel@tonic-gate 	nfs4_lo_name_t		lock_owner_name;
17850Sstevel@tonic-gate 	int			lo_ref_count;
17860Sstevel@tonic-gate 	int			lo_valid;
17870Sstevel@tonic-gate 	int			lo_pending_rqsts;
17880Sstevel@tonic-gate 	int			lo_just_created;
17890Sstevel@tonic-gate 	int			lo_flags;
17900Sstevel@tonic-gate 	kcondvar_t		lo_cv_seqid_sync;
17910Sstevel@tonic-gate 	kmutex_t		lo_lock;
17920Sstevel@tonic-gate 	kthread_t		*lo_seqid_holder; /* debugging aid */
17930Sstevel@tonic-gate } nfs4_lock_owner_t;
17940Sstevel@tonic-gate 
17950Sstevel@tonic-gate /* for nfs4_lock_owner_t lookups */
17960Sstevel@tonic-gate typedef enum {LOWN_ANY, LOWN_VALID_STATEID} lown_which_t;
17970Sstevel@tonic-gate 
17980Sstevel@tonic-gate /* Number of times to retry a call that fails with state independent error */
17990Sstevel@tonic-gate #define	NFS4_NUM_RECOV_RETRIES	3
18000Sstevel@tonic-gate 
18010Sstevel@tonic-gate typedef enum {
18020Sstevel@tonic-gate 	NO_SID,
18030Sstevel@tonic-gate 	DEL_SID,
18040Sstevel@tonic-gate 	LOCK_SID,
18050Sstevel@tonic-gate 	OPEN_SID,
18060Sstevel@tonic-gate 	SPEC_SID
18070Sstevel@tonic-gate } nfs4_stateid_type_t;
18080Sstevel@tonic-gate 
18090Sstevel@tonic-gate typedef struct nfs4_stateid_types {
18100Sstevel@tonic-gate 	stateid4 d_sid;
18110Sstevel@tonic-gate 	stateid4 l_sid;
18120Sstevel@tonic-gate 	stateid4 o_sid;
18130Sstevel@tonic-gate 	nfs4_stateid_type_t cur_sid_type;
18140Sstevel@tonic-gate } nfs4_stateid_types_t;
18150Sstevel@tonic-gate 
18160Sstevel@tonic-gate /*
18170Sstevel@tonic-gate  * Per-zone data for dealing with callbacks.  Included here solely for the
18180Sstevel@tonic-gate  * benefit of MDB.
18190Sstevel@tonic-gate  */
18200Sstevel@tonic-gate struct nfs4_callback_stats {
18210Sstevel@tonic-gate 	kstat_named_t	delegations;
18220Sstevel@tonic-gate 	kstat_named_t	cb_getattr;
18230Sstevel@tonic-gate 	kstat_named_t	cb_recall;
18240Sstevel@tonic-gate 	kstat_named_t	cb_null;
18250Sstevel@tonic-gate 	kstat_named_t	cb_dispatch;
18260Sstevel@tonic-gate 	kstat_named_t	delegaccept_r;
18270Sstevel@tonic-gate 	kstat_named_t	delegaccept_rw;
18280Sstevel@tonic-gate 	kstat_named_t	delegreturn;
18290Sstevel@tonic-gate 	kstat_named_t	callbacks;
18300Sstevel@tonic-gate 	kstat_named_t	claim_cur;
18310Sstevel@tonic-gate 	kstat_named_t	claim_cur_ok;
18320Sstevel@tonic-gate 	kstat_named_t	recall_trunc;
18330Sstevel@tonic-gate 	kstat_named_t	recall_failed;
18340Sstevel@tonic-gate 	kstat_named_t	return_limit_write;
18350Sstevel@tonic-gate 	kstat_named_t	return_limit_addmap;
18360Sstevel@tonic-gate 	kstat_named_t	deleg_recover;
18370Sstevel@tonic-gate 	kstat_named_t	cb_illegal;
18380Sstevel@tonic-gate };
18390Sstevel@tonic-gate 
18400Sstevel@tonic-gate struct nfs4_callback_globals {
18410Sstevel@tonic-gate 	kmutex_t nfs4_cb_lock;
18420Sstevel@tonic-gate 	kmutex_t nfs4_dlist_lock;
18430Sstevel@tonic-gate 	int nfs4_program_hint;
18440Sstevel@tonic-gate 	/* this table maps the program number to the nfs4_server structure */
18450Sstevel@tonic-gate 	struct nfs4_server **nfs4prog2server;
18460Sstevel@tonic-gate 	list_t nfs4_dlist;
18470Sstevel@tonic-gate 	list_t nfs4_cb_ports;
18480Sstevel@tonic-gate 	struct nfs4_callback_stats nfs4_callback_stats;
18490Sstevel@tonic-gate #ifdef DEBUG
18500Sstevel@tonic-gate 	int nfs4_dlistadd_c;
18510Sstevel@tonic-gate 	int nfs4_dlistclean_c;
18520Sstevel@tonic-gate #endif
18530Sstevel@tonic-gate };
18540Sstevel@tonic-gate 
18550Sstevel@tonic-gate typedef enum {
18560Sstevel@tonic-gate 	CLOSE_NORM,
18570Sstevel@tonic-gate 	CLOSE_DELMAP,
18580Sstevel@tonic-gate 	CLOSE_FORCE,
18590Sstevel@tonic-gate 	CLOSE_RESEND,
18600Sstevel@tonic-gate 	CLOSE_AFTER_RESEND
18610Sstevel@tonic-gate } nfs4_close_type_t;
18620Sstevel@tonic-gate 
18630Sstevel@tonic-gate /*
18640Sstevel@tonic-gate  * Structure to hold the bad seqid information that is passed
18650Sstevel@tonic-gate  * to the recovery framework.
18660Sstevel@tonic-gate  */
18670Sstevel@tonic-gate typedef struct nfs4_bseqid_entry {
18680Sstevel@tonic-gate 	nfs4_open_owner_t	*bs_oop;
18690Sstevel@tonic-gate 	nfs4_lock_owner_t	*bs_lop;
18700Sstevel@tonic-gate 	vnode_t			*bs_vp;
18710Sstevel@tonic-gate 	pid_t			bs_pid;
18720Sstevel@tonic-gate 	nfs4_tag_type_t		bs_tag;
18730Sstevel@tonic-gate 	seqid4			bs_seqid;
18740Sstevel@tonic-gate 	list_node_t		bs_node;
18750Sstevel@tonic-gate } nfs4_bseqid_entry_t;
18760Sstevel@tonic-gate 
18770Sstevel@tonic-gate #ifdef _KERNEL
18780Sstevel@tonic-gate 
18790Sstevel@tonic-gate extern void	nfs4close_one(vnode_t *, nfs4_open_stream_t *, cred_t *, int,
18800Sstevel@tonic-gate 		    nfs4_lost_rqst_t *, nfs4_error_t *, nfs4_close_type_t,
18810Sstevel@tonic-gate 		    size_t, uint_t, uint_t);
18820Sstevel@tonic-gate extern void	nfs4close_notw(vnode_t *, nfs4_open_stream_t *, int *);
18830Sstevel@tonic-gate extern void	nfs4_set_lock_stateid(nfs4_lock_owner_t *, stateid4);
18840Sstevel@tonic-gate extern void	open_owner_hold(nfs4_open_owner_t *);
18850Sstevel@tonic-gate extern void	open_owner_rele(nfs4_open_owner_t *);
18860Sstevel@tonic-gate extern nfs4_open_stream_t	*find_or_create_open_stream(nfs4_open_owner_t *,
18870Sstevel@tonic-gate 					struct rnode4 *, int *);
18880Sstevel@tonic-gate extern nfs4_open_stream_t *find_open_stream(nfs4_open_owner_t *,
18890Sstevel@tonic-gate 				struct rnode4 *);
18900Sstevel@tonic-gate extern nfs4_open_stream_t *create_open_stream(nfs4_open_owner_t *oop,
18910Sstevel@tonic-gate 				struct rnode4 *rp);
18920Sstevel@tonic-gate extern void	open_stream_hold(nfs4_open_stream_t *);
18930Sstevel@tonic-gate extern void	open_stream_rele(nfs4_open_stream_t *, struct rnode4 *);
18940Sstevel@tonic-gate extern int	nfs4close_all(vnode_t *, cred_t *);
18950Sstevel@tonic-gate extern void	lock_owner_hold(nfs4_lock_owner_t *);
18960Sstevel@tonic-gate extern void	lock_owner_rele(nfs4_lock_owner_t *);
18970Sstevel@tonic-gate extern nfs4_lock_owner_t *create_lock_owner(struct rnode4 *, pid_t);
18980Sstevel@tonic-gate extern nfs4_lock_owner_t *find_lock_owner(struct rnode4 *, pid_t, lown_which_t);
18990Sstevel@tonic-gate extern void	nfs4_rnode_remove_lock_owner(struct rnode4 *,
19000Sstevel@tonic-gate 			nfs4_lock_owner_t *);
19010Sstevel@tonic-gate extern void	nfs4_flush_lock_owners(struct rnode4 *);
19020Sstevel@tonic-gate extern void nfs4_setlockowner_args(lock_owner4 *, struct rnode4 *, pid_t);
19030Sstevel@tonic-gate extern void	nfs4_set_open_seqid(seqid4, nfs4_open_owner_t *,
19040Sstevel@tonic-gate 		    nfs4_tag_type_t);
19050Sstevel@tonic-gate extern void	nfs4_set_lock_seqid(seqid4, nfs4_lock_owner_t *);
19060Sstevel@tonic-gate extern void	nfs4_get_and_set_next_open_seqid(nfs4_open_owner_t *,
19070Sstevel@tonic-gate 		    nfs4_tag_type_t);
19080Sstevel@tonic-gate extern void	nfs4_end_open_seqid_sync(nfs4_open_owner_t *);
19090Sstevel@tonic-gate extern int	nfs4_start_open_seqid_sync(nfs4_open_owner_t *, mntinfo4_t *);
19100Sstevel@tonic-gate extern void	nfs4_end_lock_seqid_sync(nfs4_lock_owner_t *);
19110Sstevel@tonic-gate extern int	nfs4_start_lock_seqid_sync(nfs4_lock_owner_t *, mntinfo4_t *);
19120Sstevel@tonic-gate extern void	nfs4_setup_lock_args(nfs4_lock_owner_t *, nfs4_open_owner_t *,
19130Sstevel@tonic-gate 			nfs4_open_stream_t *, clientid4, locker4 *);
19140Sstevel@tonic-gate extern void	nfs4_destroy_open_owner(nfs4_open_owner_t *);
19150Sstevel@tonic-gate 
19160Sstevel@tonic-gate extern void		nfs4_renew_lease_thread(nfs4_server_t *);
19170Sstevel@tonic-gate extern nfs4_server_t	*find_nfs4_server(mntinfo4_t *);
19180Sstevel@tonic-gate extern nfs4_server_t	*find_nfs4_server_all(mntinfo4_t *, int all);
19190Sstevel@tonic-gate extern nfs4_server_t	*new_nfs4_server(servinfo4_t *,	cred_t *);
19200Sstevel@tonic-gate extern void		nfs4_mark_srv_dead(nfs4_server_t *);
19210Sstevel@tonic-gate extern nfs4_server_t	*servinfo4_to_nfs4_server(servinfo4_t *);
19220Sstevel@tonic-gate extern void		nfs4_inc_state_ref_count(mntinfo4_t *);
19230Sstevel@tonic-gate extern void		nfs4_inc_state_ref_count_nolock(nfs4_server_t *,
19240Sstevel@tonic-gate 				mntinfo4_t *);
19250Sstevel@tonic-gate extern void		nfs4_dec_state_ref_count(mntinfo4_t *);
19260Sstevel@tonic-gate extern void		nfs4_dec_state_ref_count_nolock(nfs4_server_t *,
19270Sstevel@tonic-gate 				mntinfo4_t *);
19280Sstevel@tonic-gate extern clientid4	mi2clientid(mntinfo4_t *);
19290Sstevel@tonic-gate extern int		nfs4_server_in_recovery(nfs4_server_t *);
19300Sstevel@tonic-gate extern bool_t		nfs4_server_vlock(nfs4_server_t *, int);
19310Sstevel@tonic-gate extern nfs4_open_owner_t *create_open_owner(cred_t *, mntinfo4_t *);
19320Sstevel@tonic-gate extern uint64_t		nfs4_get_new_oo_name(void);
19330Sstevel@tonic-gate extern nfs4_open_owner_t *find_open_owner(cred_t *, int, mntinfo4_t *);
19340Sstevel@tonic-gate extern nfs4_open_owner_t *find_open_owner_nolock(cred_t *, int, mntinfo4_t *);
19350Sstevel@tonic-gate extern void	nfs4frlock(nfs4_lock_call_type_t, vnode_t *, int, flock64_t *,
19360Sstevel@tonic-gate 			int, u_offset_t, cred_t *, nfs4_error_t *,
19370Sstevel@tonic-gate 			nfs4_lost_rqst_t *, int *);
19380Sstevel@tonic-gate extern void	nfs4open_dg_save_lost_rqst(int, nfs4_lost_rqst_t *,
19390Sstevel@tonic-gate 		    nfs4_open_owner_t *, nfs4_open_stream_t *, cred_t *,
19400Sstevel@tonic-gate 		    vnode_t *, int, int);
19410Sstevel@tonic-gate extern void	nfs4_open_downgrade(int, int, nfs4_open_owner_t *,
19420Sstevel@tonic-gate 		    nfs4_open_stream_t *, vnode_t *, cred_t *,
19430Sstevel@tonic-gate 		    nfs4_lost_rqst_t *, nfs4_error_t *, cred_t **, seqid4 *);
19440Sstevel@tonic-gate extern seqid4	nfs4_get_open_seqid(nfs4_open_owner_t *);
19450Sstevel@tonic-gate extern cred_t	*nfs4_get_otw_cred(cred_t *, mntinfo4_t *, nfs4_open_owner_t *);
19460Sstevel@tonic-gate extern void	nfs4_init_stateid_types(nfs4_stateid_types_t *);
19470Sstevel@tonic-gate extern void	nfs4_save_stateid(stateid4 *, nfs4_stateid_types_t *);
19480Sstevel@tonic-gate 
19490Sstevel@tonic-gate extern kmutex_t nfs4_server_lst_lock;
19500Sstevel@tonic-gate 
19510Sstevel@tonic-gate extern void	nfs4callback_destroy(nfs4_server_t *);
19520Sstevel@tonic-gate extern void	nfs4_callback_init(void);
19530Sstevel@tonic-gate extern void	nfs4_callback_fini(void);
19540Sstevel@tonic-gate extern void	nfs4_cb_args(nfs4_server_t *, struct knetconfig *,
19550Sstevel@tonic-gate 			SETCLIENTID4args *);
19560Sstevel@tonic-gate extern void	nfs4delegreturn_async(struct rnode4 *, int, bool_t);
19570Sstevel@tonic-gate 
19580Sstevel@tonic-gate extern enum nfs4_delegreturn_policy nfs4_delegreturn_policy;
19590Sstevel@tonic-gate 
19600Sstevel@tonic-gate extern void	nfs4_add_mi_to_server(nfs4_server_t *, mntinfo4_t *);
19610Sstevel@tonic-gate extern void	nfs4_remove_mi_from_server(mntinfo4_t *, nfs4_server_t *);
19620Sstevel@tonic-gate extern nfs4_server_t *nfs4_move_mi(mntinfo4_t *, servinfo4_t *, servinfo4_t *);
19630Sstevel@tonic-gate extern bool_t	nfs4_fs_active(nfs4_server_t *);
19640Sstevel@tonic-gate extern void	nfs4_server_rele(nfs4_server_t *);
19650Sstevel@tonic-gate extern bool_t	inlease(nfs4_server_t *);
19660Sstevel@tonic-gate extern bool_t	nfs4_has_pages(vnode_t *);
19670Sstevel@tonic-gate extern void	nfs4_log_badowner(mntinfo4_t *, nfs_opnum4);
19680Sstevel@tonic-gate 
19690Sstevel@tonic-gate #endif /* _KERNEL */
19700Sstevel@tonic-gate 
19710Sstevel@tonic-gate /*
19720Sstevel@tonic-gate  * Client State Recovery
19730Sstevel@tonic-gate  */
19740Sstevel@tonic-gate 
19750Sstevel@tonic-gate /*
19760Sstevel@tonic-gate  * The following defines are used for rs_flags in
19770Sstevel@tonic-gate  * a nfs4_recov_state_t structure.
19780Sstevel@tonic-gate  *
19790Sstevel@tonic-gate  * NFS4_RS_RENAME_HELD		Indicates that the mi_rename_lock was held.
19800Sstevel@tonic-gate  * NFS4_RS_GRACE_MSG		Set once we have uprintf'ed a grace message.
19810Sstevel@tonic-gate  * NFS4_RS_DELAY_MSG		Set once we have uprintf'ed a delay message.
19820Sstevel@tonic-gate  * NFS4_RS_RECALL_HELD1		r_deleg_recall_lock for vp1 was held.
19830Sstevel@tonic-gate  * NFS4_RS_RECALL_HELD2		r_deleg_recall_lock for vp2 was held.
19840Sstevel@tonic-gate  */
19850Sstevel@tonic-gate #define	NFS4_RS_RENAME_HELD	0x000000001
19860Sstevel@tonic-gate #define	NFS4_RS_GRACE_MSG	0x000000002
19870Sstevel@tonic-gate #define	NFS4_RS_DELAY_MSG	0x000000004
19880Sstevel@tonic-gate #define	NFS4_RS_RECALL_HELD1	0x000000008
19890Sstevel@tonic-gate #define	NFS4_RS_RECALL_HELD2	0x000000010
19900Sstevel@tonic-gate 
19910Sstevel@tonic-gate /*
19920Sstevel@tonic-gate  * Information that is retrieved from nfs4_start_op() and that is
19930Sstevel@tonic-gate  * passed into nfs4_end_op().
19940Sstevel@tonic-gate  *
19950Sstevel@tonic-gate  * rs_sp is a reference to the nfs4_server that was found, or NULL.
19960Sstevel@tonic-gate  *
19970Sstevel@tonic-gate  * rs_num_retry_despite_err is the number times client retried an
19980Sstevel@tonic-gate  * OTW op despite a recovery error.  It is only incremented for hints
19990Sstevel@tonic-gate  * exempt to normal R4RECOVERR processing
20000Sstevel@tonic-gate  * (OH_CLOSE/OH_LOCKU/OH_DELEGRETURN).  (XXX this special-case code
20010Sstevel@tonic-gate  * needs review for possible removal.)
20020Sstevel@tonic-gate  * It is initialized wherever nfs4_recov_state_t is declared -- usually
20030Sstevel@tonic-gate  * very near initialization of rs_flags.
20040Sstevel@tonic-gate  */
20050Sstevel@tonic-gate typedef struct {
20060Sstevel@tonic-gate 	nfs4_server_t	*rs_sp;
20070Sstevel@tonic-gate 	int		rs_flags;
20080Sstevel@tonic-gate 	int		rs_num_retry_despite_err;
20090Sstevel@tonic-gate } nfs4_recov_state_t;
20100Sstevel@tonic-gate 
20110Sstevel@tonic-gate /*
20120Sstevel@tonic-gate  * Flags for nfs4_check_remap, nfs4_remap_file and nfs4_remap_root.
20130Sstevel@tonic-gate  */
20140Sstevel@tonic-gate 
20150Sstevel@tonic-gate #define	NFS4_REMAP_CKATTRS	1
20160Sstevel@tonic-gate #define	NFS4_REMAP_NEEDSOP	2
20170Sstevel@tonic-gate 
20180Sstevel@tonic-gate #ifdef _KERNEL
20190Sstevel@tonic-gate 
20200Sstevel@tonic-gate extern int	nfs4_is_otw_open_necessary(nfs4_open_owner_t *, int,
20210Sstevel@tonic-gate 			vnode_t *, int, int *, int, nfs4_recov_state_t *);
20220Sstevel@tonic-gate extern void	nfs4setclientid(struct mntinfo4 *, struct cred *, bool_t,
20230Sstevel@tonic-gate 			nfs4_error_t *);
20240Sstevel@tonic-gate extern void	nfs4_reopen(vnode_t *, nfs4_open_stream_t *, nfs4_error_t *,
20250Sstevel@tonic-gate 			open_claim_type4, bool_t, bool_t);
20260Sstevel@tonic-gate extern void	nfs4_remap_root(struct mntinfo4 *, nfs4_error_t *, int);
20270Sstevel@tonic-gate extern void	nfs4_check_remap(mntinfo4_t *mi, vnode_t *vp, int,
20280Sstevel@tonic-gate 			nfs4_error_t *);
20290Sstevel@tonic-gate extern void	nfs4_remap_file(mntinfo4_t *mi, vnode_t *vp, int,
20300Sstevel@tonic-gate 			nfs4_error_t *);
20310Sstevel@tonic-gate extern int	nfs4_make_dotdot(struct nfs4_sharedfh *, hrtime_t,
20320Sstevel@tonic-gate 			vnode_t *, cred_t *, vnode_t **, int);
20330Sstevel@tonic-gate extern void	nfs4_fail_recov(vnode_t *, char *, int, nfsstat4);
20340Sstevel@tonic-gate 
20350Sstevel@tonic-gate extern int	nfs4_needs_recovery(nfs4_error_t *, bool_t, vfs_t *);
20360Sstevel@tonic-gate extern int	nfs4_recov_marks_dead(nfsstat4);
20370Sstevel@tonic-gate extern bool_t	nfs4_start_recovery(nfs4_error_t *, struct mntinfo4 *,
20380Sstevel@tonic-gate 			vnode_t *, vnode_t *, stateid4 *,
203911291SRobert.Thurlow@Sun.COM 			nfs4_lost_rqst_t *, nfs_opnum4, nfs4_bseqid_entry_t *,
204011291SRobert.Thurlow@Sun.COM 			vnode_t *, char *);
20410Sstevel@tonic-gate extern int	nfs4_start_op(struct mntinfo4 *, vnode_t *, vnode_t *,
20420Sstevel@tonic-gate 			nfs4_recov_state_t *);
20430Sstevel@tonic-gate extern void	nfs4_end_op(struct mntinfo4 *, vnode_t *, vnode_t *,
20440Sstevel@tonic-gate 			nfs4_recov_state_t *, bool_t);
20450Sstevel@tonic-gate extern int	nfs4_start_fop(struct mntinfo4 *, vnode_t *, vnode_t *,
20460Sstevel@tonic-gate 			nfs4_op_hint_t, nfs4_recov_state_t *, bool_t *);
20470Sstevel@tonic-gate extern void	nfs4_end_fop(struct mntinfo4 *, vnode_t *, vnode_t *,
20480Sstevel@tonic-gate 				nfs4_op_hint_t, nfs4_recov_state_t *, bool_t);
20490Sstevel@tonic-gate extern char	*nfs4_recov_action_to_str(nfs4_recov_t);
20500Sstevel@tonic-gate 
20515302Sth199096 /*
20525302Sth199096  * In sequence, code desiring to unmount an ephemeral tree must
20535302Sth199096  * call nfs4_ephemeral_umount, nfs4_ephemeral_umount_activate,
20545302Sth199096  * and nfs4_ephemeral_umount_unlock. The _unlock must also be
20555302Sth199096  * called on all error paths that occur before it would naturally
20565302Sth199096  * be invoked.
20575302Sth199096  *
20585302Sth199096  * The caller must also provde a pointer to a boolean to keep track
20595302Sth199096  * of whether or not the code in _unlock is to be ran.
20605302Sth199096  */
20615302Sth199096 extern void	nfs4_ephemeral_umount_activate(mntinfo4_t *,
206211291SRobert.Thurlow@Sun.COM     bool_t *, nfs4_ephemeral_tree_t **);
20635302Sth199096 extern int	nfs4_ephemeral_umount(mntinfo4_t *, int, cred_t *,
206411291SRobert.Thurlow@Sun.COM     bool_t *, nfs4_ephemeral_tree_t **);
206511291SRobert.Thurlow@Sun.COM extern void	nfs4_ephemeral_umount_unlock(bool_t *,
20665302Sth199096     nfs4_ephemeral_tree_t **);
20675302Sth199096 
20687318SThomas.Haynes@Sun.COM extern int	nfs4_record_ephemeral_mount(mntinfo4_t *mi, vnode_t *mvp);
20695302Sth199096 
207011291SRobert.Thurlow@Sun.COM extern int	nfs4_callmapid(utf8string *, struct nfs_fsl_info *);
207111291SRobert.Thurlow@Sun.COM extern int	nfs4_fetch_locations(mntinfo4_t *, struct nfs4_sharedfh *,
207211291SRobert.Thurlow@Sun.COM     char *, cred_t *, nfs4_ga_res_t *, COMPOUND4res_clnt *, bool_t);
207311291SRobert.Thurlow@Sun.COM 
20740Sstevel@tonic-gate extern int	wait_for_recall(vnode_t *, vnode_t *, nfs4_op_hint_t,
20750Sstevel@tonic-gate 			nfs4_recov_state_t *);
20760Sstevel@tonic-gate extern void	nfs4_end_op_recall(vnode_t *, vnode_t *, nfs4_recov_state_t *);
20770Sstevel@tonic-gate extern void	nfs4_send_siglost(pid_t, mntinfo4_t *mi, vnode_t *vp, bool_t,
20780Sstevel@tonic-gate 		    int, nfsstat4);
20790Sstevel@tonic-gate extern time_t	nfs4err_delay_time;
20800Sstevel@tonic-gate extern void	nfs4_set_grace_wait(mntinfo4_t *);
20810Sstevel@tonic-gate extern void	nfs4_set_delay_wait(vnode_t *);
20820Sstevel@tonic-gate extern int	nfs4_wait_for_grace(mntinfo4_t *, nfs4_recov_state_t *);
20830Sstevel@tonic-gate extern int	nfs4_wait_for_delay(vnode_t *, nfs4_recov_state_t *);
20840Sstevel@tonic-gate extern nfs4_bseqid_entry_t *nfs4_create_bseqid_entry(nfs4_open_owner_t *,
20850Sstevel@tonic-gate 		    nfs4_lock_owner_t *, vnode_t *, pid_t, nfs4_tag_type_t,
20860Sstevel@tonic-gate 		    seqid4);
20870Sstevel@tonic-gate 
20880Sstevel@tonic-gate extern void	nfs4_resend_open_otw(vnode_t **, nfs4_lost_rqst_t *,
20890Sstevel@tonic-gate 			nfs4_error_t *);
20900Sstevel@tonic-gate extern void	nfs4_resend_delegreturn(nfs4_lost_rqst_t *, nfs4_error_t *,
20910Sstevel@tonic-gate 			nfs4_server_t *);
20920Sstevel@tonic-gate extern int	nfs4_rpc_retry_error(int);
20930Sstevel@tonic-gate extern int	nfs4_try_failover(nfs4_error_t *);
20940Sstevel@tonic-gate extern void	nfs4_free_msg(nfs4_debug_msg_t *);
20950Sstevel@tonic-gate extern void	nfs4_mnt_recov_kstat_init(vfs_t *);
20960Sstevel@tonic-gate extern void	nfs4_mi_kstat_inc_delay(mntinfo4_t *);
20970Sstevel@tonic-gate extern void	nfs4_mi_kstat_inc_no_grace(mntinfo4_t *);
20980Sstevel@tonic-gate extern char	*nfs4_stat_to_str(nfsstat4);
20990Sstevel@tonic-gate extern char	*nfs4_op_to_str(nfs_opnum4);
21000Sstevel@tonic-gate 
21010Sstevel@tonic-gate extern void	nfs4_queue_event(nfs4_event_type_t, mntinfo4_t *, char *,
21020Sstevel@tonic-gate 		    uint_t, vnode_t *, vnode_t *, nfsstat4, char *, pid_t,
21030Sstevel@tonic-gate 		    nfs4_tag_type_t, nfs4_tag_type_t, seqid4, seqid4);
21040Sstevel@tonic-gate extern void	nfs4_queue_fact(nfs4_fact_type_t, mntinfo4_t *, nfsstat4,
21050Sstevel@tonic-gate 		    nfs4_recov_t, nfs_opnum4, bool_t, char *, int, vnode_t *);
21060Sstevel@tonic-gate #pragma	rarely_called(nfs4_queue_event)
21070Sstevel@tonic-gate #pragma	rarely_called(nfs4_queue_fact)
21080Sstevel@tonic-gate 
21090Sstevel@tonic-gate /* Used for preformed "." and ".." dirents */
21100Sstevel@tonic-gate extern char	*nfs4_dot_entries;
21110Sstevel@tonic-gate extern char	*nfs4_dot_dot_entry;
21120Sstevel@tonic-gate 
21130Sstevel@tonic-gate #ifdef	DEBUG
21140Sstevel@tonic-gate extern uint_t	nfs4_tsd_key;
21150Sstevel@tonic-gate #endif
21160Sstevel@tonic-gate 
21170Sstevel@tonic-gate #endif /* _KERNEL */
21180Sstevel@tonic-gate 
21190Sstevel@tonic-gate /*
21200Sstevel@tonic-gate  * Filehandle management.
21210Sstevel@tonic-gate  *
21220Sstevel@tonic-gate  * Filehandles can change in v4, so rather than storing the filehandle
21230Sstevel@tonic-gate  * directly in the rnode, etc., we manage the filehandle through one of
21240Sstevel@tonic-gate  * these objects.
21250Sstevel@tonic-gate  * Locking: sfh_fh and sfh_tree is protected by the filesystem's
21260Sstevel@tonic-gate  * mi_fh_lock.  The reference count and flags are protected by sfh_lock.
21270Sstevel@tonic-gate  * sfh_mi is read-only.
21280Sstevel@tonic-gate  *
21290Sstevel@tonic-gate  * mntinfo4_t::mi_fh_lock > sfh_lock.
21300Sstevel@tonic-gate  */
21310Sstevel@tonic-gate 
21320Sstevel@tonic-gate typedef struct nfs4_sharedfh {
21330Sstevel@tonic-gate 	nfs_fh4 sfh_fh;			/* key and current filehandle */
21340Sstevel@tonic-gate 	kmutex_t sfh_lock;
21350Sstevel@tonic-gate 	uint_t sfh_refcnt;		/* reference count */
21360Sstevel@tonic-gate 	uint_t sfh_flags;
21370Sstevel@tonic-gate 	mntinfo4_t *sfh_mi;		/* backptr to filesystem */
21380Sstevel@tonic-gate 	avl_node_t sfh_tree;		/* used by avl package */
21390Sstevel@tonic-gate } nfs4_sharedfh_t;
21400Sstevel@tonic-gate 
21410Sstevel@tonic-gate #define	SFH4_SAME(sfh1, sfh2)	((sfh1) == (sfh2))
21420Sstevel@tonic-gate 
21430Sstevel@tonic-gate /*
21440Sstevel@tonic-gate  * Flags.
21450Sstevel@tonic-gate  */
21460Sstevel@tonic-gate #define	SFH4_IN_TREE	0x1		/* currently in an AVL tree */
21470Sstevel@tonic-gate 
21480Sstevel@tonic-gate #ifdef _KERNEL
21490Sstevel@tonic-gate 
21500Sstevel@tonic-gate extern void sfh4_createtab(avl_tree_t *);
21510Sstevel@tonic-gate extern nfs4_sharedfh_t *sfh4_get(const nfs_fh4 *, mntinfo4_t *);
21520Sstevel@tonic-gate extern nfs4_sharedfh_t *sfh4_put(const nfs_fh4 *, mntinfo4_t *,
21530Sstevel@tonic-gate 				nfs4_sharedfh_t *);
21540Sstevel@tonic-gate extern void sfh4_update(nfs4_sharedfh_t *, const nfs_fh4 *);
21550Sstevel@tonic-gate extern void sfh4_copyval(const nfs4_sharedfh_t *, nfs4_fhandle_t *);
21560Sstevel@tonic-gate extern void sfh4_hold(nfs4_sharedfh_t *);
21570Sstevel@tonic-gate extern void sfh4_rele(nfs4_sharedfh_t **);
21580Sstevel@tonic-gate extern void sfh4_printfhandle(const nfs4_sharedfh_t *);
21590Sstevel@tonic-gate 
21600Sstevel@tonic-gate #endif
21610Sstevel@tonic-gate 
21620Sstevel@tonic-gate /*
21630Sstevel@tonic-gate  * Path and file name management.
21640Sstevel@tonic-gate  *
21650Sstevel@tonic-gate  * This type stores the name of an entry in the filesystem and keeps enough
21660Sstevel@tonic-gate  * information that it can provide a complete path.  All fields are
21670Sstevel@tonic-gate  * protected by fn_lock, except for the reference count, which is managed
21680Sstevel@tonic-gate  * using atomic add/subtract.
21690Sstevel@tonic-gate  *
21707902SNagakiran.Rajashekar@Sun.COM  * Additionally shared filehandle for this fname is stored.
21717902SNagakiran.Rajashekar@Sun.COM  * Normally, fn_get() when it creates this fname stores the passed in
21727902SNagakiran.Rajashekar@Sun.COM  * shared fh in fn_sfh by doing sfh_hold. Similarly the path which
21737902SNagakiran.Rajashekar@Sun.COM  * destroys this fname releases the reference on this fh by doing sfh_rele.
21747902SNagakiran.Rajashekar@Sun.COM  *
21757902SNagakiran.Rajashekar@Sun.COM  * fn_get uses the fn_sfh to refine the comparision in cases
21767902SNagakiran.Rajashekar@Sun.COM  * where we have matched the name but have differing file handles,
21777902SNagakiran.Rajashekar@Sun.COM  * this normally happens due to
21787902SNagakiran.Rajashekar@Sun.COM  *
21797902SNagakiran.Rajashekar@Sun.COM  *	1. Server side rename of a file/directory.
21807902SNagakiran.Rajashekar@Sun.COM  *	2. Another client renaming a file/directory on the server.
21817902SNagakiran.Rajashekar@Sun.COM  *
21827902SNagakiran.Rajashekar@Sun.COM  * Differing names but same filehandle is possible as in the case of hardlinks,
21837902SNagakiran.Rajashekar@Sun.COM  * but differing filehandles with same name component will later confuse
21847902SNagakiran.Rajashekar@Sun.COM  * the client and can cause various panics.
21857902SNagakiran.Rajashekar@Sun.COM  *
21860Sstevel@tonic-gate  * Lock order: child and then parent.
21870Sstevel@tonic-gate  */
21880Sstevel@tonic-gate 
21890Sstevel@tonic-gate typedef struct nfs4_fname {
21900Sstevel@tonic-gate 	struct nfs4_fname *fn_parent;	/* parent name; null if fs root */
21910Sstevel@tonic-gate 	char *fn_name;			/* the actual name */
21920Sstevel@tonic-gate 	ssize_t fn_len;			/* strlen(fn_name) */
21930Sstevel@tonic-gate 	uint32_t fn_refcnt;		/* reference count */
21940Sstevel@tonic-gate 	kmutex_t fn_lock;
21950Sstevel@tonic-gate 	avl_node_t fn_tree;
21960Sstevel@tonic-gate 	avl_tree_t fn_children;		/* children, if any */
21978508SNagakiran.Rajashekar@Sun.COM 	nfs4_sharedfh_t *fn_sfh;	/* The fh for this fname */
21980Sstevel@tonic-gate } nfs4_fname_t;
21990Sstevel@tonic-gate 
22000Sstevel@tonic-gate #ifdef _KERNEL
22010Sstevel@tonic-gate 
22020Sstevel@tonic-gate extern vnode_t	nfs4_xattr_notsupp_vnode;
22030Sstevel@tonic-gate #define	NFS4_XATTR_DIR_NOTSUPP	&nfs4_xattr_notsupp_vnode
22040Sstevel@tonic-gate 
22057902SNagakiran.Rajashekar@Sun.COM extern nfs4_fname_t *fn_get(nfs4_fname_t *, char *, nfs4_sharedfh_t *);
22060Sstevel@tonic-gate extern void fn_hold(nfs4_fname_t *);
22070Sstevel@tonic-gate extern void fn_rele(nfs4_fname_t **);
22080Sstevel@tonic-gate extern char *fn_name(nfs4_fname_t *);
22090Sstevel@tonic-gate extern char *fn_path(nfs4_fname_t *);
22100Sstevel@tonic-gate extern void fn_move(nfs4_fname_t *, nfs4_fname_t *, char *);
22110Sstevel@tonic-gate extern nfs4_fname_t *fn_parent(nfs4_fname_t *);
22120Sstevel@tonic-gate 
221311291SRobert.Thurlow@Sun.COM /* Referral Support */
221411291SRobert.Thurlow@Sun.COM extern int nfs4_process_referral(mntinfo4_t *, nfs4_sharedfh_t *, char *,
221511291SRobert.Thurlow@Sun.COM     cred_t *, nfs4_ga_res_t *, COMPOUND4res_clnt *, struct nfs_fsl_info *);
221611291SRobert.Thurlow@Sun.COM 
22170Sstevel@tonic-gate #endif
22180Sstevel@tonic-gate 
22190Sstevel@tonic-gate /*
22200Sstevel@tonic-gate  * Per-zone data for managing client handles, included in this file for the
22210Sstevel@tonic-gate  * benefit of MDB.
22220Sstevel@tonic-gate  */
22230Sstevel@tonic-gate struct nfs4_clnt {
22240Sstevel@tonic-gate 	struct chhead	*nfscl_chtable4;
22250Sstevel@tonic-gate 	kmutex_t	nfscl_chtable4_lock;
22260Sstevel@tonic-gate 	zoneid_t	nfscl_zoneid;
22270Sstevel@tonic-gate 	list_node_t	nfscl_node;
22280Sstevel@tonic-gate 	struct clstat4	nfscl_stat;
22290Sstevel@tonic-gate };
22300Sstevel@tonic-gate 
22310Sstevel@tonic-gate #ifdef	__cplusplus
22320Sstevel@tonic-gate }
22330Sstevel@tonic-gate #endif
22340Sstevel@tonic-gate 
22350Sstevel@tonic-gate #endif /* _NFS4_CLNT_H */
2236