Commit 469796d1 authored by Al Viro's avatar Al Viro

sysfs: switch to ->s_d_op and ->d_release()

a) ->d_iput() is wrong here - what we do to inode is completely usual, it's
dentry->d_fsdata that we want to drop.  Just use ->d_release().

b) switch to ->s_d_op - no need to play with d_set_d_op()
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 79714f72
...@@ -300,7 +300,7 @@ void release_sysfs_dirent(struct sysfs_dirent * sd) ...@@ -300,7 +300,7 @@ void release_sysfs_dirent(struct sysfs_dirent * sd)
static int sysfs_dentry_delete(const struct dentry *dentry) static int sysfs_dentry_delete(const struct dentry *dentry)
{ {
struct sysfs_dirent *sd = dentry->d_fsdata; struct sysfs_dirent *sd = dentry->d_fsdata;
return !!(sd->s_flags & SYSFS_FLAG_REMOVED); return !(sd && !(sd->s_flags & SYSFS_FLAG_REMOVED));
} }
static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
...@@ -355,18 +355,15 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) ...@@ -355,18 +355,15 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
return 0; return 0;
} }
static void sysfs_dentry_iput(struct dentry *dentry, struct inode *inode) static void sysfs_dentry_release(struct dentry *dentry)
{ {
struct sysfs_dirent * sd = dentry->d_fsdata; sysfs_put(dentry->d_fsdata);
sysfs_put(sd);
iput(inode);
} }
static const struct dentry_operations sysfs_dentry_ops = { const struct dentry_operations sysfs_dentry_ops = {
.d_revalidate = sysfs_dentry_revalidate, .d_revalidate = sysfs_dentry_revalidate,
.d_delete = sysfs_dentry_delete, .d_delete = sysfs_dentry_delete,
.d_iput = sysfs_dentry_iput, .d_release = sysfs_dentry_release,
}; };
struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type) struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
...@@ -786,6 +783,7 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -786,6 +783,7 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
ret = ERR_PTR(-ENOENT); ret = ERR_PTR(-ENOENT);
goto out_unlock; goto out_unlock;
} }
dentry->d_fsdata = sysfs_get(sd);
/* attach dentry and inode */ /* attach dentry and inode */
inode = sysfs_get_inode(dir->i_sb, sd); inode = sysfs_get_inode(dir->i_sb, sd);
...@@ -797,8 +795,6 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -797,8 +795,6 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
/* instantiate and hash dentry */ /* instantiate and hash dentry */
ret = d_find_alias(inode); ret = d_find_alias(inode);
if (!ret) { if (!ret) {
d_set_d_op(dentry, &sysfs_dentry_ops);
dentry->d_fsdata = sysfs_get(sd);
d_add(dentry, inode); d_add(dentry, inode);
} else { } else {
d_move(ret, dentry); d_move(ret, dentry);
......
...@@ -68,6 +68,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -68,6 +68,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
} }
root->d_fsdata = &sysfs_root; root->d_fsdata = &sysfs_root;
sb->s_root = root; sb->s_root = root;
sb->s_d_op = &sysfs_dentry_ops;
return 0; return 0;
} }
......
...@@ -157,6 +157,7 @@ extern struct kmem_cache *sysfs_dir_cachep; ...@@ -157,6 +157,7 @@ extern struct kmem_cache *sysfs_dir_cachep;
*/ */
extern struct mutex sysfs_mutex; extern struct mutex sysfs_mutex;
extern spinlock_t sysfs_assoc_lock; extern spinlock_t sysfs_assoc_lock;
extern const struct dentry_operations sysfs_dentry_ops;
extern const struct file_operations sysfs_dir_operations; extern const struct file_operations sysfs_dir_operations;
extern const struct inode_operations sysfs_dir_inode_operations; extern const struct inode_operations sysfs_dir_inode_operations;
......
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