Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [patch for 2.6.32? 1/3] scsi_lib.c: avoid calling scsi_device_put() from under ->host_lock
@ 2009-11-17 22:10 akpm
  2009-11-18  0:26 ` James Bottomley
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2009-11-17 22:10 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-scsi, akpm, strakh, jens.axboe

From: Alexander Strakh <strakh@ispras.ru>

Driver scsi_lib.c might sleep in atomic context, because it calls
scsi_device_put under spin_lock_irqsave.

drivers/scsi/scsi_lib.c:356:
	spin_lock_irqsave(shost->host_lock, flags);
	scsi_device_put(sdev);
Path to might_sleep macro from scsi_device_put:
1. scsi_device_put calls put_device at ./drivers/scsi/scsi.c:1111
2. put_device calls kobject_put at ./drivers/base/core.c:1038
3. kobject_put calls kref_put at ./lib/kobject.c
4. kref_put may call callback function kobject_release at ./lib/kref.c if
refcount becomes zero, which might_sleep because it calls user event. Details:
	4.1 kobject_cleanup calls kobject_uevent at ./lib/kobject.c:555
	4.2 kobject_uevent calls kobject_uevent_env at  ./lib/kobject_uevent.c:282
	4.3 kobject_uevent_env calls call_usermodehelper_exec at
./include/linux/kmod.h:83
	4.4 call_usermodehelper_exec calls wait_for_completion at
./kernel/kmod.c:481
	4.5 wait_for_completion calls wait_for_common at ./kernel/sched.c:5710
	4.5 wait_for_common calls might_sleep at ./kernels/sched.c:5692

Found by Linux Driver Verification project.

Delete wrong sleeping function calls.

Signed-off-by: Alexander Strakh <strakh@ispras.ru>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/scsi/scsi_lib.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/scsi_lib.c~scsi_libc-avoid-calling-scsi_device_put-from-under-host_lock drivers/scsi/scsi_lib.c
--- a/drivers/scsi/scsi_lib.c~scsi_libc-avoid-calling-scsi_device_put-from-under-host_lock
+++ a/drivers/scsi/scsi_lib.c
@@ -353,9 +353,9 @@ static void scsi_single_lun_run(struct s
 
 		spin_unlock_irqrestore(shost->host_lock, flags);
 		blk_run_queue(sdev->request_queue);
-		spin_lock_irqsave(shost->host_lock, flags);
 	
 		scsi_device_put(sdev);
+		spin_lock_irqsave(shost->host_lock, flags);
 	}
  out:
 	spin_unlock_irqrestore(shost->host_lock, flags);
_

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

* Re: [patch for 2.6.32? 1/3] scsi_lib.c: avoid calling scsi_device_put() from under ->host_lock
  2009-11-17 22:10 [patch for 2.6.32? 1/3] scsi_lib.c: avoid calling scsi_device_put() from under ->host_lock akpm
@ 2009-11-18  0:26 ` James Bottomley
  0 siblings, 0 replies; 2+ messages in thread
From: James Bottomley @ 2009-11-18  0:26 UTC (permalink / raw)
  To: akpm; +Cc: linux-scsi, strakh, jens.axboe

On Tue, 2009-11-17 at 14:10 -0800, akpm@linux-foundation.org wrote:
> From: Alexander Strakh <strakh@ispras.ru>
> 
> Driver scsi_lib.c might sleep in atomic context, because it calls
> scsi_device_put under spin_lock_irqsave.

I thought I already gave an explanation why this is the wrong
analysis ... sorry on a plane and can't look it up.

James



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

end of thread, other threads:[~2009-11-18  0:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-17 22:10 [patch for 2.6.32? 1/3] scsi_lib.c: avoid calling scsi_device_put() from under ->host_lock akpm
2009-11-18  0:26 ` James Bottomley

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