xref: /illumos-gate/usr/src/uts/common/nfs/nfs_clnt.h (revision e8dc3b7d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef	_NFS_NFS_CLNT_H
317c478bd9Sstevel@tonic-gate #define	_NFS_NFS_CLNT_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/utsname.h>
367c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
377c478bd9Sstevel@tonic-gate #include <sys/time.h>
387c478bd9Sstevel@tonic-gate #include <vm/page.h>
397c478bd9Sstevel@tonic-gate #include <sys/thread.h>
407c478bd9Sstevel@tonic-gate #include <nfs/rnode.h>
417c478bd9Sstevel@tonic-gate #include <sys/list.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
447c478bd9Sstevel@tonic-gate extern "C" {
457c478bd9Sstevel@tonic-gate #endif
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #define	HOSTNAMESZ	32
487c478bd9Sstevel@tonic-gate #define	ACREGMIN	3	/* min secs to hold cached file attr */
497c478bd9Sstevel@tonic-gate #define	ACREGMAX	60	/* max secs to hold cached file attr */
507c478bd9Sstevel@tonic-gate #define	ACDIRMIN	30	/* min secs to hold cached dir attr */
517c478bd9Sstevel@tonic-gate #define	ACDIRMAX	60	/* max secs to hold cached dir attr */
527c478bd9Sstevel@tonic-gate #define	ACMINMAX	3600	/* 1 hr is longest min timeout */
537c478bd9Sstevel@tonic-gate #define	ACMAXMAX	36000	/* 10 hr is longest max timeout */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #define	NFS_CALLTYPES	3	/* Lookups, Reads, Writes */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * rfscall() flags
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate #define	RFSCALL_SOFT	0x00000001	/* Do op as if fs was soft-mounted */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Fake errno passed back from rfscall to indicate transfer size adjustment
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate #define	ENFS_TRYAGAIN	999
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * The NFS specific async_reqs structure.
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate enum iotype {
727c478bd9Sstevel@tonic-gate 	NFS_READ_AHEAD,
737c478bd9Sstevel@tonic-gate 	NFS_PUTAPAGE,
747c478bd9Sstevel@tonic-gate 	NFS_PAGEIO,
757c478bd9Sstevel@tonic-gate 	NFS_READDIR,
767c478bd9Sstevel@tonic-gate 	NFS_COMMIT,
777c478bd9Sstevel@tonic-gate 	NFS_INACTIVE
787c478bd9Sstevel@tonic-gate };
797c478bd9Sstevel@tonic-gate #define	NFS_ASYNC_TYPES	(NFS_INACTIVE + 1)
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate struct nfs_async_read_req {
827c478bd9Sstevel@tonic-gate 	void (*readahead)();		/* pointer to readahead function */
837c478bd9Sstevel@tonic-gate 	u_offset_t blkoff;		/* offset in file */
847c478bd9Sstevel@tonic-gate 	struct seg *seg;		/* segment to do i/o to */
857c478bd9Sstevel@tonic-gate 	caddr_t addr;			/* address to do i/o to */
867c478bd9Sstevel@tonic-gate };
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate struct nfs_pageio_req {
897c478bd9Sstevel@tonic-gate 	int (*pageio)();		/* pointer to pageio function */
907c478bd9Sstevel@tonic-gate 	page_t *pp;			/* page list */
917c478bd9Sstevel@tonic-gate 	u_offset_t io_off;		/* offset in file */
927c478bd9Sstevel@tonic-gate 	uint_t io_len;			/* size of request */
937c478bd9Sstevel@tonic-gate 	int flags;
947c478bd9Sstevel@tonic-gate };
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate struct nfs_readdir_req {
977c478bd9Sstevel@tonic-gate 	int (*readdir)();		/* pointer to readdir function */
987c478bd9Sstevel@tonic-gate 	struct rddir_cache *rdc;	/* pointer to cache entry to fill */
997c478bd9Sstevel@tonic-gate };
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate struct nfs_commit_req {
1027c478bd9Sstevel@tonic-gate 	void (*commit)();		/* pointer to commit function */
1037c478bd9Sstevel@tonic-gate 	page_t *plist;			/* page list */
1047c478bd9Sstevel@tonic-gate 	offset3 offset;			/* starting offset */
1057c478bd9Sstevel@tonic-gate 	count3 count;			/* size of range to be commited */
1067c478bd9Sstevel@tonic-gate };
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate struct nfs_inactive_req {
1097c478bd9Sstevel@tonic-gate 	void (*inactive)();		/* pointer to inactive function */
1107c478bd9Sstevel@tonic-gate };
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate struct nfs_async_reqs {
1137c478bd9Sstevel@tonic-gate 	struct nfs_async_reqs *a_next;	/* pointer to next arg struct */
1147c478bd9Sstevel@tonic-gate #ifdef DEBUG
1157c478bd9Sstevel@tonic-gate 	kthread_t *a_queuer;		/* thread id of queueing thread */
1167c478bd9Sstevel@tonic-gate #endif
1177c478bd9Sstevel@tonic-gate 	struct vnode *a_vp;		/* vnode pointer */
1187c478bd9Sstevel@tonic-gate 	struct cred *a_cred;		/* cred pointer */
1197c478bd9Sstevel@tonic-gate 	enum iotype a_io;		/* i/o type */
1207c478bd9Sstevel@tonic-gate 	union {
1217c478bd9Sstevel@tonic-gate 		struct nfs_async_read_req a_read_args;
1227c478bd9Sstevel@tonic-gate 		struct nfs_pageio_req a_pageio_args;
1237c478bd9Sstevel@tonic-gate 		struct nfs_readdir_req a_readdir_args;
1247c478bd9Sstevel@tonic-gate 		struct nfs_commit_req a_commit_args;
1257c478bd9Sstevel@tonic-gate 		struct nfs_inactive_req a_inactive_args;
1267c478bd9Sstevel@tonic-gate 	} a_args;
1277c478bd9Sstevel@tonic-gate };
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #define	a_nfs_readahead a_args.a_read_args.readahead
1307c478bd9Sstevel@tonic-gate #define	a_nfs_blkoff a_args.a_read_args.blkoff
1317c478bd9Sstevel@tonic-gate #define	a_nfs_seg a_args.a_read_args.seg
1327c478bd9Sstevel@tonic-gate #define	a_nfs_addr a_args.a_read_args.addr
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate #define	a_nfs_putapage a_args.a_pageio_args.pageio
1357c478bd9Sstevel@tonic-gate #define	a_nfs_pageio a_args.a_pageio_args.pageio
1367c478bd9Sstevel@tonic-gate #define	a_nfs_pp a_args.a_pageio_args.pp
1377c478bd9Sstevel@tonic-gate #define	a_nfs_off a_args.a_pageio_args.io_off
1387c478bd9Sstevel@tonic-gate #define	a_nfs_len a_args.a_pageio_args.io_len
1397c478bd9Sstevel@tonic-gate #define	a_nfs_flags a_args.a_pageio_args.flags
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #define	a_nfs_readdir a_args.a_readdir_args.readdir
1427c478bd9Sstevel@tonic-gate #define	a_nfs_rdc a_args.a_readdir_args.rdc
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #define	a_nfs_commit a_args.a_commit_args.commit
1457c478bd9Sstevel@tonic-gate #define	a_nfs_plist a_args.a_commit_args.plist
1467c478bd9Sstevel@tonic-gate #define	a_nfs_offset a_args.a_commit_args.offset
1477c478bd9Sstevel@tonic-gate #define	a_nfs_count a_args.a_commit_args.count
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate #define	a_nfs_inactive a_args.a_inactive_args.inactive
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * Due to the way the address space callbacks are used to execute a delmap,
1537c478bd9Sstevel@tonic-gate  * we must keep track of how many times the same thread has called
1547c478bd9Sstevel@tonic-gate  * VOP_DELMAP()->nfs_delmap()/nfs3_delmap().  This is done by having a list of
1557c478bd9Sstevel@tonic-gate  * nfs_delmapcall_t's associated with each rnode_t.  This list is protected
1567c478bd9Sstevel@tonic-gate  * by the rnode_t's r_statelock.  The individual elements do not need to be
1577c478bd9Sstevel@tonic-gate  * protected as they will only ever be created, modified and destroyed by
1587c478bd9Sstevel@tonic-gate  * one thread (the call_id).
1597c478bd9Sstevel@tonic-gate  * See nfs_delmap()/nfs3_delmap() for further explanation.
1607c478bd9Sstevel@tonic-gate  */
1617c478bd9Sstevel@tonic-gate typedef struct nfs_delmapcall {
1627c478bd9Sstevel@tonic-gate 	kthread_t	*call_id;
1637c478bd9Sstevel@tonic-gate 	int		error;	/* error from delmap */
1647c478bd9Sstevel@tonic-gate 	list_node_t	call_node;
1657c478bd9Sstevel@tonic-gate } nfs_delmapcall_t;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate /*
1687c478bd9Sstevel@tonic-gate  * delmap address space callback args
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate typedef struct nfs_delmap_args {
1717c478bd9Sstevel@tonic-gate 	vnode_t			*vp;
1727c478bd9Sstevel@tonic-gate 	offset_t		off;
1737c478bd9Sstevel@tonic-gate 	caddr_t			addr;
1747c478bd9Sstevel@tonic-gate 	size_t			len;
1757c478bd9Sstevel@tonic-gate 	uint_t			prot;
1767c478bd9Sstevel@tonic-gate 	uint_t			maxprot;
1777c478bd9Sstevel@tonic-gate 	uint_t			flags;
1787c478bd9Sstevel@tonic-gate 	cred_t			*cr;
1797c478bd9Sstevel@tonic-gate 	nfs_delmapcall_t	*caller; /* to retrieve errors from the cb */
1807c478bd9Sstevel@tonic-gate } nfs_delmap_args_t;
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate #ifdef _KERNEL
1837c478bd9Sstevel@tonic-gate extern nfs_delmapcall_t	*nfs_init_delmapcall(void);
1847c478bd9Sstevel@tonic-gate extern void	nfs_free_delmapcall(nfs_delmapcall_t *);
1857c478bd9Sstevel@tonic-gate extern int	nfs_find_and_delete_delmapcall(rnode_t *, int *errp);
1867c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate  * The following structures, chhead and chtab,  make up the client handle
1907c478bd9Sstevel@tonic-gate  * cache.  chhead represents a quadruple(RPC program, RPC version, Protocol
1917c478bd9Sstevel@tonic-gate  * Family, and Transport).  For example, a chhead entry could represent
1927c478bd9Sstevel@tonic-gate  * NFS/V3/IPv4/TCP requests.  chhead nodes are linked together as a singly
1937c478bd9Sstevel@tonic-gate  * linked list and is referenced from chtable.
1947c478bd9Sstevel@tonic-gate  *
1957c478bd9Sstevel@tonic-gate  * chtab represents an allocated client handle bound to a particular
1967c478bd9Sstevel@tonic-gate  * quadruple. These nodes chain down from a chhead node.  chtab
1977c478bd9Sstevel@tonic-gate  * entries which are on the chain are considered free, so a thread may simply
1987c478bd9Sstevel@tonic-gate  * unlink the first node without traversing the chain.  When the thread is
1997c478bd9Sstevel@tonic-gate  * completed with its request, it puts the chtab node back on the chain.
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate typedef struct chhead {
2027c478bd9Sstevel@tonic-gate 	struct chhead *ch_next;	/* next quadruple */
2037c478bd9Sstevel@tonic-gate 	struct chtab *ch_list;	/* pointer to free client handle(s) */
2047c478bd9Sstevel@tonic-gate 	uint64_t ch_timesused;	/* times this quadruple was requested */
2057c478bd9Sstevel@tonic-gate 	rpcprog_t ch_prog;	/* RPC program number */
2067c478bd9Sstevel@tonic-gate 	rpcvers_t ch_vers;	/* RPC version number */
2077c478bd9Sstevel@tonic-gate 	dev_t ch_dev;		/* pseudo device number (i.e. /dev/udp) */
2087c478bd9Sstevel@tonic-gate 	char *ch_protofmly;	/* protocol (i.e. NC_INET, NC_LOOPBACK) */
2097c478bd9Sstevel@tonic-gate } chhead_t;
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate typedef struct chtab {
2127c478bd9Sstevel@tonic-gate 	struct chtab *ch_list;	/* next free client handle */
2137c478bd9Sstevel@tonic-gate 	struct chhead *ch_head;	/* associated quadruple */
2147c478bd9Sstevel@tonic-gate 	time_t ch_freed;	/* timestamp when freed */
2157c478bd9Sstevel@tonic-gate 	CLIENT *ch_client;	/* pointer to client handle */
2167c478bd9Sstevel@tonic-gate } chtab_t;
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate /*
2197c478bd9Sstevel@tonic-gate  * clinfo is a structure which encapsulates data that is needed to
2207c478bd9Sstevel@tonic-gate  * obtain a client handle from the cache
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate typedef struct clinfo {
2237c478bd9Sstevel@tonic-gate 	rpcprog_t cl_prog;	/* RPC program number */
2247c478bd9Sstevel@tonic-gate 	rpcvers_t cl_vers;	/* RPC version number */
2257c478bd9Sstevel@tonic-gate 	uint_t cl_readsize;	/* transfer size */
2267c478bd9Sstevel@tonic-gate 	int cl_retrans;		/* times to retry request */
2277c478bd9Sstevel@tonic-gate 	uint_t cl_flags;	/* info flags */
2287c478bd9Sstevel@tonic-gate } clinfo_t;
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate /*
2317c478bd9Sstevel@tonic-gate  * Failover information, passed opaquely through rfscall()
2327c478bd9Sstevel@tonic-gate  */
2337c478bd9Sstevel@tonic-gate typedef struct failinfo {
2347c478bd9Sstevel@tonic-gate 	struct vnode	*vp;
2357c478bd9Sstevel@tonic-gate 	caddr_t		fhp;
2367c478bd9Sstevel@tonic-gate 	void (*copyproc)(caddr_t, vnode_t *);
2377c478bd9Sstevel@tonic-gate 	int (*lookupproc)(vnode_t *, char *, vnode_t **, struct pathname *,
2387c478bd9Sstevel@tonic-gate 			int, vnode_t *, struct cred *, int);
2397c478bd9Sstevel@tonic-gate 	int (*xattrdirproc)(vnode_t *, vnode_t **, bool_t, cred_t *, int);
2407c478bd9Sstevel@tonic-gate } failinfo_t;
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate  * Static server information
2447c478bd9Sstevel@tonic-gate  *
2457c478bd9Sstevel@tonic-gate  * These fields are protected by sv_lock:
2467c478bd9Sstevel@tonic-gate  *	sv_flags
2477c478bd9Sstevel@tonic-gate  */
2487c478bd9Sstevel@tonic-gate typedef struct servinfo {
2497c478bd9Sstevel@tonic-gate 	struct knetconfig *sv_knconf;   /* bound TLI fd */
2507c478bd9Sstevel@tonic-gate 	struct knetconfig *sv_origknconf;	/* For RDMA save orig knconf */
2517c478bd9Sstevel@tonic-gate 	struct netbuf	sv_addr;	/* server's address */
2527c478bd9Sstevel@tonic-gate 	nfs_fhandle	sv_fhandle;	/* this server's filehandle */
2537c478bd9Sstevel@tonic-gate 	struct sec_data *sv_secdata;	/* security data for rpcsec module */
2547c478bd9Sstevel@tonic-gate 	char	*sv_hostname;		/* server's hostname */
2557c478bd9Sstevel@tonic-gate 	int	sv_hostnamelen;		/* server's hostname length */
2567c478bd9Sstevel@tonic-gate 	uint_t	sv_flags;		/* see below */
2577c478bd9Sstevel@tonic-gate 	struct servinfo	*sv_next;	/* next in list */
2587c478bd9Sstevel@tonic-gate 	kmutex_t sv_lock;
2597c478bd9Sstevel@tonic-gate } servinfo_t;
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate /*
2627c478bd9Sstevel@tonic-gate  * The values for sv_flags.
2637c478bd9Sstevel@tonic-gate  */
2647c478bd9Sstevel@tonic-gate #define	SV_ROOT_STALE	0x1		/* root vnode got ESTALE */
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate /*
2677c478bd9Sstevel@tonic-gate  * Switch from RDMA knconf to original mount knconf
2687c478bd9Sstevel@tonic-gate  */
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate #define	ORIG_KNCONF(mi) (mi->mi_curr_serv->sv_origknconf ? \
2717c478bd9Sstevel@tonic-gate 	mi->mi_curr_serv->sv_origknconf : mi->mi_curr_serv->sv_knconf)
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate /*
2747c478bd9Sstevel@tonic-gate  * NFS private data per mounted file system
2757c478bd9Sstevel@tonic-gate  *	The mi_lock mutex protects the following fields:
2767c478bd9Sstevel@tonic-gate  *		mi_flags
2777c478bd9Sstevel@tonic-gate  *		mi_printed
2787c478bd9Sstevel@tonic-gate  *		mi_down
2797c478bd9Sstevel@tonic-gate  *		mi_tsize
2807c478bd9Sstevel@tonic-gate  *		mi_stsize
2817c478bd9Sstevel@tonic-gate  *		mi_curread
2827c478bd9Sstevel@tonic-gate  *		mi_curwrite
2837c478bd9Sstevel@tonic-gate  *		mi_timers
2847c478bd9Sstevel@tonic-gate  *		mi_curr_serv
2857c478bd9Sstevel@tonic-gate  *		mi_readers
2867c478bd9Sstevel@tonic-gate  *		mi_klmconfig
2877c478bd9Sstevel@tonic-gate  *
2887c478bd9Sstevel@tonic-gate  *	The mi_async_lock mutex protects the following fields:
2897c478bd9Sstevel@tonic-gate  *		mi_async_reqs
2907c478bd9Sstevel@tonic-gate  *		mi_async_req_count
2917c478bd9Sstevel@tonic-gate  *		mi_async_tail
2927c478bd9Sstevel@tonic-gate  *		mi_async_curr
2937c478bd9Sstevel@tonic-gate  *		mi_async_clusters
2947c478bd9Sstevel@tonic-gate  *		mi_async_init_clusters
2957c478bd9Sstevel@tonic-gate  *		mi_threads
2967c478bd9Sstevel@tonic-gate  *		mi_manager_thread
2977c478bd9Sstevel@tonic-gate  *
2987c478bd9Sstevel@tonic-gate  *	Normally the netconfig information for the mount comes from
2997c478bd9Sstevel@tonic-gate  *	mi_curr_serv and mi_klmconfig is NULL.  If NLM calls need to use a
3007c478bd9Sstevel@tonic-gate  *	different transport, mi_klmconfig contains the necessary netconfig
3017c478bd9Sstevel@tonic-gate  *	information.
3027c478bd9Sstevel@tonic-gate  *
3037c478bd9Sstevel@tonic-gate  *	'mi_zone' is initialized at structure creation time, and never
3047c478bd9Sstevel@tonic-gate  *	changes; it may be read without a lock.
3057c478bd9Sstevel@tonic-gate  *
3067c478bd9Sstevel@tonic-gate  *	mi_zone_node is linkage into the mi4_globals.mig_list, and is
3077c478bd9Sstevel@tonic-gate  *	protected by mi4_globals.mig_list_lock.
3087c478bd9Sstevel@tonic-gate  *
3097c478bd9Sstevel@tonic-gate  *	Locking order:
3107c478bd9Sstevel@tonic-gate  *	  mi_globals::mig_lock > mi_async_lock > mi_lock
3117c478bd9Sstevel@tonic-gate  */
3127c478bd9Sstevel@tonic-gate typedef struct mntinfo {
3137c478bd9Sstevel@tonic-gate 	kmutex_t	mi_lock;	/* protects mntinfo fields */
3147c478bd9Sstevel@tonic-gate 	struct servinfo *mi_servers;    /* server list */
3157c478bd9Sstevel@tonic-gate 	struct servinfo *mi_curr_serv;  /* current server */
3167c478bd9Sstevel@tonic-gate 	kcondvar_t	mi_failover_cv;	/* failover synchronization */
3177c478bd9Sstevel@tonic-gate 	int		mi_readers;	/* failover - users of mi_curr_serv */
3187c478bd9Sstevel@tonic-gate 	struct vfs	*mi_vfsp;	/* back pointer to vfs */
3197c478bd9Sstevel@tonic-gate 	enum vtype	mi_type;	/* file type of the root vnode */
3207c478bd9Sstevel@tonic-gate 	uint_t		mi_flags;	/* see below */
3217c478bd9Sstevel@tonic-gate 	uint_t		mi_tsize;	/* max read transfer size (bytes) */
3227c478bd9Sstevel@tonic-gate 	uint_t		mi_stsize;	/* max write transfer size (bytes) */
3237c478bd9Sstevel@tonic-gate 	int		mi_timeo;	/* inital timeout in 10th sec */
3247c478bd9Sstevel@tonic-gate 	int		mi_retrans;	/* times to retry request */
3257c478bd9Sstevel@tonic-gate 	hrtime_t	mi_acregmin;	/* min time to hold cached file attr */
3267c478bd9Sstevel@tonic-gate 	hrtime_t	mi_acregmax;	/* max time to hold cached file attr */
3277c478bd9Sstevel@tonic-gate 	hrtime_t	mi_acdirmin;	/* min time to hold cached dir attr */
3287c478bd9Sstevel@tonic-gate 	hrtime_t	mi_acdirmax;	/* max time to hold cached dir attr */
3297c478bd9Sstevel@tonic-gate 	len_t		mi_maxfilesize; /* for pathconf _PC_FILESIZEBITS */
3307c478bd9Sstevel@tonic-gate 	/*
3317c478bd9Sstevel@tonic-gate 	 * Extra fields for congestion control, one per NFS call type,
3327c478bd9Sstevel@tonic-gate 	 * plus one global one.
3337c478bd9Sstevel@tonic-gate 	 */
3347c478bd9Sstevel@tonic-gate 	struct rpc_timers mi_timers[NFS_CALLTYPES+1];
3357c478bd9Sstevel@tonic-gate 	int		mi_curread;	/* current read size */
3367c478bd9Sstevel@tonic-gate 	int		mi_curwrite;	/* current write size */
3377c478bd9Sstevel@tonic-gate 	/*
3387c478bd9Sstevel@tonic-gate 	 * async I/O management
3397c478bd9Sstevel@tonic-gate 	 */
3407c478bd9Sstevel@tonic-gate 	struct nfs_async_reqs *mi_async_reqs[NFS_ASYNC_TYPES];
3417c478bd9Sstevel@tonic-gate 	struct nfs_async_reqs *mi_async_tail[NFS_ASYNC_TYPES];
3427c478bd9Sstevel@tonic-gate 	struct nfs_async_reqs **mi_async_curr;	/* current async queue */
3437c478bd9Sstevel@tonic-gate 	uint_t		mi_async_clusters[NFS_ASYNC_TYPES];
3447c478bd9Sstevel@tonic-gate 	uint_t		mi_async_init_clusters;
3457c478bd9Sstevel@tonic-gate 	uint_t		mi_async_req_count; /* # outstanding work requests */
3467c478bd9Sstevel@tonic-gate 	kcondvar_t	mi_async_reqs_cv; /* signaled when there's work */
3477c478bd9Sstevel@tonic-gate 	ushort_t	mi_threads;	/* number of active async threads */
3487c478bd9Sstevel@tonic-gate 	ushort_t	mi_max_threads;	/* max number of async worker threads */
3497c478bd9Sstevel@tonic-gate 	kthread_t	*mi_manager_thread;  /* async manager thread */
3507c478bd9Sstevel@tonic-gate 	kcondvar_t	mi_async_cv; /* signaled when the last worker dies */
3517c478bd9Sstevel@tonic-gate 	kcondvar_t	mi_async_work_cv; /* tell workers to work */
3527c478bd9Sstevel@tonic-gate 	kmutex_t	mi_async_lock;	/* lock to protect async list */
3537c478bd9Sstevel@tonic-gate 	/*
3547c478bd9Sstevel@tonic-gate 	 * Other stuff
3557c478bd9Sstevel@tonic-gate 	 */
3567c478bd9Sstevel@tonic-gate 	struct pathcnf *mi_pathconf;	/* static pathconf kludge */
3577c478bd9Sstevel@tonic-gate 	rpcprog_t	mi_prog;	/* RPC program number */
3587c478bd9Sstevel@tonic-gate 	rpcvers_t	mi_vers;	/* RPC program version number */
3597c478bd9Sstevel@tonic-gate 	char		**mi_rfsnames;	/* mapping to proc names */
3607c478bd9Sstevel@tonic-gate 	kstat_named_t	*mi_reqs;	/* count of requests */
3617c478bd9Sstevel@tonic-gate 	uchar_t		*mi_call_type;	/* dynamic retrans call types */
3627c478bd9Sstevel@tonic-gate 	uchar_t		*mi_ss_call_type;	/* semisoft call type */
3637c478bd9Sstevel@tonic-gate 	uchar_t		*mi_timer_type;	/* dynamic retrans timer types */
3647c478bd9Sstevel@tonic-gate 	clock_t		mi_printftime;	/* last error printf time */
3657c478bd9Sstevel@tonic-gate 	/*
3667c478bd9Sstevel@tonic-gate 	 * ACL entries
3677c478bd9Sstevel@tonic-gate 	 */
3687c478bd9Sstevel@tonic-gate 	char		**mi_aclnames;	/* mapping to proc names */
3697c478bd9Sstevel@tonic-gate 	kstat_named_t	*mi_aclreqs;	/* count of acl requests */
3707c478bd9Sstevel@tonic-gate 	uchar_t		*mi_acl_call_type; /* dynamic retrans call types */
3717c478bd9Sstevel@tonic-gate 	uchar_t		*mi_acl_ss_call_type; /* semisoft call types */
3727c478bd9Sstevel@tonic-gate 	uchar_t		*mi_acl_timer_type; /* dynamic retrans timer types */
3737c478bd9Sstevel@tonic-gate 	/*
3747c478bd9Sstevel@tonic-gate 	 * Client Side Failover stats
3757c478bd9Sstevel@tonic-gate 	 */
3767c478bd9Sstevel@tonic-gate 	uint_t		mi_noresponse;	/* server not responding count */
3777c478bd9Sstevel@tonic-gate 	uint_t		mi_failover; 	/* failover to new server count */
3787c478bd9Sstevel@tonic-gate 	uint_t		mi_remap;	/* remap to new server count */
3797c478bd9Sstevel@tonic-gate 	/*
3807c478bd9Sstevel@tonic-gate 	 * Kstat statistics
3817c478bd9Sstevel@tonic-gate 	 */
3827c478bd9Sstevel@tonic-gate 	struct kstat	*mi_io_kstats;
3837c478bd9Sstevel@tonic-gate 	struct kstat	*mi_ro_kstats;
3847c478bd9Sstevel@tonic-gate 	struct knetconfig *mi_klmconfig;
3857c478bd9Sstevel@tonic-gate 	/*
3867c478bd9Sstevel@tonic-gate 	 * Zones support.
3877c478bd9Sstevel@tonic-gate 	 */
3887c478bd9Sstevel@tonic-gate 	struct zone	*mi_zone;	/* Zone mounted in */
3897c478bd9Sstevel@tonic-gate 	list_node_t	mi_zone_node;	/* Linkage into per-zone mi list */
390*e8dc3b7dSvv149972 	/*
391*e8dc3b7dSvv149972 	 * Serializes threads in failover_remap.
392*e8dc3b7dSvv149972 	 * Need to acquire this lock first in failover_remap() function
393*e8dc3b7dSvv149972 	 * before acquiring any other rnode lock.
394*e8dc3b7dSvv149972 	 */
395*e8dc3b7dSvv149972 	kmutex_t	mi_remap_lock;
3967c478bd9Sstevel@tonic-gate } mntinfo_t;
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate /*
3997c478bd9Sstevel@tonic-gate  * vfs pointer to mount info
4007c478bd9Sstevel@tonic-gate  */
4017c478bd9Sstevel@tonic-gate #define	VFTOMI(vfsp)	((mntinfo_t *)((vfsp)->vfs_data))
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate /*
4047c478bd9Sstevel@tonic-gate  * vnode pointer to mount info
4057c478bd9Sstevel@tonic-gate  */
4067c478bd9Sstevel@tonic-gate #define	VTOMI(vp)	((mntinfo_t *)(((vp)->v_vfsp)->vfs_data))
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /*
4097c478bd9Sstevel@tonic-gate  * The values for mi_flags.
4107c478bd9Sstevel@tonic-gate  */
4117c478bd9Sstevel@tonic-gate #define	MI_HARD		0x1		/* hard or soft mount */
4127c478bd9Sstevel@tonic-gate #define	MI_PRINTED	0x2		/* not responding message printed */
4137c478bd9Sstevel@tonic-gate #define	MI_INT		0x4		/* interrupts allowed on hard mount */
4147c478bd9Sstevel@tonic-gate #define	MI_DOWN		0x8		/* server is down */
4157c478bd9Sstevel@tonic-gate #define	MI_NOAC		0x10		/* don't cache attributes */
4167c478bd9Sstevel@tonic-gate #define	MI_NOCTO	0x20		/* no close-to-open consistency */
4177c478bd9Sstevel@tonic-gate #define	MI_DYNAMIC	0x40		/* dynamic transfer size adjustment */
4187c478bd9Sstevel@tonic-gate #define	MI_LLOCK	0x80		/* local locking only (no lockmgr) */
4197c478bd9Sstevel@tonic-gate #define	MI_GRPID	0x100		/* System V group id inheritance */
4207c478bd9Sstevel@tonic-gate #define	MI_RPCTIMESYNC	0x200		/* RPC time sync */
4217c478bd9Sstevel@tonic-gate #define	MI_LINK		0x400		/* server supports link */
4227c478bd9Sstevel@tonic-gate #define	MI_SYMLINK	0x800		/* server supports symlink */
4237c478bd9Sstevel@tonic-gate #define	MI_READDIRONLY	0x1000		/* use readdir instead of readdirplus */
4247c478bd9Sstevel@tonic-gate #define	MI_ACL		0x2000		/* server supports NFS_ACL */
4257c478bd9Sstevel@tonic-gate #define	MI_BINDINPROG	0x4000		/* binding to server is changing */
4267c478bd9Sstevel@tonic-gate #define	MI_LOOPBACK	0x8000		/* Set if this is a loopback mount */
4277c478bd9Sstevel@tonic-gate #define	MI_SEMISOFT	0x10000		/* soft reads, hard modify */
4287c478bd9Sstevel@tonic-gate #define	MI_NOPRINT	0x20000		/* don't print messages */
4297c478bd9Sstevel@tonic-gate #define	MI_DIRECTIO	0x40000		/* do direct I/O */
4307c478bd9Sstevel@tonic-gate #define	MI_EXTATTR	0x80000		/* server supports extended attrs */
4317c478bd9Sstevel@tonic-gate #define	MI_ASYNC_MGR_STOP	0x100000	/* tell async mgr to die */
4323fd6cc29Sthurlow #define	MI_DEAD		0x200000	/* mount has been terminated */
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate /*
4357c478bd9Sstevel@tonic-gate  * Read-only mntinfo statistics
4367c478bd9Sstevel@tonic-gate  */
4377c478bd9Sstevel@tonic-gate struct mntinfo_kstat {
4387c478bd9Sstevel@tonic-gate 	char		mik_proto[KNC_STRSIZE];
4397c478bd9Sstevel@tonic-gate 	uint32_t	mik_vers;
4407c478bd9Sstevel@tonic-gate 	uint_t		mik_flags;
4417c478bd9Sstevel@tonic-gate 	uint_t		mik_secmod;
4427c478bd9Sstevel@tonic-gate 	uint32_t	mik_curread;
4437c478bd9Sstevel@tonic-gate 	uint32_t	mik_curwrite;
4447c478bd9Sstevel@tonic-gate 	int		mik_timeo;
4457c478bd9Sstevel@tonic-gate 	int		mik_retrans;
4467c478bd9Sstevel@tonic-gate 	uint_t		mik_acregmin;
4477c478bd9Sstevel@tonic-gate 	uint_t		mik_acregmax;
4487c478bd9Sstevel@tonic-gate 	uint_t		mik_acdirmin;
4497c478bd9Sstevel@tonic-gate 	uint_t		mik_acdirmax;
4507c478bd9Sstevel@tonic-gate 	struct {
4517c478bd9Sstevel@tonic-gate 		uint32_t srtt;
4527c478bd9Sstevel@tonic-gate 		uint32_t deviate;
4537c478bd9Sstevel@tonic-gate 		uint32_t rtxcur;
4547c478bd9Sstevel@tonic-gate 	} mik_timers[NFS_CALLTYPES+1];
4557c478bd9Sstevel@tonic-gate 	uint32_t	mik_noresponse;
4567c478bd9Sstevel@tonic-gate 	uint32_t	mik_failover;
4577c478bd9Sstevel@tonic-gate 	uint32_t	mik_remap;
4587c478bd9Sstevel@tonic-gate 	char		mik_curserver[SYS_NMLN];
4597c478bd9Sstevel@tonic-gate };
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate /*
4627c478bd9Sstevel@tonic-gate  * Mark cached attributes as timed out
4637c478bd9Sstevel@tonic-gate  *
4647c478bd9Sstevel@tonic-gate  * The caller must not be holding the rnode r_statelock mutex.
4657c478bd9Sstevel@tonic-gate  */
4667c478bd9Sstevel@tonic-gate #define	PURGE_ATTRCACHE(vp)	{				\
4677c478bd9Sstevel@tonic-gate 	rnode_t *rp = VTOR(vp);					\
4687c478bd9Sstevel@tonic-gate 	mutex_enter(&rp->r_statelock);				\
4697c478bd9Sstevel@tonic-gate 	PURGE_ATTRCACHE_LOCKED(rp);				\
4707c478bd9Sstevel@tonic-gate 	mutex_exit(&rp->r_statelock);				\
4717c478bd9Sstevel@tonic-gate }
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate #define	PURGE_ATTRCACHE_LOCKED(rp)	{			\
4747c478bd9Sstevel@tonic-gate 	ASSERT(MUTEX_HELD(&rp->r_statelock));			\
4757c478bd9Sstevel@tonic-gate 	rp->r_attrtime = gethrtime();				\
4767c478bd9Sstevel@tonic-gate 	rp->r_mtime = rp->r_attrtime;				\
4777c478bd9Sstevel@tonic-gate }
4787c478bd9Sstevel@tonic-gate 
4797c478bd9Sstevel@tonic-gate /*
4807c478bd9Sstevel@tonic-gate  * Is the attribute cache valid?
4817c478bd9Sstevel@tonic-gate  */
4827c478bd9Sstevel@tonic-gate #define	ATTRCACHE_VALID(vp)	(gethrtime() < VTOR(vp)->r_attrtime)
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate /*
4857c478bd9Sstevel@tonic-gate  * Flags to indicate whether to purge the DNLC for non-directory vnodes
4867c478bd9Sstevel@tonic-gate  * in a call to nfs_purge_caches.
4877c478bd9Sstevel@tonic-gate  */
4887c478bd9Sstevel@tonic-gate #define	NFS_NOPURGE_DNLC	0
4897c478bd9Sstevel@tonic-gate #define	NFS_PURGE_DNLC		1
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate /*
4927c478bd9Sstevel@tonic-gate  * If returned error is ESTALE flush all caches.
4937c478bd9Sstevel@tonic-gate  */
4947c478bd9Sstevel@tonic-gate #define	PURGE_STALE_FH(error, vp, cr)				\
4957c478bd9Sstevel@tonic-gate 	if ((error) == ESTALE) {				\
4967c478bd9Sstevel@tonic-gate 		struct rnode *rp = VTOR(vp);			\
4977c478bd9Sstevel@tonic-gate 		if (vp->v_flag & VROOT) {			\
4987c478bd9Sstevel@tonic-gate 			servinfo_t *svp = rp->r_server;		\
4997c478bd9Sstevel@tonic-gate 			mutex_enter(&svp->sv_lock);		\
5007c478bd9Sstevel@tonic-gate 			svp->sv_flags |= SV_ROOT_STALE;		\
5017c478bd9Sstevel@tonic-gate 			mutex_exit(&svp->sv_lock);		\
5027c478bd9Sstevel@tonic-gate 		}						\
5037c478bd9Sstevel@tonic-gate 		mutex_enter(&rp->r_statelock);			\
5047c478bd9Sstevel@tonic-gate 		rp->r_flags |= RSTALE;				\
5057c478bd9Sstevel@tonic-gate 		if (!rp->r_error)				\
5067c478bd9Sstevel@tonic-gate 			rp->r_error = (error);			\
5077c478bd9Sstevel@tonic-gate 		mutex_exit(&rp->r_statelock);			\
5087c478bd9Sstevel@tonic-gate 		if (vn_has_cached_data(vp))			\
5097c478bd9Sstevel@tonic-gate 			nfs_invalidate_pages((vp), (u_offset_t)0, (cr)); \
5107c478bd9Sstevel@tonic-gate 		nfs_purge_caches((vp), NFS_PURGE_DNLC, (cr));	\
5117c478bd9Sstevel@tonic-gate 	}
5127c478bd9Sstevel@tonic-gate 
5137c478bd9Sstevel@tonic-gate /*
5147c478bd9Sstevel@tonic-gate  * Is cache valid?
5157c478bd9Sstevel@tonic-gate  * Swap is always valid, if no attributes (attrtime == 0) or
5167c478bd9Sstevel@tonic-gate  * if mtime matches cached mtime it is valid
5177c478bd9Sstevel@tonic-gate  * NOTE: mtime is now a timestruc_t.
5187c478bd9Sstevel@tonic-gate  * Caller should be holding the rnode r_statelock mutex.
5197c478bd9Sstevel@tonic-gate  */
5207c478bd9Sstevel@tonic-gate #define	CACHE_VALID(rp, mtime, fsize)				\
5217c478bd9Sstevel@tonic-gate 	((RTOV(rp)->v_flag & VISSWAP) == VISSWAP ||		\
5227c478bd9Sstevel@tonic-gate 	(((mtime).tv_sec == (rp)->r_attr.va_mtime.tv_sec &&	\
5237c478bd9Sstevel@tonic-gate 	(mtime).tv_nsec == (rp)->r_attr.va_mtime.tv_nsec) &&	\
5247c478bd9Sstevel@tonic-gate 	((fsize) == (rp)->r_attr.va_size)))
5257c478bd9Sstevel@tonic-gate 
5267c478bd9Sstevel@tonic-gate /*
5277c478bd9Sstevel@tonic-gate  * Macro to detect forced unmount or a zone shutdown.
5287c478bd9Sstevel@tonic-gate  */
5297c478bd9Sstevel@tonic-gate #define	FS_OR_ZONE_GONE(vfsp) \
5307c478bd9Sstevel@tonic-gate 	(((vfsp)->vfs_flag & VFS_UNMOUNTED) || \
5317c478bd9Sstevel@tonic-gate 	zone_status_get(curproc->p_zone) >= ZONE_IS_SHUTTING_DOWN)
5327c478bd9Sstevel@tonic-gate 
5337c478bd9Sstevel@tonic-gate /*
5347c478bd9Sstevel@tonic-gate  * Convert NFS tunables to hrtime_t units, seconds to nanoseconds.
5357c478bd9Sstevel@tonic-gate  */
5367c478bd9Sstevel@tonic-gate #define	SEC2HR(sec)	((sec) * (long long)NANOSEC)
5377c478bd9Sstevel@tonic-gate #define	HR2SEC(hr)	((hr) / (long long)NANOSEC)
5387c478bd9Sstevel@tonic-gate 
5397c478bd9Sstevel@tonic-gate /*
5407c478bd9Sstevel@tonic-gate  * Structure to identify owner of a PC file share reservation.
5417c478bd9Sstevel@tonic-gate  */
5427c478bd9Sstevel@tonic-gate struct nfs_owner {
5437c478bd9Sstevel@tonic-gate 	int	magic;		/* magic uniquifying number */
5447c478bd9Sstevel@tonic-gate 	char	hname[16];	/* first 16 bytes of hostname */
5457c478bd9Sstevel@tonic-gate 	char	lowner[8];	/* local owner from fcntl */
5467c478bd9Sstevel@tonic-gate };
5477c478bd9Sstevel@tonic-gate 
5487c478bd9Sstevel@tonic-gate /*
5497c478bd9Sstevel@tonic-gate  * Values for magic.
5507c478bd9Sstevel@tonic-gate  */
5517c478bd9Sstevel@tonic-gate #define	NFS_OWNER_MAGIC	0x1D81E
5527c478bd9Sstevel@tonic-gate 
5537c478bd9Sstevel@tonic-gate /*
5547c478bd9Sstevel@tonic-gate  * Support for extended attributes
5557c478bd9Sstevel@tonic-gate  */
5567c478bd9Sstevel@tonic-gate #define	XATTR_DIR_NAME	"/@/"		/* used for DNLC entries */
5577c478bd9Sstevel@tonic-gate #define	XATTR_RPATH	"ExTaTtR"	/* used for r_path for failover */
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate /*
5607c478bd9Sstevel@tonic-gate  * Short hand for checking to see whether the file system was mounted
5617c478bd9Sstevel@tonic-gate  * interruptible or not.
5627c478bd9Sstevel@tonic-gate  */
5637c478bd9Sstevel@tonic-gate #define	INTR(vp)	(VTOMI(vp)->mi_flags & MI_INT)
5647c478bd9Sstevel@tonic-gate 
5657c478bd9Sstevel@tonic-gate /*
5667c478bd9Sstevel@tonic-gate  * Short hand for checking whether failover is enabled or not
5677c478bd9Sstevel@tonic-gate  */
5687c478bd9Sstevel@tonic-gate #define	FAILOVER_MOUNT(mi)	(mi->mi_servers->sv_next)
5697c478bd9Sstevel@tonic-gate 
5707c478bd9Sstevel@tonic-gate /*
5717c478bd9Sstevel@tonic-gate  * How long will async threads wait for additional work.
5727c478bd9Sstevel@tonic-gate  */
5737c478bd9Sstevel@tonic-gate #define	NFS_ASYNC_TIMEOUT	(60 * 1 * hz)	/* 1 minute */
5747c478bd9Sstevel@tonic-gate 
5757c478bd9Sstevel@tonic-gate #ifdef _KERNEL
5767c478bd9Sstevel@tonic-gate extern int	clget(clinfo_t *, servinfo_t *, cred_t *, CLIENT **,
5777c478bd9Sstevel@tonic-gate 		    struct chtab **);
5787c478bd9Sstevel@tonic-gate extern void	clfree(CLIENT *, struct chtab *);
5797c478bd9Sstevel@tonic-gate extern void	nfs_mi_zonelist_add(mntinfo_t *);
5807c478bd9Sstevel@tonic-gate extern void	nfs_free_mi(mntinfo_t *);
5817c478bd9Sstevel@tonic-gate extern void	nfs_mnt_kstat_init(struct vfs *);
5827c478bd9Sstevel@tonic-gate #endif
5837c478bd9Sstevel@tonic-gate 
5847c478bd9Sstevel@tonic-gate /*
5857c478bd9Sstevel@tonic-gate  * Per-zone data for managing client handles.  Included here solely for the
5867c478bd9Sstevel@tonic-gate  * benefit of MDB.
5877c478bd9Sstevel@tonic-gate  */
5887c478bd9Sstevel@tonic-gate /*
5897c478bd9Sstevel@tonic-gate  * client side statistics
5907c478bd9Sstevel@tonic-gate  */
5917c478bd9Sstevel@tonic-gate struct clstat {
5927c478bd9Sstevel@tonic-gate 	kstat_named_t	calls;			/* client requests */
5937c478bd9Sstevel@tonic-gate 	kstat_named_t	badcalls;		/* rpc failures */
5947c478bd9Sstevel@tonic-gate 	kstat_named_t	clgets;			/* client handle gets */
5957c478bd9Sstevel@tonic-gate 	kstat_named_t	cltoomany;		/* client handle cache misses */
5967c478bd9Sstevel@tonic-gate #ifdef DEBUG
5977c478bd9Sstevel@tonic-gate 	kstat_named_t	clalloc;		/* number of client handles */
5987c478bd9Sstevel@tonic-gate 	kstat_named_t	noresponse;		/* server not responding cnt */
5997c478bd9Sstevel@tonic-gate 	kstat_named_t	failover;		/* server failover count */
6007c478bd9Sstevel@tonic-gate 	kstat_named_t	remap;			/* server remap count */
6017c478bd9Sstevel@tonic-gate #endif
6027c478bd9Sstevel@tonic-gate };
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate struct nfs_clnt {
6057c478bd9Sstevel@tonic-gate 	struct chhead	*nfscl_chtable;
6067c478bd9Sstevel@tonic-gate 	kmutex_t	nfscl_chtable_lock;
6077c478bd9Sstevel@tonic-gate 	zoneid_t	nfscl_zoneid;
6087c478bd9Sstevel@tonic-gate 	list_node_t	nfscl_node;
6097c478bd9Sstevel@tonic-gate 	struct clstat	nfscl_stat;
6107c478bd9Sstevel@tonic-gate };
6117c478bd9Sstevel@tonic-gate 
6127c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6137c478bd9Sstevel@tonic-gate }
6147c478bd9Sstevel@tonic-gate #endif
6157c478bd9Sstevel@tonic-gate 
6167c478bd9Sstevel@tonic-gate #endif	/* _NFS_NFS_CLNT_H */
617