Skip to contentSkip to conversation

remove arbitrary SD_MAX_DISKS namespace limit

PATCH Superseded Dave Kleikamp 2 participants 4 messages Oct 3, 2011 – Oct 19, 2011 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove arbitrary SD_MAX_DISKS namespace limit

I see no reason to limit the SCSI disk namespace to sdXXX. We test systems with more than 18278 LUNs.

drivers/scsi/sd.c +0 -6
index 953773c..741c7f7 100644
@@ -2592,12 +2592,6 @@ static int sd_probe(struct device *dev)
 	if (error)
 		goto out_put;
 
-	if (index >= SD_MAX_DISKS) {
-		error = -ENODEV;
-		sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name space exhausted.\n");
-		goto out_free_index;
-	}
-
 	error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN);
 	if (error)
 		goto out_free_index;
drivers/scsi/sd.h +0 -6
index 6ad798b..4163f29 100644
@@ -9,12 +9,6 @@
 #define SD_MAJORS	16
 
 /*
- * This is limited by the naming scheme enforced in sd_probe,
- * add another character to it if you really need more disks.
- */
-#define SD_MAX_DISKS	(((26 * 26) + 26 + 1) * 26)
-
-/*
  * Time out in seconds for disks and Magneto-opticals (which are slower).
  */
 #define SD_TIMEOUT		(30 * HZ)
maintainer
#1 lore raw
Quoted 2 lines · Dave Kleikamp

I see no reason to limit the SCSI disk namespace to sdXXX. We test systems with more than 18278 LUNs.

I suppose we kept the old limit for historical reasons, so I've no real objection to raising it, except the error messages now need to be beefed up. We need one for the ida_get_new() failure and the original exhaustion messages needs to move to the sd_format_disk_name() check ... that's now what checks we don't go over the possible size in DISK_NAME_LEN (I know at 32 it's way beyond INT_MAX ... but just in case someone decides to lower it) ... probably it's the same error message (but better make it unique for the static checkers).

James

#2 lore raw
Quoted 4 lines · James Bottomley
Quoted 2 lines · Dave Kleikamp

I see no reason to limit the SCSI disk namespace to sdXXX. We test systems with more than 18278 LUNs.

Quoted 8 lines

I suppose we kept the old limit for historical reasons, so I've no real objection to raising it, except the error messages now need to be beefed up. We need one for the ida_get_new() failure and the original exhaustion messages needs to move to the sd_format_disk_name() check ... that's now what checks we don't go over the possible size in DISK_NAME_LEN (I know at 32 it's way beyond INT_MAX ... but just in case someone decides to lower it) ... probably it's the same error message (but better make it unique for the static checkers).

I'll defer to your judgment on how to fix this. I didn't look at your git tree, just mainline. Just bumping up SD_MAX_DISKS is sufficient. Wrapping the calculation in another (( ...) + 1) * 26 should get us through another decade, I would think. :-) Or any reasonably high number. INT_MAX?

Thanks,
Shaggy

#3 lore raw

PATCH v2 1/1 remove arbitrary SD_MAX_DISKS namespace limit

In reply to James Bottomley
Quoted 4 lines · James Bottomley
Quoted 2 lines · Dave Kleikamp

I see no reason to limit the SCSI disk namespace to sdXXX. We test systems with more than 18278 LUNs.

Quoted 8 lines

I suppose we kept the old limit for historical reasons, so I've no real objection to raising it, except the error messages now need to be beefed up. We need one for the ida_get_new() failure and the original exhaustion messages needs to move to the sd_format_disk_name() check ... that's now what checks we don't go over the possible size in DISK_NAME_LEN (I know at 32 it's way beyond INT_MAX ... but just in case someone decides to lower it) ... probably it's the same error message (but better make it unique for the static checkers).

There is no reason to limit the SCSI disk namespace to sdXXX.

Add new error messages to sd_probe() in the unlikely event that either ida_get_new() or sd_format_disk_name() fail.

drivers/scsi/sd.c +5 -7
index 953773c..55424c8 100644
@@ -2589,18 +2589,16 @@ static int sd_probe(struct device *dev)
 		spin_unlock(&sd_index_lock);
 	} while (error == -EAGAIN);
 
-	if (error)
+	if (error) {
+		sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n");
 		goto out_put;
-
-	if (index >= SD_MAX_DISKS) {
-		error = -ENODEV;
-		sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name space exhausted.\n");
-		goto out_free_index;
 	}
 
 	error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN);
-	if (error)
+	if (error) {
+		sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name length exceeded.\n");
 		goto out_free_index;
+	}
 
 	sdkp->device = sdp;
 	sdkp->driver = &sd_template;
drivers/scsi/sd.h +0 -6
index 6ad798b..4163f29 100644
@@ -9,12 +9,6 @@
 #define SD_MAJORS	16
 
 /*
- * This is limited by the naming scheme enforced in sd_probe,
- * add another character to it if you really need more disks.
- */
-#define SD_MAX_DISKS	(((26 * 26) + 26 + 1) * 26)
-
-/*
  * Time out in seconds for disks and Magneto-opticals (which are slower).
  */
 #define SD_TIMEOUT		(30 * HZ)