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

Next file: linux/fs/nfs/inode.c
Previous file: linux/fs/ncpfs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.50/linux/fs/nfs/dir.c linux/fs/nfs/dir.c
@@ -672,7 +672,7 @@
 		struct dentry * dentry = list_entry(tmp, struct dentry, d_alias);
 		const char * unhashed = "";
 
-		if (list_empty(&dentry->d_hash))
+		if (d_unhashed(dentry))
 			unhashed = "(unhashed)";
 
 		printk("show_dentry: %s/%s, d_count=%d%s\n",
@@ -1027,7 +1027,7 @@
 	/*
 	 * Unhash the dentry while we remove the file ...
 	 */
-	if (!list_empty(&dentry->d_hash)) {
+	if (!d_unhashed(dentry)) {
 		d_drop(dentry);
 		rehash = 1;
 	}
@@ -1194,11 +1194,13 @@
 	 * For files, make a copy of the dentry and then do a 
 	 * silly-rename. If the silly-rename succeeds, the
 	 * copied dentry is hashed and becomes the new target.
-	 *
-	 * With directories check is done in VFS.
 	 */
+	if (!new_inode)
+		goto go_ahead;
 	error = -EBUSY;
-	if (new_dentry->d_count > 1 && new_inode) {
+	if (S_ISDIR(new_inode->i_mode))
+		goto out;
+	else if (new_dentry->d_count > 1) {
 		int err;
 		/* copy the target dentry's name */
 		dentry = d_alloc(new_dentry->d_parent,
@@ -1227,6 +1229,7 @@
 		}
 	}
 
+go_ahead:
 	/*
 	 * ... prune child dentries and writebacks if needed.
 	 */
@@ -1235,21 +1238,11 @@
 		shrink_dcache_parent(old_dentry);
 	}
 
-	if (new_dentry->d_count > 1 && new_inode) {
-#ifdef NFS_PARANOIA
-		printk("nfs_rename: new dentry %s/%s busy, d_count=%d\n",
-		       new_dentry->d_parent->d_name.name,
-		       new_dentry->d_name.name,
-		       new_dentry->d_count);
-#endif
-		goto out;
-	}
-
 	/*
 	 * To prevent any new references to the target during the rename,
 	 * we unhash the dentry and free the inode in advance.
 	 */
-	if (!list_empty(&new_dentry->d_hash)) {
+	if (!d_unhashed(new_dentry)) {
 		d_drop(new_dentry);
 		rehash = 1;
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)