<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/sysfs/inode.c, branch v2.6.22</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>sysfs: fix race condition around sd-&gt;s_dentry, take#2</title>
<updated>2007-06-12T23:08:47+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>htejun@gmail.com</email>
</author>
<published>2007-06-11T05:04:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=dd14cbc994709a1c5a64ed3621f583c49a27e521'/>
<id>dd14cbc994709a1c5a64ed3621f583c49a27e521</id>
<content type='text'>
Allowing attribute and symlink dentries to be reclaimed means
sd-&gt;s_dentry can change dynamically.  However, updates to the field
are unsynchronized leading to race conditions.  This patch adds
sysfs_lock and use it to synchronize updates to sd-&gt;s_dentry.

Due to the locking around -&gt;d_iput, the check in sysfs_drop_dentry()
is complex.  sysfs_lock only protect sd-&gt;s_dentry pointer itself.  The
validity of the dentry is protected by dcache_lock, so whether dentry
is alive or not can only be tested while holding both locks.

This is minimal backport of sysfs_drop_dentry() rewrite in devel
branch.

Signed-off-by: Tejun Heo &lt;htejun@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Allowing attribute and symlink dentries to be reclaimed means
sd-&gt;s_dentry can change dynamically.  However, updates to the field
are unsynchronized leading to race conditions.  This patch adds
sysfs_lock and use it to synchronize updates to sd-&gt;s_dentry.

Due to the locking around -&gt;d_iput, the check in sysfs_drop_dentry()
is complex.  sysfs_lock only protect sd-&gt;s_dentry pointer itself.  The
validity of the dentry is protected by dcache_lock, so whether dentry
is alive or not can only be tested while holding both locks.

This is minimal backport of sysfs_drop_dentry() rewrite in devel
branch.

Signed-off-by: Tejun Heo &lt;htejun@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: fix condition check in sysfs_drop_dentry()</title>
<updated>2007-06-12T23:08:46+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>htejun@gmail.com</email>
</author>
<published>2007-06-11T05:03:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6aa054aadfea613a437ad0b15d38eca2b963fc0a'/>
<id>6aa054aadfea613a437ad0b15d38eca2b963fc0a</id>
<content type='text'>
The condition check doesn't make much sense as it basically always
succeeds.  This causes NULL dereferencing on certain cases.  It seems
that parentheses are put in the wrong place.  Fix it.

Signed-off-by: Tejun Heo &lt;htejun@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The condition check doesn't make much sense as it basically always
succeeds.  This causes NULL dereferencing on certain cases.  It seems
that parentheses are put in the wrong place.  Fix it.

Signed-off-by: Tejun Heo &lt;htejun@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: store sysfs inode nrs in s_ino to avoid readdir oopses</title>
<updated>2007-06-12T23:08:46+00:00</updated>
<author>
<name>Eric Sandeen</name>
<email>sandeen@sandeen.net</email>
</author>
<published>2007-06-11T05:02:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=dc351252b33f8fede396d6173dba117bcb933607'/>
<id>dc351252b33f8fede396d6173dba117bcb933607</id>
<content type='text'>
Backport of
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.22-rc1/2.6.22-rc1-mm1/broken-out/gregkh-driver-sysfs-allocate-inode-number-using-ida.patch

For regular files in sysfs, sysfs_readdir wants to traverse
sysfs_dirent-&gt;s_dentry-&gt;d_inode-&gt;i_ino to get to the inode number.
But, the dentry can be reclaimed under memory pressure, and there is
no synchronization with readdir.  This patch follows Tejun's scheme of
allocating and storing an inode number in the new s_ino member of a
sysfs_dirent, when dirents are created, and retrieving it from there
for readdir, so that the pointer chain doesn't have to be traversed.

Tejun's upstream patch uses a new-ish "ida" allocator which brings
along some extra complexity; this -stable patch has a brain-dead
incrementing counter which does not guarantee uniqueness, but because
sysfs doesn't hash inodes as iunique expects, uniqueness wasn't
guaranteed today anyway.

Signed-off-by: Eric Sandeen &lt;sandeen@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;htejun@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Backport of
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.22-rc1/2.6.22-rc1-mm1/broken-out/gregkh-driver-sysfs-allocate-inode-number-using-ida.patch

