ia64/xen-unstable

changeset 272:61f8bbaac0a6

bitkeeper revision 1.118 (3e6c9011AqlyQcEHaXEFaZYbfVfgPQ)

Many files:
Fixed Xen blkdev probing to return device numbers.
author kaf24@labyrinth.cl.cam.ac.uk
date Mon Mar 10 13:16:01 2003 +0000 (2003-03-10)
parents 0bd810c3a05e
children 666728c2dad4
files xen/drivers/block/xen_block.c xen/drivers/block/xen_segment.c xen/drivers/ide/ide-xeno.c xen/drivers/scsi/sd.c xen/include/hypervisor-ifs/block.h xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_scsi.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment.c
line diff
     1.1 --- a/xen/drivers/block/xen_block.c	Mon Mar 10 00:04:52 2003 +0000
     1.2 +++ b/xen/drivers/block/xen_block.c	Mon Mar 10 13:16:01 2003 +0000
     1.3 @@ -482,7 +482,8 @@ static void dispatch_probe_blk(struct ta
     1.4  
     1.5  static void dispatch_probe_seg(struct task_struct *p, int index)
     1.6  {
     1.7 -    extern void xen_segment_probe(xen_disk_info_t *xdi);
     1.8 +    extern void xen_segment_probe(struct task_struct *, xen_disk_info_t *);
     1.9 +
    1.10      blk_ring_t *blk_ring = p->blk_ring_base;
    1.11      xen_disk_info_t *xdi;
    1.12      unsigned long flags, buffer;
    1.13 @@ -502,7 +503,7 @@ static void dispatch_probe_seg(struct ta
    1.14      spin_unlock_irqrestore(&p->page_lock, flags);
    1.15  
    1.16      xdi = phys_to_virt(buffer);
    1.17 -    xen_segment_probe(xdi);
    1.18 +    xen_segment_probe(p, xdi);
    1.19  
    1.20      unlock_buffer(p, buffer, sizeof(xen_disk_info_t), 1);
    1.21  
     2.1 --- a/xen/drivers/block/xen_segment.c	Mon Mar 10 00:04:52 2003 +0000
     2.2 +++ b/xen/drivers/block/xen_segment.c	Mon Mar 10 13:16:01 2003 +0000
     2.3 @@ -97,27 +97,28 @@ int xen_segment_map_request(
     2.4   *
     2.5   * return a list of segments to the guestos
     2.6   */
     2.7 -void xen_segment_probe (xen_disk_info_t *raw_xdi, int *count)
     2.8 +void xen_segment_probe(struct task_struct *p, xen_disk_info_t *raw_xdi)
     2.9  {
    2.10      int loop, i;
    2.11      xen_disk_info_t *xdi = map_domain_mem(virt_to_phys(raw_xdi));
    2.12  
    2.13 -    for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++ )
    2.14 +    for ( loop = 0; loop < XEN_MAX_SEGMENTS; loop++ )
    2.15      {
    2.16 -        if (xsegments[loop].mode != XEN_SEGMENT_UNUSED)
    2.17 +        if ( (xsegments[loop].mode == XEN_SEGMENT_UNUSED) ||
    2.18 +             (xsegments[loop].domain != p->domain) )
    2.19 +            continue;
    2.20 +
    2.21 +        xdi->disks[xdi->count].device = 
    2.22 +            MK_VIRTUAL_XENDEV(xsegments[loop].segment_number);
    2.23 +        for ( i = 0; i < xsegments[loop].num_extents; i++ )
    2.24          {
    2.25 -            xdi->disks[xdi->count].type = XEN_DISK_VIRTUAL;
    2.26 -            for (i = 0; i < xsegments[loop].num_extents; i++)
    2.27 -            {
    2.28 -                xdi->disks[xdi->count].capacity += 
    2.29 -                    xsegments[loop].extents[i].size;
    2.30 -            }
    2.31 -            xdi->count++;
    2.32 +            xdi->disks[xdi->count].capacity += 
    2.33 +                xsegments[loop].extents[i].size;
    2.34          }
    2.35 +        xdi->count++;
    2.36      }
    2.37  
    2.38      unmap_domain_mem(xdi);
    2.39 -    return;
    2.40  }
    2.41  
    2.42  /*
    2.43 @@ -132,14 +133,13 @@ void xen_refresh_segment_list (struct ta
    2.44  
    2.45      for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++)
    2.46      {
    2.47 -        if (xsegments[loop].mode != XEN_SEGMENT_UNUSED &&
    2.48 -            xsegments[loop].domain == p->domain)
    2.49 -        {
    2.50 -            p->segment_list[xsegments[loop].segment_number] = &xsegments[loop];
    2.51 -            p->segment_count++;
    2.52 -        }
    2.53 +        if ( (xsegments[loop].mode == XEN_SEGMENT_UNUSED) ||
    2.54 +             (xsegments[loop].domain != p->domain) )
    2.55 +            continue;
    2.56 +
    2.57 +        p->segment_list[xsegments[loop].segment_number] = &xsegments[loop];
    2.58 +        p->segment_count++;
    2.59      }
    2.60 -    return;
    2.61  }
    2.62  
    2.63  /*
     3.1 --- a/xen/drivers/ide/ide-xeno.c	Mon Mar 10 00:04:52 2003 +0000
     3.2 +++ b/xen/drivers/ide/ide-xeno.c	Mon Mar 10 13:16:01 2003 +0000
     3.3 @@ -26,7 +26,8 @@ void ide_probe_devices(xen_disk_info_t* 
     3.4              if ( !drive->present ) continue;
     3.5              
     3.6              capacity = current_capacity(drive);
     3.7 -            xen_xdi->disks[xen_xdi->count].type = XEN_DISK_IDE;
     3.8 +            xen_xdi->disks[xen_xdi->count].device =
     3.9 +                MK_IDE_XENDEV((loop * MAX_DRIVES) + unit);
    3.10              xen_xdi->disks[xen_xdi->count].capacity = capacity;
    3.11              xen_xdi->count++;
    3.12  
     4.1 --- a/xen/drivers/scsi/sd.c	Mon Mar 10 00:04:52 2003 +0000
     4.2 +++ b/xen/drivers/scsi/sd.c	Mon Mar 10 13:16:01 2003 +0000
     4.3 @@ -1325,7 +1325,7 @@ void scsi_probe_devices(xen_disk_info_t 
     4.4      {
     4.5          if ( sd->device == NULL ) continue;
     4.6  
     4.7 -        xen_xdi->disks[xen_xdi->count].type = XEN_DISK_SCSI; 
     4.8 +        xen_xdi->disks[xen_xdi->count].device   = MK_SCSI_XENDEV(i);
     4.9          xen_xdi->disks[xen_xdi->count].capacity = sd->capacity; 
    4.10          xen_xdi->count++; 
    4.11                  
     5.1 --- a/xen/include/hypervisor-ifs/block.h	Mon Mar 10 00:04:52 2003 +0000
     5.2 +++ b/xen/include/hypervisor-ifs/block.h	Mon Mar 10 13:16:01 2003 +0000
     5.3 @@ -21,6 +21,10 @@
     5.4  #define XENDEV_SCSI           (2 << XENDEV_TYPE_SHIFT)
     5.5  #define XENDEV_VIRTUAL        (3 << XENDEV_TYPE_SHIFT)
     5.6  
     5.7 +#define IS_IDE_XENDEV(_d)     (((_d) & XENDEV_TYPE_MASK) == XENDEV_IDE)
     5.8 +#define IS_SCSI_XENDEV(_d)    (((_d) & XENDEV_TYPE_MASK) == XENDEV_SCSI)
     5.9 +#define IS_VIRTUAL_XENDEV(_d) (((_d) & XENDEV_TYPE_MASK) == XENDEV_VIRTUAL)
    5.10 +
    5.11  #define MK_IDE_XENDEV(_i)     ((_i) | XENDEV_IDE)
    5.12  #define MK_SCSI_XENDEV(_i)    ((_i) | XENDEV_SCSI)
    5.13  #define MK_VIRTUAL_XENDEV(_i) ((_i) | XENDEV_VIRTUAL)
    5.14 @@ -90,19 +94,15 @@ typedef struct blk_ring_st
    5.15  
    5.16  #define XEN_MAX_DISK_COUNT 100
    5.17  
    5.18 -#define XEN_DISK_IDE  1
    5.19 -#define XEN_DISK_SCSI 2
    5.20 -#define XEN_DISK_VIRTUAL 3                                            /* vhd */
    5.21 -
    5.22 -typedef struct xen_disk                                     /* physical disk */
    5.23 +typedef struct xen_disk
    5.24  {
    5.25 -  int           type;                                           /* disk type */
    5.26 -  unsigned long capacity;
    5.27 +    unsigned short device;
    5.28 +    unsigned long  capacity;
    5.29  } xen_disk_t;
    5.30  
    5.31  typedef struct xen_disk_info
    5.32  {
    5.33 -  int         count;            /* number of xen_disk_t structures to follow */
    5.34 +  int         count;
    5.35    xen_disk_t  disks[XEN_MAX_DISK_COUNT];
    5.36  } xen_disk_info_t;
    5.37  
     6.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c	Mon Mar 10 00:04:52 2003 +0000
     6.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c	Mon Mar 10 13:16:01 2003 +0000
     6.3 @@ -73,12 +73,15 @@ int xlide_init(xen_disk_info_t *xdi)
     6.4       */
     6.5      blk_queue_headactive(BLK_DEFAULT_QUEUE(XLIDE_MAJOR), 0);
     6.6  
     6.7 -    /* Count number of IDE devices installed in the system. */
     6.8 +    /* If we don't have any usable IDE devices we may as well bail now. */
     6.9      units = 0;
    6.10      for ( i = 0; i < xdi->count; i++ )
    6.11 -        if ( xdi->disks[i].type == XEN_DISK_IDE ) units++;
    6.12 +        if ( IS_IDE_XENDEV(xdi->disks[i].device) &&
    6.13 +             ((xdi->disks[i].device & XENDEV_IDX_MASK) < 16) ) units++;
    6.14 +    if ( units == 0 ) return 0;
    6.15  
    6.16 -    if ( units == 0 ) return 0;
    6.17 +    /* We may register up to 16 devices in a sparse identifier space. */
    6.18 +    units = 16;
    6.19  
    6.20      /* Construct an appropriate gendisk structure. */
    6.21      minors    = units * (1<<IDE_PARTN_BITS);
    6.22 @@ -104,10 +107,13 @@ int xlide_init(xen_disk_info_t *xdi)
    6.23      add_gendisk(gd);
    6.24      
    6.25      /* Now register each disk in turn. */
    6.26 -    disk = 0;
    6.27      for ( i = 0; i < xdi->count; i++ )
    6.28      {
    6.29 -        if ( xdi->disks[i].type != XEN_DISK_IDE ) continue;
    6.30 +        disk = xdi->disks[i].device & XENDEV_IDX_MASK;
    6.31 +
    6.32 +        /* We can use the first 16 IDE devices. */
    6.33 +        if ( !IS_IDE_XENDEV(xdi->disks[i].device) || (disk >= 16) ) continue;
    6.34 +
    6.35          ((xl_disk_t *)gd->real_devices)[disk].capacity =
    6.36              xdi->disks[i].capacity;
    6.37          register_disk(gd, 
    6.38 @@ -115,7 +121,6 @@ int xlide_init(xen_disk_info_t *xdi)
    6.39                        1<<IDE_PARTN_BITS, 
    6.40                        &xlide_block_fops, 
    6.41                        xdi->disks[i].capacity);
    6.42 -        disk++;
    6.43      }
    6.44  
    6.45      printk(KERN_ALERT 
     7.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_scsi.c	Mon Mar 10 00:04:52 2003 +0000
     7.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_scsi.c	Mon Mar 10 13:16:01 2003 +0000
     7.3 @@ -74,12 +74,15 @@ int xlscsi_init(xen_disk_info_t *xdi)
     7.4       */
     7.5      blk_queue_headactive(BLK_DEFAULT_QUEUE(XLSCSI_MAJOR), 0);
     7.6  
     7.7 -    /* Count number of SCSI devices installed in the system. */
     7.8 +    /* If we don't have any usable SCSI devices we may as well bail now. */
     7.9      units = 0;
    7.10      for ( i = 0; i < xdi->count; i++ )
    7.11 -        if ( xdi->disks[i].type == XEN_DISK_SCSI ) units++;
    7.12 +        if ( IS_SCSI_XENDEV(xdi->disks[i].device) &&
    7.13 +             ((xdi->disks[i].device & XENDEV_IDX_MASK) < 16) ) units++;
    7.14 +    if ( units == 0 ) return 0;
    7.15  
    7.16 -    if ( units == 0 ) return 0;
    7.17 +    /* We may register up to 16 devices in a sparse identifier space. */
    7.18 +    units = 16;
    7.19  
    7.20      /* Construct an appropriate gendisk structure. */
    7.21      minors    = units * (1<<SCSI_PARTN_BITS);
    7.22 @@ -105,10 +108,13 @@ int xlscsi_init(xen_disk_info_t *xdi)
    7.23      add_gendisk(gd);
    7.24  
    7.25      /* Now register each disk in turn. */
    7.26 -    disk = 0;
    7.27      for ( i = 0; i < xdi->count; i++ )
    7.28      {
    7.29 -        if ( xdi->disks[i].type != XEN_DISK_SCSI ) continue;
    7.30 +        disk = xdi->disks[i].device & XENDEV_IDX_MASK;
    7.31 +
    7.32 +        /* We can use the first 16 IDE devices. */
    7.33 +        if ( !IS_SCSI_XENDEV(xdi->disks[i].device) || (disk >= 16) ) continue;
    7.34 +
    7.35          ((xl_disk_t *)gd->real_devices)[disk].capacity =
    7.36              xdi->disks[i].capacity;
    7.37          register_disk(gd,
    7.38 @@ -116,7 +122,6 @@ int xlscsi_init(xen_disk_info_t *xdi)
    7.39                        1<<SCSI_PARTN_BITS, 
    7.40                        &xlscsi_block_fops, 
    7.41                        xdi->disks[i].capacity);
    7.42 -        disk++;
    7.43      }
    7.44     
    7.45      printk(KERN_ALERT 
     8.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment.c	Mon Mar 10 00:04:52 2003 +0000
     8.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment.c	Mon Mar 10 13:16:01 2003 +0000
     8.3 @@ -90,13 +90,12 @@ int __init xlseg_init(void)
     8.4       */
     8.5      blk_queue_headactive(BLK_DEFAULT_QUEUE(XLVIRT_MAJOR), 0);
     8.6  
     8.7 -
     8.8 -    /* Count number of virtual devices installed in the system. */
     8.9 -    units = 0;
    8.10 -    for ( i = 0; i < xdi->count; i++ )
    8.11 -        if ( xdi->disks[i].type == XEN_DISK_VIRTUAL ) units++;
    8.12 -
    8.13 -    if ( units == 0 ) return 0;
    8.14 +    /*
    8.15 +     * We may register up to 16 devices in a sparse identifier space.
    8.16 +     * Unlike with IDE and SCSI, we always register a gendisk, as new
    8.17 +     * virtual devices may get allocate dto us later on.
    8.18 +     */
    8.19 +    units = 16;
    8.20  
    8.21      /* Construct an appropriate gendisk structure. */
    8.22      minors    = units * (1<<VIRT_PARTN_BITS);
    8.23 @@ -122,10 +121,14 @@ int __init xlseg_init(void)
    8.24      add_gendisk(gd);
    8.25  
    8.26      /* Now register each disk in turn. */
    8.27 -    disk = 0;
    8.28      for ( i = 0; i < xdi->count; i++ )
    8.29      {
    8.30 -        if ( xdi->disks[i].type != XEN_DISK_VIRTUAL ) continue;
    8.31 +        disk = xdi->disks[i].device & XENDEV_IDX_MASK;
    8.32 +
    8.33 +        /* We can use the first 16 IDE devices. */
    8.34 +        if ( !IS_VIRTUAL_XENDEV(xdi->disks[i].device) || (disk >= 16) )
    8.35 +            continue;
    8.36 +
    8.37          ((xl_disk_t *)gd->real_devices)[disk].capacity =
    8.38              xdi->disks[i].capacity;
    8.39          register_disk(gd, 
    8.40 @@ -133,7 +136,6 @@ int __init xlseg_init(void)
    8.41                        1<<VIRT_PARTN_BITS, 
    8.42                        &xlsegment_block_fops, 
    8.43                        xdi->disks[i].capacity);
    8.44 -        disk++;
    8.45      }
    8.46  
    8.47      printk(KERN_ALERT