diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-08-20 08:36:30 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:51:08 -0400 |
commit | 5a26b79c426f8e55ebf7204cb138eb6b1645d4d3 (patch) | |
tree | 4cdcd80f88a479a6ed1ef53042f3b17359c0e80e /fs/sysfs | |
parent | e0712bbfd9cb617fc3a822781c2466fb6b7ede50 (diff) |
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: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs')
-rw-r--r-- | fs/sysfs/dir.c | 32 | ||||
-rw-r--r-- | fs/sysfs/mount.c | 1 | ||||
-rw-r--r-- | fs/sysfs/sysfs.h | 1 |
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 | }; |