6939136 assertion failed: dv->sdev_nlink == 0, file: ../../common/fs/dev/sdev_subr.c, line: 905
authorJerry Gilliam <Jerry.Gilliam@Sun.COM>
Tue, 11 May 2010 17:02:46 -0700
changeset 12387 e2a7d18f1d90
parent 12386 b989d9696c5b
child 12388 1bc8d55b0dfd
6939136 assertion failed: dv->sdev_nlink == 0, file: ../../common/fs/dev/sdev_subr.c, line: 905
usr/src/uts/common/fs/dev/sdev_vnops.c
--- a/usr/src/uts/common/fs/dev/sdev_vnops.c	Tue May 11 15:16:46 2010 -0700
+++ b/usr/src/uts/common/fs/dev/sdev_vnops.c	Tue May 11 17:02:46 2010 -0700
@@ -508,7 +508,7 @@
 	struct vnode *vp = NULL;
 	struct sdev_node *dv = NULL;
 	int len;
-	int bkstore = 0;
+	int bkstore;
 
 	/* bail out early */
 	len = strlen(nm);
@@ -555,17 +555,25 @@
 		return (error);
 	}
 
+	bkstore = SDEV_IS_PERSIST(dv) ? 1 : 0;
+	if (!rw_tryupgrade(&parent->sdev_contents)) {
+		rw_exit(&parent->sdev_contents);
+		rw_enter(&parent->sdev_contents, RW_WRITER);
+	}
+
+	/* we do not support unlinking a non-empty directory */
+	if (vp->v_type == VDIR && dv->sdev_nlink > 2) {
+		rw_exit(&parent->sdev_contents);
+		VN_RELE(vp);
+		return (EBUSY);
+	}
+
 	/*
 	 * sdev_dirdelete does the real job of:
 	 *  - make sure no open ref count
 	 *  - destroying the sdev_node
 	 *  - releasing the hold on attrvp
 	 */
-	bkstore = SDEV_IS_PERSIST(dv) ? 1 : 0;
-	if (!rw_tryupgrade(&parent->sdev_contents)) {
-		rw_exit(&parent->sdev_contents);
-		rw_enter(&parent->sdev_contents, RW_WRITER);
-	}
 	error = sdev_cache_update(parent, &dv, nm, SDEV_CACHE_DELETE);
 	rw_exit(&parent->sdev_contents);