patch-2.1.48 linux/fs/nfs/dir.c

Next file: linux/fs/pipe.c
Previous file: linux/fs/namei.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.47/linux/fs/nfs/dir.c linux/fs/nfs/dir.c
@@ -326,7 +326,28 @@
 		cache->entry = NULL;
 	}
 }
- 
+
+/*
+ * This is called every time the dcache has a lookup hit,
+ * and we should check whether we can really trust that
+ * lookup.
+ *
+ * NOTE! The hit can be a negative hit too, don't assume
+ * we have an inode!
+ *
+ * The decision to drop the dentry should probably be
+ * smarter than this. Right now we believe in directories
+ * for 10 seconds, and in normal files for five..
+ */
+static int nfs_lookup_revalidate(struct dentry * dentry)
+{
+	unsigned long time = jiffies - dentry->d_time;
+	unsigned long max = 5*HZ;
+
+	if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))
+		max = 10*HZ;
+	return time < max;
+}
 
 static int nfs_lookup(struct inode *dir, struct dentry * dentry)
 {
@@ -358,6 +379,8 @@
 	} else if (error != -ENOENT)
 		return error;
 
+	dentry->d_time = jiffies;
+	dentry->d_revalidate = nfs_lookup_revalidate;
 	d_add(dentry, inode);
 	return 0;
 }
@@ -394,6 +417,7 @@
 	if (!inode)
 		return -EACCES;
 
+	nfs_invalidate_dircache(dir);
 	d_instantiate(dentry, inode);
 	return 0;
 }
@@ -433,6 +457,7 @@
 	if (!inode)
 		return -EACCES;
 
+	nfs_invalidate_dircache(dir);
 	d_instantiate(dentry, inode);
 	return 0;
 }
@@ -470,6 +495,7 @@
 	if (!inode)
 		return -EACCES;
 
+	nfs_invalidate_dircache(dir);
 	d_instantiate(dentry, inode);
 	return 0;
 }
@@ -493,6 +519,7 @@
 	if (error)
 		return error;
 
+	nfs_invalidate_dircache(dir);
 	d_delete(dentry);
 	return 0;
 }
@@ -520,6 +547,7 @@
 	if (error)
 		return error;
 
+	nfs_invalidate_dircache(dir);
 	d_delete(dentry);
 	return 0;
 }
@@ -560,6 +588,7 @@
 	if (!inode)
 		return -EACCES;
 
+	nfs_invalidate_dircache(dir);
 	d_instantiate(dentry, inode);
 	return 0;
 }
@@ -586,6 +615,7 @@
 	if (error)
 		return error;
 
+	nfs_invalidate_dircache(dir);
 	inode->i_count++;
 	d_instantiate(dentry, inode);
 	return 0;
@@ -628,6 +658,9 @@
 
 	if (error)
 		return error;
+
+	nfs_invalidate_dircache(old_dir);
+	nfs_invalidate_dircache(new_dir);
 
 	/* Update the dcache */
 	d_move(old_dentry, new_dentry->d_parent, &new_dentry->d_name);

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