From: Dan Aloni <da-x@gmx.net>

This removes a copy of d_unhash() from drivers/usb/core/inode.c and and
exports d_unhash() from fs/namei.c as dentry_unhash().

Signed-off-by: Dan Aloni <da-x@gmx.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/usb/core/inode.c |   19 +------------------
 25-akpm/fs/namei.c               |    7 ++++---
 25-akpm/include/linux/fs.h       |    5 +++++
 3 files changed, 10 insertions(+), 21 deletions(-)

diff -puN drivers/usb/core/inode.c~d_unhash-consolidation drivers/usb/core/inode.c
--- 25/drivers/usb/core/inode.c~d_unhash-consolidation	2004-07-28 22:11:13.352636920 -0700
+++ 25-akpm/drivers/usb/core/inode.c	2004-07-28 22:11:13.361635552 -0700
@@ -345,30 +345,13 @@ static int usbfs_unlink (struct inode *d
 	return 0;
 }
 
-static void d_unhash(struct dentry *dentry)
-{
-	dget(dentry);
-	spin_lock(&dcache_lock);
-	switch (atomic_read(&dentry->d_count)) {
-	default:
-		spin_unlock(&dcache_lock);
-		shrink_dcache_parent(dentry);
-		spin_lock(&dcache_lock);
-		if (atomic_read(&dentry->d_count) != 2)
-			break;
-	case 2:
-		__d_drop(dentry);
-	}
-	spin_unlock(&dcache_lock);
-}
-
 static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
 {
 	int error = -ENOTEMPTY;
 	struct inode * inode = dentry->d_inode;
 
 	down(&inode->i_sem);
-	d_unhash(dentry);
+	dentry_unhash(dentry);
 	if (usbfs_empty(dentry)) {
 		dentry->d_inode->i_nlink -= 2;
 		dput(dentry);
diff -puN fs/namei.c~d_unhash-consolidation fs/namei.c
--- 25/fs/namei.c~d_unhash-consolidation	2004-07-28 22:11:13.354636616 -0700
+++ 25-akpm/fs/namei.c	2004-07-28 22:11:13.364635096 -0700
@@ -1659,7 +1659,7 @@ out:
  * if it cannot handle the case of removing a directory
  * that is still in use by something else..
  */
-static void d_unhash(struct dentry *dentry)
+void dentry_unhash(struct dentry *dentry)
 {
 	dget(dentry);
 	spin_lock(&dcache_lock);
@@ -1689,7 +1689,7 @@ int vfs_rmdir(struct inode *dir, struct 
 	DQUOT_INIT(dir);
 
 	down(&dentry->d_inode->i_sem);
-	d_unhash(dentry);
+	dentry_unhash(dentry);
 	if (d_mountpoint(dentry))
 		error = -EBUSY;
 	else {
@@ -2032,7 +2032,7 @@ int vfs_rename_dir(struct inode *old_dir
 	target = new_dentry->d_inode;
 	if (target) {
 		down(&target->i_sem);
-		d_unhash(new_dentry);
+		dentry_unhash(new_dentry);
 	}
 	if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
 		error = -EBUSY;
@@ -2410,4 +2410,5 @@ EXPORT_SYMBOL(vfs_rename);
 EXPORT_SYMBOL(vfs_rmdir);
 EXPORT_SYMBOL(vfs_symlink);
 EXPORT_SYMBOL(vfs_unlink);
+EXPORT_SYMBOL(dentry_unhash);
 EXPORT_SYMBOL(generic_readlink);
diff -puN include/linux/fs.h~d_unhash-consolidation include/linux/fs.h
--- 25/include/linux/fs.h~d_unhash-consolidation	2004-07-28 22:11:13.357636160 -0700
+++ 25-akpm/include/linux/fs.h	2004-07-28 22:11:13.366634792 -0700
@@ -820,6 +820,11 @@ extern int vfs_unlink(struct inode *, st
 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
 
 /*
+ * VFS dentry helper functions.
+ */
+extern void dentry_unhash(struct dentry *dentry);
+
+/*
  * File types
  *
  * NOTE! These match bits 12..15 of stat.st_mode
_