aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/dir.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-06-14 03:45:16 +0900
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 16:09:06 -0700
commitdbde0fcf9f8f6d477af3c32d9979e789ee680cde (patch)
tree12a1240213d59c061fec60325c7d5ebb1edebcd7 /fs/sysfs/dir.c
parentsysfs: separate out sysfs_attach_dentry() (diff)
downloadlinux-dev-dbde0fcf9f8f6d477af3c32d9979e789ee680cde.tar.xz
linux-dev-dbde0fcf9f8f6d477af3c32d9979e789ee680cde.zip
sysfs: reimplement sysfs_drop_dentry()
This patch reimplements sysfs_drop_dentry() such that remove_dir() can use it to drop dentry instead of using a separate mechanism. With this change, making directories reclaimable is much easier. This patch used to contain fixes for two race conditions around sd->s_dentry but that part has been separated out and included into mainline early as commit 6aa054aadfea613a437ad0b15d38eca2b963fc0a and dd14cbc994709a1c5a64ed3621f583c49a27e521. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r--fs/sysfs/dir.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 01eeb4b954b1..bc11a263aa53 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -372,22 +372,19 @@ const struct inode_operations sysfs_dir_inode_operations = {
static void remove_dir(struct dentry * d)
{
- struct dentry * parent = dget(d->d_parent);
- struct sysfs_dirent * sd;
+ struct dentry *parent = d->d_parent;
+ struct sysfs_dirent *sd = d->d_fsdata;
mutex_lock(&parent->d_inode->i_mutex);
- d_delete(d);
- sd = d->d_fsdata;
+
list_del_init(&sd->s_sibling);
- if (d->d_inode)
- simple_rmdir(parent->d_inode,d);
pr_debug(" o %s removing done (%d)\n",d->d_name.name,
atomic_read(&d->d_count));
mutex_unlock(&parent->d_inode->i_mutex);
- dput(parent);
+ sysfs_drop_dentry(sd);
sysfs_deactivate(sd);
sysfs_put(sd);
}
@@ -404,7 +401,6 @@ static void __sysfs_remove_dir(struct dentry *dentry)
struct sysfs_dirent * parent_sd;
struct sysfs_dirent * sd, * tmp;
- dget(dentry);
if (!dentry)
return;
@@ -415,21 +411,17 @@ static void __sysfs_remove_dir(struct dentry *dentry)
if (!sd->s_type || !(sd->s_type & SYSFS_NOT_PINNED))
continue;
list_move(&sd->s_sibling, &removed);
- sysfs_drop_dentry(sd, dentry);
}
mutex_unlock(&dentry->d_inode->i_mutex);
list_for_each_entry_safe(sd, tmp, &removed, s_sibling) {
list_del_init(&sd->s_sibling);
+ sysfs_drop_dentry(sd);
sysfs_deactivate(sd);
sysfs_put(sd);
}
remove_dir(dentry);
- /**
- * Drop reference from dget() on entrance.
- */
- dput(dentry);
}
/**