--- old/usr/src/uts/common/fs/tmpfs/tmp_vnops.c	Wed Oct  5 00:33:44 2016
+++ new/usr/src/uts/common/fs/tmpfs/tmp_vnops.c	Wed Oct  5 00:33:44 2016
@@ -25,7 +25,7 @@
  */
 
 /*
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2016, Joyent, Inc.
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2016 RackTop Systems.
  */
@@ -585,10 +585,6 @@
 	struct tmount *tm = (struct tmount *)VTOTM(vp);
 	int error;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	/*
 	 * We don't currently support reading non-regular files
 	 */
@@ -618,10 +614,6 @@
 	struct tmount *tm = (struct tmount *)VTOTM(vp);
 	int error;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	/*
 	 * We don't currently support writing to non-regular files
 	 */
@@ -847,9 +839,6 @@
 	struct tmpnode *ntp = NULL;
 	int error;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (dvp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
 
 	/* allow cd into @ dir */
 	if (flags & LOOKUP_XATTR) {
@@ -868,8 +857,6 @@
 
 		rw_enter(&tp->tn_rwlock, RW_WRITER);
 		if (tp->tn_xattrdp == NULL) {
-			int err;
-
 			if (!(flags & CREATE_XATTR_DIR)) {
 				rw_exit(&tp->tn_rwlock);
 				return (ENOENT);
@@ -890,13 +877,9 @@
 				return (error);
 			}
 
+			xdp = tmp_memalloc(sizeof (struct tmpnode),
+			    TMP_MUSTHAVE);
 			tm = VTOTM(dvp);
-			xdp = tmp_kmem_zalloc(tm, sizeof (struct tmpnode),
-			    KM_SLEEP);
-			if (xdp == NULL) {
-				rw_exit(&tp->tn_rwlock);
-				return (ENOSPC);
-			}
 			tmpnode_init(tm, xdp, &tp->tn_attr, NULL);
 			/*
 			 * Fix-up fields unique to attribute directories.
@@ -914,16 +897,7 @@
 			}
 			xdp->tn_vnode->v_type = VDIR;
 			xdp->tn_vnode->v_flag |= V_XATTRDIR;
-			if ((err = tdirinit(tp, xdp)) != 0) {
-				rw_exit(&tp->tn_rwlock);
-				/*
-				 * This never got properly initialized so we can
-				 * just clean it up.
-				 */
-				xdp->tn_vnode->v_flag &= V_XATTRDIR;
-				tmpnode_cleanup(tp);
-				return (err);
-			}
+			tdirinit(tp, xdp);
 			tp->tn_xattrdp = xdp;
 		} else {
 			VN_HOLD(tp->tn_xattrdp->tn_vnode);
@@ -1505,10 +1479,6 @@
 	int reclen;
 	caddr_t outbuf;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	if (uiop->uio_loffset >= MAXOFF_T) {
 		if (eofp)
 			*eofp = 1;
@@ -1642,12 +1612,12 @@
 	rw_exit(&parent->tn_rwlock);
 
 	if (error) {
-		if (self != NULL)
+		if (self)
 			tmpnode_rele(self);
 		return (error);
 	}
 	len = strlen(tnm) + 1;
-	cp = tmp_kmem_zalloc(tm, len, KM_NOSLEEP | KM_NORMALPRI);
+	cp = tmp_memalloc(len, 0);
 	if (cp == NULL) {
 		tmpnode_rele(self);
 		return (ENOSPC);
@@ -1712,27 +1682,10 @@
 	 * there's little to do -- just drop our hold.
 	 */
 	if (vp->v_count > 1 || tp->tn_nlink != 0) {
-		if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED) {
-			/*
-			 * Since the file system was forcibly unmounted, we can
-			 * have a case (v_count == 1, tn_nlink != 0) where this
-			 * file was open so we didn't add an extra hold on the
-			 * file in tmp_unmount. We are counting on the
-			 * interaction of the hold made in tmp_unmount and
-			 * rele-ed in tmp_vfsfree so we need to be sure we
-			 * don't decrement in this case.
-			 */
-			if (vp->v_count > 1)
-				vp->v_count--;
-		} else {
-			vp->v_count--;
-		}
+		vp->v_count--;
 		mutex_exit(&vp->v_lock);
 		mutex_exit(&tp->tn_tlock);
 		rw_exit(&tp->tn_rwlock);
-		/* If the filesystem was umounted by force, rele the vfs ref */
-		if (tm->tm_vfsp->vfs_flag & VFS_UNMOUNTED)
-			VFS_RELE(tm->tm_vfsp);
 		return;
 	}
 
@@ -1757,7 +1710,7 @@
 			goto top;
 		}
 		if (tp->tn_type == VLNK)
-			tmp_kmem_free(tm, tp->tn_symlink, tp->tn_size + 1);
+			tmp_memfree(tp->tn_symlink, tp->tn_size + 1);
 	}
 
 	/*
@@ -1791,11 +1744,7 @@
 	rw_destroy(&tp->tn_rwlock);
 	mutex_destroy(&tp->tn_tlock);
 	vn_free(TNTOV(tp));
-	tmp_kmem_free(tm, tp, sizeof (struct tmpnode));
-
-	/* If the filesystem was umounted by force, rele the vfs ref */
-	if (tm->tm_vfsp->vfs_flag & VFS_UNMOUNTED)
-		VFS_RELE(tm->tm_vfsp);
+	tmp_memfree(tp, sizeof (struct tmpnode));
 }
 
 /* ARGSUSED2 */
@@ -1917,10 +1866,6 @@
 	struct vnode *pvp;
 	u_offset_t poff;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	if (protp != NULL)
 		*protp = PROT_ALL;
 again:
@@ -2142,10 +2087,6 @@
 	u_offset_t offset;
 	u_offset_t tmpoff;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	ASSERT(PAGE_LOCKED(pp));
 
 	/* Kluster in tmp_klustsize chunks */
