aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/sysfs/dir.c32
-rw-r--r--fs/sysfs/mount.c1
-rw-r--r--fs/sysfs/sysfs.h1
3 files changed, 4 insertions, 30 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 1c3dc5d01ccd..36b6c796d4d5 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -289,22 +289,7 @@ static void sysfs_d_iput(struct dentry * dentry, struct inode * inode)
289{ 289{
290 struct sysfs_dirent * sd = dentry->d_fsdata; 290 struct sysfs_dirent * sd = dentry->d_fsdata;
291 291
292 if (sd) { 292 sysfs_put(sd);
293 /* sd->s_dentry is protected with sysfs_assoc_lock.
294 * This allows sysfs_drop_dentry() to dereference it.
295 */
296 spin_lock(&sysfs_assoc_lock);
297
298 /* The dentry might have been deleted or another
299 * lookup could have happened updating sd->s_dentry to
300 * point the new dentry. Ignore if it isn't pointing
301 * to this dentry.
302 */
303 if (sd->s_dentry == dentry)
304 sd->s_dentry = NULL;
305 spin_unlock(&sysfs_assoc_lock);
306 sysfs_put(sd);
307 }
308 iput(inode); 293 iput(inode);
309} 294}
310 295
@@ -352,9 +337,6 @@ struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
352 * @sd: target sysfs_dirent 337 * @sd: target sysfs_dirent
353 * @dentry: dentry to associate 338 * @dentry: dentry to associate
354 * 339 *
355 * Associate @sd with @dentry. This is protected by
356 * sysfs_assoc_lock to avoid race with sysfs_d_iput().
357 *
358 * LOCKING: 340 * LOCKING:
359 * mutex_lock(sysfs_mutex) 341 * mutex_lock(sysfs_mutex)
360 */ 342 */
@@ -362,12 +344,6 @@ static void sysfs_attach_dentry(struct sysfs_dirent *sd, struct dentry *dentry)
362{ 344{
363 dentry->d_op = &sysfs_dentry_ops; 345 dentry->d_op = &sysfs_dentry_ops;
364 dentry->d_fsdata = sysfs_get(sd); 346 dentry->d_fsdata = sysfs_get(sd);
365
366 /* protect sd->s_dentry against sysfs_d_iput */
367 spin_lock(&sysfs_assoc_lock);
368 sd->s_dentry = dentry;
369 spin_unlock(&sysfs_assoc_lock);
370
371 d_rehash(dentry); 347 d_rehash(dentry);
372} 348}
373 349
@@ -846,7 +822,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
846 822
847 /* rename */ 823 /* rename */
848 d_add(new_dentry, NULL); 824 d_add(new_dentry, NULL);
849 d_move(sd->s_dentry, new_dentry); 825 d_move(old_dentry, new_dentry);
850 826
851 error = 0; 827 error = 0;
852 goto out_unlock; 828 goto out_unlock;
@@ -881,7 +857,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
881 error = PTR_ERR(old_dentry); 857 error = PTR_ERR(old_dentry);
882 goto out_dput; 858 goto out_dput;
883 } 859 }
884 old_parent = sd->s_parent->s_dentry; 860 old_parent = old_dentry->d_parent;
885 861
886 new_parent = sysfs_get_dentry(new_parent_sd); 862 new_parent = sysfs_get_dentry(new_parent_sd);
887 if (IS_ERR(new_parent)) { 863 if (IS_ERR(new_parent)) {
@@ -907,7 +883,7 @@ again:
907 } else 883 } else
908 error = 0; 884 error = 0;
909 d_add(new_dentry, NULL); 885 d_add(new_dentry, NULL);
910 d_move(sd->s_dentry, new_dentry); 886 d_move(old_dentry, new_dentry);
911 dput(new_dentry); 887 dput(new_dentry);
912 888
913 /* Remove from old parent's list and insert into new parent's list. */ 889 /* Remove from old parent's list and insert into new parent's list. */
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 8989cbb51a39..28bf359981fc 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -56,7 +56,6 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
56 iput(inode); 56 iput(inode);
57 return -ENOMEM; 57 return -ENOMEM;
58 } 58 }
59 sysfs_root.s_dentry = root;
60 root->d_fsdata = &sysfs_root; 59 root->d_fsdata = &sysfs_root;
61 sb->s_root = root; 60 sb->s_root = root;
62 return 0; 61 return 0;
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 179e6a26ece1..791b3ed91a9b 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -37,7 +37,6 @@ struct sysfs_dirent {
37 unsigned int s_flags; 37 unsigned int s_flags;
38 umode_t s_mode; 38 umode_t s_mode;
39 ino_t s_ino; 39 ino_t s_ino;
40 struct dentry * s_dentry;
41 struct iattr * s_iattr; 40 struct iattr * s_iattr;
42 atomic_t s_event; 41 atomic_t s_event;
43}; 42};