[PATCH] Fix units/partition count in sd.c

Linux Kernel Mailing List <[email protected]> Sat, 26 Feb 2005 13:45:45 +0000
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1558, 2005/02/26 10:45:45-03:00, [email protected]

	[PATCH] Fix units/partition count in sd.c
	
	Symptom:
	   When a scsi disk is removed other scsi disk with biggest minor #
	   disapears in /proc/partition at the same time.
	
	Cause and fix:
	   sd.c decreases nr_real on disk removal but because nr_real is not
	   real # of devices but max # of devices of a major #,
	   it doesn't need to be changed on disk add/remove.
	
	2.6 has little different structure but it does like this
	
	sd.c:sd_probe()
		gd->minors = 16;



 sd.c |    4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)


diff -Nru a/drivers/scsi/sd.c b/drivers/scsi/sd.c
--- a/drivers/scsi/sd.c	2005-02-26 11:06:51 -08:00
+++ b/drivers/scsi/sd.c	2005-02-26 11:06:51 -08:00
@@ -1220,7 +1220,7 @@
 			goto cleanup_gendisks_part;
 		memset(sd_gendisks[i].part, 0, (SCSI_DISKS_PER_MAJOR << 4) * sizeof(struct hd_struct));
 		sd_gendisks[i].sizes = sd_sizes + (i * SCSI_DISKS_PER_MAJOR << 4);
-		sd_gendisks[i].nr_real = 0;
+		sd_gendisks[i].nr_real = SCSI_DISKS_PER_MAJOR;
 		sd_gendisks[i].real_devices =
 		    (void *) (rscsi_disks + i * SCSI_DISKS_PER_MAJOR);
 	}
@@ -1333,7 +1333,6 @@
 	rscsi_disks[i].device = SDp;
 	rscsi_disks[i].has_part_table = 0;
 	sd_template.nr_dev++;
-	SD_GENDISK(i).nr_real++;
         devnum = i % SCSI_DISKS_PER_MAJOR;
         SD_GENDISK(i).de_arr[devnum] = SDp->de;
         if (SDp->removable)
@@ -1447,7 +1446,6 @@
 			SDp->attached--;
 			sd_template.dev_noticed--;
 			sd_template.nr_dev--;
-			SD_GENDISK(i).nr_real--;
 			return;
 		}
 	return;