Commit 9091e62b authored by Dan Aloni's avatar Dan Aloni Committed by Greg Kroah-Hartman

[PATCH] d_unhash consolidation

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().
Tested - compiled and running.
Signed-off-by: default avatarDan Aloni <da-x@gmx.net>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 4d69c668
...@@ -345,30 +345,13 @@ static int usbfs_unlink (struct inode *dir, struct dentry *dentry) ...@@ -345,30 +345,13 @@ static int usbfs_unlink (struct inode *dir, struct dentry *dentry)
return 0; 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) static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
{ {
int error = -ENOTEMPTY; int error = -ENOTEMPTY;
struct inode * inode = dentry->d_inode; struct inode * inode = dentry->d_inode;
down(&inode->i_sem); down(&inode->i_sem);
d_unhash(dentry); dentry_unhash(dentry);
if (usbfs_empty(dentry)) { if (usbfs_empty(dentry)) {
dentry->d_inode->i_nlink -= 2; dentry->d_inode->i_nlink -= 2;
dput(dentry); dput(dentry);
......
...@@ -1659,7 +1659,7 @@ asmlinkage long sys_mkdir(const char __user * pathname, int mode) ...@@ -1659,7 +1659,7 @@ asmlinkage long sys_mkdir(const char __user * pathname, int mode)
* if it cannot handle the case of removing a directory * if it cannot handle the case of removing a directory
* that is still in use by something else.. * that is still in use by something else..
*/ */
static void d_unhash(struct dentry *dentry) void dentry_unhash(struct dentry *dentry)
{ {
dget(dentry); dget(dentry);
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
...@@ -1689,7 +1689,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -1689,7 +1689,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
DQUOT_INIT(dir); DQUOT_INIT(dir);
down(&dentry->d_inode->i_sem); down(&dentry->d_inode->i_sem);
d_unhash(dentry); dentry_unhash(dentry);
if (d_mountpoint(dentry)) if (d_mountpoint(dentry))
error = -EBUSY; error = -EBUSY;
else { else {
...@@ -2032,7 +2032,7 @@ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2032,7 +2032,7 @@ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
target = new_dentry->d_inode; target = new_dentry->d_inode;
if (target) { if (target) {
down(&target->i_sem); down(&target->i_sem);
d_unhash(new_dentry); dentry_unhash(new_dentry);
} }
if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
error = -EBUSY; error = -EBUSY;
...@@ -2410,4 +2410,5 @@ EXPORT_SYMBOL(vfs_rename); ...@@ -2410,4 +2410,5 @@ EXPORT_SYMBOL(vfs_rename);
EXPORT_SYMBOL(vfs_rmdir); EXPORT_SYMBOL(vfs_rmdir);
EXPORT_SYMBOL(vfs_symlink); EXPORT_SYMBOL(vfs_symlink);
EXPORT_SYMBOL(vfs_unlink); EXPORT_SYMBOL(vfs_unlink);
EXPORT_SYMBOL(dentry_unhash);
EXPORT_SYMBOL(generic_readlink); EXPORT_SYMBOL(generic_readlink);
...@@ -808,6 +808,11 @@ extern int vfs_rmdir(struct inode *, struct dentry *); ...@@ -808,6 +808,11 @@ extern int vfs_rmdir(struct inode *, struct dentry *);
extern int vfs_unlink(struct inode *, struct dentry *); extern int vfs_unlink(struct inode *, struct dentry *);
extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); 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 * File types
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment