public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [GIT PATCH] driver core fixes for 2.6.32-git
@ 2009-10-14 23:04 Greg KH
  2009-10-14 23:51 ` [PATCH 1/2] sysfs: Allow sysfs_move_dir(..., NULL) again Greg Kroah-Hartman
  2009-10-14 23:51 ` [PATCH 2/2] sysfs: Allow sysfs_notify_dirent to be called from interrupt context Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: Greg KH @ 2009-10-14 23:04 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton; +Cc: linux-kernel

Here are 2 bugfixes for the driver core code for your .32 git tree.

They do:
	- fix sysfs_move_dir()
	- fix sysfs interrupt context issue that was being triggered by
	  users.


Please pull from:
	master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-core-2.6.git/

All of these patches have been in the linux-next and mm trees for a
long time.

The patches will be sent as a follow-on to this message to lkml for people
to see.

thanks,

greg k-h

------------

 fs/sysfs/dir.c  |    3 ++-
 fs/sysfs/file.c |   14 ++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

---------------

Cornelia Huck (1):
      sysfs: Allow sysfs_move_dir(..., NULL) again.

Neil Brown (1):
      sysfs: Allow sysfs_notify_dirent to be called from interrupt context.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] sysfs: Allow sysfs_move_dir(..., NULL) again.
  2009-10-14 23:04 [GIT PATCH] driver core fixes for 2.6.32-git Greg KH
@ 2009-10-14 23:51 ` Greg Kroah-Hartman
  2009-10-14 23:51 ` [PATCH 2/2] sysfs: Allow sysfs_notify_dirent to be called from interrupt context Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2009-10-14 23:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Cornelia Huck, Phil Carmody, Greg Kroah-Hartman

From: Cornelia Huck <cornelia.huck@de.ibm.com>

As device_move() and kobject_move() both handle a NULL destination,
sysfs_move_dir() should do this as well (again) and fall back to
sysfs_root in that case.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 fs/sysfs/dir.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 0050fc4..5fad489 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -894,7 +894,8 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
 
 	mutex_lock(&sysfs_rename_mutex);
 	BUG_ON(!sd->s_parent);
-	new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root;
+	new_parent_sd = (new_parent_kobj && new_parent_kobj->sd) ?
+		new_parent_kobj->sd : &sysfs_root;
 
 	error = 0;
 	if (sd->s_parent == new_parent_sd)
-- 
1.6.4.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] sysfs: Allow sysfs_notify_dirent to be called from interrupt context.
  2009-10-14 23:04 [GIT PATCH] driver core fixes for 2.6.32-git Greg KH
  2009-10-14 23:51 ` [PATCH 1/2] sysfs: Allow sysfs_move_dir(..., NULL) again Greg Kroah-Hartman
@ 2009-10-14 23:51 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2009-10-14 23:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Neil Brown, Dan Williams, stable, Greg Kroah-Hartman

From: Neil Brown <neilb@suse.de>

sysfs_notify_dirent is a simple atomic operation that can be used to
alert user-space that new data can be read from a sysfs attribute.

Unfortunately it cannot currently be called from non-process context
because of its use of spin_lock which is sometimes taken with
interrupts enabled.

So change all lockers of sysfs_open_dirent_lock to disable interrupts,
thus making sysfs_notify_dirent safe to be called from non-process
context (as drivers/md does in md_safemode_timeout).

sysfs_get_open_dirent is (documented as being) only called from
process context, so it uses spin_lock_irq.  Other places
use spin_lock_irqsave.

The usage for sysfs_notify_dirent in md_safemode_timeout was
introduced in 2.6.28, so this patch is suitable for that and more
recent kernels.

Reported-by: Joel Andres Granados <jgranado@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 fs/sysfs/file.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 561a9c0..f5ea468 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -268,7 +268,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
 	struct sysfs_open_dirent *od, *new_od = NULL;
 
  retry:
-	spin_lock(&sysfs_open_dirent_lock);
+	spin_lock_irq(&sysfs_open_dirent_lock);
 
 	if (!sd->s_attr.open && new_od) {
 		sd->s_attr.open = new_od;
@@ -281,7 +281,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
 		list_add_tail(&buffer->list, &od->buffers);
 	}
 
-	spin_unlock(&sysfs_open_dirent_lock);
+	spin_unlock_irq(&sysfs_open_dirent_lock);
 
 	if (od) {
 		kfree(new_od);
@@ -315,8 +315,9 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd,
 				  struct sysfs_buffer *buffer)
 {
 	struct sysfs_open_dirent *od = sd->s_attr.open;
+	unsigned long flags;
 
-	spin_lock(&sysfs_open_dirent_lock);
+	spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
 
 	list_del(&buffer->list);
 	if (atomic_dec_and_test(&od->refcnt))
@@ -324,7 +325,7 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd,
 	else
 		od = NULL;
 
-	spin_unlock(&sysfs_open_dirent_lock);
+	spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);
 
 	kfree(od);
 }
@@ -456,8 +457,9 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
 void sysfs_notify_dirent(struct sysfs_dirent *sd)
 {
 	struct sysfs_open_dirent *od;
+	unsigned long flags;
 
-	spin_lock(&sysfs_open_dirent_lock);
+	spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
 
 	od = sd->s_attr.open;
 	if (od) {
@@ -465,7 +467,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
 		wake_up_interruptible(&od->poll);
 	}
 
-	spin_unlock(&sysfs_open_dirent_lock);
+	spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);
 }
 EXPORT_SYMBOL_GPL(sysfs_notify_dirent);
 
-- 
1.6.4.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-10-14 23:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-14 23:04 [GIT PATCH] driver core fixes for 2.6.32-git Greg KH
2009-10-14 23:51 ` [PATCH 1/2] sysfs: Allow sysfs_move_dir(..., NULL) again Greg Kroah-Hartman
2009-10-14 23:51 ` [PATCH 2/2] sysfs: Allow sysfs_notify_dirent to be called from interrupt context Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox