Print this page
Be far more judicious in the use of curzone-using macros.
(Merge and extra asserts by danmcd.)
Try to remove assumption that zone's root vnode is marked VROOT

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/nfs/nfs4_srv_attr.c
          +++ new/usr/src/uts/common/fs/nfs/nfs4_srv_attr.c
↓ open down ↓ 127 lines elided ↑ open up ↑
 128  128   */
 129  129  void
 130  130  rfs4_attr_init()
 131  131  {
 132  132          int i;
 133  133          struct nfs4_svgetit_arg sarg;
 134  134          struct compound_state cs;
 135  135          struct statvfs64 sb;
 136  136  
 137  137          rfs4_init_compound_state(&cs);
 138      -        cs.vp = ZONE_ROOTVP();
      138 +        /*
      139 +         * This is global state checking, called once. We might be in
      140 +         * non-global-zone context here (say a modload happens from a zone
      141 +         * process) so in this case, we want the global-zone root vnode.
      142 +         */
      143 +        cs.vp = rootvp;
 139  144          cs.fh.nfs_fh4_val = NULL;
 140  145          cs.cr = kcred;
 141  146  
 142  147          /*
 143  148           * Get all the supported attributes
 144  149           */
 145  150          sarg.op = NFS4ATTR_SUPPORTED;
 146  151          sarg.cs = &cs;
 147  152          sarg.vap->va_mask = AT_ALL;
 148  153          sarg.sbp = &sb;
↓ open down ↓ 1147 lines elided ↑ open up ↑
1296 1301  static int
1297 1302  rfs4_get_mntdfileid(nfs4_attr_cmd_t cmd, struct nfs4_svgetit_arg *sarg)
1298 1303  {
1299 1304          int error = 0;
1300 1305          vattr_t *vap, va;
1301 1306          vnode_t *stubvp = NULL, *vp;
1302 1307  
1303 1308          vp = sarg->cs->vp;
1304 1309          sarg->mntdfid_set = FALSE;
1305 1310  
1306      -        /* VROOT object, must untraverse */
1307      -        if (vp->v_flag & VROOT) {
     1311 +        /*
     1312 +         * VROOT object or zone's root, must untraverse.
     1313 +         *
     1314 +         * NOTE: Not doing reality checks on curzone vs. compound
     1315 +         * state vnode because it will mismatch once at initialization
     1316 +         * if a non-global-zone triggers the module load, BUT in that case
     1317 +         * the vp is literally "/" which has VROOT set.
     1318 +         */
     1319 +        if ((vp->v_flag & VROOT) || VN_IS_CURZONEROOT(vp)) {
1308 1320  
1309 1321                  /* extra hold for vp since untraverse might rele */
1310 1322                  VN_HOLD(vp);
1311 1323                  stubvp = untraverse(vp);
1312 1324  
1313 1325                  /*
1314      -                 * If vp/stubvp are same, we must be at system
     1326 +                 * If vp/stubvp are same, we must be at system-or-zone
1315 1327                   * root because untraverse returned same vp
1316 1328                   * for a VROOT object.  sarg->vap was setup
1317 1329                   * before we got here, so there's no need to do
1318 1330                   * another getattr -- just use the one in sarg.
1319 1331                   */
1320 1332                  if (VN_CMP(vp, stubvp)) {
1321      -                        ASSERT(VN_CMP(vp, ZONE_ROOTVP()));
     1333 +                        ASSERT(VN_IS_CURZONEROOT(vp));
1322 1334                          vap = sarg->vap;
1323 1335                  } else {
1324 1336                          va.va_mask = AT_NODEID;
1325 1337                          vap = &va;
1326 1338                          error = rfs4_vop_getattr(stubvp, vap, 0, sarg->cs->cr);
1327 1339                  }
1328 1340  
1329 1341                  /*
1330 1342                   * Done with stub, time to rele.  If vp and stubvp
1331 1343                   * were the same, then we need to rele either vp or
↓ open down ↓ 38 lines elided ↑ open up ↑
1370 1382          if (RFS4_MANDATTR_ONLY)
1371 1383                  return (ENOTSUP);
1372 1384  
1373 1385          switch (cmd) {
1374 1386          case NFS4ATTR_SUPPORTED:
1375 1387                  if (sarg->op == NFS4ATTR_SETIT)
1376 1388                          error = EINVAL;
1377 1389                  break;          /* this attr is supported */
1378 1390          case NFS4ATTR_GETIT:
1379 1391          case NFS4ATTR_VERIT:
1380      -                if (! sarg->mntdfid_set)
     1392 +                if (!sarg->mntdfid_set)
1381 1393                          error = rfs4_get_mntdfileid(cmd, sarg);
1382 1394  
1383      -                if (! error && sarg->mntdfid_set) {
     1395 +                if (!error && sarg->mntdfid_set) {
1384 1396                          if (cmd == NFS4ATTR_GETIT)
1385 1397                                  na->mounted_on_fileid = sarg->mounted_on_fileid;
1386 1398                          else
1387 1399                                  if (na->mounted_on_fileid !=
1388 1400                                      sarg->mounted_on_fileid)
1389 1401                                          error = -1;
1390 1402                  }
1391 1403                  break;
1392 1404          case NFS4ATTR_SETIT:
1393 1405                  /* read-only attr */
↓ open down ↓ 1469 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX