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.)
        
*** 151,161 ****
   *
   */
  #define DIRENT64_TO_DIRCOUNT(dp) \
          (3 * BYTES_PER_XDR_UNIT + DIRENT64_NAMELEN((dp)->d_reclen))
  
- zone_key_t      rfs4_zone_key;
  
  static sysid_t          lockt_sysid;    /* dummy sysid for all LOCKT calls */
  
  u_longlong_t    nfs4_srv_caller_id;
  uint_t          nfs4_srv_vkey = 0;
--- 151,160 ----
*** 499,512 ****
          VOPNAME_SETSECATTR,     { .femop_setsecattr = deleg_wr_setsecattr },
          VOPNAME_VNEVENT,        { .femop_vnevent = deleg_wr_vnevent },
          NULL,                   NULL
  };
  
! /* ARGSUSED */
! static void *
! rfs4_zone_init(zoneid_t zoneid)
  {
          nfs4_srv_t *nsrv4;
          timespec32_t verf;
  
          nsrv4 = kmem_zalloc(sizeof (*nsrv4), KM_SLEEP);
  
--- 498,519 ----
          VOPNAME_SETSECATTR,     { .femop_setsecattr = deleg_wr_setsecattr },
          VOPNAME_VNEVENT,        { .femop_vnevent = deleg_wr_vnevent },
          NULL,                   NULL
  };
  
! nfs4_srv_t *
! nfs4_get_srv(void)
  {
+         nfs_globals_t *ng = zone_getspecific(nfssrv_zone_key, curzone);
+         nfs4_srv_t *srv = ng->nfs4_srv;
+         ASSERT(srv != NULL);
+         return (srv);
+ }
+ 
+ void
+ rfs4_srv_zone_init(nfs_globals_t *ng)
+ {
          nfs4_srv_t *nsrv4;
          timespec32_t verf;
  
          nsrv4 = kmem_zalloc(sizeof (*nsrv4), KM_SLEEP);
  
*** 547,565 ****
          mutex_init(&nsrv4->deleg_lock, NULL, MUTEX_DEFAULT, NULL);
          mutex_init(&nsrv4->state_lock, NULL, MUTEX_DEFAULT, NULL);
          mutex_init(&nsrv4->servinst_lock, NULL, MUTEX_DEFAULT, NULL);
          rw_init(&nsrv4->deleg_policy_lock, NULL, RW_DEFAULT, NULL);
  
!         return (nsrv4);
  }
  
! /* ARGSUSED */
! static void
! rfs4_zone_fini(zoneid_t zoneid, void *data)
  {
!         nfs4_srv_t *nsrv4 = data;
  
          mutex_destroy(&nsrv4->deleg_lock);
          mutex_destroy(&nsrv4->state_lock);
          mutex_destroy(&nsrv4->servinst_lock);
          rw_destroy(&nsrv4->deleg_policy_lock);
  
--- 554,573 ----
          mutex_init(&nsrv4->deleg_lock, NULL, MUTEX_DEFAULT, NULL);
          mutex_init(&nsrv4->state_lock, NULL, MUTEX_DEFAULT, NULL);
          mutex_init(&nsrv4->servinst_lock, NULL, MUTEX_DEFAULT, NULL);
          rw_init(&nsrv4->deleg_policy_lock, NULL, RW_DEFAULT, NULL);
  
!         ng->nfs4_srv = nsrv4;
  }
  
