[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Blkfront cleanups and fix whole-device mapping.



ChangeSet 1.1159.258.141, 2005/05/20 14:32:19+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Blkfront cleanups and fix whole-device mapping.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 blkfront.c |   10 -
 block.h    |    8 
 vbd.c      |  607 ++++++++++++++++++++++++++++++-------------------------------
 3 files changed, 316 insertions(+), 309 deletions(-)


diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   2005-05-20 
10:03:06 -04:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   2005-05-20 
10:03:06 -04:00
@@ -60,8 +60,6 @@
 #define BLKIF_STATE_DISCONNECTED 1
 #define BLKIF_STATE_CONNECTED    2
 
-#define WPRINTK(fmt, args...) printk(KERN_WARNING "xen_blk: " fmt, ##args)
-
 static int blkif_handle = 0;
 static unsigned int blkif_state = BLKIF_STATE_CLOSED;
 static unsigned int blkif_evtchn = 0;
@@ -694,7 +692,7 @@
         return -ENOSYS;
 
     default:
-        printk(KERN_ALERT "ioctl %08x not supported by XL blkif\n", command);
+        WPRINTK("ioctl %08x not supported by XL blkif\n", command);
         return -ENOSYS;
     }
     
@@ -1206,7 +1204,7 @@
     err = request_irq(blkif_irq, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
     if ( err )
     {
-        printk(KERN_ALERT "xen_blk: request_irq failed (err=%d)\n", err);
+        WPRINTK("request_irq failed (err=%d)\n", err);
         return;
     }
 
@@ -1353,7 +1351,7 @@
 
     if ( blkif_state != BLKIF_STATE_CONNECTED )
     {
-        printk(KERN_INFO "xen_blk: Timeout connecting to device!\n");
+        WPRINTK("Timeout connecting to device!\n");
         err = -ENOSYS;
     }
     return err;
@@ -1367,7 +1365,7 @@
          (xen_start_info.flags & SIF_BLK_BE_DOMAIN) )
         return 0;
 
-    printk(KERN_INFO "xen_blk: Initialising virtual block device driver\n");
+    IPRINTK("Initialising virtual block device driver\n");
 
     rec_ring_free = 0;
     for ( i = 0; i < BLKIF_RING_SIZE; i++ )
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/block.h 
b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/block.h
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/block.h      2005-05-20 
10:03:06 -04:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/block.h      2005-05-20 
10:03:06 -04:00
@@ -50,6 +50,11 @@
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 
+#define IPRINTK(fmt, args...) \
+    printk(KERN_INFO "xen_blk: " fmt, ##args)
+#define WPRINTK(fmt, args...) \
+    printk(KERN_WARNING "xen_blk: " fmt, ##args)
+
 #if 0
 #define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
 #else
@@ -64,8 +69,7 @@
 
 struct xlbd_type_info {
     int partn_shift;
-    int partn_per_major;
-    int devs_per_major;
+    int disks_per_major;
     char *devname;
     char *diskname;
 };
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c        2005-05-20 
10:03:06 -04:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c        2005-05-20 
10:03:06 -04:00
@@ -31,6 +31,7 @@
 
 #include "block.h"
 #include <linux/blkdev.h>
+#include <linux/list.h>
 
 /*
  * For convenience we distinguish between ide, scsi and 'other' (i.e.,
@@ -42,23 +43,31 @@
 #define NUM_SCSI_MAJORS 9
 #define NUM_VBD_MAJORS 1
 
+struct lvdisk
+{
+    blkif_sector_t capacity; /*  0: Size in terms of 512-byte sectors.   */
+    blkif_vdev_t   device;   /*  8: Device number (opaque 16 bit value). */
+    u16            info; 
+    struct list_head list;
+};
+
 static struct xlbd_type_info xlbd_ide_type = {
     .partn_shift = 6,
-    .partn_per_major = 2,
+    .disks_per_major = 2,
     .devname = "ide",
     .diskname = "hd",
 };
 
 static struct xlbd_type_info xlbd_scsi_type = {
     .partn_shift = 4,
-    .partn_per_major = 16,
+    .disks_per_major = 16,
     .devname = "sd",
     .diskname = "sd",
 };
 
 static struct xlbd_type_info xlbd_vbd_type = {
     .partn_shift = 4,
-    .partn_per_major = 16,
+    .disks_per_major = 16,
     .devname = "xvd",
     .diskname = "xvd",
 };
@@ -66,10 +75,17 @@
 static struct xlbd_major_info *major_info[NUM_IDE_MAJORS + NUM_SCSI_MAJORS +
                                          NUM_VBD_MAJORS];
 
+#define XLBD_MAJOR_IDE_START    0
+#define XLBD_MAJOR_SCSI_START   (NUM_IDE_MAJORS)
+#define XLBD_MAJOR_VBD_START    (NUM_IDE_MAJORS + NUM_SCSI_MAJORS)
+
+#define XLBD_MAJOR_IDE_RANGE    XLBD_MAJOR_IDE_START ... XLBD_MAJOR_SCSI_START 
- 1
+#define XLBD_MAJOR_SCSI_RANGE   XLBD_MAJOR_SCSI_START ... XLBD_MAJOR_VBD_START 
- 1
+#define XLBD_MAJOR_VBD_RANGE    XLBD_MAJOR_VBD_START ... XLBD_MAJOR_VBD_START 
+ NUM_VBD_MAJORS - 1
+
 /* Information about our VBDs. */
 #define MAX_VBDS 64
-static int nr_vbds;
-static vdisk_t *vbd_info;
+struct list_head vbds_list;
 
 struct request_queue *xlbd_blk_queue = NULL;
 
@@ -82,388 +98,381 @@
     .open  = blkif_open,
     .release = blkif_release,
     .ioctl  = blkif_ioctl,
-#if 0
-    check_media_change: blkif_check,
-    revalidate:         blkif_revalidate,
-#endif
 };
 
 spinlock_t blkif_io_lock = SPIN_LOCK_UNLOCKED;
 
-static int xlvbd_get_vbd_info(vdisk_t *disk_info)
+static struct lvdisk *xlvbd_device_alloc(void)
+{
+    struct lvdisk *disk;
+
+    disk = kmalloc(sizeof(*disk), GFP_KERNEL);
+    if (disk != NULL) {
+        memset(disk, 0, sizeof(*disk));
+        INIT_LIST_HEAD(&disk->list);
+    }
+    return disk;
+}
+
+static void xlvbd_device_free(struct lvdisk *disk)
+{
+    list_del(&disk->list);
+    kfree(disk);
+}
+
+static vdisk_t *xlvbd_probe(int *ret)
 {
-    vdisk_t         *buf = (vdisk_t *)__get_free_page(GFP_KERNEL);
-    blkif_request_t  req;
     blkif_response_t rsp;
-    int              nr;
+    blkif_request_t req;
+    vdisk_t *disk_info = NULL;
+    unsigned long buf;
+    int nr;
+
+    buf = __get_free_page(GFP_KERNEL);
+    if ((void *)buf == NULL)
+        goto out;
 
     memset(&req, 0, sizeof(req));
-    req.operation   = BLKIF_OP_PROBE;
+    req.operation = BLKIF_OP_PROBE;
     req.nr_segments = 1;
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+    blkif_control_probe_send(&req, &rsp,
+                             (unsigned long)(virt_to_machine(buf)));
+#else
     req.frame_and_sects[0] = virt_to_machine(buf) | 7;
 
     blkif_control_send(&req, &rsp);
-
-    if ( rsp.status <= 0 )
-    {
-        printk(KERN_ALERT "Could not probe disks (%d)\n", rsp.status);
-        return -1;
+#endif
+    if ( rsp.status <= 0 ) {
+        WPRINTK("Could not probe disks (%d)\n", rsp.status);
+        goto out;
     }
-
-    if ( (nr = rsp.status) > MAX_VBDS )
+    nr = rsp.status;
+    if ( nr > MAX_VBDS )
         nr = MAX_VBDS;
-    memcpy(disk_info, buf, nr * sizeof(vdisk_t));
 
-    free_page((unsigned long)buf);
+    disk_info = kmalloc(nr * sizeof(vdisk_t), GFP_KERNEL);
+    if (disk_info != NULL)
+        memcpy(disk_info, (void *) buf, nr * sizeof(vdisk_t));
 
-    return nr;
+    if (ret != NULL)
+        *ret = nr;
+
+out:
+    free_page(buf);
+    return disk_info;
 }
 
-static struct xlbd_major_info *xlbd_get_major_info(int xd_device, int *minor)
+static struct xlbd_major_info *xlbd_alloc_major_info(
+    int major, int minor, int index)
 {
-    int mi_idx, new_major;
-    int xd_major = MAJOR_XEN(xd_device); 
-    int xd_minor = MINOR_XEN(xd_device);
+    struct xlbd_major_info *ptr;
 
-    *minor = xd_minor;
+    ptr = kmalloc(sizeof(struct xlbd_major_info), GFP_KERNEL);
+    if (ptr == NULL)
+        return NULL;
 
-    switch (xd_major) {
-    case IDE0_MAJOR: mi_idx = 0; new_major = IDE0_MAJOR; break;
-    case IDE1_MAJOR: mi_idx = 1; new_major = IDE1_MAJOR; break;
-    case IDE2_MAJOR: mi_idx = 2; new_major = IDE2_MAJOR; break;
-    case IDE3_MAJOR: mi_idx = 3; new_major = IDE3_MAJOR; break;
-    case IDE4_MAJOR: mi_idx = 4; new_major = IDE4_MAJOR; break;
-    case IDE5_MAJOR: mi_idx = 5; new_major = IDE5_MAJOR; break;
-    case IDE6_MAJOR: mi_idx = 6; new_major = IDE6_MAJOR; break;
-    case IDE7_MAJOR: mi_idx = 7; new_major = IDE7_MAJOR; break;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.