From: Badari Pulavarty <pbadari@us.ibm.com>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: [patch for playing] Patch to support 4000 disks and maintain backward compatibility
Date: Thu, 10 Apr 2003 13:39:49 -0700 [thread overview]
Message-ID: <200304101339.49895.pbadari@us.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 571 bytes --]
Hi,
Here is the (sd) patch to support > 4000 disks on 32-bit dev_t work
in 2.5.67-mm tree.
This patch addresses the backward compatibility with device nodes
issue. All the new disks will be addressed by only last major.
SCSI has 16 majors. Each major supports 16 disks currently.
This patch leaves this assumption for first 15 majors and all the
new disks addressable by 32/64 dev_t work will be added to
SCSI last major#. This way, we don't need to create device
nodes in /dev, if you switch between 2.4 and 2.5.
Any comments ?
Thanks,
Badari
[-- Attachment #2: sd.new --]
[-- Type: text/x-diff, Size: 2514 bytes --]
--- linux-2.5.67/drivers/scsi/sd.c Wed Apr 9 13:12:38 2003
+++ linux-2.5.67.new/drivers/scsi/sd.c Thu Apr 10 13:23:49 2003
@@ -56,7 +56,9 @@
* Remaining dev_t-handling stuff
*/
#define SD_MAJORS 16
-#define SD_DISKS (SD_MAJORS << 4)
+#define SD_DISKS ((SD_MAJORS - 1) << 4)
+#define LAST_MAJOR_DISKS (1 << (KDEV_MINOR_BITS - 4))
+#define TOTAL_SD_DISKS (SD_DISKS + LAST_MAJOR_DISKS)
/*
* Time out in seconds for disks and Magneto-opticals (which are slower).
@@ -85,7 +87,7 @@ struct scsi_disk {
static LIST_HEAD(sd_devlist);
static spinlock_t sd_devlist_lock = SPIN_LOCK_UNLOCKED;
-static unsigned long sd_index_bits[SD_DISKS / BITS_PER_LONG];
+static unsigned long sd_index_bits[TOTAL_SD_DISKS / BITS_PER_LONG];
static spinlock_t sd_index_lock = SPIN_LOCK_UNLOCKED;
static void sd_init_onedisk(struct scsi_disk * sdkp, struct gendisk *disk);
@@ -123,7 +125,10 @@ static int sd_major(int major_idx)
case 1 ... 7:
return SCSI_DISK1_MAJOR + major_idx - 1;
case 8 ... 15:
- return SCSI_DISK8_MAJOR + major_idx;
+ return SCSI_DISK8_MAJOR + major_idx - 8;
+#define MAX_IDX (TOTAL_SD_DISKS >> 4)
+ case 16 ... MAX_IDX:
+ return SCSI_DISK15_MAJOR;
default:
BUG();
return 0; /* shut up gcc */
@@ -1313,8 +1318,8 @@ static int sd_attach(struct scsi_device
goto out_free;
spin_lock(&sd_index_lock);
- index = find_first_zero_bit(sd_index_bits, SD_DISKS);
- if (index == SD_DISKS) {
+ index = find_first_zero_bit(sd_index_bits, TOTAL_SD_DISKS);
+ if (index == TOTAL_SD_DISKS) {
spin_unlock(&sd_index_lock);
error = -EBUSY;
goto out_put;
@@ -1329,15 +1334,25 @@ static int sd_attach(struct scsi_device
gd->de = sdp->de;
gd->major = sd_major(index >> 4);
- gd->first_minor = (index & 15) << 4;
+#define DISKS_PER_MINOR_MASK ((1 << (KDEV_MINOR_BITS - 4)) - 1)
+ if (index > SD_DISKS)
+ gd->first_minor = ((index - SD_DISKS) & DISKS_PER_MINOR_MASK) << 4;
+ else
+ gd->first_minor = (index & 15) << 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);
next reply other threads:[~2003-04-10 20:30 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-10 20:39 Badari Pulavarty [this message]
2003-04-10 20:54 ` [patch for playing] Patch to support 4000 disks and maintain backward compatibility Randy.Dunlap
2003-04-11 0:08 ` Roman Zippel
2003-04-11 1:25 ` Badari Pulavarty
2003-04-11 15:43 ` Joel Becker
2003-04-11 8:04 ` [patch for playing] Patch to support 4000 disks and maintain Giuliano Pochini
2003-04-11 15:44 ` Joel Becker
2003-04-11 16:28 ` Badari Pulavarty
2003-04-11 17:57 ` Joel Becker
2003-04-11 18:12 ` Patrick Mansfield
2003-04-11 18:35 ` Joel Becker
2003-04-11 20:04 ` Patrick Mansfield
2003-04-11 23:18 ` Joel Becker
-- strict thread matches above, loose matches on Subject: below --
2003-04-10 22:09 [patch for playing] Patch to support 4000 disks and maintain backward compatibility Andries.Brouwer
2003-04-10 22:22 ` Badari Pulavarty
2003-04-10 23:57 ` Roman Zippel
2003-04-10 23:09 Andries.Brouwer
2003-04-10 23:16 ` Badari Pulavarty
2003-04-10 23:33 Andries.Brouwer
2003-04-10 23:37 ` Badari Pulavarty
2003-04-10 23:53 Andries.Brouwer
2003-04-11 1:09 ` Badari Pulavarty
2003-04-11 10:09 ` Douglas Gilbert
2003-04-11 16:12 ` Badari Pulavarty
2003-04-11 0:13 Andries.Brouwer
2003-04-11 11:42 Andries.Brouwer
2003-04-11 14:33 ` James Bottomley
2003-04-11 16:21 ` Badari Pulavarty
2003-04-11 18:07 Andries.Brouwer
2003-04-11 19:12 ` James Bottomley
2003-04-11 19:45 Andries.Brouwer
2003-04-11 20:14 ` James Bottomley
2003-04-11 23:21 ` Joel Becker
2003-04-11 21:13 Andries.Brouwer
2003-04-12 1:13 Paul McKenney
2003-04-12 14:14 ` James Bottomley
2003-04-13 13:59 Paul McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200304101339.49895.pbadari@us.ibm.com \
--to=pbadari@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox