分类: LINUX
2010-05-13 10:57:49
How many SCSI disks can be supported in Red Hat Enterprise Linux 5?
Red Hat Enterprise Linux 5
To know the truth, the best way is the code. Let's look into the SCSI driver.
In file linux-2.6.18.i386/drivers/scsi/sd.c, (All codes in this article are from this file)
315 /*
316 * Device no to disk mapping:
317 *
318 * major disc2 disc p1
319 * |............|.............|....|....| <- dev_t
320 * 31 20 19 8 7 4 3 0
321 *
322 * Inside a major, we have 16k disks, however mapped non-
323 * contiguously. The first 16 disks are for major0, the next
324 * ones with major1, ... Disk 256 is for major0 again, disk 272
325 * for major1, ...
326 * As we stay compatible with our numbering scheme, we can reuse
327 * the well-know SCSI majors 8, 65--71, 136--143.
328 */
1654 u32 index;
1709 gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
From the description, Using a 4 bytes number to represent a disk in
disk mapping. The high 10 bits are used for major, and the low 20 bits
are used for minor. According to the code, I call 4 to 19 bits the
first minor, and 0 to 3 bits partition number. So the number of max
supported disks is 16*2^16, totally 1M! Really? Test it by using mknod.
[root@dom0 ~]# mknod sdx15 b 8 1048576
mknod: `sdx': Invalid argument
[root@dom0 ~]# mknod sdx15 b 8 1048575
[root@dom0 ~]# ll sdx15
brw-r--r-- 1 root root 8, 1048575 May 14 17:47 sdx15
More information about major, please see /usr/share/doc/kernel-doc-2.6.18 /Documentation /devices.txt.
But there is another limitation in naming these disks.
94 * This is limited by the naming scheme enforced in sd_probe,
95 * add another character to it if you really need more disks.
96 */
97 #define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26
1680 if (index >= SD_MAX_DISKS)
1681 error = -EBUSY;
1713 if (index < 26) {
1714 sprintf(gd->disk_name, "sd%c", 'a' + index % 26);
1715 } else if (index < (26 + 1) * 26) {
1716 sprintf(gd->disk_name, "sd%c%c",
1717 'a' + index / 26 - 1,'a' + index % 26);
1718 } else {
1719 const unsigned int m1 = (index / 26 - 1) / 26 - 1;
1720 const unsigned int m2 = (index / 26 - 1) % 26;
1721 const unsigned int m3 = index % 26;
1722 sprintf(gd->disk_name, "sd%c%c%c",
1723 'a' + m1, 'a' + m2, 'a' + m3);
1724 }
So the max supported number of disk is (((26 * 26) + 26 + 1) * 26 = 18278, that means the maximum name of disk is sdzzz.