--- old/usr/src/uts/common/fs/nfs/nfs3_srv.c	2012-08-04 02:30:35.694492713 +0400
+++ new/usr/src/uts/common/fs/nfs/nfs3_srv.c	2012-08-04 02:30:35.074492697 +0400
@@ -71,12 +71,6 @@
  * for a description of this interface.
  */
 
-#ifdef DEBUG
-int rfs3_do_pre_op_attr = 1;
-int rfs3_do_post_op_attr = 1;
-int rfs3_do_post_op_fh3 = 1;
-#endif
-
 static writeverf3 write3verf;
 
 static int	sattr3_to_vattr(sattr3 *, struct vattr *);
@@ -227,12 +221,7 @@
 	if (error)
 		goto out;
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr)
-		bvap = &bva;
-#else
 	bvap = &bva;
-#endif
 
 	if (rdonly(exi, req) || vn_is_readonly(vp)) {
 		resp->status = NFS3ERR_ROFS;
@@ -322,16 +311,8 @@
 		goto out1;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		ava.va_mask = AT_ALL;
-		avap = rfs4_delegated_getattr(vp, &ava, 0, cr) ? NULL : &ava;
-	} else
-		avap = NULL;
-#else
 	ava.va_mask = AT_ALL;
 	avap = rfs4_delegated_getattr(vp, &ava, 0, cr) ? NULL : &ava;
-#endif
 
 	/*
 	 * Force modified metadata out to stable storage.
@@ -421,15 +402,8 @@
 		}
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		dva.va_mask = AT_ALL;
-		dvap = VOP_GETATTR(dvp, &dva, 0, cr, NULL) ? NULL : &dva;
-	}
-#else
 	dva.va_mask = AT_ALL;
 	dvap = VOP_GETATTR(dvp, &dva, 0, cr, NULL) ? NULL : &dva;
-#endif
 
 	if (args->what.name == nfs3nametoolong) {
 		resp->status = NFS3ERR_NAMETOOLONG;
@@ -457,16 +431,25 @@
 		goto out1;
 	}
 
+	exi_hold(exi);
+
 	/*
 	 * If the public filehandle is used then allow
 	 * a multi-component lookup
 	 */
 	if (PUBLIC_FH3(&args->what.dir)) {
+		struct exportinfo *new;
+
 		publicfh_flag = TRUE;
+
 		error = rfs_publicfh_mclookup(name, dvp, cr, &vp,
-		    &exi, &sec);
-		if (error && exi != NULL)
-			exi_rele(exi); /* See comment below Re: publicfh_flag */
+		    &new, &sec);
+
+		if (error == 0) {
+			exi_rele(exi);
+			exi = new;
+		}
+
 		/*
 		 * Since WebNFS may bypass MOUNT, we need to ensure this
 		 * request didn't come from an unlabeled admin_low client.
@@ -488,8 +471,6 @@
 			if (tp == NULL || tp->tpc_tp.tp_doi !=
 			    l_admin_low->tsl_doi || tp->tpc_tp.host_type !=
 			    SUN_CIPSO) {
-				if (exi != NULL)
-					exi_rele(exi);
 				VN_RELE(vp);
 				resp->status = NFS3ERR_ACCES;
 				error = 1;
@@ -505,6 +486,12 @@
 	if (name != args->what.name)
 		kmem_free(name, MAXPATHLEN + 1);
 
+	if (error == 0 && vn_ismntpt(vp)) {
+		error = rfs_cross_mnt(&vp, &exi);
+		if (error)
+			VN_RELE(vp);
+	}
+
 	if (is_system_labeled() && error == 0) {
 		bslabel_t *clabel = req->rq_label;
 
@@ -515,8 +502,6 @@
 		if (!blequal(&l_admin_low->tsl_label, clabel)) {
 			if (!do_rfs_label_check(clabel, dvp,
 			    DOMINANCE_CHECK, exi)) {
-				if (publicfh_flag && exi != NULL)
-					exi_rele(exi);
 				VN_RELE(vp);
 				resp->status = NFS3ERR_ACCES;
 				error = 1;
@@ -524,16 +509,8 @@
 		}
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		dva.va_mask = AT_ALL;
-		dvap = VOP_GETATTR(dvp, &dva, 0, cr, NULL) ? NULL : &dva;
-	} else
-		dvap = NULL;
-#else
 	dva.va_mask = AT_ALL;
 	dvap = VOP_GETATTR(dvp, &dva, 0, cr, NULL) ? NULL : &dva;
-#endif
 
 	if (error)
 		goto out;
@@ -551,26 +528,10 @@
 		goto out;
 	}
 
-	/*
-	 * If publicfh_flag is true then we have called rfs_publicfh_mclookup
-	 * and have obtained a new exportinfo in exi which needs to be
-	 * released. Note the the original exportinfo pointed to by exi
-	 * will be released by the caller, common_dispatch.
-	 */
-	if (publicfh_flag)
-		exi_rele(exi);
-
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
-#endif
 
+	exi_rele(exi);
 	VN_RELE(vp);
 
 	resp->status = NFS3_OK;
@@ -592,6 +553,12 @@
 	return;
 
 out:
+	/*
+	 * The passed argument exportinfo is released by the
+	 * caller, common_dispatch
+	 */
+	exi_rele(exi);
+
 	if (curthread->t_flag & T_WOULDBLOCK) {
 		curthread->t_flag &= ~T_WOULDBLOCK;
 		resp->status = NFS3ERR_JUKEBOX;
@@ -662,12 +629,7 @@
 	if (error)
 		goto out;
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr)
-		vap = &va;
-#else
 	vap = &va;
-#endif
 
 	resp->resok.access = 0;
 
@@ -742,16 +704,8 @@
 			resp->resok.access |= ACCESS3_EXECUTE;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
-#endif
 
 	resp->status = NFS3_OK;
 	vattr_to_post_op_attr(vap, &resp->resok.obj_attributes);
@@ -816,12 +770,7 @@
 	if (error)
 		goto out;
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr)
-		vap = &va;
-#else
 	vap = &va;
-#endif
 
 	/* We lied about the object type for a referral */
 	if (vn_is_nfs_reparse(vp, cr))
@@ -889,16 +838,9 @@
 			*(data + MAXPATHLEN - uio.uio_resid) = '\0';
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
+
 	/* Lie about object type again just to be consistent */
 	if (is_referral && vap != NULL)
 		vap->va_type = VLNK;
@@ -1077,12 +1019,7 @@
 	if (error)
 		goto out;
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr)
-		vap = &va;
-#else
 	vap = &va;
-#endif
 
 	if (vp->v_type != VREG) {
 		resp->status = NFS3ERR_INVAL;
@@ -1232,20 +1169,10 @@
 	va.va_mask = AT_ALL;
 	error = VOP_GETATTR(vp, &va, 0, cr, &ct);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		if (error)
-			vap = NULL;
-		else
-			vap = &va;
-	} else
-		vap = NULL;
-#else
 	if (error)
 		vap = NULL;
 	else
 		vap = &va;
-#endif
 
 	VOP_RWUNLOCK(vp, V_WRITELOCK_FALSE, &ct);
 
@@ -1419,10 +1346,6 @@
 		goto err;
 
 	bvap = &bva;
-#ifdef DEBUG
-	if (!rfs3_do_pre_op_attr)
-		bvap = NULL;
-#endif
 	avap = bvap;
 
 	if (args->count != args->data.data_len) {
@@ -1534,11 +1457,6 @@
 	ava.va_mask = AT_ALL;
 	avap = VOP_GETATTR(vp, &ava, 0, cr, &ct) ? NULL : &ava;
 
-#ifdef DEBUG
-	if (!rfs3_do_post_op_attr)
-		avap = NULL;
-#endif
-
 	if (error)
 		goto err;
 
@@ -1627,16 +1545,8 @@
 		goto out;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		dbva.va_mask = AT_ALL;
-		dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-	} else
-		dbvap = NULL;
-#else
 	dbva.va_mask = AT_ALL;
 	dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-#endif
 	davap = dbvap;
 
 	if (args->where.name == nfs3nametoolong) {
@@ -1799,16 +1709,8 @@
 	error = VOP_CREATE(dvp, name, &va, excl, VWRITE,
 	    &vp, cr, 0, NULL, NULL);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		dava.va_mask = AT_ALL;
-		davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-	} else
-		davap = NULL;
-#else
 	dava.va_mask = AT_ALL;
 	davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-#endif
 
 	if (error) {
 		/*
@@ -1912,24 +1814,11 @@
 	if (name != args->where.name)
 		kmem_free(name, MAXPATHLEN + 1);
 
-#ifdef DEBUG
-	if (!rfs3_do_post_op_attr)
-		vap = NULL;
-#endif
-
-#ifdef DEBUG
-	if (!rfs3_do_post_op_fh3)
-		resp->resok.obj.handle_follows = FALSE;
-	else {
-#endif
 	error = makefh3(&resp->resok.obj.handle, vp, exi);
 	if (error)
 		resp->resok.obj.handle_follows = FALSE;
 	else
 		resp->resok.obj.handle_follows = TRUE;
-#ifdef DEBUG
-	}
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -2013,16 +1902,8 @@
 		goto out;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		dbva.va_mask = AT_ALL;
-		dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-	} else
-		dbvap = NULL;
-#else
 	dbva.va_mask = AT_ALL;
 	dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-#endif
 	davap = dbvap;
 
 	if (args->where.name == nfs3nametoolong) {
@@ -2082,16 +1963,8 @@
 	if (name != args->where.name)
 		kmem_free(name, MAXPATHLEN + 1);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		dava.va_mask = AT_ALL;
-		davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-	} else
-		davap = NULL;
-#else
 	dava.va_mask = AT_ALL;
 	davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -2101,30 +1974,14 @@
 	if (error)
 		goto out;
 
-#ifdef DEBUG
-	if (!rfs3_do_post_op_fh3)
-		resp->resok.obj.handle_follows = FALSE;
-	else {
-#endif
 	error = makefh3(&resp->resok.obj.handle, vp, exi);
 	if (error)
 		resp->resok.obj.handle_follows = FALSE;
 	else
 		resp->resok.obj.handle_follows = TRUE;
-#ifdef DEBUG
-	}
-#endif
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -2194,16 +2051,8 @@
 		goto err;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		dbva.va_mask = AT_ALL;
-		dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-	} else
-		dbvap = NULL;
-#else
 	dbva.va_mask = AT_ALL;
 	dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-#endif
 	davap = dbvap;
 
 	if (args->where.name == nfs3nametoolong) {
@@ -2275,16 +2124,8 @@
 
 	error = VOP_SYMLINK(dvp, name, &va, symdata, cr, NULL, 0);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		dava.va_mask = AT_ALL;
-		davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-	} else
-		davap = NULL;
-#else
 	dava.va_mask = AT_ALL;
 	davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-#endif
 
 	if (error)
 		goto err;
@@ -2306,30 +2147,14 @@
 		goto out;
 	}
 
-#ifdef DEBUG
-	if (!rfs3_do_post_op_fh3)
-		resp->resok.obj.handle_follows = FALSE;
-	else {
-#endif
 	error = makefh3(&resp->resok.obj.handle, vp, exi);
 	if (error)
 		resp->resok.obj.handle_follows = FALSE;
 	else
 		resp->resok.obj.handle_follows = TRUE;
-#ifdef DEBUG
-	}
-#endif
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -2402,16 +2227,8 @@
 		goto out;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		dbva.va_mask = AT_ALL;
-		dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-	} else
-		dbvap = NULL;
-#else
 	dbva.va_mask = AT_ALL;
 	dbvap = VOP_GETATTR(dvp, &dbva, 0, cr, NULL) ? NULL : &dbva;
-#endif
 	davap = dbvap;
 
 	if (args->where.name == nfs3nametoolong) {
@@ -2513,16 +2330,8 @@
 	if (name != args->where.name)
 		kmem_free(name, MAXPATHLEN + 1);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		dava.va_mask = AT_ALL;
-		davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-	} else
-		davap = NULL;
-#else
 	dava.va_mask = AT_ALL;
 	davap = VOP_GETATTR(dvp, &dava, 0, cr, NULL) ? NULL : &dava;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -2534,30 +2343,14 @@
 
 	resp->status = NFS3_OK;
 
-#ifdef DEBUG
-	if (!rfs3_do_post_op_fh3)
-		resp->resok.obj.handle_follows = FALSE;
-	else {
-#endif
 	error = makefh3(&resp->resok.obj.handle, vp, exi);
 	if (error)
 		resp->resok.obj.handle_follows = FALSE;
 	else
 		resp->resok.obj.handle_follows = TRUE;
-#ifdef DEBUG
-	}
-#endif
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	/*
 	 * Force modified metadata out to stable storage.
@@ -2626,16 +2419,8 @@
 		goto err;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		bva.va_mask = AT_ALL;
-		bvap = VOP_GETATTR(vp, &bva, 0, cr, NULL) ? NULL : &bva;
-	} else
-		bvap = NULL;
-#else
 	bva.va_mask = AT_ALL;
 	bvap = VOP_GETATTR(vp, &bva, 0, cr, NULL) ? NULL : &bva;
-#endif
 	avap = bvap;
 
 	if (vp->v_type != VDIR) {
@@ -2711,16 +2496,8 @@
 	VN_RELE(targvp);
 	targvp = NULL;
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		ava.va_mask = AT_ALL;
-		avap = VOP_GETATTR(vp, &ava, 0, cr, NULL) ? NULL : &ava;
-	} else
-		avap = NULL;
-#else
 	ava.va_mask = AT_ALL;
 	avap = VOP_GETATTR(vp, &ava, 0, cr, NULL) ? NULL : &ava;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -2786,16 +2563,8 @@
 		goto err;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		bva.va_mask = AT_ALL;
-		bvap = VOP_GETATTR(vp, &bva, 0, cr, NULL) ? NULL : &bva;
-	} else
-		bvap = NULL;
-#else
 	bva.va_mask = AT_ALL;
 	bvap = VOP_GETATTR(vp, &bva, 0, cr, NULL) ? NULL : &bva;
-#endif
 	avap = bvap;
 
 	if (vp->v_type != VDIR) {
@@ -2848,16 +2617,8 @@
 	if (name != args->object.name)
 		kmem_free(name, MAXPATHLEN + 1);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		ava.va_mask = AT_ALL;
-		avap = VOP_GETATTR(vp, &ava, 0, cr, NULL) ? NULL : &ava;
-	} else
-		avap = NULL;
-#else
 	ava.va_mask = AT_ALL;
 	avap = VOP_GETATTR(vp, &ava, 0, cr, NULL) ? NULL : &ava;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -2958,16 +2719,8 @@
 		}
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		fbva.va_mask = AT_ALL;
-		fbvap = VOP_GETATTR(fvp, &fbva, 0, cr, NULL) ? NULL : &fbva;
-	} else
-		fbvap = NULL;
-#else
 	fbva.va_mask = AT_ALL;
 	fbvap = VOP_GETATTR(fvp, &fbva, 0, cr, NULL) ? NULL : &fbva;
-#endif
 	favap = fbvap;
 
 	fh3 = &args->to.dir;
@@ -2989,16 +2742,8 @@
 		goto err;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		tbva.va_mask = AT_ALL;
-		tbvap = VOP_GETATTR(tvp, &tbva, 0, cr, NULL) ? NULL : &tbva;
-	} else
-		tbvap = NULL;
-#else
 	tbva.va_mask = AT_ALL;
 	tbvap = VOP_GETATTR(tvp, &tbva, 0, cr, NULL) ? NULL : &tbva;
-#endif
 	tavap = tbvap;
 
 	if (fvp->v_type != VDIR || tvp->v_type != VDIR) {
@@ -3100,22 +2845,10 @@
 	VN_RELE(srcvp);
 	srcvp = NULL;
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		fava.va_mask = AT_ALL;
-		favap = VOP_GETATTR(fvp, &fava, 0, cr, NULL) ? NULL : &fava;
-		tava.va_mask = AT_ALL;
-		tavap = VOP_GETATTR(tvp, &tava, 0, cr, NULL) ? NULL : &tava;
-	} else {
-		favap = NULL;
-		tavap = NULL;
-	}
-#else
 	fava.va_mask = AT_ALL;
 	favap = VOP_GETATTR(fvp, &fava, 0, cr, NULL) ? NULL : &fava;
 	tava.va_mask = AT_ALL;
 	tavap = VOP_GETATTR(tvp, &tava, 0, cr, NULL) ? NULL : &tava;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -3197,16 +2930,8 @@
 		goto out;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	fh3 = &args->link.dir;
 	to_exi = checkexport(&fh3->fh3_fsid, FH3TOXFIDP(fh3));
@@ -3243,16 +2968,8 @@
 		goto out;
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		bva.va_mask = AT_ALL;
-		bvap = VOP_GETATTR(dvp, &bva, 0, cr, NULL) ? NULL : &bva;
-	} else
-		bvap = NULL;
-#else
 	bva.va_mask = AT_ALL;
 	bvap = VOP_GETATTR(dvp, &bva, 0, cr, NULL) ? NULL : &bva;
-#endif
 
 	if (dvp->v_type != VDIR) {
 		resp->status = NFS3ERR_NOTDIR;
@@ -3298,22 +3015,10 @@
 
 	error = VOP_LINK(dvp, vp, name, cr, NULL, 0);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-		ava.va_mask = AT_ALL;
-		avap = VOP_GETATTR(dvp, &ava, 0, cr, NULL) ? NULL : &ava;
-	} else {
-		vap = NULL;
-		avap = NULL;
-	}
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
 	ava.va_mask = AT_ALL;
 	avap = VOP_GETATTR(dvp, &ava, 0, cr, NULL) ? NULL : &ava;
-#endif
 
 	/*
 	 * Force modified data and metadata out to stable storage.
@@ -3442,16 +3147,8 @@
 
 	(void) VOP_RWLOCK(vp, V_WRITELOCK_FALSE, NULL);
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	if (vp->v_type != VDIR) {
 		resp->status = NFS3ERR_NOTDIR;
@@ -3491,16 +3188,8 @@
 
 	error = VOP_READDIR(vp, &uio, cr, &iseof, NULL, 0);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	if (error) {
 		kmem_free(data, count);
@@ -3730,16 +3419,8 @@
 
 	(void) VOP_RWLOCK(vp, V_WRITELOCK_FALSE, NULL);
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	if (vp->v_type != VDIR) {
 		error = ENOTDIR;
@@ -3898,19 +3579,9 @@
 
 		/* else, fall through */
 	}
