summaryrefslogtreecommitdiff
path: root/fs/sysfs/inode.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-06-14 04:27:23 +0900
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 16:09:08 -0700
commit3007e997de91ec59af39a3f9c91595b31ae6e08b (patch)
tree4ed4df3ef3a249d2a4b562e36876fc8d4a3fabd9 /fs/sysfs/inode.c
parent5f9953237f684ea1778adb9d26162da00b282225 (diff)
sysfs: use sysfs_mutex to protect the sysfs_dirent tree
As kobj sysfs dentries and inodes are gonna be made reclaimable, i_mutex can't be used to protect sysfs_dirent tree. Use sysfs_mutex globally instead. As the whole tree is protected with sysfs_mutex, there is no reason to keep sysfs_rename_sem. Drop it. While at it, add docbook comments to functions which require sysfs_mutex locking. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/inode.c')
-rw-r--r--fs/sysfs/inode.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index e4c23939fb36..d439c0b4bfce 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -277,20 +277,14 @@ void sysfs_drop_dentry(struct sysfs_dirent *sd)
int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name)
{
- struct dentry *dir;
struct sysfs_dirent **pos, *sd;
int found = 0;
if (!dir_sd)
return -ENOENT;
- dir = dir_sd->s_dentry;
+ mutex_lock(&sysfs_mutex);
- if (dir->d_inode == NULL)
- /* no inode means this hasn't been made visible yet */
- return -ENOENT;
-
- mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
for (pos = &dir_sd->s_children; *pos; pos = &(*pos)->s_sibling) {
sd = *pos;
@@ -304,7 +298,8 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name)
break;
}
}
- mutex_unlock(&dir->d_inode->i_mutex);
+
+ mutex_unlock(&sysfs_mutex);
if (!found)
return -ENOENT;