ia64/xen-unstable

changeset 5037:08bcb94afa37

bitkeeper revision 1.1483 (428de756rFBp-KHtm51Jw47YJiLjXA)

Manual merge.
author kaf24@firebug.cl.cam.ac.uk
date Fri May 20 13:34:14 2005 +0000 (2005-05-20)
parents 5b1f038d3d65 664508b09c16
children 847a499e8b29 90feb98108de
files linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.11-xen-sparse/drivers/xen/blkfront/block.h linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri May 20 10:29:43 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri May 20 13:34:14 2005 +0000
     1.3 @@ -75,8 +75,6 @@ static void vbd_update(void){};
     1.4  #define BLKIF_STATE_DISCONNECTED 1
     1.5  #define BLKIF_STATE_CONNECTED    2
     1.6  
     1.7 -#define WPRINTK(fmt, args...) printk(KERN_WARNING "xen_blk: " fmt, ##args)
     1.8 -
     1.9  static int blkif_handle = 0;
    1.10  static unsigned int blkif_state = BLKIF_STATE_CLOSED;
    1.11  static unsigned int blkif_evtchn = 0;
    1.12 @@ -671,7 +669,7 @@ int blkif_ioctl(struct inode *inode, str
    1.13          return -ENOSYS;
    1.14  
    1.15      default:
    1.16 -        printk(KERN_ALERT "ioctl %08x not supported by XL blkif\n", command);
    1.17 +        WPRINTK("ioctl %08x not supported by XL blkif\n", command);
    1.18          return -ENOSYS;
    1.19      }
    1.20      
    1.21 @@ -1264,7 +1262,7 @@ static void blkif_connect(blkif_fe_inter
    1.22      err = request_irq(blkif_irq, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
    1.23      if ( err )
    1.24      {
    1.25 -        printk(KERN_ALERT "xen_blk: request_irq failed (err=%d)\n", err);
    1.26 +        WPRINTK("request_irq failed (err=%d)\n", err);
    1.27          return;
    1.28      }
    1.29  
    1.30 @@ -1406,7 +1404,7 @@ int wait_for_blkif(void)
    1.31  
    1.32      if ( blkif_state != BLKIF_STATE_CONNECTED )
    1.33      {
    1.34 -        printk(KERN_INFO "xen_blk: Timeout connecting to device!\n");
    1.35 +        WPRINTK("Timeout connecting to device!\n");
    1.36          err = -ENOSYS;
    1.37      }
    1.38      return err;
    1.39 @@ -1427,7 +1425,7 @@ int __init xlblk_init(void)
    1.40           (xen_start_info.flags & SIF_BLK_BE_DOMAIN) )
    1.41          return 0;
    1.42  
    1.43 -    printk(KERN_INFO "xen_blk: Initialising virtual block device driver\n");
    1.44 +    IPRINTK("Initialising virtual block device driver\n");
    1.45  
    1.46      blk_shadow_free = 0;
    1.47      memset(blk_shadow, 0, sizeof(blk_shadow));
     2.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/block.h	Fri May 20 10:29:43 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/block.h	Fri May 20 13:34:14 2005 +0000
     2.3 @@ -51,6 +51,11 @@
     2.4  #include <asm/atomic.h>
     2.5  #include <asm/uaccess.h>
     2.6  
     2.7 +#define IPRINTK(fmt, args...) \
     2.8 +    printk(KERN_INFO "xen_blk: " fmt, ##args)
     2.9 +#define WPRINTK(fmt, args...) \
    2.10 +    printk(KERN_WARNING "xen_blk: " fmt, ##args)
    2.11 +
    2.12  #if 0
    2.13  #define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
    2.14  #else
    2.15 @@ -65,8 +70,7 @@
    2.16  
    2.17  struct xlbd_type_info {
    2.18      int partn_shift;
    2.19 -    int partn_per_major;
    2.20 -    int devs_per_major;
    2.21 +    int disks_per_major;
    2.22      char *devname;
    2.23      char *diskname;
    2.24  };
     3.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Fri May 20 10:29:43 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Fri May 20 13:34:14 2005 +0000
     3.3 @@ -53,21 +53,21 @@ struct lvdisk
     3.4  
     3.5  static struct xlbd_type_info xlbd_ide_type = {
     3.6      .partn_shift = 6,
     3.7 -    .partn_per_major = 2,
     3.8 +    .disks_per_major = 2,
     3.9      .devname = "ide",
    3.10      .diskname = "hd",
    3.11  };
    3.12  
    3.13  static struct xlbd_type_info xlbd_scsi_type = {
    3.14      .partn_shift = 4,
    3.15 -    .partn_per_major = 16,
    3.16 +    .disks_per_major = 16,
    3.17      .devname = "sd",
    3.18      .diskname = "sd",
    3.19  };
    3.20  
    3.21  static struct xlbd_type_info xlbd_vbd_type = {
    3.22      .partn_shift = 4,
    3.23 -    .partn_per_major = 16,
    3.24 +    .disks_per_major = 16,
    3.25      .devname = "xvd",
    3.26      .diskname = "xvd",
    3.27  };
    3.28 @@ -107,7 +107,7 @@ static struct lvdisk *xlvbd_device_alloc
    3.29      struct lvdisk *disk;
    3.30  
    3.31      disk = kmalloc(sizeof(*disk), GFP_KERNEL);
    3.32 -    if (disk) {
    3.33 +    if (disk != NULL) {
    3.34          memset(disk, 0, sizeof(*disk));
    3.35          INIT_LIST_HEAD(&disk->list);
    3.36      }
    3.37 @@ -120,7 +120,7 @@ static void xlvbd_device_free(struct lvd
    3.38      kfree(disk);
    3.39  }
    3.40  
    3.41 -static vdisk_t * xlvbd_probe(int *ret)
    3.42 +static vdisk_t *xlvbd_probe(int *ret)
    3.43  {
    3.44      blkif_response_t rsp;
    3.45      blkif_request_t req;
    3.46 @@ -129,7 +129,7 @@ static vdisk_t * xlvbd_probe(int *ret)
    3.47      int nr;
    3.48  
    3.49      buf = __get_free_page(GFP_KERNEL);
    3.50 -    if ( !buf )
    3.51 +    if ((void *)buf == NULL)
    3.52          goto out;
    3.53  
    3.54      memset(&req, 0, sizeof(req));
    3.55 @@ -144,7 +144,7 @@ static vdisk_t * xlvbd_probe(int *ret)
    3.56      blkif_control_send(&req, &rsp);
    3.57  #endif
    3.58      if ( rsp.status <= 0 ) {
    3.59 -        printk(KERN_ALERT "Could not probe disks (%d)\n", rsp.status);
    3.60 +        WPRINTK("Could not probe disks (%d)\n", rsp.status);
    3.61          goto out;
    3.62      }
    3.63      nr = rsp.status;
    3.64 @@ -152,21 +152,24 @@ static vdisk_t * xlvbd_probe(int *ret)
    3.65          nr = MAX_VBDS;
    3.66  
    3.67      disk_info = kmalloc(nr * sizeof(vdisk_t), GFP_KERNEL);
    3.68 -    if ( disk_info )
    3.69 +    if (disk_info != NULL)
    3.70          memcpy(disk_info, (void *) buf, nr * sizeof(vdisk_t));
    3.71 -    if ( ret )
    3.72 +
    3.73 +    if (ret != NULL)
    3.74          *ret = nr;
    3.75 +
    3.76  out:
    3.77      free_page(buf);
    3.78      return disk_info;
    3.79  }
    3.80  
    3.81 -static struct xlbd_major_info *xlbd_alloc_major_info(int major, int minor, int index)
    3.82 +static struct xlbd_major_info *xlbd_alloc_major_info(
    3.83 +    int major, int minor, int index)
    3.84  {
    3.85      struct xlbd_major_info *ptr;
    3.86  
    3.87      ptr = kmalloc(sizeof(struct xlbd_major_info), GFP_KERNEL);
    3.88 -    if ( !ptr )
    3.89 +    if (ptr == NULL)
    3.90          return NULL;
    3.91  
    3.92      memset(ptr, 0, sizeof(struct xlbd_major_info));
    3.93 @@ -188,9 +191,9 @@ static struct xlbd_major_info *xlbd_allo
    3.94          break;
    3.95      }
    3.96      
    3.97 -    if ( register_blkdev(ptr->major, ptr->type->devname) ) {
    3.98 -        printk(KERN_ALERT "XL VBD: can't get major %d with name %s\n",
    3.99 -                    ptr->major, ptr->type->devname);
   3.100 +    if (register_blkdev(ptr->major, ptr->type->devname)) {
   3.101 +        WPRINTK("can't get major %d with name %s\n",
   3.102 +                ptr->major, ptr->type->devname);
   3.103          kfree(ptr);
   3.104          return NULL;
   3.105      }
   3.106 @@ -226,15 +229,14 @@ static struct xlbd_major_info *xlbd_get_
   3.107      default: index = 19; break;
   3.108      }
   3.109  
   3.110 -    return major_info[index]
   3.111 -        ? major_info[index]
   3.112 -        : xlbd_alloc_major_info(major, minor, index);
   3.113 +    return ((major_info[index] != NULL) ? major_info[index] :
   3.114 +            xlbd_alloc_major_info(major, minor, index));
   3.115  }
   3.116  
   3.117  static int xlvbd_blk_queue_alloc(struct xlbd_type_info *type)
   3.118  {
   3.119      xlbd_blk_queue = blk_init_queue(do_blkif_request, &blkif_io_lock);
   3.120 -    if ( !xlbd_blk_queue )
   3.121 +    if (xlbd_blk_queue == NULL)
   3.122          return -1;
   3.123  
   3.124      elevator_init(xlbd_blk_queue, "noop");
   3.125 @@ -263,35 +265,35 @@ static int xlvbd_blk_queue_alloc(struct 
   3.126      return 0;
   3.127  }
   3.128  
   3.129 -struct gendisk *xlvbd_alloc_gendisk(struct xlbd_major_info *mi, int minor,
   3.130 -                    vdisk_t *disk)
   3.131 +struct gendisk *xlvbd_alloc_gendisk(
   3.132 +    struct xlbd_major_info *mi, int minor, vdisk_t *disk)
   3.133  {
   3.134      struct gendisk *gd;
   3.135      struct xlbd_disk_info *di;
   3.136 -    int nb_minors;
   3.137 +    int nr_minors = 1;
   3.138  
   3.139      di = kmalloc(sizeof(struct xlbd_disk_info), GFP_KERNEL);
   3.140 -    if ( !di )
   3.141 +    if (di == NULL)
   3.142          goto out;
   3.143      di->mi = mi;
   3.144      di->xd_device = disk->device;
   3.145  
   3.146 -    nb_minors = ((minor & ((1 << mi->type->partn_shift) - 1)) == 0)
   3.147 -            ? mi->type->partn_per_major
   3.148 -            : 1;
   3.149 +    /* Full disk rather than a single partition? */
   3.150 +    if ((minor & ((1 << mi->type->partn_shift) - 1)) == 0)
   3.151 +        nr_minors = 1 << mi->type->partn_shift;
   3.152  
   3.153 -    gd = alloc_disk(nb_minors);
   3.154 +    gd = alloc_disk(nr_minors);
   3.155      if ( !gd )
   3.156          goto out;
   3.157  
   3.158 -    if ( nb_minors > 1 )
   3.159 +    if ( nr_minors > 1 ) /* full disk? */
   3.160          sprintf(gd->disk_name, "%s%c", mi->type->diskname,
   3.161 -                'a' + mi->index * mi->type->partn_per_major +
   3.162 +                'a' + mi->index * mi->type->disks_per_major +
   3.163                      (minor >> mi->type->partn_shift));
   3.164      else
   3.165          sprintf(gd->disk_name, "%s%c%d", mi->type->diskname,
   3.166 -                'a' + mi->index * mi->type->partn_per_major +
   3.167 -                    (minor >> mi->type->partn_shift),
   3.168 +                'a' + mi->index * mi->type->disks_per_major +
   3.169 +                (minor >> mi->type->partn_shift),
   3.170                  minor & ((1 << mi->type->partn_shift) - 1));
   3.171  
   3.172      gd->major = mi->major;
   3.173 @@ -300,18 +302,16 @@ struct gendisk *xlvbd_alloc_gendisk(stru
   3.174      gd->private_data = di;
   3.175      set_capacity(gd, disk->capacity);
   3.176  
   3.177 -    if ( !xlbd_blk_queue )
   3.178 -        if ( xlvbd_blk_queue_alloc(mi->type) )
   3.179 +    if ((xlbd_blk_queue == NULL) && xlvbd_blk_queue_alloc(mi->type))
   3.180              goto out_gendisk;
   3.181  
   3.182      gd->queue = xlbd_blk_queue;
   3.183      add_disk(gd);
   3.184      return gd;
   3.185 +
   3.186  out_gendisk:
   3.187 -    printk(KERN_ALERT "error gendisk\n");
   3.188      del_gendisk(gd);
   3.189  out:
   3.190 -    printk(KERN_ALERT "error out\n");
   3.191      kfree(di);
   3.192      return NULL;
   3.193  }
   3.194 @@ -326,11 +326,11 @@ static int xlvbd_device_add(struct list_
   3.195      struct xlbd_major_info *mi;
   3.196  
   3.197      mi = xlbd_get_major_info(disk->device);
   3.198 -    if ( !mi )
   3.199 +    if (mi == NULL)
   3.200          return -EPERM;
   3.201  
   3.202      new = xlvbd_device_alloc();
   3.203 -    if ( !new )
   3.204 +    if (new == NULL)
   3.205          return -1;
   3.206      new->capacity = disk->capacity;
   3.207      new->device = disk->device;
   3.208 @@ -340,14 +340,14 @@ static int xlvbd_device_add(struct list_
   3.209      device = MKDEV(mi->major, minor);
   3.210      
   3.211      bd = bdget(device);
   3.212 -    if ( !bd )
   3.213 +    if (bd == NULL)
   3.214          goto out;
   3.215      
   3.216      gd = xlvbd_alloc_gendisk(mi, minor, disk);
   3.217 -    if ( !gd )
   3.218 +    if (gd == NULL)
   3.219          goto out_bd;
   3.220  
   3.221 -    if ( VDISK_READONLY(disk->info) )
   3.222 +    if (VDISK_READONLY(disk->info))
   3.223          set_disk_ro(gd, 1);
   3.224  
   3.225      switch (VDISK_TYPE(disk->info)) {
   3.226 @@ -361,8 +361,7 @@ static int xlvbd_device_add(struct list_
   3.227      case VDISK_TYPE_DISK:
   3.228          break;
   3.229      default:
   3.230 -        printk(KERN_ALERT "XenLinux: unknown device type %d\n",
   3.231 -                        VDISK_TYPE(disk->info));
   3.232 +        WPRINTK("unknown device type %d\n", VDISK_TYPE(disk->info));
   3.233          break;
   3.234      }    
   3.235  
   3.236 @@ -384,14 +383,14 @@ static int xlvbd_device_del(struct lvdis
   3.237      device = MKDEV(MAJOR_XEN(disk->device), MINOR_XEN(disk->device));
   3.238  
   3.239      bd = bdget(device);
   3.240 -    if ( !bd )
   3.241 +    if (bd == NULL)
   3.242          return -1;
   3.243  
   3.244      gd = get_gendisk(device, &unused);
   3.245      di = gd->private_data;
   3.246  
   3.247 -    if ( di->mi->usage != 0 ) {
   3.248 -        printk(KERN_ALERT "VBD removal failed: used [dev=%x]\n", device);
   3.249 +    if (di->mi->usage != 0) {
   3.250 +        WPRINTK("disk removal failed: used [dev=%x]\n", device);
   3.251          ret = -1;
   3.252          goto out;
   3.253      }
   3.254 @@ -411,13 +410,13 @@ static int xlvbd_device_update(struct lv
   3.255      struct gendisk *gd;
   3.256      int unused;
   3.257  
   3.258 -    if ( ldisk->capacity == disk->capacity && ldisk->info == disk->info )
   3.259 +    if ((ldisk->capacity == disk->capacity) && (ldisk->info == disk->info))
   3.260          return 0;    
   3.261  
   3.262      device = MKDEV(MAJOR_XEN(ldisk->device), MINOR_XEN(ldisk->device));
   3.263  
   3.264      bd = bdget(device);
   3.265 -    if ( !bd )
   3.266 +    if (bd == NULL)
   3.267          return -1;
   3.268  
   3.269      gd = get_gendisk(device, &unused);
   3.270 @@ -437,8 +436,8 @@ void xlvbd_refresh(void)
   3.271      int i, nr;
   3.272  
   3.273      newdisks = xlvbd_probe(&nr);
   3.274 -    if ( !newdisks ) {
   3.275 -        printk(KERN_ALERT "failed to probe\n");
   3.276 +    if (newdisks == NULL) {
   3.277 +        WPRINTK("failed to probe\n");
   3.278          return;
   3.279      }
   3.280      
   3.281 @@ -455,7 +454,7 @@ void xlvbd_refresh(void)
   3.282                  break;
   3.283              }
   3.284          }
   3.285 -        if ( i == nr ) {
   3.286 +        if (i == nr) {
   3.287              xlvbd_device_del(disk);
   3.288              newdisks[i].device = 0;
   3.289          }
   3.290 @@ -495,13 +494,14 @@ int xlvbd_init(void)
   3.291      memset(major_info, 0, sizeof(major_info));
   3.292      
   3.293      disks = xlvbd_probe(&nr);
   3.294 -    if ( !disks ) {
   3.295 -        printk(KERN_ALERT "failed to probe\n");
   3.296 +    if (disks == NULL) {
   3.297 +        WPRINTK("failed to probe\n");
   3.298          return -1;
   3.299      }
   3.300  
   3.301      for (i = 0; i < nr; i++)
   3.302          xlvbd_device_add(&vbds_list, &disks[i]);
   3.303 +
   3.304      kfree(disks);
   3.305      return 0;
   3.306  }