| From htejun@gmail.com Thu Apr 12 14:19:18 2007 |
| From: Tejun Heo <htejun@gmail.com> |
| Date: Thu, 12 Apr 2007 17:06:35 +0900 |
| Subject: sysfs: make lockdep ignore s_active |
| To: gregkh@suse.de, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, cornelia.huck@de.ibm.com |
| Message-ID: <20070412080635.GH10619@htj.dyndns.org> |
| Content-Disposition: inline |
| |
| |
| s_active is released by the thread doing the final sysfs_put() which |
| can be different from the thread which did sysfs_deactivate(). Make |
| lockdep think that s_active is unlocked immediately after it's write |
| locked. |
| |
| Signed-off-by: Tejun Heo <htejun@gmail.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
| |
| --- |
| fs/sysfs/dir.c | 7 ++++++- |
| fs/sysfs/sysfs.h | 5 +++++ |
| 2 files changed, 11 insertions(+), 1 deletion(-) |
| |
| --- a/fs/sysfs/dir.c |
| +++ b/fs/sysfs/dir.c |
| @@ -25,8 +25,13 @@ void release_sysfs_dirent(struct sysfs_d |
| /* If @sd is being released after deletion, s_active is write |
| * locked. If @sd is cursor for directory walk or being |
| * released prematurely, s_active has no reader or writer. |
| + * |
| + * sysfs_deactivate() lies to lockdep that s_active is |
| + * unlocked immediately. Lie one more time to cover the |
| + * previous lie. |
| */ |
| - down_write_trylock(&sd->s_active); |
| + if (!down_write_trylock(&sd->s_active)) |
| + rwsem_acquire(&sd->s_active.dep_map, 0, 0, _RET_IP_); |
| up_write(&sd->s_active); |
| |
| if (sd->s_type & SYSFS_KOBJ_LINK) |
| --- a/fs/sysfs/sysfs.h |
| +++ b/fs/sysfs/sysfs.h |
| @@ -171,6 +171,11 @@ static inline void sysfs_put_active_two( |
| static inline void sysfs_deactivate(struct sysfs_dirent *sd) |
| { |
| down_write(&sd->s_active); |
| + |
| + /* s_active will be unlocked by the thread doing the final put |
| + * on @sd. Lie to lockdep. |
| + */ |
| + rwsem_release(&sd->s_active.dep_map, 1, _RET_IP_); |
| } |
| |
| static inline int sysfs_is_shadowed_inode(struct inode *inode) |