-
 good:
-
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	VOP_RWUNLOCK(vp, V_WRITELOCK_FALSE, NULL);
 
@@ -3938,36 +3609,25 @@
 			continue;
 		}
 
-#ifdef DEBUG
-		if (rfs3_do_post_op_attr) {
-			nva.va_mask = AT_ALL;
-			nvap = rfs4_delegated_getattr(nvp, &nva, 0, cr) ?
-			    NULL : &nva;
-		} else
-			nvap = NULL;
-#else
 		nva.va_mask = AT_ALL;
 		nvap = rfs4_delegated_getattr(nvp, &nva, 0, cr) ? NULL : &nva;
-#endif
+
 		/* Lie about the object type for a referral */
 		if (vn_is_nfs_reparse(nvp, cr))
 			nvap->va_type = VLNK;
 
-		vattr_to_post_op_attr(nvap, &infop[i].attr);
-
-#ifdef DEBUG
-		if (!rfs3_do_post_op_fh3)
-			infop[i].fh.handle_follows = FALSE;
-		else {
-#endif
-		error = makefh3(&infop[i].fh.handle, nvp, exi);
-		if (!error)
-			infop[i].fh.handle_follows = TRUE;
-		else
+		if (vn_ismntpt(nvp)) {
+			infop[i].attr.attributes = FALSE;
 			infop[i].fh.handle_follows = FALSE;
-#ifdef DEBUG
+		} else {
+			vattr_to_post_op_attr(nvap, &infop[i].attr);
+
+			error = makefh3(&infop[i].fh.handle, nvp, exi);
+			if (!error)
+				infop[i].fh.handle_follows = TRUE;
+			else
+				infop[i].fh.handle_follows = FALSE;
 		}
-#endif
 
 		VN_RELE(nvp);
 		dp = nextdp(dp);
@@ -4106,16 +3766,8 @@
 
 	error = VFS_STATVFS(vp->v_vfsp, &sb);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	if (error)
 		goto out;
@@ -4211,16 +3863,8 @@
 		}
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	resp->status = NFS3_OK;
 	vattr_to_post_op_attr(vap, &resp->resok.obj_attributes);
