Print this page
NEX-15279 support NFS server in zone
NEX-15520 online NFS shares cause zoneadm halt to hang in nfs_export_zone_fini
Portions contributed by: Dan Kruchinin dan.kruchinin@nexenta.com
Portions contributed by: Stepan Zastupov stepan.zastupov@gmail.com
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
re #13613 rb4516 Tunables needs volatile keyword

@@ -16,17 +16,24 @@
  * fields enclosed by brackets "[]" replaced with your own identifying
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved.
- *
+ */
+
+/*
  *      Copyright (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  *      All rights reserved.
  */
 
+/*
+ * Copyright 2018 Nexenta Systems, Inc.
+ */
+
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/thread.h>
 #include <sys/t_lock.h>

@@ -58,10 +65,11 @@
 #include <rpc/auth.h>
 #include <rpc/clnt.h>
 
 #include <nfs/nfs.h>
 #include <nfs/nfs_clnt.h>
+#include <nfs/nfs_cmd.h>
 
 #include <nfs/rnode.h>
 #include <nfs/nfs_acl.h>
 #include <nfs/lm.h>
 

@@ -1179,11 +1187,11 @@
  * nfs_async_timeout is the amount of time a thread will live after it
  * becomes idle, unless new I/O requests are received before the thread
  * dies.  See nfs_async_putpage and nfs_async_start.
  */
 
-int nfs_async_timeout = -1;     /* uninitialized */
+volatile int nfs_async_timeout = -1;    /* uninitialized */
 
 static void     nfs_async_start(struct vfs *);
 static void     nfs_async_pgops_start(struct vfs *);
 static void     nfs_async_common_start(struct vfs *, int);
 

@@ -1352,12 +1360,12 @@
         mutex_exit(&mi->mi_async_lock);
 }
 
 int
 nfs_async_readahead(vnode_t *vp, u_offset_t blkoff, caddr_t addr,
-        struct seg *seg, cred_t *cr, void (*readahead)(vnode_t *,
-        u_offset_t, caddr_t, struct seg *, cred_t *))
+    struct seg *seg, cred_t *cr, void (*readahead)(vnode_t *, u_offset_t,
+    caddr_t, struct seg *, cred_t *))
 {
         rnode_t *rp;
         mntinfo_t *mi;
         struct nfs_async_reqs *args;
 

@@ -1452,12 +1460,12 @@
         return (-1);
 }
 
 int
 nfs_async_putapage(vnode_t *vp, page_t *pp, u_offset_t off, size_t len,
-        int flags, cred_t *cr, int (*putapage)(vnode_t *, page_t *,
-        u_offset_t, size_t, int, cred_t *))
+    int flags, cred_t *cr, int (*putapage)(vnode_t *, page_t *, u_offset_t,
+    size_t, int, cred_t *))
 {
         rnode_t *rp;
         mntinfo_t *mi;
         struct nfs_async_reqs *args;
 

@@ -1804,12 +1812,11 @@
         rddir_cache_rele(rdc);
 }
 
 void
 nfs_async_commit(vnode_t *vp, page_t *plist, offset3 offset, count3 count,
-        cred_t *cr, void (*commit)(vnode_t *, page_t *, offset3, count3,
-        cred_t *))
+    cred_t *cr, void (*commit)(vnode_t *, page_t *, offset3, count3, cred_t *))
 {
         rnode_t *rp;
         mntinfo_t *mi;
         struct nfs_async_reqs *args;
         page_t *pp;

@@ -2542,11 +2549,11 @@
         rp->r_flags &= ~RTRUNCATE;
         cv_broadcast(&rp->r_cv);
         mutex_exit(&rp->r_statelock);
 }
 
-static int nfs_write_error_to_cons_only = 0;
+volatile int nfs_write_error_to_cons_only = 0;
 #define MSG(x)  (nfs_write_error_to_cons_only ? (x) : (x) + 1)
 
 /*
  * Print a file handle
  */

@@ -2592,11 +2599,11 @@
  * Notify the system administrator that an NFS write error has
  * occurred.
  */
 
 /* seconds between ENOSPC/EDQUOT messages */
-clock_t nfs_write_error_interval = 5;
+volatile clock_t nfs_write_error_interval = 5;
 
 void
 nfs_write_error(vnode_t *vp, int error, cred_t *cr)
 {
         mntinfo_t *mi;

@@ -2826,10 +2833,12 @@
         zone_key_create(&mi_list_key, nfs_mi_init, nfs_mi_shutdown,
             nfs_mi_destroy);
 
         nfs4_clnt_init();
 
+        nfscmd_init();
+
 #ifdef DEBUG
         nfs_clntup = B_TRUE;
 #endif
 
         return (0);

@@ -2845,10 +2854,11 @@
 {
         (void) zone_key_delete(mi_list_key);
         nfs_subrfini();
         nfs_vfsfini();
         nfs4_clnt_fini();
+        nfscmd_fini();
 }
 
 /*
  * nfs_lockrelease:
  *