From: Tejun Heo <htejun@gmail.com>
To: Miles Lane <miles.lane@gmail.com>
Cc: Andrew Morton <akpm@osdl.org>,
LKML <linux-kernel@vger.kernel.org>,
greg@kroah.com
Subject: [PATCH] sysfs: use different lockdep subclass for s_active deactivation
Date: Thu, 26 Apr 2007 23:50:47 +0900 [thread overview]
Message-ID: <20070426145047.GF17130@htj.dyndns.org> (raw)
In-Reply-To: <462EE4B7.6000708@gmail.com>
A sysfs node can delete other sysfs files when accessed. This results
in recursive s_active locking - read lock for file access, down lock
of the vicitim for deactivation. Tell lockdep that it's okay.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
Miles, please test this patch. It should remove the lockdep warning.
Fixes for the other two problems will soon follow.
Greg, Andrew, after all the fixes are verified, I'll merge the fixes
into the original patches and resend all the sysfs updates in better
shape. Sorry about all the trouble.
Thanks.
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 8f7b65e..4a418bd 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -60,7 +60,8 @@ void release_sysfs_dirent(struct sysfs_dirent * sd)
* previous lie.
*/
if (!down_write_trylock(&sd->s_active))
- rwsem_acquire(&sd->s_active.dep_map, 0, 0, _RET_IP_);
+ rwsem_acquire(&sd->s_active.dep_map,
+ SYSFS_S_ACTIVE_DEACTIVATE, 0, _RET_IP_);
up_write(&sd->s_active);
sysfs_free_ino(sd->s_ino);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 4ed6f77..add2725 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -41,6 +41,17 @@ struct sysfs_dirent {
atomic_t s_event;
};
+/*
+ * A sysfs file which deletes another file when written to need to
+ * write lock the s_active of the victim while its s_active is read
+ * locked for the write operation. Tell lockdep that this is okay.
+ */
+enum sysfs_s_active_class
+{
+ SYSFS_S_ACTIVE_NORMAL, /* file r/w access, etc - default */
+ SYSFS_S_ACTIVE_DEACTIVATE, /* file deactivation */
+};
+
extern struct vfsmount * sysfs_mount;
extern struct kmem_cache *sysfs_dir_cachep;
@@ -172,7 +183,7 @@ static inline void sysfs_put_active_two(struct sysfs_dirent *sd)
*/
static inline void sysfs_deactivate(struct sysfs_dirent *sd)
{
- down_write(&sd->s_active);
+ down_write_nested(&sd->s_active, SYSFS_S_ACTIVE_DEACTIVATE);
/* s_active will be unlocked by the thread doing the final put
* on @sd. Lie to lockdep.
next prev parent reply other threads:[~2007-04-26 14:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-25 5:15 2.6.21-rc7-mm1 + sysfs-oops-workaround.patch -- INFO: possible recursive locking detected Miles Lane
2007-04-25 5:18 ` Tejun Heo
2007-04-25 14:48 ` Antonino A. Daplas
2007-04-25 23:45 ` Nonfunctional ethernet (was Re: 2.6.21-rc7-mm1 + sysfs-oops-workaround.patch -- INFO: possible recursive locking detected) Antonino A. Daplas
2007-04-26 1:02 ` Antonino A. Daplas
2007-04-26 1:13 ` Andrew Morton
2007-04-26 2:26 ` Tejun Heo
2007-04-26 2:53 ` Andrew Morton
2007-04-26 14:50 ` Tejun Heo [this message]
2007-04-26 15:22 ` [PATCH] sysfs: use different lockdep subclass for s_active deactivation Greg KH
2007-04-26 17:21 ` Miles Lane
2007-04-26 17:33 ` Tejun Heo
2007-04-26 18:51 ` Miles Lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070426145047.GF17130@htj.dyndns.org \
--to=htejun@gmail.com \
--cc=akpm@osdl.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miles.lane@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®