For regular files in sysfs, sysfs_readdir wants to traverse
sysfs_dirent-&gt;s_dentry-&gt;d_inode-&gt;i_ino to get to the inode number.
But, the dentry can be reclaimed under memory pressure, and there is
no synchronization with readdir.  This patch follows Tejun's scheme of
allocating and storing an inode number in the new s_ino member of a
sysfs_dirent, when dirents are created, and retrieving it from there
for readdir, so that the pointer chain doesn't have to be traversed.

Tejun's upstream patch uses a new-ish "ida" allocator which brings
along some extra complexity; this -stable patch has a brain-dead
incrementing counter which does not guarantee uniqueness, but because
sysfs doesn't hash inodes as iunique expects, uniqueness wasn't
guaranteed today anyway.

Signed-off-by: Eric Sandeen &lt;sandeen@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;htejun@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>Detach sched.h from mm.h</title>
<updated>2007-05-21T16:18:19+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2007-05-20T21:22:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e8edc6e03a5c8562dc70a6d969f732bdb355a7e7'/>
<id>e8edc6e03a5c8562dc70a6d969f732bdb355a7e7</id>
<content type='text'>
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.

This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
   getting them indirectly

Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
   they don't need sched.h
b) sched.h stops being dependency for significant number of files:
   on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
   after patch it's only 3744 (-8.3%).

Cross-compile tested on

	all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
	alpha alpha-up
	arm
	i386 i386-up i386-defconfig i386-allnoconfig
	ia64 ia64-up
	m68k
	mips
	parisc parisc-up
	powerpc powerpc-up
	s390 s390-up
	sparc sparc-up
	sparc64 sparc64-up
	um-x86_64
	x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig

as well as my two usual configs.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.

This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
   getting them indirectly

Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
   they don't need sched.h
b) sched.h stops being dependency for significant number of files:
   on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
   after patch it's only 3744 (-8.3%).

Cross-compile tested on

	all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
	alpha alpha-up
	arm
	i386 i386-up i386-defconfig i386-allnoconfig
	ia64 ia64-up
	m68k
	mips
	parisc parisc-up
	powerpc powerpc-up
	s390 s390-up
	sparc sparc-up
	sparc64 sparc64-up
	um-x86_64
	x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig

as well as my two usual configs.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[PATCH] sysfs: reinstate exclusion between method calls and attribute unregistration</title>
<updated>2007-03-15T22:29:26+00:00</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2007-03-15T19:51:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e7b0d26a86943370c04d6833c6edba2a72a6e240'/>
<id>e7b0d26a86943370c04d6833c6edba2a72a6e240</id>
<content type='text'>
This patch (as869) reinstates the mutual exclusion between sysfs
attribute method calls and attribute unregistration.  The
previously-reported deadlocks have been fixed, and this exclusion is
by far the simplest way to avoid races during driver unbinding.

The check for orphaned read-buffers has been moved down slightly, so
that the remainder of a partially-read buffer will still be available
to userspace even after the attribute has been unregistered.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: Hugh Dickins &lt;hugh@veritas.com&gt;
Cc: Cornelia Huck &lt;cornelia.huck@de.ibm.com&gt;
Cc: Oliver Neukum &lt;oneukum@suse.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch (as869) reinstates the mutual exclusion between sysfs
attribute method calls and attribute unregistration.  The
previously-reported deadlocks have been fixed, and this exclusion is
by far the simplest way to avoid races during driver unbinding.

The check for orphaned read-buffers has been moved down slightly, so
that the remainder of a partially-read buffer will still be available
to userspace even after the attribute has been unregistered.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: Hugh Dickins &lt;hugh@veritas.com&gt;
Cc: Cornelia Huck &lt;cornelia.huck@de.ibm.com&gt;
Cc: Oliver Neukum &lt;oneukum@suse.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[PATCH] suspend regression: sysfs deadlock</title>
<updated>2007-03-07T01:59:14+00:00</updated>
<author>
<name>Hugh Dickins</name>
<email>hugh@veritas.com</email>
</author>
<published>2007-03-06T19:20:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=266d4f40370757459f8aa063976c932d0de5e59b'/>
<id>266d4f40370757459f8aa063976c932d0de5e59b</id>
<content type='text'>
Suspend deadlocks when trying to unregister /sys/block/sr0.

This comes from Oliver's commit 94bebf4d1b8e7719f0f3944c037a21cfd99a4af7
"Driver core: fix race in sysfs between sysfs_remove_file() and
read()/write()".

sysfs_write_file downs buffer-&gt;sem while calling flush_write_buffer, and
flushing that particular write buffer entails downing buffer-&gt;sem in
orphan_all_buffers, resulting in the obvious self-deadlock.

Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Suspend deadlocks when trying to unregister /sys/block/sr0.

This comes from Oliver's commit 94bebf4d1b8e7719f0f3944c037a21cfd99a4af7
"Driver core: fix race in sysfs between sysfs_remove_file() and
read()/write()".

sysfs_write_file downs buffer-&gt;sem while calling flush_write_buffer, and
flushing that particular write buffer entails downing buffer-&gt;sem in
orphan_all_buffers, resulting in the obvious self-deadlock.

Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[PATCH] mark struct inode_operations const 3</title>
<updated>2007-02-12T17:48:46+00:00</updated>
<author>
<name>Arjan van de Ven</name>
<email>arjan@linux.intel.com</email>
</author>
<published>2007-02-12T08:55:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c5ef1c42c51b1b5b4a401a6517bdda30933ddbaf'/>
<id>c5ef1c42c51b1b5b4a401a6517bdda30933ddbaf</id>
<content type='text'>
Many struct inode_operations in the kernel can be "const".  Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data.  In addition it'll catch accidental writes at compile time to
these shared resources.

Signed-off-by: Arjan van de Ven &lt;arjan@linux.intel.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Many struct inode_operations in the kernel can be "const".  Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data.  In addition it'll catch accidental writes at compile time to
these shared resources.