@@ -4323,16 +3967,8 @@
 		}
 	}
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		va.va_mask = AT_ALL;
-		vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-	} else
-		vap = NULL;
-#else
 	va.va_mask = AT_ALL;
 	vap = VOP_GETATTR(vp, &va, 0, cr, NULL) ? NULL : &va;
-#endif
 
 	error = VOP_PATHCONF(vp, _PC_LINK_MAX, &val, cr, NULL);
 	if (error)
@@ -4424,14 +4060,7 @@
 	if (error)
 		goto out;
 
-#ifdef DEBUG
-	if (rfs3_do_pre_op_attr)
-		bvap = &bva;
-	else
-		bvap = NULL;
-#else
 	bvap = &bva;
-#endif
 
 	if (rdonly(exi, req)) {
 		resp->status = NFS3ERR_ROFS;
@@ -4465,16 +4094,8 @@
 
 	error = VOP_FSYNC(vp, FSYNC, cr, NULL);
 
-#ifdef DEBUG
-	if (rfs3_do_post_op_attr) {
-		ava.va_mask = AT_ALL;
-		avap = VOP_GETATTR(vp, &ava, 0, cr, NULL) ? NULL : &ava;
-	} else
-		avap = NULL;
-#else
 	ava.va_mask = AT_ALL;
 	avap = VOP_GETATTR(vp, &ava, 0, cr, NULL) ? NULL : &ava;
-#endif
 
 	if (error)
 		goto out;
