--- old/usr/src/uts/common/nfs/nfs.h	Mon Aug  5 17:32:41 2019
+++ new/usr/src/uts/common/nfs/nfs.h	Mon Aug  5 17:32:41 2019
@@ -20,19 +20,20 @@
  */
 
 /*
- * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013 by Delphix. All rights reserved.
  */
 
 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved	*/
 
+/*
+ * Copyright 2018 Nexenta Systems, Inc.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
+ */
+
 #ifndef	_NFS_NFS_H
 #define	_NFS_NFS_H
 
-/*	nfs.h 2.38 88/08/19 SMI 	*/
-
 #include <sys/isa_defs.h>
 #include <sys/vfs.h>
 #include <sys/stream.h>
@@ -72,10 +73,36 @@
 #define	NFS_VERSMIN_DEFAULT	((rpcvers_t)2)
 #define	NFS_VERSMAX_DEFAULT	((rpcvers_t)4)
 
-extern rpcvers_t nfs_versmin;
-extern rpcvers_t nfs_versmax;
+/*
+ * Used to track the state of the server so that initialization
+ * can be done properly.
+ */
+typedef enum {
+	NFS_SERVER_STOPPED,	/* server state destroyed */
+	NFS_SERVER_STOPPING,	/* server state being destroyed */
+	NFS_SERVER_RUNNING,
+	NFS_SERVER_QUIESCED,	/* server state preserved */
+	NFS_SERVER_OFFLINE	/* server pool offline */
+} nfs_server_running_t;
 
 /*
+ * Zone globals variables of NFS server
+ */
+typedef struct nfs_globals {
+	rpcvers_t		nfs_versmin;
+	rpcvers_t		nfs_versmax;
+
+	/* NFS server locks and state */
+	nfs_server_running_t	nfs_server_upordown;
+	kmutex_t		nfs_server_upordown_lock;
+	kcondvar_t		nfs_server_upordown_cv;
+
+	/* RDMA wait variables */
+	kcondvar_t		rdma_wait_cv;
+	kmutex_t		rdma_wait_mutex;
+} nfs_globals_t;
+
+/*
  * Default delegation setting for the server ==> "on"
  */
 #define	NFS_SERVER_DELEGATION_DEFAULT	(TRUE)
@@ -243,7 +270,7 @@
  */
 #ifdef _KERNEL
 
-extern bool_t		nfs_allow_preepoch_time;
+extern volatile bool_t	nfs_allow_preepoch_time;
 
 #ifdef _LP64
 
@@ -615,13 +642,25 @@
 };
 
 /*
+ * Entry structure
+ */
+struct nfsentry {
+	uint32_t fileid;
+	char *name;
+	uint32_t cookie;
+	struct nfsentry *nextentry;
+};
+
+/*
  * NFS_OK part of readdir result
  */
 struct nfsrdok {
+	struct nfsentry *rdok_entries;	/* variable number of entries */
+	bool_t rdok_eof;		/* true if last entry is in result */
+
 	uint32_t rdok_offset;		/* next offset (opaque) */
 	uint32_t rdok_size;		/* size in bytes of entries */
-	bool_t	rdok_eof;		/* true if last entry is in result */
-	struct dirent64 *rdok_entries;	/* variable number of entries */
+	struct dirent64 *rdok_dirents;	/* variable number of entries */
 };
 
 /*
@@ -629,16 +668,17 @@
  */
 struct nfsrddirres {
 	nfsstat	rd_status;
-	uint_t		rd_bufsize;	/* client request size (not xdr'ed) */
 	union {
 		struct nfsrdok rd_rdok_u;
 	} rd_u;
 };
 #define	rd_rdok		rd_u.rd_rdok_u
+#define	rd_entries	rd_u.rd_rdok_u.rdok_entries
+#define	rd_eof		rd_u.rd_rdok_u.rdok_eof
+
 #define	rd_offset	rd_u.rd_rdok_u.rdok_offset
 #define	rd_size		rd_u.rd_rdok_u.rdok_size
