diff -uNr linux-2.4.19-rc3.sdm5.v6/drivers/scsi/sd.c linux-2.4.19-rc3.sdm5/drivers/scsi/sd.c --- linux-2.4.19-rc3.sdm5.v6/drivers/scsi/sd.c Tue Jul 30 11:45:18 2002 +++ linux-2.4.19-rc3.sdm5/drivers/scsi/sd.c Tue Aug 13 13:18:39 2002 @@ -865,7 +865,7 @@ return -1; } - buffer = (unsigned char *) scsi_malloc(256); + buffer = (unsigned char *) scsi_malloc(512); if (!buffer) { printk(KERN_WARNING "(sd_init_onedisk:) Memory allocation failure.\n"); scsi_release_request(SRpnt); @@ -1138,7 +1138,7 @@ scsi_release_request(SRpnt); SRpnt = NULL; - scsi_free(buffer, 256); + scsi_free(buffer, 512); return 0; } diff -uNr linux-2.4.19-rc3.sdm5.v6/drivers/scsi/sd_dynalloc.c linux-2.4.19-rc3.sdm5/drivers/scsi/sd_dynalloc.c --- linux-2.4.19-rc3.sdm5.v6/drivers/scsi/sd_dynalloc.c Tue Jul 30 12:30:18 2002 +++ linux-2.4.19-rc3.sdm5/drivers/scsi/sd_dynalloc.c Tue Aug 13 12:10:50 2002 @@ -17,14 +17,18 @@ * Fix /proc/partitions by calling sd_devname() via gendisk * * TODO: - Check locking issues. - * - More intelligent reuse of sd slots(?) - * - Remove debug printks * * 2002-07-25: (sd_many-5) * - Added the officially assigned SCSI majors 9--15. * (Thanks to Pete Zaitvec for telling!) * - Made maximum number of SCSI majors a config option * - SysRq preference for all SCSI disk majors (Pete ...) + * + * 2002-08-12: (sd_many-7) + * - pass buffer length 252 consistent with alloc length + * in sd_init_onedisk() + * - Fix deallocation of majors. + * - Fix locking issue with blk_getfops() */ @@ -32,7 +36,7 @@ #include #define SD_REUSE_SLOTS 1 -#define SD_DYN_DEBUG 1 +#define SD_DYN_DEBUG 0 # define SDD_PRINTK(ARGS...) printk(KERN_WARNING "sd: " ARGS) #ifdef SD_DYN_DEBUG @@ -158,7 +162,7 @@ /* We should already have the lock in write mode when entering */ int sd_alloc_major (void) { - int major; + int major, rc; SD_Major *sd_major; /* Initialize sd_major_to_midx array */ @@ -177,7 +181,9 @@ #ifdef CONFIG_DEVFS_FS major = devfs_alloc_major(DEVFS_SPECIAL_BLK); #else + SD_UNLOCK_W; major = sd_find_major (); + SD_LOCK_W; #endif if (major == SD_NO_MAJOR) { SDD_PRINTK("alloc_major: could not get major\n"); @@ -192,14 +198,15 @@ } memset (sd_major, 0, sizeof (*sd_major)); - sd_major->sd_gendisk.major = major; - - if (devfs_register_blkdev(major, "sd", &sd_fops)) { + if ((rc = devfs_register_blkdev(major, "sd", &sd_fops)) < 0) { SDD_PRINTK("alloc_major: could not register major %i\n", major); goto dealloc_sd_major; - } + } else if (major == 0) + major = rc; + sd_major->sd_gendisk.major = major; + /* Now, nothing can fail ... except the programmer, of course */ sd_fill_defaults (sd_major); sd_set_major_arrays (sd_major); @@ -228,7 +235,7 @@ void sd_dealloc_major (const int midx) { SD_Major *sd_major = SD_MAJOR_PTR(midx); - const int major = MIDX_TO_MAJOR(midx); + const int major = sd_major->sd_gendisk.major; del_gendisk(&sd_major->sd_gendisk); devfs_unregister_blkdev(major, "sd"); sd_major_ptrs[midx] = NULL;