sysfs: make lockdep ignore s_active
PATCH 1/1 sysfs: make lockdep ignore s_active
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 <[email protected]>
---
Greg, this patch fixes lockdep error reported by Cornelia. Please add this to the patch series. Andrew, this is the same one you took earlier only with comments added.
Thanks.
fs/sysfs/dir.c | 7 ++++++- fs/sysfs/sysfs.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-)
fs/sysfs/dir.c +6 -1
@@ -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 )
fs/sysfs/sysfs.h +5 -0
@@ -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)