Hi Linus, Alan,

appended a patch to prevent the deadlock on io_request_lock.

If the sd code detected an invalid sector size, it didn't release the
io_request_lock acquired a few instructions above. Also the code to free the
unuseable disk was wrong: It left the attach counter with 1.
The code in revalidate_scsidisk stumbled across the removed disk with oopses.

The attached patch (against 2.2.12) fixes these problems.

-- 
Kurt Garloff  <[EMAIL PROTECTED]>                             Wuppertal, FRG
PGP2 key: See mail header, key servers            Linux kernel development
SuSE GmbH, N�rnberg, FRG               SCSI drivers: tmscsim(DC390), DC395
--- linux/drivers/scsi/sd.c.orig        Fri Aug 27 13:39:10 1999
+++ linux/drivers/scsi/sd.c     Sat Aug 28 17:02:07 1999
@@ -1358,15 +1358,19 @@
                rscsi_disks[i].capacity = 0;
            } else {
                printk ("scsi : deleting disk entry.\n");
+               sd_detach(rscsi_disks[i].device);
                rscsi_disks[i].device = NULL;
+               /*
                sd_template.nr_dev--;
                SD_GENDISK(i).nr_real--;
-
+               */
                 /* Wake up a process waiting for device */
                 wake_up(&SCpnt->device->device_wait);
                 scsi_release_command(SCpnt);
                 SCpnt = NULL;
                 
+               scsi_free(buffer, 512);
+               spin_unlock_irq(&io_request_lock);
                return i;
            }
        }
@@ -1720,6 +1724,7 @@
 #endif
 
     sd_gendisks->part[start].nr_sects = CAPACITY;
+    if (!rscsi_disks[target].device) return -EBUSY;
     resetup_one_dev(&SD_GENDISK(target),
                    target % SCSI_DISKS_PER_MAJOR);
 

PGP signature

Reply via email to