Print this page
Hyperaggressive asserts pt 1/N
Ooops exi_zoneid isn't a variable again yet
Be far more judicious in the use of curzone-using macros.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/nfs/nfs_export.c
          +++ new/usr/src/uts/common/fs/nfs/nfs_export.c
↓ open down ↓ 711 lines elided ↑ open up ↑
 712  712  
 713  713          ASSERT(exi_ret); /* Every visible should have its home exportinfo */
 714  714          return (exi_ret);
 715  715  }
 716  716  
 717  717  /*
 718  718   * For NFS V4.
 719  719   * Add or remove the newly exported or unexported security flavors of the
 720  720   * given exportinfo from its ancestors upto the system root.
 721  721   */
 722      -void
      722 +static void
 723  723  srv_secinfo_treeclimb(nfs_export_t *ne, exportinfo_t *exip, secinfo_t *sec,
 724  724      int seccnt, bool_t isadd)
 725  725  {
 726  726          treenode_t *tnode;
 727  727  
 728  728          ASSERT(RW_WRITE_HELD(&ne->exported_lock));
      729 +        ASSERT3U(exip->exi_zoneid, ==, curzone->zone_id);
 729  730  
 730  731          /*
 731  732           * exi_tree can be null for the zone root
 732  733           * which means we're already at the "top"
 733  734           * and there's nothing more to "climb".
 734  735           */
 735  736          tnode = exip->exi_tree;
 736  737          if (tnode == NULL) {
 737  738                  /* Should only happen for... */
 738  739                  ASSERT(exip == ne->exi_root);
↓ open down ↓ 70 lines elided ↑ open up ↑
 809  810          if ((exi)->hash_name.next) \
 810  811                  (exi)->hash_name.next->hash_name.prev = (exi); \
 811  812          *(bucket) = (exi);
 812  813  
 813  814  void
 814  815  export_link(nfs_export_t *ne, exportinfo_t *exi)
 815  816  {
 816  817          exportinfo_t **bckt;
 817  818  
 818  819          ASSERT(RW_WRITE_HELD(&ne->exported_lock));
 819      -        ASSERT(exi->exi_zoneid == ne->ne_globals->nfs_zoneid);
 820  820  
 821  821          bckt = &ne->exptable[exptablehash(&exi->exi_fsid, &exi->exi_fid)];
 822  822          exp_hash_link(exi, fid_hash, bckt);
 823  823  
 824  824          bckt = &ne->exptable_path_hash[pkp_tab_hash(exi->exi_export.ex_path,
 825  825              strlen(exi->exi_export.ex_path))];
 826  826          exp_hash_link(exi, path_hash, bckt);
 827  827  }
 828  828  
 829  829  /*
↓ open down ↓ 63 lines elided ↑ open up ↑
 893  893          ne->exi_root->exi_fh.fh_len = sizeof (ne->exi_root->exi_fh.fh_data);
 894  894  
 895  895          return (0);
 896  896  }
 897  897  
 898  898  void
 899  899  nfs_export_zone_init(nfs_globals_t *ng)
 900  900  {
 901  901          int i;
 902  902          nfs_export_t *ne;
      903 +        zone_t *zone;
 903  904  
 904  905          ne = kmem_zalloc(sizeof (*ne), KM_SLEEP);
 905  906  
 906  907          rw_init(&ne->exported_lock, NULL, RW_DEFAULT, NULL);
 907  908  
 908  909          ne->ne_globals = ng; /* "up" pointer */
 909  910  
 910  911          /*
 911  912           * Allocate the place holder for the public file handle, which
 912  913           * is all zeroes. It is initially set to the root filesystem.
↓ open down ↓ 4 lines elided ↑ open up ↑
 917  918          ne->exi_root->exi_export.ex_flags = EX_PUBLIC;
 918  919          ne->exi_root->exi_export.ex_pathlen = 1;        /* length of "/" */
 919  920          ne->exi_root->exi_export.ex_path =
 920  921              kmem_alloc(ne->exi_root->exi_export.ex_pathlen + 1, KM_SLEEP);
 921  922          ne->exi_root->exi_export.ex_path[0] = '/';
 922  923          ne->exi_root->exi_export.ex_path[1] = '\0';
 923  924  
 924  925          ne->exi_root->exi_count = 1;
 925  926          mutex_init(&ne->exi_root->exi_lock, NULL, MUTEX_DEFAULT, NULL);
 926  927  
 927      -        ASSERT(curzone->zone_id == ng->nfs_zoneid);
 928      -        ne->exi_root->exi_vp = ZONE_ROOTVP();
 929      -        ne->exi_root->exi_zoneid = ng->nfs_zoneid;
      928 +        /*
      929 +         * Because we cannot:
      930 +         *      ASSERT(curzone->zone_id == ng->nfs_zoneid);
      931 +         * We grab the zone pointer explicitly (like netstacks do) and
      932 +         * set the rootvp here.
      933 +         */
      934 +        zone = zone_find_by_id_nolock(ng->nfs_zoneid);
      935 +        ne->exi_root->exi_vp = zone->zone_rootvp;
      936 +        ne->exi_root->exi_zone = zone;  /* XXX KEBE SAYS lose me, and... */
      937 +        /* ne->exi_root->exi_zoneid = ng->nfs_zoneid; */ /* use me instead! */
 930  938  
 931  939          /*
 932  940           * Fill in ne->exi_rootfid later, in nfs_export_get_rootfid
 933  941           * because we can't correctly return errors here.
 934  942           */
 935  943  
 936  944          /* Initialize auth cache and auth cache lock */
 937  945          for (i = 0; i < AUTH_TABLESIZE; i++) {
 938  946                  ne->exi_root->exi_cache[i] = kmem_alloc(sizeof (avl_tree_t),
 939  947                      KM_SLEEP);
↓ open down ↓ 973 lines elided ↑ open up ↑
1913 1921           * for paths to exports below.
1914 1922           */
1915 1923          if (exi->exi_visible != NULL) {
1916 1924                  struct exportinfo *newexi;
1917 1925  
1918 1926                  newexi = pseudo_exportfs(ne, exi->exi_vp, &exi->exi_fid,
1919 1927                      exi->exi_visible, &exi->exi_export);
1920 1928                  exi->exi_visible = NULL;
1921 1929  
1922 1930                  /* interconnect the existing treenode with the new exportinfo */
1923      -                newexi->exi_zone = exi->exi_zone;
     1931 +                newexi->exi_zone = exi->exi_zone; /* XXX KEBE SAYS LOSE ME */
1924 1932                  newexi->exi_tree = exi->exi_tree;
1925 1933                  newexi->exi_tree->tree_exi = newexi;
1926 1934  
1927 1935                  /* Update the change timestamp */
1928 1936                  tree_update_change(ne, exi->exi_tree, NULL);
1929 1937          } else {
1930 1938                  treeclimb_unexport(ne, exi);
1931 1939          }
1932 1940  
1933 1941          rw_exit(&ne->exported_lock);
↓ open down ↓ 248 lines elided ↑ open up ↑
2182 2190                           * Found the export info
2183 2191                           */
2184 2192                          break;
2185 2193                  }
2186 2194  
2187 2195                  /*
2188 2196                   * We have just failed finding a matching export.
2189 2197                   * If we're at the root of this filesystem, then
2190 2198                   * it's time to stop (with failure).
2191 2199                   */
     2200 +                ASSERT3P(vp->v_vfsp->vfs_zone, ==, curzone);
2192 2201                  if ((vp->v_flag & VROOT) || VN_IS_CURZONEROOT(vp)) {
2193 2202                          error = EINVAL;
2194 2203                          break;
2195 2204                  }
2196 2205  
2197 2206                  if (walk != NULL)
2198 2207                          (*walk)++;
2199 2208  
2200 2209                  /*
2201 2210                   * Now, do a ".." up vp. If dvp is supplied, use it,
↓ open down ↓ 785 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX