Skip to contentSkip to conversation

Support for official xvd major number

PATCH In review Jeremy Katz 3 participants 5 messages Jul 14, 2005 – Jul 15, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support for official xvd major number

LANANA has officially assigned the block major of 202 for xvd devices
(http://www.lanana.org/docs/device-list/devices-2.6+.txt). Take advantage of knowing this so people don't have to do the mknod on their system. Also, fix up the scsi regex to get sda correct without having to do hacks like sda0.

Jeremy

# HG changeset patch
# User [email protected]
# Node ID 974ff5b2329a6e544202b1d6806455abbd8243b8 # Parent b5bf769f2c228a9a00b88b8e62719f58eb58726e
* support proper scsi disk name
* xvd now has an official lanana assigned major, use it

tools/python/xen/util/blkif.py +5 -2
diff -r b5bf769f2c22 -r 974ff5b2329a tools/python/xen/util/blkif.py
@@ -24,14 +24,17 @@
         log.debug("exception looking up device number for %s: %s", name, ex)
         pass
 
-    if re.match( '/dev/sd[a-p]([0-9]|1[0-5])', n):
-        return 8 * 256 + 16 * (ord(n[7:8]) - ord('a')) + int(n[8:])
+    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)
 
     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 ]
         major = ide_majors[(ord(n[7:8]) - ord('a')) / 2]
         minor = ((ord(n[7:8]) - ord('a')) % 2) * 64 + int(n[8:] or 0)
         return major * 256 + minor
+
+    if re.match( '/dev/xvd[a-p]([1-9]|1[0-5])?', n):
+        return 202 * 256 + 16 * (ord(n[8:9]) - ord('a')) + int(n[9:] or 0)
 
     # see if this is a hex device number
     if re.match( '^(0x)?[0-9a-fA-F]+$', name ):

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Jeremy Katz

LANANA has officially assigned the block major of 202 for xvd devices
(http://www.lanana.org/docs/device-list/devices-2.6+.txt). Take advantage of knowing this so people don't have to do the mknod on their system. Also, fix up the scsi regex to get sda correct without having to do hacks like sda0.

Also, on a side note that is really unrelated to the patch, is there really a good reason why these hoops are still gone through instead of having the kernel allocate the next disk instead of the hard-coding with things somewhat out of order and stealing the major/minors of other subsystems?

Jeremy

#2 lore raw
Quoted 5 lines · Jeremy Katz

Also, on a side note that is really unrelated to the patch, is there really a good reason why these hoops are still gone through instead of having the kernel allocate the next disk instead of the hard-coding with things somewhat out of order and stealing the major/minors of other subsystems?

I'm not sure what you mean? Specifying device numbers up front in a config file means that you know e.g., what device names to put in your fstab and what to specify as your rootfs device. And stealing scsi/ide device names/numbers is the strategy of least surprise to userspace tools and scripts (e.g., some vendor init scripts have a baby if filesystems are mounted on a weirdly-named block device like xvd<foo>). And the xvd* names and numbers are there if you want to avoid clashes with other subsystems.

-- Keir

#3 lore raw
Quoted 11 lines · Keir Fraser
Quoted 6 lines · Jeremy Katz

Also, on a side note that is really unrelated to the patch, is there really a good reason why these hoops are still gone through instead of having the kernel allocate the next disk instead of the hard-coding with
things somewhat out of order and stealing the major/minors of other subsystems?

I'm not sure what you mean? Specifying device numbers up front in a config file means that you know e.g., what device names to put in your fstab and what to specify as your rootfs device.

Your first disk should get registered first and be xvda, your second xvdb, etc. If you're afraid of the order changing, you should be using label or uuid to mount. The same questions come up with physical devices.

Quoted 4 lines

And stealing scsi/ide
device names/numbers is the strategy of least surprise to userspace tools and scripts (e.g., some vendor init scripts have a baby if filesystems are mounted on a weirdly-named block device like xvd<foo>).

Those scripts are broken and are going to break with a fair bit of other hardware too. There are more of these "weird" block devices being added and not less. And as it stands now, if something sees "scsi disk" and then tries to do any checks with /proc/scsi, they're going to fail. So there are common things that get broken with both.

Jeremy

#4 lore raw

Hi,

Quoted 9 lines · Rumor has it that on Thu, Jul 14, 2005 at 05:57:58PM -0400 Jeremy Katz said:
Quoted 8 lines · Keir Fraser
Quoted 6 lines · Jeremy Katz

Also, on a side note that is really unrelated to the patch, is there really a good reason why these hoops are still gone through instead of having the kernel allocate the next disk instead of the hard-coding with
things somewhat out of order and stealing the major/minors of other subsystems?

Quoted 8 lines
Quoted 3 lines

I'm not sure what you mean? Specifying device numbers up front in a config file means that you know e.g., what device names to put in your fstab and what to specify as your rootfs device.

Your first disk should get registered first and be xvda, your second xvdb, etc. If you're afraid of the order changing, you should be using label or uuid to mount. The same questions come up with physical devices.

In a virtualized world where your block device can be moved from system to system in software using labels is unwise. When your disk is internal it's not really a problem, but when you move disks around easily the labels get in the way. Duplicate "/" will keep your system from booting. The label thing is basically a hack to get around the brain dead device naming in linux. The hda/hdb/hdc thing only makes sense for internal IDE disks and even then you have issues now that sata shows up the same way. It's too bad the original linux scsi implementation followed this model.

There's no reason to enforce that first-in ordering for xvd devices that I can see. Specify where you want the device to show up and then access it there.

Physical devices do have the same issues, but those are really solved by using udev (and helpers like scsi_id) not fs labels and uuids. Besides, labels are only useful if you have a filesystem on that block device. Not all block devices have file systems...

Cheers,

Phil

Signature · 3 lines
Philip R. Auld, Ph.D.  	        	       Egenera, Inc.    
Software Architect                            165 Forest St.
(508) 858-2628                            Marlboro, MA 01752