ia64/xen-unstable

changeset 4156:5c5ca35a900a

bitkeeper revision 1.1236.34.2 (4236f1cenxl0_Wb4JHfN5yqRDIoKOw)

Merge arcadians.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
into arcadians.cl.cam.ac.uk:/local/scratch-2/vh249/xen-unstable.bk
author vh249@arcadians.cl.cam.ac.uk
date Tue Mar 15 14:31:42 2005 +0000 (2005-03-15)
parents ce88c0b8cb9c 6fea1828365e
children 7a281bd1e0f5
files BitKeeper/etc/logging_ok linux-2.4.29-xen-sparse/arch/xen/drivers/blkif/frontend/vbd.c linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c
line diff
     1.1 --- a/BitKeeper/etc/logging_ok	Tue Mar 15 09:00:10 2005 +0000
     1.2 +++ b/BitKeeper/etc/logging_ok	Tue Mar 15 14:31:42 2005 +0000
     1.3 @@ -81,5 +81,6 @@ tlh20@labyrinth.cl.cam.ac.uk
     1.4  tw275@labyrinth.cl.cam.ac.uk
     1.5  tw275@striker.cl.cam.ac.uk
     1.6  vh249@airwolf.cl.cam.ac.uk
     1.7 +vh249@arcadians.cl.cam.ac.uk
     1.8  xen-ia64.adm@bkbits.net
     1.9  xenbk@gandalf.hpl.hp.com
     2.1 --- a/linux-2.4.29-xen-sparse/arch/xen/drivers/blkif/frontend/vbd.c	Tue Mar 15 09:00:10 2005 +0000
     2.2 +++ b/linux-2.4.29-xen-sparse/arch/xen/drivers/blkif/frontend/vbd.c	Tue Mar 15 14:31:42 2005 +0000
     2.3 @@ -442,11 +442,11 @@ void xlvbd_update_vbds(void)
     2.4      old_nr   = nr_vbds;
     2.5  
     2.6      new_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL);
     2.7 +    if (!new_info)
     2.8 +        return;
     2.9 +
    2.10      if ( unlikely(new_nr = xlvbd_get_vbd_info(new_info)) < 0 )
    2.11 -    {
    2.12 -        kfree(new_info);
    2.13 -        return;
    2.14 -    }
    2.15 +        goto out;
    2.16  
    2.17      /*
    2.18       * Final list maximum size is old list + new list. This occurs only when
    2.19 @@ -454,6 +454,8 @@ void xlvbd_update_vbds(void)
    2.20       * VBDs in the old list because the usage counts are busy.
    2.21       */
    2.22      merged_info = kmalloc((old_nr + new_nr) * sizeof(vdisk_t), GFP_KERNEL);
    2.23 +    if (!merged_info)
    2.24 +        goto out;
    2.25  
    2.26      /* @i tracks old list; @j tracks new list; @k tracks merged list. */
    2.27      i = j = k = 0;
    2.28 @@ -500,6 +502,7 @@ void xlvbd_update_vbds(void)
    2.29      nr_vbds  = k;
    2.30  
    2.31      kfree(old_info);
    2.32 +out:
    2.33      kfree(new_info);
    2.34  }
    2.35  
    2.36 @@ -543,6 +546,9 @@ int xlvbd_init(void)
    2.37      }
    2.38  
    2.39      vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL);
    2.40 +    if (!vbd_info)
    2.41 +        return -ENOMEM;
    2.42 +
    2.43      nr_vbds  = xlvbd_get_vbd_info(vbd_info);
    2.44  
    2.45      if ( nr_vbds < 0 )
     3.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Mar 15 09:00:10 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Mar 15 14:31:42 2005 +0000
     3.3 @@ -165,8 +165,15 @@ static inline void flush_requests(void)
     3.4  module_init(xlblk_init);
     3.5  
     3.6  #if ENABLE_VBD_UPDATE
     3.7 +static void update_vbds_task(void *unused)
     3.8 +{ 
     3.9 +    xlvbd_update_vbds();
    3.10 +}
    3.11 +
    3.12  static void vbd_update(void)
    3.13  {
    3.14 +    static DECLARE_WORK(update_tq, update_vbds_task, NULL);
    3.15 +    schedule_work(&update_tq);
    3.16  }
    3.17  #endif /* ENABLE_VBD_UPDATE */
    3.18  
     4.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Tue Mar 15 09:00:10 2005 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Tue Mar 15 14:31:42 2005 +0000
     4.3 @@ -354,7 +354,6 @@ static int xlvbd_init_device(vdisk_t *xd
     4.4      return err;
     4.5  }
     4.6  
     4.7 -#if 0
     4.8  /*
     4.9   * xlvbd_remove_device - remove a device node if possible
    4.10   * @device:       numeric device ID
    4.11 @@ -364,14 +363,16 @@ static int xlvbd_init_device(vdisk_t *xd
    4.12   * This is OK for now but in future, should perhaps consider where this should
    4.13   * deallocate gendisks / unregister devices.
    4.14   */
    4.15 -static int xlvbd_remove_device(int device)
    4.16 +static int xlvbd_remove_device(int dev16)
    4.17  {
    4.18 -    int i, rc = 0, minor = MINOR(device);
    4.19 +    int i, rc = 0, minor = MINOR(dev16);
    4.20      struct gendisk *gd;
    4.21      struct block_device *bd;
    4.22 -    xen_block_t *disk = NULL;
    4.23 +    struct xlbd_disk_info *di;
    4.24 +    dev_t device = MKDEV(MAJOR_XEN(dev16), MINOR_XEN(dev16));
    4.25  
    4.26 -    if ( (bd = bdget(device)) == NULL )
    4.27 +    bd = bdget(device);
    4.28 +    if (!bd)
    4.29          return -1;
    4.30  
    4.31      /*
    4.32 @@ -380,67 +381,25 @@ static int xlvbd_remove_device(int devic
    4.33       */
    4.34      down(&bd->bd_sem);
    4.35  
    4.36 -    if ( ((gd = get_gendisk(device)) == NULL) ||
    4.37 -         ((disk = xldev_to_xldisk(device)) == NULL) )
    4.38 -        BUG();
    4.39 +    gd = get_gendisk(device, &i);
    4.40 +    BUG_ON(gd == NULL);
    4.41 +    di = (struct xlbd_disk_info *) gd->private_data;
    4.42 +    BUG_ON(di == NULL);
    4.43  
    4.44 -    if ( disk->usage != 0 )
    4.45 +    if ( di->mi->usage != 0 )
    4.46      {
    4.47          printk(KERN_ALERT "VBD removal failed - in use [dev=%x]\n", device);
    4.48          rc = -1;
    4.49          goto out;
    4.50      }
    4.51 - 
    4.52 -    if ( (minor & (gd->max_p-1)) != 0 )
    4.53 -    {
    4.54 -        /* 1: The VBD is mapped to a partition rather than a whole unit. */
    4.55 -        invalidate_device(device, 1);
    4.56 -        gd->part[minor].start_sect = 0;
    4.57 -        gd->part[minor].nr_sects   = 0;
    4.58 -        gd->sizes[minor]           = 0;
    4.59 -
    4.60 -        /* Clear the consists-of-virtual-partitions flag if possible. */
    4.61 -        gd->flags[minor >> gd->minor_shift] &= ~GENHD_FL_VIRT_PARTNS;
    4.62 -        for ( i = 1; i < gd->max_p; i++ )
    4.63 -            if ( gd->sizes[(minor & ~(gd->max_p-1)) + i] != 0 )
    4.64 -                gd->flags[minor >> gd->minor_shift] |= GENHD_FL_VIRT_PARTNS;
    4.65  
    4.66 -        /*
    4.67 -         * If all virtual partitions are now gone, and a 'whole unit' VBD is
    4.68 -         * present, then we can try to grok the unit's real partition table.
    4.69 -         */
    4.70 -        if ( !(gd->flags[minor >> gd->minor_shift] & GENHD_FL_VIRT_PARTNS) &&
    4.71 -             (gd->sizes[minor & ~(gd->max_p-1)] != 0) &&
    4.72 -             !(gd->flags[minor >> gd->minor_shift] & GENHD_FL_REMOVABLE) )
    4.73 -        {
    4.74 -            register_disk(gd,
    4.75 -                          device&~(gd->max_p-1), 
    4.76 -                          gd->max_p, 
    4.77 -                          &xlvbd_block_fops,
    4.78 -                          gd->part[minor&~(gd->max_p-1)].nr_sects);
    4.79 -        }
    4.80 -    }
    4.81 -    else
    4.82 -    {
    4.83 -        /*
    4.84 -         * 2: The VBD is mapped to an entire 'unit'. Clear all partitions.
    4.85 -         * NB. The partition entries are only cleared if there are no VBDs
    4.86 -         * mapped to individual partitions on this unit.
    4.87 -         */
    4.88 -        i = gd->max_p - 1; /* Default: clear subpartitions as well. */
    4.89 -        if ( gd->flags[minor >> gd->minor_shift] & GENHD_FL_VIRT_PARTNS )
    4.90 -            i = 0; /* 'Virtual' mode: only clear the 'whole unit' entry. */
    4.91 -        while ( i >= 0 )
    4.92 -        {
    4.93 -            invalidate_device(device+i, 1);
    4.94 -            gd->part[minor+i].start_sect = 0;
    4.95 -            gd->part[minor+i].nr_sects   = 0;
    4.96 -            gd->sizes[minor+i]           = 0;
    4.97 -            i--;
    4.98 -        }
    4.99 -    }
   4.100 +    BUG_ON(minor != gd->first_minor);
   4.101 +    /* The VBD is mapped to an entire unit. */
   4.102 +    
   4.103 +    invalidate_partition(gd, 0);
   4.104 +    set_capacity(gd, 0);
   4.105  
   4.106 - out:
   4.107 +out:
   4.108      up(&bd->bd_sem);
   4.109      bdput(bd);
   4.110      return rc;
   4.111 @@ -460,11 +419,11 @@ void xlvbd_update_vbds(void)
   4.112      old_nr   = nr_vbds;
   4.113  
   4.114      new_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL);
   4.115 +    if (!new_info)
   4.116 +        return;
   4.117 +
   4.118      if ( unlikely(new_nr = xlvbd_get_vbd_info(new_info)) < 0 )
   4.119 -    {
   4.120 -        kfree(new_info);
   4.121 -        return;
   4.122 -    }
   4.123 +        goto out;
   4.124  
   4.125      /*
   4.126       * Final list maximum size is old list + new list. This occurs only when
   4.127 @@ -472,6 +431,8 @@ void xlvbd_update_vbds(void)
   4.128       * VBDs in the old list because the usage counts are busy.
   4.129       */
   4.130      merged_info = kmalloc((old_nr + new_nr) * sizeof(vdisk_t), GFP_KERNEL);
   4.131 +    if (!merged_info)
   4.132 +        goto out;
   4.133  
   4.134      /* @i tracks old list; @j tracks new list; @k tracks merged list. */
   4.135      i = j = k = 0;
   4.136 @@ -518,9 +479,9 @@ void xlvbd_update_vbds(void)
   4.137      nr_vbds  = k;
   4.138  
   4.139      kfree(old_info);
   4.140 +out:
   4.141      kfree(new_info);
   4.142  }
   4.143 -#endif
   4.144  
   4.145  /*
   4.146   * Set up all the linux device goop for the virtual block devices