-#define	rd_eof		rd_u.rd_rdok_u.rdok_eof
-#define	rd_entries	rd_u.rd_rdok_u.rdok_entries
+#define	rd_dirents	rd_u.rd_rdok_u.rdok_dirents
 
 
 /*
@@ -904,7 +944,7 @@
 extern int	nfs_clntinit(void);
 extern void	nfs_clntfini(void);
 extern int	nfstsize(void);
-extern int	nfs_srvinit(void);
+extern void	nfs_srvinit(void);
 extern void	nfs_srvfini(void);
 extern int	vattr_to_sattr(struct vattr *, struct nfssattr *);
 extern void	setdiropargs(struct nfsdiropargs *, char *, vnode_t *);
@@ -957,9 +997,12 @@
 
 extern kstat_named_t	*global_svstat_ptr[];
 
+extern zone_key_t	rfs4_zone_key;
+extern zone_key_t	nfssrv_zone_key;
 extern krwlock_t	rroklock;
 extern vtype_t		nf_to_vt[];
 extern kstat_named_t	*rfsproccnt_v2_ptr;
+extern kstat_t		**rfsprocio_v2_ptr;
 extern kmutex_t		nfs_minor_lock;
 extern int		nfs_major;
 extern int		nfs_minor;
@@ -971,13 +1014,17 @@
 extern int		(*nfs_srv_dss_func)(char *, size_t);
 
 /*
- * Per-zone stats as consumed by nfsstat(1m)
+ * Per-zone stats
  */
 struct nfs_version_stats {
 	kstat_named_t	*aclreqcnt_ptr;		/* nfs_acl:0:aclreqcnt_v? */
 	kstat_named_t	*aclproccnt_ptr;	/* nfs_acl:0:aclproccnt_v? */
+	kstat_t		**aclprocio_ptr;	/* nfs_acl:0:aclprocio_v?_* */
+	kmutex_t	aclprocio_lock;		/* protects aclprocio */
 	kstat_named_t	*rfsreqcnt_ptr;		/* nfs:0:rfsreqcnt_v? */
 	kstat_named_t	*rfsproccnt_ptr;	/* nfs:0:rfsproccnt_v? */
+	kstat_t		**rfsprocio_ptr;	/* nfs:0:rfsprocio_v?_* */
+	kmutex_t	rfsprocio_lock;		/* protects rfsprocio */
 };
 
 /*
@@ -1001,6 +1048,31 @@
 extern void	*nfsstat_zone_init(zoneid_t);
 extern void	nfsstat_zone_fini(zoneid_t, void *);
 
+/*
+ * Per-exportinfo stats
+ */
+struct exp_kstats {
+	kstat_t		*share_kstat;		/* Generic share kstat */
+	struct {
+		kstat_named_t	path;		/* Shared path */
+		kstat_named_t	filesystem;	/* pseudo|real */
+	} share_kstat_data;			/* Generic share kstat data */
+	char		*share_path;		/* Shared path string */
+	kstat_t		**rfsshr_v3_ptr;	/* NFS v3 per share stats */
+	kstat_t		**rfsshr_v4_ptr;	/* NFS v4 per share stats */
+	kmutex_t	procio_lock;		/* protects all exp_kstats */
+};
+
+extern struct exp_kstats *exp_kstats_init(zoneid_t, int, const char *, size_t,
+    bool_t);
+extern void exp_kstats_delete(struct exp_kstats *);
+extern void exp_kstats_fini(struct exp_kstats *);
+extern void exp_kstats_reset(struct exp_kstats *, const char *, size_t, bool_t);
+
+extern kstat_t *exp_kstats_v2(struct exp_kstats *, uint_t);
+extern kstat_t *exp_kstats_v3(struct exp_kstats *, uint_t);
+extern kstat_t *exp_kstats_v4(struct exp_kstats *, uint_t);
+
 #endif	/* _KERNEL */
 
 /*
@@ -1821,10 +1893,6 @@
 	post_op_attr dir_attributes;
 	cookieverf3 cookieverf;
 	dirlist3 reply;
-	uint_t size;
-	uint_t count;
-	uint_t freecount;
-	cookie3 cookie;
 };
 typedef struct READDIR3resok READDIR3resok;
 
@@ -1881,21 +1949,10 @@
 };
 typedef struct dirlistplus3 dirlistplus3;
 
-struct entryplus3_info {
-	post_op_attr attr;
-	post_op_fh3 fh;
-	uint_t namelen;
-};
-typedef struct entryplus3_info entryplus3_info;
-
 struct READDIRPLUS3resok {
 	post_op_attr dir_attributes;
 	cookieverf3 cookieverf;
 	dirlistplus3 reply;
-	uint_t size;
-	uint_t count;
-	uint_t maxcount;
-	entryplus3_info *infop;
 };
 typedef struct READDIRPLUS3resok READDIRPLUS3resok;
 
@@ -2278,9 +2335,12 @@
     struct exportinfo **, struct sec_ol *);
 extern int	rfs_pathname(char *, vnode_t **, vnode_t **, vnode_t *,
     cred_t *, int);
+extern int	rfs_cross_mnt(vnode_t **, struct exportinfo **);
+extern int	rfs_climb_crossmnt(vnode_t **, struct exportinfo **, cred_t *);
 
 extern vtype_t		nf3_to_vt[];
 extern kstat_named_t	*rfsproccnt_v3_ptr;
+extern kstat_t		**rfsprocio_v3_ptr;
 extern vfsops_t		*nfs3_vfsops;
 extern struct vnodeops	*nfs3_vnodeops;
 extern const struct fs_operation_def nfs3_vnodeops_template[];
@@ -2291,7 +2351,7 @@
  * with these broken servers, the nfs_disable_rddir_cache
  * parameter can be used to disable readdir response caching.
  */
-extern int		nfs_disable_rddir_cache;
+extern volatile int	nfs_disable_rddir_cache;
 
 /*
  * External functions called by the v2/v3 code into the v4 code
@@ -2310,11 +2370,11 @@
  * if no delegation is present.
  */
 extern int	rfs4_delegated_getattr(vnode_t *, vattr_t *, int, cred_t *);
-extern void	rfs4_hold_deleg_policy(void);
-extern void	rfs4_rele_deleg_policy(void);
 
 extern int	do_xattr_exists_check(vnode_t *, ulong_t *, cred_t *);
 
+extern int	protect_zfs_mntpt(vnode_t *);
+
 extern ts_label_t *nfs_getflabel(vnode_t *, struct exportinfo *);
 extern boolean_t do_rfs_label_check(bslabel_t *, vnode_t *, int,
     struct exportinfo *);
