aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-07 20:51:39 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:35:06 -0400
commit469796d10590341c53cff0a2959254eaf5d465de (patch)
tree74728e34d43bbcd16600de66df8c453d3a35ee63 /fs
parent79714f72d3b964611997de512cb29198c9f2dbbb (diff)
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: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/sysfs/dir.c16
-rw-r--r--fs/sysfs/mount.c1
-rw-r--r--fs/sysfs/sysfs.h1
3 files changed, 8 insertions, 10 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index efd373e3e0aa..77c44ce493f8 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -300,7 +300,7 @@ void release_sysfs_dirent(struct sysfs_dirent * sd)
300static int sysfs_dentry_delete(const struct dentry *dentry) 300static int sysfs_dentry_delete(const struct dentry *dentry)
301{ 301{
302 struct sysfs_dirent *sd = dentry->d_fsdata; 302 struct sysfs_dirent *sd = dentry->d_fsdata;
303 return !!(sd->s_flags & SYSFS_FLAG_REMOVED); 303 return !(sd && !(sd->s_flags & SYSFS_FLAG_REMOVED));
304} 304}
305 305
306static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) 306static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
@@ -355,18 +355,15 @@ out_bad:
355 return 0; 355 return 0;
356} 356}
357 357
358static void sysfs_dentry_iput(struct dentry *dentry, struct inode *inode) 358static void sysfs_dentry_release(struct dentry *dentry)
359{ 359{
360 struct sysfs_dirent * sd = dentry->d_fsdata; 360 sysfs_put(dentry->d_fsdata);
361
362 sysfs_put(sd);
363 iput(inode);
364} 361}
365 362
366static const struct dentry_operations sysfs_dentry_ops = { 363const struct dentry_operations sysfs_dentry_ops = {
367 .d_revalidate = sysfs_dentry_revalidate, 364 .d_revalidate = sysfs_dentry_revalidate,
368 .d_delete = sysfs_dentry_delete, 365 .d_delete = sysfs_dentry_delete,
369 .d_iput = sysfs_dentry_iput, 366 .d_release = sysfs_dentry_release,
370}; 367};
371 368
372struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type) 369struct 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 ret = ERR_PTR(-ENOENT); 783 ret = ERR_PTR(-ENOENT);
787 goto out_unlock; 784 goto out_unlock;
788 } 785 }
786 dentry->d_fsdata = sysfs_get(sd);
789 787
790 /* attach dentry and inode */ 788 /* attach dentry and inode */
791 inode = sysfs_get_inode(dir->i_sb, sd); 789 inode = sysfs_get_inode(dir->i_sb, sd);
@@ -797,8 +795,6 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
797 /* instantiate and hash dentry */ 795 /* instantiate and hash dentry */
798 ret = d_find_alias(inode); 796 ret = d_find_alias(inode);
799 if (!ret) { 797 if (!ret) {
800 d_set_d_op(dentry, &sysfs_dentry_ops);
801 dentry->d_fsdata = sysfs_get(sd);
802 d_add(dentry, inode); 798 d_add(dentry, inode);
803 } else { 799 } else {
804 d_move(ret, dentry); 800 d_move(ret, dentry);
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 52c3bdb66a84..c15a7a3572e9 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -68,6 +68,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
68 } 68 }
69 root->d_fsdata = &sysfs_root; 69 root->d_fsdata = &sysfs_root;
70 sb->s_root = root; 70 sb->s_root = root;
71 sb->s_d_op = &sysfs_dentry_ops;
71 return 0; 72 return 0;
72} 73}
73 74
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 661a9639570b..d73c0932bbd6 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -157,6 +157,7 @@ extern struct kmem_cache *sysfs_dir_cachep;
157 */ 157 */
158extern struct mutex sysfs_mutex; 158extern struct mutex sysfs_mutex;
159extern spinlock_t sysfs_assoc_lock; 159extern spinlock_t sysfs_assoc_lock;
160extern const struct dentry_operations sysfs_dentry_ops;
160 161
161extern const struct file_operations sysfs_dir_operations; 162extern const struct file_operations sysfs_dir_operations;
162extern const struct inode_operations sysfs_dir_inode_operations; 163extern const struct inode_operations sysfs_dir_inode_operations;