[BLK] Expand number of fake-SCSI VBD volumes supported to 120.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 9 Nov 2006 12:07:28 +0000 (12:07 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 9 Nov 2006 12:07:28 +0000 (12:07 +0000)
Signed-off-by: Takanori Kasai <Kasai.Takanori@jp.fujitsu.com>
Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
tools/python/xen/util/blkif.py

index 0c8b508c9a8182a55f6c069d193aeb1d470134d2..bbb16a956e7cd4ac21638ca07c6ea7bd440c7aef 100644 (file)
@@ -50,7 +50,7 @@
  */
 
 #define NUM_IDE_MAJORS 10
-#define NUM_SCSI_MAJORS 9
+#define NUM_SCSI_MAJORS 17
 #define NUM_VBD_MAJORS 1
 
 static struct xlbd_type_info xlbd_ide_type = {
@@ -165,8 +165,11 @@ xlbd_get_major_info(int vdevice)
        case SCSI_DISK1_MAJOR ... SCSI_DISK7_MAJOR:
                index = 11 + major - SCSI_DISK1_MAJOR;
                break;
-       case SCSI_CDROM_MAJOR: index = 18; break;
-       default: index = 19; break;
+        case SCSI_DISK8_MAJOR ... SCSI_DISK15_MAJOR:
+                index = 18 + major - SCSI_DISK8_MAJOR;
+                break;
+        case SCSI_CDROM_MAJOR: index = 26; break;
+        default: index = 27; break;
        }
 
        mi = ((major_info[index] != NULL) ? major_info[index] :
@@ -227,6 +230,7 @@ xlvbd_alloc_gendisk(int minor, blkif_sector_t capacity, int vdevice,
        struct xlbd_major_info *mi;
        int nr_minors = 1;
        int err = -ENODEV;
+       unsigned int offset;
 
        BUG_ON(info->gd != NULL);
        BUG_ON(info->mi != NULL);
@@ -244,15 +248,33 @@ xlvbd_alloc_gendisk(int minor, blkif_sector_t capacity, int vdevice,
        if (gd == NULL)
                goto out;
 
-       if (nr_minors > 1)
-               sprintf(gd->disk_name, "%s%c", mi->type->diskname,
-                       'a' + mi->index * mi->type->disks_per_major +
-                       (minor >> mi->type->partn_shift));
-       else
-               sprintf(gd->disk_name, "%s%c%d", mi->type->diskname,
-                       'a' + mi->index * mi->type->disks_per_major +
-                       (minor >> mi->type->partn_shift),
-                       minor & ((1 << mi->type->partn_shift) - 1));
+       offset =  mi->index * mi->type->disks_per_major +
+                       (minor >> mi->type->partn_shift);
+       if (nr_minors > 1) {
+               if (offset < 26) {
+                       sprintf(gd->disk_name, "%s%c",
+                                mi->type->diskname, 'a' + offset );
+               }
+               else {
+                       sprintf(gd->disk_name, "%s%c%c",
+                               mi->type->diskname,
+                               'a' + ((offset/26)-1), 'a' + (offset%26) );
+               }
+       }
+       else {
+               if (offset < 26) {
+                       sprintf(gd->disk_name, "%s%c%d",
+                               mi->type->diskname,
+                               'a' + offset,
+                               minor & ((1 << mi->type->partn_shift) - 1));
+               }
+               else {
+                       sprintf(gd->disk_name, "%s%c%c%d",
+                               mi->type->diskname,
+                               'a' + ((offset/26)-1), 'a' + (offset%26),
+                               minor & ((1 << mi->type->partn_shift) - 1));
+               }
+       }
 
        gd->major = mi->major;
        gd->first_minor = minor;
index 859361970c0badf4990ee0a5046ce8d814b3c20f..363bd41dd2120f1d514acb844395a96be3cef195 100644 (file)
@@ -23,8 +23,15 @@ def blkdev_name_to_number(name):
     except Exception, ex:
         pass
 
-    if re.match( '/dev/sd[a-p]([1-9]|1[0-5])?', n):
-        return 8 * 256 + 16 * (ord(n[7:8]) - ord('a')) + int(n[8:] or 0)
+    scsi_major = [ 8, 65, 66, 67, 68, 69, 70, 71, 128, 129, 130, 131, 132, 133, 134, 135 ]
+    if re.match( '/dev/sd[a-z]([1-9]|1[0-5])?$', n):
+        major = scsi_major[(ord(n[7:8]) - ord('a')) / 16]
+        minor = ((ord(n[7:8]) - ord('a')) % 16) * 16 + int(n[8:] or 0)
+        return major * 256 + minor
+    if re.match( '/dev/sd[a-i][a-z]([1-9]|1[0-5])?$', n):
+        major = scsi_major[((ord(n[7:8]) - ord('a') + 1) * 26 + (ord(n[8:9]) - ord('a'))) / 16 ]
+        minor = (((ord(n[7:8]) - ord('a') + 1 ) * 26 + (ord(n[8:9]) - ord('a'))) % 16) * 16 + int(n[9:] or 0)
+        return major * 256 + minor
 
     if re.match( '/dev/hd[a-t]([1-9]|[1-5][0-9]|6[0-3])?', n):
         ide_majors = [ 3, 22, 33, 34, 56, 57, 88, 89, 90, 91 ]