[patch for playing] 2.5.65 patch to support > 256 disks

Badari Pulavarty
2003-03-21T18:56:04Z

[-- Attachment #1: Type: text/plain, Size: 1655 bytes --]

Hi,

Andries Brouwer recently submitted 32 bit dev_t patches,
which are in 2.5.65-mm2. This patch applies on those patches to support
more than 256 disks. This is for playing only.

I tested this with 4000 disks using scsi_debug. I attached my actual
disks (50) after 4000 scsi_debug disks. I am able to access my disks
fine and do IO on them.

Problems (so far):

1) sd.c - sd_index_bits[] arrys became big - need to be fixed.

2) 4000 disks eats up lots of low memory (~460 MB). Here is the
/proc/meminfo output before & after insmod.

Before:
MemTotal: 3883276 kB
MemFree: 3808028 kB
Buffers: 3240 kB
Cached: 41860 kB
SwapCached: 0 kB
Active: 45360 kB
Inactive: 7288 kB
HighTotal: 3014616 kB
HighFree: 2961856 kB
LowTotal: 868660 kB
LowFree: 846172 kB
SwapTotal: 2040244 kB
SwapFree: 2040244 kB
Dirty: 192 kB
Writeback: 0 kB
Mapped: 14916 kB
Slab: 7164 kB
Committed_AS: 12952 kB
PageTables: 312 kB
ReverseMaps: 1895
====
After:
MemTotal: 3883276 kB
MemFree: 3224140 kB
Buffers: 3880 kB
Cached: 140376 kB
SwapCached: 0 kB
Active: 47512 kB
Inactive: 105508 kB
HighTotal: 3014616 kB
HighFree: 2838144 kB
LowTotal: 868660 kB
LowFree: 385996 kB
SwapTotal: 2040244 kB
SwapFree: 2040244 kB
Dirty: 92 kB
Writeback: 0 kB
Mapped: 16172 kB
Slab: 464364 kB
Committed_AS: 14996 kB
PageTables: 412 kB
ReverseMaps: 2209

[-- Attachment #2: sd.patch --]
[-- Type: text/x-diff, Size: 1353 bytes --]

--- linux/drivers/scsi/sd.c Thu Mar 20 15:06:00 2003
+++ linux.new/drivers/scsi/sd.c Fri Mar 21 11:50:54 2003
@@ -56,7 +56,9 @@
* Remaining dev_t-handling stuff
*/
#define SD_MAJORS 16
-#define SD_DISKS (SD_MAJORS << 4)
+#define SD_DISKS_PER_MAJOR_SHIFT (KDEV_MINOR_BITS - 4)
+#define SD_DISKS_PER_MAJOR (1 << SD_DISKS_PER_MAJOR_SHIFT)
+#define SD_DISKS (SD_MAJORS << SD_DISKS_PER_MAJOR_SHIFT)

/*
* Time out in seconds for disks and Magneto-opticals (which are slower).
@@ -1328,17 +1330,23 @@ static int sd_attach(struct scsi_device
sdkp->index = index;

gd->de = sdp->de;
- gd->major = sd_major(index >> 4);
- gd->first_minor = (index & 15) << 4;
+ gd->major = sd_major(index >> SD_DISKS_PER_MAJOR_SHIFT);
+ gd->first_minor = (index & (SD_DISKS_PER_MAJOR - 1)) << 4;
gd->minors = 16;
gd->fops = &sd_fops;

- if (index >= 26) {
+ if (index < 26) {
+ sprintf(gd->disk_name, "sd%c", 'a' + index % 26);
+ } else if (index < (26*27)) {
sprintf(gd->disk_name, "sd%c%c",
'a' + index/26-1,'a' + index % 26);
} else {
- sprintf(gd->disk_name, "sd%c", 'a' + index % 26);
- }
+ const unsigned int m1 = (index/ 26 - 1) / 26 - 1;
+ const unsigned int m2 = (index / 26 - 1) % 26;
+ const unsigned int m3 = index % 26;
+ sprintf(gd->disk_name, "sd%c%c%c",
+ 'a' + m1, 'a' + m2, 'a' + m3);
+ }

sd_init_onedisk(sdkp, gd);