提交 5a26b79c 编写于 作者: E Eric W. Biederman 提交者: Greg Kroah-Hartman

sysfs: Remove s_dentry

The only uses of s_dentry left are the code that maintains
s_dentry and trivial users that don't actually need it.
So this patch removes the s_dentry maintenance code and
restructures the trivial uses to use something else.
Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: NTejun Heo <htejun@gmail.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 e0712bbf
...@@ -289,22 +289,7 @@ static void sysfs_d_iput(struct dentry * dentry, struct inode * inode) ...@@ -289,22 +289,7 @@ static void sysfs_d_iput(struct dentry * dentry, struct inode * inode)
{ {
struct sysfs_dirent * sd = dentry->d_fsdata; struct sysfs_dirent * sd = dentry->d_fsdata;
if (sd) { sysfs_put(sd);
/* sd->s_dentry is protected with sysfs_assoc_lock.
* This allows sysfs_drop_dentry() to dereference it.
*/
spin_lock(&sysfs_assoc_lock);
/* The dentry might have been deleted or another
* lookup could have happened updating sd->s_dentry to
* point the new dentry. Ignore if it isn't pointing
* to this dentry.
*/
if (sd->s_dentry == dentry)
sd->s_dentry = NULL;
spin_unlock(&sysfs_assoc_lock);
sysfs_put(sd);
}
iput(inode); iput(inode);
} }
...@@ -352,9 +337,6 @@ struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type) ...@@ -352,9 +337,6 @@ struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
* @sd: target sysfs_dirent * @sd: target sysfs_dirent
* @dentry: dentry to associate * @dentry: dentry to associate
* *
* Associate @sd with @dentry. This is protected by
* sysfs_assoc_lock to avoid race with sysfs_d_iput().
*
* LOCKING: * LOCKING:
* mutex_lock(sysfs_mutex) * mutex_lock(sysfs_mutex)
*/ */
...@@ -362,12 +344,6 @@ static void sysfs_attach_dentry(struct sysfs_dirent *sd, struct dentry *dentry) ...@@ -362,12 +344,6 @@ static void sysfs_attach_dentry(struct sysfs_dirent *sd, struct dentry *dentry)
{ {
dentry->d_op = &sysfs_dentry_ops; dentry->d_op = &sysfs_dentry_ops;
dentry->d_fsdata = sysfs_get(sd); dentry->d_fsdata = sysfs_get(sd);
/* protect sd->s_dentry against sysfs_d_iput */
spin_lock(&sysfs_assoc_lock);
sd->s_dentry = dentry;
spin_unlock(&sysfs_assoc_lock);
d_rehash(dentry); d_rehash(dentry);
} }
...@@ -846,7 +822,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name) ...@@ -846,7 +822,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
/* rename */ /* rename */
d_add(new_dentry, NULL); d_add(new_dentry, NULL);
d_move(sd->s_dentry, new_dentry); d_move(old_dentry, new_dentry);
error = 0; error = 0;
goto out_unlock; goto out_unlock;
...@@ -881,7 +857,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) ...@@ -881,7 +857,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
error = PTR_ERR(old_dentry); error = PTR_ERR(old_dentry);
goto out_dput; goto out_dput;
} }
old_parent = sd->s_parent->s_dentry; old_parent = old_dentry->d_parent;
new_parent = sysfs_get_dentry(new_parent_sd); new_parent = sysfs_get_dentry(new_parent_sd);
if (IS_ERR(new_parent)) { if (IS_ERR(new_parent)) {
...@@ -907,7 +883,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) ...@@ -907,7 +883,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
} else } else
error = 0; error = 0;
d_add(new_dentry, NULL); d_add(new_dentry, NULL);
d_move(sd->s_dentry, new_dentry); d_move(old_dentry, new_dentry);
dput(new_dentry); dput(new_dentry);
/* Remove from old parent's list and insert into new parent's list. */ /* Remove from old parent's list and insert into new parent's list. */
......
...@@ -56,7 +56,6 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -56,7 +56,6 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
iput(inode); iput(inode);
return -ENOMEM; return -ENOMEM;
} }
sysfs_root.s_dentry = root;
root->d_fsdata = &sysfs_root; root->d_fsdata = &sysfs_root;
sb->s_root = root; sb->s_root = root;
return 0; return 0;
......
...@@ -37,7 +37,6 @@ struct sysfs_dirent { ...@@ -37,7 +37,6 @@ struct sysfs_dirent {
unsigned int s_flags; unsigned int s_flags;
umode_t s_mode; umode_t s_mode;
ino_t s_ino; ino_t s_ino;
struct dentry * s_dentry;
struct iattr * s_iattr; struct iattr * s_iattr;
atomic_t s_event; atomic_t s_event;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册