usr/src/uts/common/fs/zfs/zfs_dir.c
changeset 5860 4e1dc300d1d7
parent 5824 1d2d522d19b5
child 5959 1e1904b8526d
--- a/usr/src/uts/common/fs/zfs/zfs_dir.c	Thu Jan 17 21:40:02 2008 -0800
+++ b/usr/src/uts/common/fs/zfs/zfs_dir.c	Fri Jan 18 10:20:38 2008 -0800
@@ -505,7 +505,9 @@
 
 /*
  * Delete the entire contents of a directory.  Return a count
- * of the number of entries that could not be deleted.
+ * of the number of entries that could not be deleted. If we encounter
+ * an error, return a count of at least one so that the directory stays
+ * in the unlinked set.
  *
  * NOTE: this function assumes that the directory is inactive,
  *	so there is no need to lock its entries before deletion.
@@ -529,7 +531,10 @@
 	    zap_cursor_advance(&zc)) {
 		error = zfs_zget(zfsvfs,
 		    ZFS_DIRENT_OBJ(zap.za_first_integer), &xzp);
-		ASSERT3U(error, ==, 0);
+		if (error) {
+			skipped += 1;
+			continue;
+		}
 
 		ASSERT((ZTOV(xzp)->v_type == VREG) ||
 		    (ZTOV(xzp)->v_type == VLNK));
@@ -551,13 +556,15 @@
 		dl.dl_name = zap.za_name;
 
 		error = zfs_link_destroy(&dl, xzp, tx, 0, NULL);
-		ASSERT3U(error, ==, 0);
+		if (error)
+			skipped += 1;
 		dmu_tx_commit(tx);
 
 		VN_RELE(ZTOV(xzp));
 	}
 	zap_cursor_fini(&zc);
-	ASSERT(error == ENOENT);
+	if (error != ENOENT)
+		skipped += 1;
 	return (skipped);
 }