Print this page
Untrip aggressive assert AND use EXI_TO_ZONEROOTVP
Revert exi_zone to exi_zoneid, and install exi_ne backpointer

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 ↓ 685 lines elided ↑ open up ↑
 686  686   * exp_visible linked on its exi_visible list.
 687  687   *
 688  688   * Note: We could add new pointer either to treenode or
 689  689   * to exp_visible, which will point there directly.
 690  690   * This would buy some speed for some memory.
 691  691   */
 692  692  exportinfo_t *
 693  693  vis2exi(treenode_t *tnode)
 694  694  {
 695  695          exportinfo_t *exi_ret = NULL;
 696      -#ifdef DEBUG
 697      -        zone_t *zone = NULL;
 698      -#endif
 699  696  
 700  697          for (;;) {
 701  698                  tnode = tnode->tree_parent;
 702      -#ifdef DEBUG
 703      -                if (zone == NULL && tnode->tree_exi != NULL)
 704      -                        zone = tnode->tree_exi->exi_zone;
 705      -#endif
 706  699                  if (TREE_ROOT(tnode)) {
 707      -                        ASSERT3P(zone, ==, tnode->tree_exi->exi_zone);
 708  700                          exi_ret = tnode->tree_exi;
 709  701                          break;
 710  702                  }
 711  703          }
 712  704  
 713      -        ASSERT(exi_ret); /* Every visible should have its home exportinfo */
      705 +        /* Every visible should have its home exportinfo */
      706 +        ASSERT(exi_ret != NULL);
 714  707          return (exi_ret);
 715  708  }
 716  709  
 717  710  /*
 718  711   * For NFS V4.
 719  712   * Add or remove the newly exported or unexported security flavors of the
 720  713   * given exportinfo from its ancestors upto the system root.
 721  714   */
 722  715  static void
 723  716  srv_secinfo_treeclimb(nfs_export_t *ne, exportinfo_t *exip, secinfo_t *sec,
 724  717      int seccnt, bool_t isadd)
 725  718  {
 726  719          treenode_t *tnode;
 727  720  
 728  721          ASSERT(RW_WRITE_HELD(&ne->exported_lock));
 729      -        ASSERT3U(exip->exi_zoneid, ==, curzone->zone_id);
 730  722  
 731  723          /*
 732  724           * exi_tree can be null for the zone root
 733  725           * which means we're already at the "top"
 734  726           * and there's nothing more to "climb".
 735  727           */
 736  728          tnode = exip->exi_tree;
 737  729          if (tnode == NULL) {
 738  730                  /* Should only happen for... */
 739  731                  ASSERT(exip == ne->exi_root);
↓ open down ↓ 4 lines elided ↑ open up ↑
 744  736                  return;
 745  737  
 746  738          /*
 747  739           * If flavors are being added and the new export root isn't
 748  740           * also VROOT, its implicitly allowed flavors are inherited from
 749  741           * its pseudonode.
 750  742           * Note - for VROOT exports the implicitly allowed flavors were
 751  743           * transferred from the PSEUDO export in exportfs()
 752  744           */
 753  745          if (isadd && !(exip->exi_vp->v_flag & VROOT) &&
 754      -            !VN_IS_CURZONEROOT(exip->exi_vp) &&
      746 +            !VN_CMP(exip->exi_vp, EXI_TO_ZONEROOTVP(exip)) &&
 755  747              tnode->tree_vis->vis_seccnt > 0) {
 756  748                  srv_secinfo_add(&exip->exi_export.ex_secinfo,
 757  749                      &exip->exi_export.ex_seccnt, tnode->tree_vis->vis_secinfo,
 758  750                      tnode->tree_vis->vis_seccnt, FALSE);
 759  751          }
 760  752  
 761  753          /*
 762  754           * Move to parent node and propagate sec flavor
 763  755           * to exportinfo and to visible structures.
 764  756           */
↓ open down ↓ 52 lines elided ↑ open up ↑
 817  809          exportinfo_t **bckt;
 818  810  
 819  811          ASSERT(RW_WRITE_HELD(&ne->exported_lock));
 820  812  
 821  813          bckt = &ne->exptable[exptablehash(&exi->exi_fsid, &exi->exi_fid)];
 822  814          exp_hash_link(exi, fid_hash, bckt);
 823  815  
 824  816          bckt = &ne->exptable_path_hash[pkp_tab_hash(exi->exi_export.ex_path,
 825  817              strlen(exi->exi_export.ex_path))];
 826  818          exp_hash_link(exi, path_hash, bckt);
      819 +        exi->exi_ne = ne;
 827  820  }
 828  821  
 829  822  /*
 830  823   * Helper functions for exi_id handling
 831  824   */
 832  825  static int
 833  826  exi_id_compar(const void *v1, const void *v2)
 834  827  {
 835  828          const struct exportinfo *e1 = v1;
 836  829          const struct exportinfo *e2 = v2;
↓ open down ↓ 86 lines elided ↑ open up ↑
 923  916          ne->exi_root->exi_export.ex_path[1] = '\0';
 924  917  
 925  918          ne->exi_root->exi_count = 1;
 926  919          mutex_init(&ne->exi_root->exi_lock, NULL, MUTEX_DEFAULT, NULL);
 927  920  
 928  921          /*
 929  922           * Because we cannot:
 930  923           *      ASSERT(curzone->zone_id == ng->nfs_zoneid);
 931  924           * We grab the zone pointer explicitly (like netstacks do) and
 932  925           * set the rootvp here.
      926 +         *
      927 +         * Subsequent exportinfo_t's that get export_link()ed to "ne" also
      928 +         * will backpoint to "ne" such that exi->exi_ne->exi_root->exi_vp
      929 +         * will get the zone's rootvp for a given exportinfo_t.
 933  930           */
 934  931          zone = zone_find_by_id_nolock(ng->nfs_zoneid);
 935  932          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! */
      933 +        ne->exi_root->exi_zoneid = ng->nfs_zoneid;
 938  934  
 939  935          /*
 940  936           * Fill in ne->exi_rootfid later, in nfs_export_get_rootfid
 941  937           * because we can't correctly return errors here.
 942  938           */
 943  939  
 944  940          /* Initialize auth cache and auth cache lock */
 945  941          for (i = 0; i < AUTH_TABLESIZE; i++) {
 946  942                  ne->exi_root->exi_cache[i] = kmem_alloc(sizeof (avl_tree_t),
 947  943                      KM_SLEEP);
↓ open down ↓ 457 lines elided ↑ open up ↑
1405 1401          }
1406 1402          DTRACE_PROBE(nfss__i__exported_lock2_stop);
1407 1403          rw_exit(&ne->exported_lock);
1408 1404          pn_free(&lookpn);
1409 1405  
1410 1406          exi = kmem_zalloc(sizeof (*exi), KM_SLEEP);
1411 1407          exi->exi_fsid = fsid;
1412 1408          exi->exi_fid = fid;
1413 1409          exi->exi_vp = vp;
1414 1410          exi->exi_count = 1;
1415      -        exi->exi_zone = crgetzone(cr);
1416      -        ASSERT(exi->exi_zone != NULL);          /* XXX KEBE ASKS... */
1417      -        ASSERT3P(exi->exi_zone, ==, curzone);   /* ... are these legit? */
     1411 +        exi->exi_zoneid = crgetzoneid(cr);
     1412 +        ASSERT3U(exi->exi_zoneid, ==, curzone->zone_id);
1418 1413          exi->exi_volatile_dev = (vfssw[vp->v_vfsp->vfs_fstype].vsw_flag &
1419 1414              VSW_VOLATILEDEV) ? 1 : 0;
1420 1415          mutex_init(&exi->exi_lock, NULL, MUTEX_DEFAULT, NULL);
1421 1416          exi->exi_dvp = dvp;
1422 1417  
1423 1418          /*
1424 1419           * Initialize auth cache and auth cache lock
1425 1420           */
1426 1421          for (i = 0; i < AUTH_TABLESIZE; i++) {
1427 1422                  exi->exi_cache[i] = kmem_alloc(sizeof (avl_tree_t), KM_SLEEP);
↓ open down ↓ 449 lines elided ↑ open up ↑
1877 1872  /*
1878 1873   * Remove the exportinfo from the export list
1879 1874   */
1880 1875  void
1881 1876  export_unlink(nfs_export_t *ne, struct exportinfo *exi)
1882 1877  {
1883 1878          ASSERT(RW_WRITE_HELD(&ne->exported_lock));
1884 1879  
1885 1880          exp_hash_unlink(exi, fid_hash);
1886 1881          exp_hash_unlink(exi, path_hash);
     1882 +        ASSERT3P(exi->exi_ne, ==, ne);
     1883 +        exi->exi_ne = NULL;
1887 1884  }
1888 1885  
1889 1886  /*
1890 1887   * Unexport an exported filesystem
1891 1888   */
1892 1889  static int
1893 1890  unexport(nfs_export_t *ne, struct exportinfo *exi)
1894 1891  {
1895 1892          struct secinfo cursec[MAX_FLAVORS];
1896 1893          int curcnt;
↓ open down ↓ 24 lines elided ↑ open up ↑
1921 1918           * for paths to exports below.
1922 1919           */
1923 1920          if (exi->exi_visible != NULL) {
1924 1921                  struct exportinfo *newexi;
1925 1922  
1926 1923                  newexi = pseudo_exportfs(ne, exi->exi_vp, &exi->exi_fid,
1927 1924                      exi->exi_visible, &exi->exi_export);
1928 1925                  exi->exi_visible = NULL;
1929 1926  
1930 1927                  /* interconnect the existing treenode with the new exportinfo */
1931      -                newexi->exi_zone = exi->exi_zone; /* XXX KEBE SAYS LOSE ME */
1932 1928                  newexi->exi_tree = exi->exi_tree;
1933 1929                  newexi->exi_tree->tree_exi = newexi;
1934 1930  
1935 1931                  /* Update the change timestamp */
1936 1932                  tree_update_change(ne, exi->exi_tree, NULL);
1937 1933          } else {
1938 1934                  treeclimb_unexport(ne, exi);
1939 1935          }
1940 1936  
1941 1937          rw_exit(&ne->exported_lock);
↓ open down ↓ 1054 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX