sd/usb deadlock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not sure if I should report this or ask around elsewhere... This was
also sent to drew@xxxxxxxxxxxx, as he was first in sd.c.


sd_open in drivers/scsi/sd.c  seems to have a deadlock.  It was noticed
when plugging and unplugging lots of usb disks in random order on a slow
machine.  The hotplug scripts were running fdisk -l on the devices and
trying to mount the disks as they were getting (un)plugged.  I saw this
in version 2.4.21, but the code is the same at least up to 2.4.30.

revalidate_scsidisk marks the disk as busy, then we hit an sd_open and
got stuck in a loop waiting for the disk to become not busy.  The change
is to fail on open if the disk is busy.  Requiring a mount retry is
better behavior than hanging the kernel.

The diff is attached... I'm not sure the process to getting it in a
release... pointers would be helpful.  If there is a reason this
shouldn't be used let me know, as I'm not much of a kernel hacker.

--- sd.c	2006-02-10 12:22:41.000000000 -0500
+++ sd.c~	2006-02-08 16:27:31.000000000 -0500
@@ -466,10 +466,15 @@
 	 * is being re-read.
 	 */
 
- 	if  (rscsi_disks[target].device->busy) {
-		printk("device %d was busy, can't open it, try again soon.\n", target);
- 		return -ENXIO;
- 	}
+
+	while (rscsi_disks[target].device->busy) {
+		barrier();
+		cpu_relax();
+	}
+
 	/*
 	 * The following code can sleep.
 	 * Module unloading must be prevented


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux