Print this page
Fix NFS design problems re. multiple zone keys
Make NFS server zone-specific data all have the same lifetime
Fix rfs4_clean_state_exi
Fix exi_cache_reclaim
Fix mistakes in zone keys work
More fixes re. exi_zoneid and exi_tree
(danmcd -> Keep some ASSERT()s around for readability.)
        
*** 97,108 ****
   */
  
  static int      sattr_to_vattr(struct nfssattr *, struct vattr *);
  static void     acl_perm(struct vnode *, struct exportinfo *, struct vattr *,
                          cred_t *);
- static void     *rfs_zone_init(zoneid_t zoneid);
- static void     rfs_zone_fini(zoneid_t zoneid, void *data);
  
  
  /*
   * Some "over the wire" UNIX file types.  These are encoded
   * into the mode.  This needs to be fixed in the next rev.
--- 97,106 ----
*** 111,122 ****
  #define IFCHR           0020000         /* character special */
  #define IFBLK           0060000         /* block special */
  #define IFSOCK          0140000         /* socket */
  
  u_longlong_t nfs2_srv_caller_id;
- static zone_key_t rfs_zone_key;
  
  /*
   * Get file attributes.
   * Returns the current attributes of the file with the given fhandle.
   */
  /* ARGSUSED */
--- 109,128 ----
  #define IFCHR           0020000         /* character special */
  #define IFBLK           0060000         /* block special */
  #define IFSOCK          0140000         /* socket */
  
  u_longlong_t nfs2_srv_caller_id;
  
+ static nfs_srv_t *
+ nfs_get_srv(void)
+ {
+         nfs_globals_t *ng = zone_getspecific(nfssrv_zone_key, curzone);
+         nfs_srv_t *srv = ng->nfs_srv;
+         ASSERT(srv != NULL);
+         return (srv);
+ }
+ 
  /*
   * Get file attributes.
   * Returns the current attributes of the file with the given fhandle.
   */
  /* ARGSUSED */
*** 1313,1324 ****
          cred_t *savecred;
          int in_crit = 0;
          caller_context_t ct;
          nfs_srv_t *nsrv;
  
!         ASSERT3P(curzone, ==, ((exi == NULL) ? curzone : exi->exi_zone));
!         nsrv = zone_getspecific(rfs_zone_key, curzone);
          if (!nsrv->write_async) {
                  rfs_write_sync(wa, ns, exi, req, cr, ro);
                  return;
          }
  
--- 1319,1330 ----
          cred_t *savecred;
          int in_crit = 0;
          caller_context_t ct;
          nfs_srv_t *nsrv;
  
!         ASSERT(exi == NULL || exi->exi_zoneid == curzone->zone_id);
!         nsrv = nfs_get_srv();
          if (!nsrv->write_async) {
                  rfs_write_sync(wa, ns, exi, req, cr, ro);
                  return;
          }
  
*** 3101,3139 ****
  
  void
  rfs_srvrinit(void)
  {
          nfs2_srv_caller_id = fs_new_caller_id();
-         zone_key_create(&rfs_zone_key, rfs_zone_init, NULL, rfs_zone_fini);
  }
  
  void
  rfs_srvrfini(void)
  {
  }
  
  /* ARGSUSED */
! static void *
! rfs_zone_init(zoneid_t zoneid)
  {
          nfs_srv_t *ns;
  
          ns = kmem_zalloc(sizeof (*ns), KM_SLEEP);
  
          mutex_init(&ns->async_write_lock, NULL, MUTEX_DEFAULT, NULL);
          ns->write_async = 1;
  
!         return (ns);
  }
  
  /* ARGSUSED */
! static void
! rfs_zone_fini(zoneid_t zoneid, void *data)
  {
!         nfs_srv_t *ns;
  
!         ns = (nfs_srv_t *)data;
          mutex_destroy(&ns->async_write_lock);
          kmem_free(ns, sizeof (*ns));
  }
  
  static int
--- 3107,3145 ----
  
  void
  rfs_srvrinit(void)
  {
          nfs2_srv_caller_id = fs_new_caller_id();
  }
  
  void
  rfs_srvrfini(void)
  {
  }
  
  /* ARGSUSED */
! void
! rfs_srv_zone_init(nfs_globals_t *ng)
  {
          nfs_srv_t *ns;
  
          ns = kmem_zalloc(sizeof (*ns), KM_SLEEP);
  
          mutex_init(&ns->async_write_lock, NULL, MUTEX_DEFAULT, NULL);
          ns->write_async = 1;
  
!         ng->nfs_srv = ns;
  }
  
  /* ARGSUSED */
! void
! rfs_srv_zone_fini(nfs_globals_t *ng)
  {
!         nfs_srv_t *ns = ng->nfs_srv;
  
!         ng->nfs_srv = NULL;
! 
          mutex_destroy(&ns->async_write_lock);
          kmem_free(ns, sizeof (*ns));
  }
  
  static int