linux 2.2.8: problems with sd_detach + fix

Maciej W. Rozycki (macro@ds2.pg.gda.pl)
Fri, 14 May 1999 17:51:32 +0200 (MET DST)


Hi,

The following problem exists for quite a long time. After removing the
module for the second SCSI host adapter (ppa; the first one is ncr53c8xx
and is compiled into the kernel), further /proc/scsi accesses cause bad
things to happen to my Alpha system. Sometimes the process is being
killed due to unaligned code accesses and sometimes it just hangs forever.

I believe I finally tracked down the problem to be sd_detach which seems
to contain some mess, unfortunately. The "SD_GENDISK(start).nr_real--;"
statement decrements "scsi_hosts->proc_dir->fill_inode" on my system which
explains why there are unaligned code accesses. Also the steering
variable of the outer loop is being reused for the similar purpose in the
inner one.

The following patch works for me. Comments?

Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

diff -u --recursive --new-file linux-2.2.8.macro/drivers/scsi/sd.c linux-2.2.8/drivers/scsi/sd.c --- linux-2.2.8.macro/drivers/scsi/sd.c Fri May 14 14:12:43 1999 +++ linux-2.2.8/drivers/scsi/sd.c Fri May 14 14:06:28 1999 @@ -1729,7 +1729,7 @@ static void sd_detach(Scsi_Device * SDp) { Scsi_Disk * dpnt; - int i; + int i, j; int max_p; int start; @@ -1741,8 +1741,8 @@ max_p = sd_gendisk.max_p; start = i << sd_gendisk.minor_shift; - for (i=max_p - 1; i >=0 ; i--) { - int index = start+i; + for (j=max_p - 1; j >=0 ; j--) { + int index = start+j; kdev_t devi = MKDEV_SD_PARTITION(index); struct super_block *sb = get_super(devi); sync_dev(devi); @@ -1759,7 +1759,7 @@ SDp->attached--; sd_template.dev_noticed--; sd_template.nr_dev--; - SD_GENDISK(start).nr_real--; + SD_GENDISK(i).nr_real--; return; } return;

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/