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.)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/nfs/nfs_srv.c
          +++ new/usr/src/uts/common/fs/nfs/nfs_srv.c
↓ open down ↓ 91 lines elided ↑ open up ↑
  92   92  
  93   93  /*
  94   94   * These are the interface routines for the server side of the
  95   95   * Network File System.  See the NFS version 2 protocol specification
  96   96   * for a description of this interface.
  97   97   */
  98   98  
  99   99  static int      sattr_to_vattr(struct nfssattr *, struct vattr *);
 100  100  static void     acl_perm(struct vnode *, struct exportinfo *, struct vattr *,
 101  101                          cred_t *);
 102      -static void     *rfs_zone_init(zoneid_t zoneid);
 103      -static void     rfs_zone_fini(zoneid_t zoneid, void *data);
 104  102  
 105  103  
 106  104  /*
 107  105   * Some "over the wire" UNIX file types.  These are encoded
 108  106   * into the mode.  This needs to be fixed in the next rev.
 109  107   */
 110  108  #define IFMT            0170000         /* type of file */
 111  109  #define IFCHR           0020000         /* character special */
 112  110  #define IFBLK           0060000         /* block special */
 113  111  #define IFSOCK          0140000         /* socket */
 114  112  
 115  113  u_longlong_t nfs2_srv_caller_id;
 116      -static zone_key_t rfs_zone_key;
 117  114  
      115 +static nfs_srv_t *
      116 +nfs_get_srv(void)
      117 +{
      118 +        nfs_globals_t *ng = zone_getspecific(nfssrv_zone_key, curzone);
      119 +        nfs_srv_t *srv = ng->nfs_srv;
      120 +        ASSERT(srv != NULL);
      121 +        return (srv);
      122 +}
      123 +
 118  124  /*
 119  125   * Get file attributes.
 120  126   * Returns the current attributes of the file with the given fhandle.
 121  127   */
 122  128  /* ARGSUSED */
 123  129  void
 124  130  rfs_getattr(fhandle_t *fhp, struct nfsattrstat *ns, struct exportinfo *exi,
 125  131      struct svc_req *req, cred_t *cr, bool_t ro)
 126  132  {
 127  133          int error;
↓ open down ↓ 1180 lines elided ↑ open up ↑
1308 1314          uint_t off;
1309 1315          uint_t len;
1310 1316          struct rfs_async_write nrpsp;
1311 1317          struct rfs_async_write_list nlpsp;
1312 1318          ushort_t t_flag;
1313 1319          cred_t *savecred;
1314 1320          int in_crit = 0;
1315 1321          caller_context_t ct;
1316 1322          nfs_srv_t *nsrv;
1317 1323  
1318      -        ASSERT3P(curzone, ==, ((exi == NULL) ? curzone : exi->exi_zone));
1319      -        nsrv = zone_getspecific(rfs_zone_key, curzone);
     1324 +        ASSERT(exi == NULL || exi->exi_zoneid == curzone->zone_id);
     1325 +        nsrv = nfs_get_srv();
1320 1326          if (!nsrv->write_async) {
1321 1327                  rfs_write_sync(wa, ns, exi, req, cr, ro);
1322 1328                  return;
1323 1329          }
1324 1330  
1325 1331          /*
1326 1332           * Initialize status to RFSWRITE_INITVAL instead of 0, since value of 0
1327 1333           * is considered an OK.
1328 1334           */
1329 1335          ns->ns_status = RFSWRITE_INITVAL;
↓ open down ↓ 1766 lines elided ↑ open up ↑
3096 3102                  if (vsa.vsa_aclcnt)
3097 3103                          kmem_free(vsa.vsa_aclentp,
3098 3104                              vsa.vsa_aclcnt * sizeof (aclent_t));
3099 3105          }
3100 3106  }
3101 3107  
3102 3108  void
3103 3109  rfs_srvrinit(void)
3104 3110  {
3105 3111          nfs2_srv_caller_id = fs_new_caller_id();
3106      -        zone_key_create(&rfs_zone_key, rfs_zone_init, NULL, rfs_zone_fini);
3107 3112  }
3108 3113  
3109 3114  void
3110 3115  rfs_srvrfini(void)
3111 3116  {
3112 3117  }
3113 3118  
3114 3119  /* ARGSUSED */
3115      -static void *
3116      -rfs_zone_init(zoneid_t zoneid)
     3120 +void
     3121 +rfs_srv_zone_init(nfs_globals_t *ng)
3117 3122  {
3118 3123          nfs_srv_t *ns;
3119 3124  
3120 3125          ns = kmem_zalloc(sizeof (*ns), KM_SLEEP);
3121 3126  
3122 3127          mutex_init(&ns->async_write_lock, NULL, MUTEX_DEFAULT, NULL);
3123 3128          ns->write_async = 1;
3124 3129  
3125      -        return (ns);
     3130 +        ng->nfs_srv = ns;
3126 3131  }
3127 3132  
3128 3133  /* ARGSUSED */
3129      -static void
3130      -rfs_zone_fini(zoneid_t zoneid, void *data)
     3134 +void
     3135 +rfs_srv_zone_fini(nfs_globals_t *ng)
3131 3136  {
3132      -        nfs_srv_t *ns;
     3137 +        nfs_srv_t *ns = ng->nfs_srv;
3133 3138  
3134      -        ns = (nfs_srv_t *)data;
     3139 +        ng->nfs_srv = NULL;
     3140 +
3135 3141          mutex_destroy(&ns->async_write_lock);
3136 3142          kmem_free(ns, sizeof (*ns));
3137 3143  }
3138 3144  
3139 3145  static int
3140 3146  rdma_setup_read_data2(struct nfsreadargs *ra, struct nfsrdresult *rr)
3141 3147  {
3142 3148          struct clist    *wcl;
3143 3149          int             wlist_len;
3144 3150          uint32_t        count = rr->rr_count;
↓ open down ↓ 13 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX