ia64/xen-unstable

changeset 12328:b1a68f065fbd

[BLK] Expand number of fake-SCSI VBD volumes supported to 120.

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>
author kfraser@localhost.localdomain
date Thu Nov 09 12:07:28 2006 +0000 (2006-11-09)
parents eea9247ad5a0
children 0b8f79563bcd
files linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c tools/python/xen/util/blkif.py
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Nov 09 11:47:42 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Nov 09 12:07:28 2006 +0000
     1.3 @@ -50,7 +50,7 @@
     1.4   */
     1.5  
     1.6  #define NUM_IDE_MAJORS 10
     1.7 -#define NUM_SCSI_MAJORS 9
     1.8 +#define NUM_SCSI_MAJORS 17
     1.9  #define NUM_VBD_MAJORS 1
    1.10  
    1.11  static struct xlbd_type_info xlbd_ide_type = {
    1.12 @@ -165,8 +165,11 @@ xlbd_get_major_info(int vdevice)
    1.13  	case SCSI_DISK1_MAJOR ... SCSI_DISK7_MAJOR:
    1.14  		index = 11 + major - SCSI_DISK1_MAJOR;
    1.15  		break;
    1.16 -	case SCSI_CDROM_MAJOR: index = 18; break;
    1.17 -	default: index = 19; break;
    1.18 +        case SCSI_DISK8_MAJOR ... SCSI_DISK15_MAJOR:
    1.19 +                index = 18 + major - SCSI_DISK8_MAJOR;
    1.20 +                break;
    1.21 +        case SCSI_CDROM_MAJOR: index = 26; break;
    1.22 +        default: index = 27; break;
    1.23  	}
    1.24  
    1.25  	mi = ((major_info[index] != NULL) ? major_info[index] :
    1.26 @@ -227,6 +230,7 @@ xlvbd_alloc_gendisk(int minor, blkif_sec
    1.27  	struct xlbd_major_info *mi;
    1.28  	int nr_minors = 1;
    1.29  	int err = -ENODEV;
    1.30 +	unsigned int offset;
    1.31  
    1.32  	BUG_ON(info->gd != NULL);
    1.33  	BUG_ON(info->mi != NULL);
    1.34 @@ -244,15 +248,33 @@ xlvbd_alloc_gendisk(int minor, blkif_sec
    1.35  	if (gd == NULL)
    1.36  		goto out;
    1.37  
    1.38 -	if (nr_minors > 1)
    1.39 -		sprintf(gd->disk_name, "%s%c", mi->type->diskname,
    1.40 -			'a' + mi->index * mi->type->disks_per_major +
    1.41 -			(minor >> mi->type->partn_shift));
    1.42 -	else
    1.43 -		sprintf(gd->disk_name, "%s%c%d", mi->type->diskname,
    1.44 -			'a' + mi->index * mi->type->disks_per_major +
    1.45 -			(minor >> mi->type->partn_shift),
    1.46 -			minor & ((1 << mi->type->partn_shift) - 1));
    1.47 +	offset =  mi->index * mi->type->disks_per_major +
    1.48 +			(minor >> mi->type->partn_shift);
    1.49 +	if (nr_minors > 1) {
    1.50 +		if (offset < 26) {
    1.51 +			sprintf(gd->disk_name, "%s%c",
    1.52 +				 mi->type->diskname, 'a' + offset );
    1.53 +		}
    1.54 +		else {
    1.55 +			sprintf(gd->disk_name, "%s%c%c",
    1.56 +				mi->type->diskname,
    1.57 +				'a' + ((offset/26)-1), 'a' + (offset%26) );
    1.58 +		}
    1.59 +	}
    1.60 +	else {
    1.61 +		if (offset < 26) {
    1.62 +			sprintf(gd->disk_name, "%s%c%d",
    1.63 +				mi->type->diskname,
    1.64 +				'a' + offset,
    1.65 +				minor & ((1 << mi->type->partn_shift) - 1));
    1.66 +		}
    1.67 +		else {
    1.68 +			sprintf(gd->disk_name, "%s%c%c%d",
    1.69 +				mi->type->diskname,
    1.70 +				'a' + ((offset/26)-1), 'a' + (offset%26),
    1.71 +				minor & ((1 << mi->type->partn_shift) - 1));
    1.72 +		}
    1.73 +	}
    1.74  
    1.75  	gd->major = mi->major;
    1.76  	gd->first_minor = minor;
     2.1 --- a/tools/python/xen/util/blkif.py	Thu Nov 09 11:47:42 2006 +0000
     2.2 +++ b/tools/python/xen/util/blkif.py	Thu Nov 09 12:07:28 2006 +0000
     2.3 @@ -23,8 +23,15 @@ def blkdev_name_to_number(name):
     2.4      except Exception, ex:
     2.5          pass
     2.6  
     2.7 -    if re.match( '/dev/sd[a-p]([1-9]|1[0-5])?', n):
     2.8 -        return 8 * 256 + 16 * (ord(n[7:8]) - ord('a')) + int(n[8:] or 0)
     2.9 +    scsi_major = [ 8, 65, 66, 67, 68, 69, 70, 71, 128, 129, 130, 131, 132, 133, 134, 135 ]
    2.10 +    if re.match( '/dev/sd[a-z]([1-9]|1[0-5])?$', n):
    2.11 +        major = scsi_major[(ord(n[7:8]) - ord('a')) / 16]
    2.12 +        minor = ((ord(n[7:8]) - ord('a')) % 16) * 16 + int(n[8:] or 0)
    2.13 +        return major * 256 + minor
    2.14 +    if re.match( '/dev/sd[a-i][a-z]([1-9]|1[0-5])?$', n):
    2.15 +        major = scsi_major[((ord(n[7:8]) - ord('a') + 1) * 26 + (ord(n[8:9]) - ord('a'))) / 16 ]
    2.16 +        minor = (((ord(n[7:8]) - ord('a') + 1 ) * 26 + (ord(n[8:9]) - ord('a'))) % 16) * 16 + int(n[9:] or 0)
    2.17 +        return major * 256 + minor
    2.18  
    2.19      if re.match( '/dev/hd[a-t]([1-9]|[1-5][0-9]|6[0-3])?', n):
    2.20          ide_majors = [ 3, 22, 33, 34, 56, 57, 88, 89, 90, 91 ]