From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Lalancette Subject: [PATCH 1/5]: Fix blkfront to accept expanded devices v2 Date: Wed, 25 Jun 2008 16:32:54 +0200 Message-ID: <48625716.2000306@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080109030004040506050105" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------080109030004040506050105 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit This patch implements the new extended allocation scheme on the blkfront end. Note that there is a new xenbus node for the extended stuff, called "virtual-device-ext". On a blkfront_probe(), if nothing is found in "virtual-device", then it will go looking in "virtual-device-ext". This prevents old guest kernels from potentially mis-interpreting data in "virtual-device" (and then subsequently crashing). Changes since v1: - Restructure the changes to remove duplicate code - Add some error checks on the xlvbd_add() path. Note that I did not do full error checking on the existing numbering scheme (i.e. the 202<<8 for xvd, 3<<8 for IDE, 8<<8 for SCSI, etc). The reason I didn't do full checking is that it is perfectly legal to do something like: "xm block-attach pv tap:aio:/disk 0xCB10 w" (which is major 203), which then maps onto the 202 xvd device. It's not particularly nice behavior, in my opinion, but changing it now would change this behavior. So the only check I added was to make sure we weren't above the extended device range (1<<28). Signed-off-by: Chris Lalancette --------------080109030004040506050105 Content-Type: text/x-patch; name="xen-unstable-greater-16-vbd-kernel-blkfront-fixes-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="xen-unstable-greater-16-vbd-kernel-blkfront-fixes-2.patch" diff -r 5201a184f513 drivers/xen/blkfront/blkfront.c --- a/drivers/xen/blkfront/blkfront.c Fri Jun 20 17:43:16 2008 +0100 +++ b/drivers/xen/blkfront/blkfront.c Wed Jun 25 15:34:09 2008 +0200 @@ -92,8 +92,13 @@ static int blkfront_probe(struct xenbus_ err = xenbus_scanf(XBT_NIL, dev->nodename, "virtual-device", "%i", &vdevice); if (err != 1) { - xenbus_dev_fatal(dev, err, "reading virtual-device"); - return err; + /* go looking in the extended area instead */ + err = xenbus_scanf(XBT_NIL, dev->nodename, "virtual-device-ext", + "%i", &vdevice); + if (err != 1) { + xenbus_dev_fatal(dev, err, "reading virtual-device"); + return err; + } } info = kzalloc(sizeof(*info), GFP_KERNEL); diff -r 5201a184f513 drivers/xen/blkfront/vbd.c --- a/drivers/xen/blkfront/vbd.c Fri Jun 20 17:43:16 2008 +0100 +++ b/drivers/xen/blkfront/vbd.c Wed Jun 25 15:34:09 2008 +0200 @@ -43,6 +43,11 @@ #define BLKIF_MAJOR(dev) ((dev)>>8) #define BLKIF_MINOR(dev) ((dev) & 0xff) +#define EXT_SHIFT 28 +#define EXTENDED (1<mi != NULL); BUG_ON(info->rq != NULL); - mi = xlbd_get_major_info(vdevice); + mi = xlbd_get_major_info(major, minor); if (mi == NULL) goto out; + if (VDEV_IS_EXTENDED(vdevice)) + mi->type = &xlbd_vbd_type_ext; info->mi = mi; if ((minor & ((1 << mi->type->partn_shift) - 1)) == 0) @@ -318,15 +325,30 @@ xlvbd_add(blkif_sector_t capacity, int v { struct block_device *bd; int err = 0; + int major, minor; - info->dev = MKDEV(BLKIF_MAJOR(vdevice), BLKIF_MINOR(vdevice)); + if ((vdevice>>EXT_SHIFT) > 1) { + /* this is above the extended range; something is wrong */ + printk(KERN_WARNING "blkfront: vdevice 0x%x is above the extended range; ignoring\n", vdevice); + return -ENODEV; + } + if (!VDEV_IS_EXTENDED(vdevice)) { + major = BLKIF_MAJOR(vdevice); + minor = BLKIF_MINOR(vdevice); + } + else { + major = 202; + minor = BLKIF_MINOR_EXT(vdevice); + } + + info->dev = MKDEV(major, minor); bd = bdget(info->dev); if (bd == NULL) return -ENODEV; - err = xlvbd_alloc_gendisk(BLKIF_MINOR(vdevice), capacity, vdevice, - vdisk_info, sector_size, info); + err = xlvbd_alloc_gendisk(major, minor, capacity, vdevice, vdisk_info, + sector_size, info); bdput(bd); return err; --------------080109030004040506050105 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------080109030004040506050105--