Signed-off-by: Arjan van de Ven &lt;arjan@linux.intel.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: Shadow directory support</title>
<updated>2007-02-07T18:37:14+00:00</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2007-01-24T19:35:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=b592fcfe7f06c15ec11774b5be7ce0de3aa86e73'/>
<id>b592fcfe7f06c15ec11774b5be7ce0de3aa86e73</id>
<content type='text'>
The problem.  When implementing a network namespace I need to be able
to have multiple network devices with the same name.  Currently this
is a problem for /sys/class/net/*. 

What I want is a separate /sys/class/net directory in sysfs for each
network namespace, and I want to name each of them /sys/class/net.

I looked and the VFS actually allows that.  All that is needed is
for /sys/class/net to implement a follow link method to redirect
lookups to the real directory you want. 

Implementing a follow link method that is sensitive to the current
network namespace turns out to be 3 lines of code so it looks like a
clean approach.  Modifying sysfs so it doesn't get in my was is a bit
trickier. 

I am calling the concept of multiple directories all at the same path
in the filesystem shadow directories.  With the directory entry really
at that location the shadow master. 

The following patch modifies sysfs so it can handle a directory
structure slightly different from the kobject tree so I can implement
the shadow directories for handling /sys/class/net/.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Maneesh Soni &lt;maneesh@in.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The problem.  When implementing a network namespace I need to be able
to have multiple network devices with the same name.  Currently this
is a problem for /sys/class/net/*. 

What I want is a separate /sys/class/net directory in sysfs for each
network namespace, and I want to name each of them /sys/class/net.

I looked and the VFS actually allows that.  All that is needed is
for /sys/class/net to implement a follow link method to redirect
lookups to the real directory you want. 

Implementing a follow link method that is sensitive to the current
network namespace turns out to be 3 lines of code so it looks like a
clean approach.  Modifying sysfs so it doesn't get in my was is a bit
trickier. 

I am calling the concept of multiple directories all at the same path
in the filesystem shadow directories.  With the directory entry really
at that location the shadow master. 

The following patch modifies sysfs so it can handle a directory
structure slightly different from the kobject tree so I can implement
the shadow directories for handling /sys/class/net/.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Maneesh Soni &lt;maneesh@in.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: suppress lockdep warnings</title>
<updated>2007-02-07T18:37:13+00:00</updated>
<author>
<name>Frederik Deweerdt</name>
<email>deweerdt@free.fr</email>
</author>
<published>2007-01-05T20:04:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=d3fc373ac5061cab7a654502b942e7d00e77f733'/>
<id>d3fc373ac5061cab7a654502b942e7d00e77f733</id>
<content type='text'>
Lockdep issues the following warning:
[    9.064000] =============================================
[    9.064000] [ INFO: possible recursive locking detected ]
[    9.064000] 2.6.20-rc3-mm1 #3
[    9.064000] ---------------------------------------------
[    9.064000] init/1 is trying to acquire lock:
[    9.064000]  (&amp;sysfs_inode_imutex_key){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.064000]
[    9.064000] but task is already holding lock:
[    9.064000]  (&amp;sysfs_inode_imutex_key){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.065000]
[    9.065000] other info that might help us debug this:
[    9.065000] 2 locks held by init/1:
[    9.065000]  #0:  (tty_mutex){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.065000]  #1:  (&amp;sysfs_inode_imutex_key){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.065000]
[    9.065000] stack backtrace:
[    9.065000]  [&lt;c010390d&gt;] show_trace_log_lvl+0x1a/0x30
[    9.066000]  [&lt;c0103935&gt;] show_trace+0x12/0x14
[    9.066000]  [&lt;c0103a2f&gt;] dump_stack+0x16/0x18
[    9.066000]  [&lt;c0138cb8&gt;] print_deadlock_bug+0xb9/0xc3
[    9.066000]  [&lt;c0138d17&gt;] check_deadlock+0x55/0x5a
[    9.066000]  [&lt;c013a953&gt;] __lock_acquire+0x371/0xbf0
[    9.066000]  [&lt;c013b7a9&gt;] lock_acquire+0x69/0x83
[    9.066000]  [&lt;c03e6b7e&gt;] __mutex_lock_slowpath+0x75/0x2d1
[    9.066000]  [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.066000]  [&lt;c01b249c&gt;] sysfs_drop_dentry+0xb1/0x133
[    9.066000]  [&lt;c01b25d1&gt;] sysfs_hash_and_remove+0xb3/0x142
[    9.066000]  [&lt;c01b30ed&gt;] sysfs_remove_file+0xd/0x10
[    9.067000]  [&lt;c02849e0&gt;] device_remove_file+0x23/0x2e
[    9.067000]  [&lt;c02850b2&gt;] device_del+0x188/0x1e6
[    9.067000]  [&lt;c028511b&gt;] device_unregister+0xb/0x15
[    9.067000]  [&lt;c0285318&gt;] device_destroy+0x9c/0xa9
[    9.067000]  [&lt;c0261431&gt;] vcs_remove_sysfs+0x1c/0x3b
[    9.067000]  [&lt;c0267a08&gt;] con_close+0x5e/0x6b
[    9.067000]  [&lt;c02598f2&gt;] release_dev+0x4c4/0x6e5
[    9.067000]  [&lt;c0259faa&gt;] tty_release+0x12/0x1c
[    9.067000]  [&lt;c0174872&gt;] __fput+0x177/0x1a0
[    9.067000]  [&lt;c01746f5&gt;] fput+0x3b/0x41
[    9.068000]  [&lt;c0172ee1&gt;] filp_close+0x36/0x65
[    9.068000]  [&lt;c0172f73&gt;] sys_close+0x63/0xa4
[    9.068000]  [&lt;c0102a96&gt;] sysenter_past_esp+0x5f/0x99
[    9.068000]  =======================

This is due to sysfs_hash_and_remove() holding dir-&gt;d_inode-&gt;i_mutex
before calling sysfs_drop_dentry() which calls orphan_all_buffers()
which in turn takes node-&gt;i_mutex.

Signed-off-by: Frederik Deweerdt &lt;frederik.deweerdt@gmail.com&gt;
Cc: Oliver Neukum &lt;oliver@neukum.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Lockdep issues the following warning:
[    9.064000] =============================================
[    9.064000] [ INFO: possible recursive locking detected ]
[    9.064000] 2.6.20-rc3-mm1 #3
[    9.064000] ---------------------------------------------
[    9.064000] init/1 is trying to acquire lock:
[    9.064000]  (&amp;sysfs_inode_imutex_key){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.064000]
[    9.064000] but task is already holding lock:
[    9.064000]  (&amp;sysfs_inode_imutex_key){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.065000]
[    9.065000] other info that might help us debug this:
[    9.065000] 2 locks held by init/1:
[    9.065000]  #0:  (tty_mutex){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.065000]  #1:  (&amp;sysfs_inode_imutex_key){--..}, at: [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.065000]
[    9.065000] stack backtrace:
[    9.065000]  [&lt;c010390d&gt;] show_trace_log_lvl+0x1a/0x30
[    9.066000]  [&lt;c0103935&gt;] show_trace+0x12/0x14
[    9.066000]  [&lt;c0103a2f&gt;] dump_stack+0x16/0x18
[    9.066000]  [&lt;c0138cb8&gt;] print_deadlock_bug+0xb9/0xc3
[    9.066000]  [&lt;c0138d17&gt;] check_deadlock+0x55/0x5a
[    9.066000]  [&lt;c013a953&gt;] __lock_acquire+0x371/0xbf0
[    9.066000]  [&lt;c013b7a9&gt;] lock_acquire+0x69/0x83
[    9.066000]  [&lt;c03e6b7e&gt;] __mutex_lock_slowpath+0x75/0x2d1
[    9.066000]  [&lt;c03e6afc&gt;] mutex_lock+0x1c/0x1f
[    9.066000]  [&lt;c01b249c&gt;] sysfs_drop_dentry+0xb1/0x133
[    9.066000]  [&lt;c01b25d1&gt;] sysfs_hash_and_remove+0xb3/0x142
[    9.066000]  [&lt;c01b30ed&gt;] sysfs_remove_file+0xd/0x10
[    9.067000]  [&lt;c02849e0&gt;] device_remove_file+0x23/0x2e
[    9.067000]  [&lt;c02850b2&gt;] device_del+0x188/0x1e6
[    9.067000]  [&lt;c028511b&gt;] device_unregister+0xb/0x15
[    9.067000]  [&lt;c0285318&gt;] device_destroy+0x9c/0xa9
[    9.067000]  [&lt;c0261431&gt;] vcs_remove_sysfs+0x1c/0x3b
[    9.067000]  [&lt;c0267a08&gt;] con_close+0x5e/0x6b
[    9.067000]  [&lt;c02598f2&gt;] release_dev+0x4c4/0x6e5
[    9.067000]  [&lt;c0259faa&gt;] tty_release+0x12/0x1c
[    9.067000]  [&lt;c0174872&gt;] __fput+0x177/0x1a0
[    9.067000]  [&lt;c01746f5&gt;] fput+0x3b/0x41
[    9.068000]  [&lt;c0172ee1&gt;] filp_close+0x36/0x65
[    9.068000]  [&lt;c0172f73&gt;] sys_close+0x63/0xa4
[    9.068000]  [&lt;c0102a96&gt;] sysenter_past_esp+0x5f/0x99
[    9.068000]  =======================

This is due to sysfs_hash_and_remove() holding dir-&gt;d_inode-&gt;i_mutex
before calling sysfs_drop_dentry() which calls orphan_all_buffers()
which in turn takes node-&gt;i_mutex.

Signed-off-by: Frederik Deweerdt &lt;frederik.deweerdt@gmail.com&gt;
Cc: Oliver Neukum &lt;oliver@neukum.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>Driver core: fix race in sysfs between sysfs_remove_file() and read()/write()</title>
<updated>2007-02-07T18:37:13+00:00</updated>
<author>
<name>Oliver Neukum</name>
<email>oliver@neukum.org</email>
</author>
<published>2006-12-20T09:52:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=94bebf4d1b8e7719f0f3944c037a21cfd99a4af7'/>
<id>94bebf4d1b8e7719f0f3944c037a21cfd99a4af7</id>
<content type='text'>
This patch prevents a race between IO and removing a file from sysfs.
It introduces a list of sysfs_buffers associated with a file at the inode.
Upon removal of a file the list is walked and the buffers marked orphaned.
IO to orphaned buffers fails with -ENODEV. The driver can safely free
associated data structures or be unloaded.

Signed-off-by: Oliver Neukum &lt;oliver@neukum.name&gt;
Acked-by: Maneesh Soni &lt;maneesh@in.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;


</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch prevents a race between IO and removing a file from sysfs.
It introduces a list of sysfs_buffers associated with a file at the inode.
Upon removal of a file the list is walked and the buffers marked orphaned.
IO to orphaned buffers fails with -ENODEV. The driver can safely free
associated data structures or be unloaded.

Signed-off-by: Oliver Neukum &lt;oliver@neukum.name&gt;
Acked-by: Maneesh Soni &lt;maneesh@in.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;


</pre>
</div>
</content>
</entry>
</feed>