! void
! rfs4_srv_zone_fini(nfs_globals_t *ng)
  {
!         nfs4_srv_t *nsrv4 = ng->nfs4_srv;
  
+         ng->nfs4_srv = NULL;
+ 
          mutex_destroy(&nsrv4->deleg_lock);
          mutex_destroy(&nsrv4->state_lock);
          mutex_destroy(&nsrv4->servinst_lock);
          rw_destroy(&nsrv4->deleg_policy_lock);
  
*** 569,583 ****
  void
  rfs4_srvrinit(void)
  {
          extern void rfs4_attr_init();
  
-         zone_key_create(&rfs4_zone_key, rfs4_zone_init, NULL, rfs4_zone_fini);
- 
          rfs4_attr_init();
  
- 
          if (fem_create("deleg_rdops", nfs4_rd_deleg_tmpl, &deleg_rdops) != 0) {
                  rfs4_disable_delegation();
          } else if (fem_create("deleg_wrops", nfs4_wr_deleg_tmpl,
              &deleg_wrops) != 0) {
                  rfs4_disable_delegation();
--- 577,588 ----
*** 600,618 ****
  
          rfs4_state_g_fini();
  
          fem_free(deleg_rdops);
          fem_free(deleg_wrops);
- 
-         (void) zone_key_delete(rfs4_zone_key);
  }
  
  void
  rfs4_do_server_start(int server_upordown,
      int srv_delegation, int cluster_booted)
  {
!         nfs4_srv_t *nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
  
          /* Is this a warm start? */
          if (server_upordown == NFS_SERVER_QUIESCED) {
                  cmn_err(CE_NOTE, "nfs4_srv: "
                      "server was previously quiesced; "
--- 605,621 ----
  
          rfs4_state_g_fini();
  
          fem_free(deleg_rdops);
          fem_free(deleg_wrops);
  }
  
  void
  rfs4_do_server_start(int server_upordown,
      int srv_delegation, int cluster_booted)
  {
!         nfs4_srv_t *nsrv4 = nfs4_get_srv();
  
          /* Is this a warm start? */
          if (server_upordown == NFS_SERVER_QUIESCED) {
                  cmn_err(CE_NOTE, "nfs4_srv: "
                      "server was previously quiesced; "
*** 1515,1525 ****
          if (error) {
                  *cs->statusp = resp->status = puterrno4(error);
                  goto out;
          }
  
!         nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
          *cs->statusp = resp->status = NFS4_OK;
          resp->writeverf = nsrv4->write4verf;
  out:
          DTRACE_NFSV4_2(op__commit__done, struct compound_state *, cs,
              COMMIT4res *, resp);
--- 1518,1528 ----
          if (error) {
                  *cs->statusp = resp->status = puterrno4(error);
                  goto out;
          }
  
!         nsrv4 = nfs4_get_srv();
          *cs->statusp = resp->status = NFS4_OK;
          resp->writeverf = nsrv4->write4verf;
  out:
          DTRACE_NFSV4_2(op__commit__done, struct compound_state *, cs,
              COMMIT4res *, resp);
*** 5662,5672 ****
          if (MANDLOCK(vp, bva.va_mode)) {
                  *cs->statusp = resp->status = NFS4ERR_ACCESS;
                  goto out;
          }
  
!         nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
          if (args->data_len == 0) {
                  *cs->statusp = resp->status = NFS4_OK;
                  resp->count = 0;
                  resp->committed = args->stable;
                  resp->writeverf = nsrv4->write4verf;
--- 5665,5675 ----
          if (MANDLOCK(vp, bva.va_mode)) {
                  *cs->statusp = resp->status = NFS4ERR_ACCESS;
                  goto out;
          }
  
!         nsrv4 = nfs4_get_srv();
          if (args->data_len == 0) {
                  *cs->statusp = resp->status = NFS4_OK;
                  resp->count = 0;
                  resp->committed = args->stable;
                  resp->writeverf = nsrv4->write4verf;
*** 5842,5852 ****
          resp->array_len = args->array_len;
          resp->array = kmem_zalloc(args->array_len * sizeof (nfs_resop4),
              KM_SLEEP);
  
          cs.basecr = cr;
!         nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
  
          DTRACE_NFSV4_2(compound__start, struct compound_state *, &cs,
              COMPOUND4args *, args);
  
          /*
--- 5845,5855 ----
          resp->array_len = args->array_len;
          resp->array = kmem_zalloc(args->array_len * sizeof (nfs_resop4),
              KM_SLEEP);
  
          cs.basecr = cr;
!         nsrv4 = nfs4_get_srv();
  
          DTRACE_NFSV4_2(compound__start, struct compound_state *, &cs,
              COMPOUND4args *, args);
  
          /*
*** 6654,6664 ****
  
                          /*
                           * We are writing over an existing file.
                           * Check to see if we need to recall a delegation.
                           */
!                         nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
                          rfs4_hold_deleg_policy(nsrv4);
                          if ((fp = rfs4_findfile(vp, NULL, &create)) != NULL) {
                                  if (rfs4_check_delegated_byfp(FWRITE, fp,
                                      (reqsize == 0), FALSE, FALSE, &clientid)) {
                                          rfs4_file_rele(fp);
--- 6657,6667 ----
  
                          /*
                           * We are writing over an existing file.
                           * Check to see if we need to recall a delegation.
                           */
!                         nsrv4 = nfs4_get_srv();
                          rfs4_hold_deleg_policy(nsrv4);
                          if ((fp = rfs4_findfile(vp, NULL, &create)) != NULL) {
                                  if (rfs4_check_delegated_byfp(FWRITE, fp,
                                      (reqsize == 0), FALSE, FALSE, &clientid)) {
                                          rfs4_file_rele(fp);
*** 8231,8241 ****
  
          DTRACE_NFSV4_2(op__setclientid__confirm__start,
              struct compound_state *, cs,
              SETCLIENTID_CONFIRM4args *, args);
  
!         nsrv4 = zone_getspecific(rfs4_zone_key, curzone);
          *cs->statusp = res->status = NFS4_OK;
  
          cp = rfs4_findclient_by_id(args->clientid, TRUE);
  
          if (cp == NULL) {
--- 8234,8244 ----
  
          DTRACE_NFSV4_2(op__setclientid__confirm__start,
              struct compound_state *, cs,
              SETCLIENTID_CONFIRM4args *, args);
  
!         nsrv4 = nfs4_get_srv();
          *cs->statusp = res->status = NFS4_OK;
  
          cp = rfs4_findclient_by_id(args->clientid, TRUE);
  
          if (cp == NULL) {