patch-2.1.56 linux/fs/dcache.c

Next file: linux/fs/exec.c
Previous file: linux/fs/buffer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.55/linux/fs/dcache.c linux/fs/dcache.c
@@ -119,7 +119,7 @@
  * something (at which point we need to unuse
  * all dentries).
  */
-void shrink_dcache(void)
+void prune_dcache(int count)
 {
 	for (;;) {
 		struct dentry *dentry;
@@ -143,6 +143,8 @@
 			parent = dentry->d_parent;
 			d_free(dentry);
 			dput(parent);
+			if (!--count)
+				break;
 		}
 	}
 }
@@ -177,7 +179,12 @@
 	dentry->d_count = 1;
 	dentry->d_flags = 0;
 	dentry->d_inode = NULL;
-	dentry->d_parent = dget(parent);
+	dentry->d_parent = NULL;
+	dentry->d_sb = NULL;
+	if (parent) {
+		dentry->d_parent = dget(parent);
+		dentry->d_sb = parent->d_sb;
+	}
 	dentry->d_mounts = dentry;
 	dentry->d_covers = dentry;
 	INIT_LIST_HEAD(&dentry->d_hash);
@@ -211,8 +218,11 @@
 
 	if (root_inode) {
 		res = d_alloc(NULL, &(const struct qstr) { "/", 1, 0 });
-		res->d_parent = res;
-		d_instantiate(res, root_inode);
+		if (res) {
+			res->d_sb = root_inode->i_sb;
+			res->d_parent = res;
+			d_instantiate(res, root_inode);
+		}
 	}
 	return res;
 }
@@ -344,7 +354,7 @@
 	x = y; y = __tmp; } while (0)
 
 /*
- * We cannibalize "newdentry" when moving dentry on top of it,
+ * We cannibalize "target" when moving dentry on top of it,
  * because it's going to be thrown away anyway. We could be more
  * polite about it, though.
  *

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov