patch-2.1.79 linux/fs/dcache.c

Next file: linux/fs/dquot.c
Previous file: linux/fs/coda/symlink.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.78/linux/fs/dcache.c linux/fs/dcache.c
@@ -59,6 +59,22 @@
 }
 
 /*
+ * Release the dentry's inode, using the fileystem
+ * d_iput() operation if defined.
+ */
+static inline void dentry_iput(struct dentry * dentry)
+{
+	struct inode *inode = dentry->d_inode;
+	if (inode) {
+		dentry->d_inode = NULL;
+		if (dentry->d_op && dentry->d_op->d_iput)
+			dentry->d_op->d_iput(dentry, inode);
+		else
+			iput(inode);
+	}
+}
+
+/*
  * dput()
  *
  * This is complicated by the fact that we do not want to put
@@ -104,13 +120,10 @@
 		list_del(&dentry->d_lru);
 	}
 	if (list_empty(&dentry->d_hash)) {
-		struct inode *inode = dentry->d_inode;
 		struct dentry * parent;
+
 		list_del(&dentry->d_child);
-		if (inode) {
-			dentry->d_inode = NULL;
-			iput(inode);
-		}
+		dentry_iput(dentry);
 		parent = dentry->d_parent;
 		d_free(dentry);
 		if (dentry == parent)
@@ -146,8 +159,9 @@
 int d_invalidate(struct dentry * dentry)
 {
 	/* Check whether to do a partial shrink_dcache */
-	if (dentry->d_count > 1 && !list_empty(&dentry->d_subdirs))
+	if (!list_empty(&dentry->d_subdirs))
 		shrink_dcache_parent(dentry);
+
 	if (dentry->d_count != 1)
 		return -EBUSY;
 
@@ -259,12 +273,7 @@
 
 	list_del(&dentry->d_hash);
 	list_del(&dentry->d_child);
-	if (dentry->d_inode) {
-		struct inode * inode = dentry->d_inode;
-
-		dentry->d_inode = NULL;
-		iput(inode);
-	}
+	dentry_iput(dentry);
 	parent = dentry->d_parent;
 	d_free(dentry);
 	dput(parent);
@@ -636,11 +645,7 @@
 	 * Are we the only user?
 	 */
 	if (dentry->d_count == 1) {
-		struct inode * inode = dentry->d_inode;
-		if (inode) {
-			dentry->d_inode = NULL;
-			iput(inode);
-		}
+		dentry_iput(dentry);
 		return;
 	}
 

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