ia64/xen-unstable
changeset 3409:2162fcd0d254
bitkeeper revision 1.1159.217.3 (41e3e41d3THhxhJrWMZu3Arcs8K-Rw)
Manual merge
Manual merge
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Tue Jan 11 14:35:09 2005 +0000 (2005-01-11) |
parents | 46e21e3f8bee ea428d76cfb3 |
children | 7a39463e17ce |
files | linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.10-xen-sparse/drivers/xen/blkfront/block.h linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c |
line diff
1.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c Tue Jan 11 12:07:58 2005 +0000 1.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c Tue Jan 11 14:35:09 2005 +0000 1.3 @@ -62,21 +62,6 @@ static void vbd_update(void){}; 1.4 #define BLKIF_STATE_DISCONNECTED 1 1.5 #define BLKIF_STATE_CONNECTED 2 1.6 1.7 -#ifdef VERBOSE 1.8 -static char *blkif_state_name[] = { 1.9 - [BLKIF_STATE_CLOSED] = "closed", 1.10 - [BLKIF_STATE_DISCONNECTED] = "disconnected", 1.11 - [BLKIF_STATE_CONNECTED] = "connected", 1.12 -}; 1.13 - 1.14 -static char * blkif_status_name[] = { 1.15 - [BLKIF_INTERFACE_STATUS_CLOSED] = "closed", 1.16 - [BLKIF_INTERFACE_STATUS_DISCONNECTED] = "disconnected", 1.17 - [BLKIF_INTERFACE_STATUS_CONNECTED] = "connected", 1.18 - [BLKIF_INTERFACE_STATUS_CHANGED] = "changed", 1.19 -}; 1.20 -#endif 1.21 - 1.22 #define WPRINTK(fmt, args...) printk(KERN_WARNING "xen_blk: " fmt, ##args) 1.23 1.24 static int blkif_handle = 0; 1.25 @@ -331,11 +316,11 @@ static int blkif_queue_request(struct re 1.26 blkif_request_t *ring_req; 1.27 struct bio *bio; 1.28 struct bio_vec *bvec; 1.29 - int idx, s; 1.30 + int idx; 1.31 unsigned long id; 1.32 unsigned int fsect, lsect; 1.33 1.34 - if (unlikely(blkif_state != BLKIF_STATE_CONNECTED)) 1.35 + if ( unlikely(blkif_state != BLKIF_STATE_CONNECTED) ) 1.36 return 1; 1.37 1.38 /* Fill out a communications ring structure. */ 1.39 @@ -349,29 +334,25 @@ static int blkif_queue_request(struct re 1.40 ring_req->sector_number = (blkif_sector_t)req->sector; 1.41 ring_req->device = di->xd_device; 1.42 1.43 - s = 0; 1.44 ring_req->nr_segments = 0; 1.45 - rq_for_each_bio(bio, req) { 1.46 - bio_for_each_segment(bvec, bio, idx) { 1.47 + rq_for_each_bio(bio, req) 1.48 + { 1.49 + bio_for_each_segment(bvec, bio, idx) 1.50 + { 1.51 + if ( ring_req->nr_segments == BLKIF_MAX_SEGMENTS_PER_REQUEST ) 1.52 + BUG(); 1.53 buffer_ma = page_to_phys(bvec->bv_page); 1.54 - if (unlikely((buffer_ma & ((1<<9)-1)) != 0)) 1.55 - BUG(); 1.56 - 1.57 fsect = bvec->bv_offset >> 9; 1.58 lsect = fsect + (bvec->bv_len >> 9) - 1; 1.59 - if (unlikely(lsect > 7)) 1.60 - BUG(); 1.61 - 1.62 ring_req->frame_and_sects[ring_req->nr_segments++] = 1.63 buffer_ma | (fsect << 3) | lsect; 1.64 - s += bvec->bv_len >> 9; 1.65 } 1.66 } 1.67 1.68 blk_ring.req_prod_pvt++; 1.69 1.70 /* Keep a private copy so we can reissue requests when recovering. */ 1.71 - translate_req_to_pfn( &rec_ring[id], ring_req); 1.72 + translate_req_to_pfn(&rec_ring[id], ring_req); 1.73 1.74 return 0; 1.75 } 1.76 @@ -1241,9 +1222,8 @@ static void blkif_connect(blkif_fe_inter 1.77 1.78 static void unexpected(blkif_fe_interface_status_t *status) 1.79 { 1.80 - DPRINTK(" Unexpected blkif status %s in state %s\n", 1.81 - blkif_status_name[status->status], 1.82 - blkif_state_name[blkif_state]); 1.83 + DPRINTK(" Unexpected blkif status %u in state %u\n", 1.84 + status->status, blkif_state); 1.85 } 1.86 1.87 static void blkif_status(blkif_fe_interface_status_t *status)
2.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/block.h Tue Jan 11 12:07:58 2005 +0000 2.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/block.h Tue Jan 11 14:35:09 2005 +0000 2.3 @@ -64,12 +64,12 @@ 2.4 #endif 2.5 2.6 struct xlbd_type_info { 2.7 - int partn_shift; 2.8 - int partn_per_major; 2.9 - int devs_per_major; 2.10 - int hardsect_size; 2.11 - int max_sectors; 2.12 - char *name; 2.13 + int partn_shift; 2.14 + int partn_per_major; 2.15 + int devs_per_major; 2.16 + int hardsect_size; 2.17 + int max_sectors; 2.18 + char *name; 2.19 }; 2.20 2.21 /* 2.22 @@ -78,19 +78,19 @@ struct xlbd_type_info { 2.23 * putting all kinds of interesting stuff here :-) 2.24 */ 2.25 struct xlbd_major_info { 2.26 - int major; 2.27 - int index; 2.28 - int usage; 2.29 - struct xlbd_type_info *type; 2.30 + int major; 2.31 + int index; 2.32 + int usage; 2.33 + struct xlbd_type_info *type; 2.34 }; 2.35 2.36 struct xlbd_disk_info { 2.37 - int xd_device; 2.38 - struct xlbd_major_info *mi; 2.39 + int xd_device; 2.40 + struct xlbd_major_info *mi; 2.41 }; 2.42 2.43 typedef struct xen_block { 2.44 - int usage; 2.45 + int usage; 2.46 } xen_block_t; 2.47 2.48 extern struct request_queue *xlbd_blk_queue; 2.49 @@ -99,7 +99,7 @@ extern spinlock_t blkif_io_lock; 2.50 extern int blkif_open(struct inode *inode, struct file *filep); 2.51 extern int blkif_release(struct inode *inode, struct file *filep); 2.52 extern int blkif_ioctl(struct inode *inode, struct file *filep, 2.53 - unsigned command, unsigned long argument); 2.54 + unsigned command, unsigned long argument); 2.55 extern int blkif_check(dev_t dev); 2.56 extern int blkif_revalidate(dev_t dev); 2.57 extern void blkif_control_send(blkif_request_t *req, blkif_response_t *rsp);
3.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c Tue Jan 11 12:07:58 2005 +0000 3.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c Tue Jan 11 14:35:09 2005 +0000 3.3 @@ -43,39 +43,37 @@ 3.4 #define NUM_VBD_MAJORS 1 3.5 3.6 static struct xlbd_type_info xlbd_ide_type = { 3.7 - .partn_shift = 6, 3.8 - .partn_per_major = 2, 3.9 - // XXXcl todo blksize_size[major] = 1024; 3.10 - .hardsect_size = 512, 3.11 - .max_sectors = 128, /* 'hwif->rqsize' if we knew it */ 3.12 - // XXXcl todo read_ahead[major] = 8; /* from drivers/ide/ide-probe.c */ 3.13 - .name = "hd", 3.14 + .partn_shift = 6, 3.15 + .partn_per_major = 2, 3.16 + // XXXcl todo blksize_size[major] = 1024; 3.17 + .hardsect_size = 512, 3.18 + .max_sectors = 128, /* 'hwif->rqsize' if we knew it */ 3.19 + // XXXcl todo read_ahead[major] = 8; /* from drivers/ide/ide-probe.c */ 3.20 + .name = "hd", 3.21 }; 3.22 3.23 static struct xlbd_type_info xlbd_scsi_type = { 3.24 - .partn_shift = 4, 3.25 - .partn_per_major = 16, 3.26 - // XXXcl todo blksize_size[major] = 1024; /* XXX 512; */ 3.27 - .hardsect_size = 512, 3.28 - .max_sectors = 128*8, /* XXX 128; */ 3.29 - // XXXcl todo read_ahead[major] = 0; /* XXX 8; -- guessing */ 3.30 - .name = "sd", 3.31 + .partn_shift = 4, 3.32 + .partn_per_major = 16, 3.33 + // XXXcl todo blksize_size[major] = 1024; /* XXX 512; */ 3.34 + .hardsect_size = 512, 3.35 + .max_sectors = 128*8, /* XXX 128; */ 3.36 + // XXXcl todo read_ahead[major] = 0; /* XXX 8; -- guessing */ 3.37 + .name = "sd", 3.38 }; 3.39 3.40 static struct xlbd_type_info xlbd_vbd_type = { 3.41 - .partn_shift = 4, 3.42 - .partn_per_major = 16, 3.43 - // XXXcl todo blksize_size[major] = 512; 3.44 - .hardsect_size = 512, 3.45 - .max_sectors = 128, 3.46 - // XXXcl todo read_ahead[major] = 8; 3.47 - .name = "xvd", 3.48 + .partn_shift = 4, 3.49 + .partn_per_major = 16, 3.50 + // XXXcl todo blksize_size[major] = 512; 3.51 + .hardsect_size = 512, 3.52 + .max_sectors = 128, 3.53 + // XXXcl todo read_ahead[major] = 8; 3.54 + .name = "xvd", 3.55 }; 3.56 3.57 -/* XXXcl handle cciss after finding out why it's "hacked" in */ 3.58 - 3.59 static struct xlbd_major_info *major_info[NUM_IDE_MAJORS + NUM_SCSI_MAJORS + 3.60 - NUM_VBD_MAJORS]; 3.61 + NUM_VBD_MAJORS]; 3.62 3.63 /* Information about our VBDs. */ 3.64 #define MAX_VBDS 64 3.65 @@ -84,15 +82,15 @@ static vdisk_t *vbd_info; 3.66 3.67 struct request_queue *xlbd_blk_queue = NULL; 3.68 3.69 -#define MAJOR_XEN(dev) ((dev)>>8) 3.70 -#define MINOR_XEN(dev) ((dev) & 0xff) 3.71 +#define MAJOR_XEN(dev) ((dev)>>8) 3.72 +#define MINOR_XEN(dev) ((dev) & 0xff) 3.73 3.74 static struct block_device_operations xlvbd_block_fops = 3.75 { 3.76 - .owner = THIS_MODULE, 3.77 - .open = blkif_open, 3.78 - .release = blkif_release, 3.79 - .ioctl = blkif_ioctl, 3.80 + .owner = THIS_MODULE, 3.81 + .open = blkif_open, 3.82 + .release = blkif_release, 3.83 + .ioctl = blkif_ioctl, 3.84 #if 0 3.85 check_media_change: blkif_check, 3.86 revalidate: blkif_revalidate, 3.87 @@ -122,7 +120,7 @@ static int xlvbd_get_vbd_info(vdisk_t *d 3.88 } 3.89 3.90 if ( (nr = rsp.status) > MAX_VBDS ) 3.91 - nr = MAX_VBDS; 3.92 + nr = MAX_VBDS; 3.93 memcpy(disk_info, buf, nr * sizeof(vdisk_t)); 3.94 3.95 free_page((unsigned long)buf); 3.96 @@ -132,153 +130,154 @@ static int xlvbd_get_vbd_info(vdisk_t *d 3.97 3.98 static struct xlbd_major_info *xlbd_get_major_info(int xd_device, int *minor) 3.99 { 3.100 - int mi_idx, new_major; 3.101 - int xd_major = MAJOR_XEN(xd_device); 3.102 - int xd_minor = MINOR_XEN(xd_device); 3.103 + int mi_idx, new_major; 3.104 + int xd_major = MAJOR_XEN(xd_device); 3.105 + int xd_minor = MINOR_XEN(xd_device); 3.106 3.107 - *minor = xd_minor; 3.108 + *minor = xd_minor; 3.109 3.110 - switch (xd_major) { 3.111 - case IDE0_MAJOR: mi_idx = 0; new_major = IDE0_MAJOR; break; 3.112 - case IDE1_MAJOR: mi_idx = 1; new_major = IDE1_MAJOR; break; 3.113 - case IDE2_MAJOR: mi_idx = 2; new_major = IDE2_MAJOR; break; 3.114 - case IDE3_MAJOR: mi_idx = 3; new_major = IDE3_MAJOR; break; 3.115 - case IDE4_MAJOR: mi_idx = 4; new_major = IDE4_MAJOR; break; 3.116 - case IDE5_MAJOR: mi_idx = 5; new_major = IDE5_MAJOR; break; 3.117 - case IDE6_MAJOR: mi_idx = 6; new_major = IDE6_MAJOR; break; 3.118 - case IDE7_MAJOR: mi_idx = 7; new_major = IDE7_MAJOR; break; 3.119 - case IDE8_MAJOR: mi_idx = 8; new_major = IDE8_MAJOR; break; 3.120 - case IDE9_MAJOR: mi_idx = 9; new_major = IDE9_MAJOR; break; 3.121 - case SCSI_DISK0_MAJOR: mi_idx = 10; new_major = SCSI_DISK0_MAJOR; break; 3.122 - case SCSI_DISK1_MAJOR ... SCSI_DISK7_MAJOR: 3.123 - mi_idx = 11 + xd_major - SCSI_DISK1_MAJOR; 3.124 - new_major = SCSI_DISK1_MAJOR + xd_major - SCSI_DISK1_MAJOR; 3.125 - break; 3.126 - case SCSI_CDROM_MAJOR: mi_idx = 18; new_major = SCSI_CDROM_MAJOR; break; 3.127 - default: mi_idx = 19; new_major = 0;/* XXXcl notyet */ break; 3.128 - } 3.129 + switch (xd_major) { 3.130 + case IDE0_MAJOR: mi_idx = 0; new_major = IDE0_MAJOR; break; 3.131 + case IDE1_MAJOR: mi_idx = 1; new_major = IDE1_MAJOR; break; 3.132 + case IDE2_MAJOR: mi_idx = 2; new_major = IDE2_MAJOR; break; 3.133 + case IDE3_MAJOR: mi_idx = 3; new_major = IDE3_MAJOR; break; 3.134 + case IDE4_MAJOR: mi_idx = 4; new_major = IDE4_MAJOR; break; 3.135 + case IDE5_MAJOR: mi_idx = 5; new_major = IDE5_MAJOR; break; 3.136 + case IDE6_MAJOR: mi_idx = 6; new_major = IDE6_MAJOR; break; 3.137 + case IDE7_MAJOR: mi_idx = 7; new_major = IDE7_MAJOR; break; 3.138 + case IDE8_MAJOR: mi_idx = 8; new_major = IDE8_MAJOR; break; 3.139 + case IDE9_MAJOR: mi_idx = 9; new_major = IDE9_MAJOR; break; 3.140 + case SCSI_DISK0_MAJOR: mi_idx = 10; new_major = SCSI_DISK0_MAJOR; break; 3.141 + case SCSI_DISK1_MAJOR ... SCSI_DISK7_MAJOR: 3.142 + mi_idx = 11 + xd_major - SCSI_DISK1_MAJOR; 3.143 + new_major = SCSI_DISK1_MAJOR + xd_major - SCSI_DISK1_MAJOR; 3.144 + break; 3.145 + case SCSI_CDROM_MAJOR: mi_idx = 18; new_major = SCSI_CDROM_MAJOR; break; 3.146 + default: mi_idx = 19; new_major = 0;/* XXXcl notyet */ break; 3.147 + } 3.148 3.149 - if (major_info[mi_idx]) 3.150 - return major_info[mi_idx]; 3.151 + if (major_info[mi_idx]) 3.152 + return major_info[mi_idx]; 3.153 3.154 - major_info[mi_idx] = kmalloc(sizeof(struct xlbd_major_info), GFP_KERNEL); 3.155 - if (major_info[mi_idx] == NULL) 3.156 - return NULL; 3.157 + major_info[mi_idx] = kmalloc(sizeof(struct xlbd_major_info), GFP_KERNEL); 3.158 + if (major_info[mi_idx] == NULL) 3.159 + return NULL; 3.160 3.161 - memset(major_info[mi_idx], 0, sizeof(struct xlbd_major_info)); 3.162 + memset(major_info[mi_idx], 0, sizeof(struct xlbd_major_info)); 3.163 3.164 - switch (mi_idx) { 3.165 - case 0 ... (NUM_IDE_MAJORS - 1): 3.166 - major_info[mi_idx]->type = &xlbd_ide_type; 3.167 - major_info[mi_idx]->index = mi_idx; 3.168 - break; 3.169 - case NUM_IDE_MAJORS ... (NUM_IDE_MAJORS + NUM_SCSI_MAJORS - 1): 3.170 - major_info[mi_idx]->type = &xlbd_scsi_type; 3.171 - major_info[mi_idx]->index = mi_idx - NUM_IDE_MAJORS; 3.172 - break; 3.173 - case (NUM_IDE_MAJORS + NUM_SCSI_MAJORS) ... 3.174 - (NUM_IDE_MAJORS + NUM_SCSI_MAJORS + NUM_VBD_MAJORS - 1): 3.175 - major_info[mi_idx]->type = &xlbd_vbd_type; 3.176 - major_info[mi_idx]->index = mi_idx - 3.177 - (NUM_IDE_MAJORS + NUM_SCSI_MAJORS); 3.178 - break; 3.179 - } 3.180 - major_info[mi_idx]->major = new_major; 3.181 + switch (mi_idx) { 3.182 + case 0 ... (NUM_IDE_MAJORS - 1): 3.183 + major_info[mi_idx]->type = &xlbd_ide_type; 3.184 + major_info[mi_idx]->index = mi_idx; 3.185 + break; 3.186 + case NUM_IDE_MAJORS ... (NUM_IDE_MAJORS + NUM_SCSI_MAJORS - 1): 3.187 + major_info[mi_idx]->type = &xlbd_scsi_type; 3.188 + major_info[mi_idx]->index = mi_idx - NUM_IDE_MAJORS; 3.189 + break; 3.190 + case (NUM_IDE_MAJORS + NUM_SCSI_MAJORS) ... 3.191 + (NUM_IDE_MAJORS + NUM_SCSI_MAJORS + NUM_VBD_MAJORS - 1): 3.192 + major_info[mi_idx]->type = &xlbd_vbd_type; 3.193 + major_info[mi_idx]->index = mi_idx - 3.194 + (NUM_IDE_MAJORS + NUM_SCSI_MAJORS); 3.195 + break; 3.196 + } 3.197 + major_info[mi_idx]->major = new_major; 3.198 3.199 - if (register_blkdev(major_info[mi_idx]->major, major_info[mi_idx]->type->name)) { 3.200 - printk(KERN_ALERT "XL VBD: can't get major %d with name %s\n", 3.201 - major_info[mi_idx]->major, major_info[mi_idx]->type->name); 3.202 - goto out; 3.203 - } 3.204 + if (register_blkdev(major_info[mi_idx]->major, major_info[mi_idx]->type->name)) { 3.205 + printk(KERN_ALERT "XL VBD: can't get major %d with name %s\n", 3.206 + major_info[mi_idx]->major, major_info[mi_idx]->type->name); 3.207 + goto out; 3.208 + } 3.209 3.210 - devfs_mk_dir(major_info[mi_idx]->type->name); 3.211 + devfs_mk_dir(major_info[mi_idx]->type->name); 3.212 3.213 - return major_info[mi_idx]; 3.214 + return major_info[mi_idx]; 3.215 3.216 out: 3.217 - kfree(major_info[mi_idx]); 3.218 - major_info[mi_idx] = NULL; 3.219 - return NULL; 3.220 + kfree(major_info[mi_idx]); 3.221 + major_info[mi_idx] = NULL; 3.222 + return NULL; 3.223 } 3.224 3.225 static struct gendisk *xlvbd_get_gendisk(struct xlbd_major_info *mi, 3.226 - int xd_minor, vdisk_t *xd) 3.227 + int xd_minor, vdisk_t *xd) 3.228 { 3.229 - struct gendisk *gd; 3.230 - struct xlbd_disk_info *di; 3.231 - int device, partno; 3.232 + struct gendisk *gd; 3.233 + struct xlbd_disk_info *di; 3.234 + int device, partno; 3.235 3.236 - device = MKDEV(mi->major, xd_minor); 3.237 - gd = get_gendisk(device, &partno); 3.238 - if (gd) 3.239 - return gd; 3.240 - 3.241 - di = kmalloc(sizeof(struct xlbd_disk_info), GFP_KERNEL); 3.242 - if (di == NULL) 3.243 - return NULL; 3.244 - di->mi = mi; 3.245 - di->xd_device = xd->device; 3.246 + device = MKDEV(mi->major, xd_minor); 3.247 + gd = get_gendisk(device, &partno); 3.248 + if ( gd != NULL ) 3.249 + return gd; 3.250 3.251 - /* Construct an appropriate gendisk structure. */ 3.252 - gd = alloc_disk(1); 3.253 - if (gd == NULL) 3.254 - goto out; 3.255 + di = kmalloc(sizeof(struct xlbd_disk_info), GFP_KERNEL); 3.256 + if ( di == NULL ) 3.257 + return NULL; 3.258 + di->mi = mi; 3.259 + di->xd_device = xd->device; 3.260 + 3.261 + /* Construct an appropriate gendisk structure. */ 3.262 + gd = alloc_disk(1); 3.263 + if ( gd == NULL ) 3.264 + goto out; 3.265 3.266 - gd->major = mi->major; 3.267 - gd->first_minor = xd_minor; 3.268 - gd->fops = &xlvbd_block_fops; 3.269 - gd->private_data = di; 3.270 - sprintf(gd->disk_name, "%s%c%d", mi->type->name, 3.271 - 'a' + mi->index * mi->type->partn_per_major + 3.272 - (xd_minor >> mi->type->partn_shift), 3.273 - xd_minor & ((1 << mi->type->partn_shift) - 1)); 3.274 - /* sprintf(gd->devfs_name, "%s%s/disc%d", mi->type->name, , ); XXXdevfs */ 3.275 + gd->major = mi->major; 3.276 + gd->first_minor = xd_minor; 3.277 + gd->fops = &xlvbd_block_fops; 3.278 + gd->private_data = di; 3.279 + sprintf(gd->disk_name, "%s%c%d", mi->type->name, 3.280 + 'a' + mi->index * mi->type->partn_per_major + 3.281 + (xd_minor >> mi->type->partn_shift), 3.282 + xd_minor & ((1 << mi->type->partn_shift) - 1)); 3.283 3.284 - set_capacity(gd, xd->capacity); 3.285 + set_capacity(gd, xd->capacity); 3.286 3.287 - if (xlbd_blk_queue == NULL) { 3.288 - xlbd_blk_queue = blk_init_queue(do_blkif_request, 3.289 - &blkif_io_lock); 3.290 - if (xlbd_blk_queue == NULL) 3.291 - goto out; 3.292 - elevator_init(xlbd_blk_queue, "noop"); 3.293 + if ( xlbd_blk_queue == NULL ) 3.294 + { 3.295 + xlbd_blk_queue = blk_init_queue(do_blkif_request, 3.296 + &blkif_io_lock); 3.297 + if ( xlbd_blk_queue == NULL ) 3.298 + goto out; 3.299 + elevator_init(xlbd_blk_queue, "noop"); 3.300 3.301 - /* 3.302 - * Turn off barking 'headactive' mode. We dequeue 3.303 - * buffer heads as soon as we pass them to back-end 3.304 - * driver. 3.305 - */ 3.306 - blk_queue_headactive(xlbd_blk_queue, 0); /* XXXcl: noop according to blkdev.h */ 3.307 - 3.308 - blk_queue_hardsect_size(xlbd_blk_queue, 3.309 - mi->type->hardsect_size); 3.310 - blk_queue_max_sectors(xlbd_blk_queue, mi->type->max_sectors); /* 'hwif->rqsize' if we knew it */ 3.311 + /* 3.312 + * Turn off barking 'headactive' mode. We dequeue 3.313 + * buffer heads as soon as we pass them to back-end 3.314 + * driver. 3.315 + */ 3.316 + blk_queue_headactive(xlbd_blk_queue, 0); 3.317 3.318 - /* XXXcl: set mask to PAGE_SIZE for now, to improve either use 3.319 - - blk_queue_merge_bvec to merge requests with adjacent ma's 3.320 - - the tags infrastructure 3.321 - - the dma infrastructure 3.322 - */ 3.323 - blk_queue_segment_boundary(xlbd_blk_queue, PAGE_SIZE - 1); 3.324 + /* Hard sector size and max sectors impersonate the equiv. hardware. */ 3.325 + blk_queue_hardsect_size( 3.326 + xlbd_blk_queue, mi->type->hardsect_size); 3.327 + blk_queue_max_sectors( 3.328 + xlbd_blk_queue, mi->type->max_sectors); 3.329 + 3.330 + /* Each segment in a request is up to an aligned page in size. */ 3.331 + blk_queue_segment_boundary(xlbd_blk_queue, PAGE_SIZE - 1); 3.332 + blk_queue_max_segment_size(xlbd_blk_queue, PAGE_SIZE); 3.333 3.334 - blk_queue_max_phys_segments(xlbd_blk_queue, 3.335 - BLKIF_MAX_SEGMENTS_PER_REQUEST); 3.336 - blk_queue_max_hw_segments(xlbd_blk_queue, 3.337 - BLKIF_MAX_SEGMENTS_PER_REQUEST); /* XXXcl not needed? */ 3.338 - 3.339 + /* Ensure a merged request will fit in a single I/O ring slot. */ 3.340 + blk_queue_max_phys_segments( 3.341 + xlbd_blk_queue, BLKIF_MAX_SEGMENTS_PER_REQUEST); 3.342 + blk_queue_max_hw_segments( 3.343 + xlbd_blk_queue, BLKIF_MAX_SEGMENTS_PER_REQUEST); 3.344 3.345 - } 3.346 - gd->queue = xlbd_blk_queue; 3.347 + /* Make sure buffer addresses are sector-aligned. */ 3.348 + blk_queue_dma_alignment(xlbd_blk_queue, 511); 3.349 + } 3.350 + gd->queue = xlbd_blk_queue; 3.351 3.352 - add_disk(gd); 3.353 + add_disk(gd); 3.354 3.355 - return gd; 3.356 + return gd; 3.357 3.358 out: 3.359 - if (gd) 3.360 - del_gendisk(gd); 3.361 - kfree(di); 3.362 - return NULL; 3.363 + if ( gd != NULL ) 3.364 + del_gendisk(gd); 3.365 + kfree(di); 3.366 + return NULL; 3.367 } 3.368 3.369 /* 3.370 @@ -294,62 +293,62 @@ static struct gendisk *xlvbd_get_gendisk 3.371 */ 3.372 static int xlvbd_init_device(vdisk_t *xd) 3.373 { 3.374 - struct block_device *bd; 3.375 - struct gendisk *gd; 3.376 - struct xlbd_major_info *mi; 3.377 - int device; 3.378 - int minor; 3.379 + struct block_device *bd; 3.380 + struct gendisk *gd; 3.381 + struct xlbd_major_info *mi; 3.382 + int device; 3.383 + int minor; 3.384 3.385 - int err = -ENOMEM; 3.386 + int err = -ENOMEM; 3.387 3.388 - mi = xlbd_get_major_info(xd->device, &minor); 3.389 - if (mi == NULL) 3.390 - return -EPERM; 3.391 + mi = xlbd_get_major_info(xd->device, &minor); 3.392 + if (mi == NULL) 3.393 + return -EPERM; 3.394 3.395 - device = MKDEV(mi->major, minor); 3.396 + device = MKDEV(mi->major, minor); 3.397 3.398 - if ((bd = bdget(device)) == NULL) 3.399 - return -EPERM; 3.400 + if ((bd = bdget(device)) == NULL) 3.401 + return -EPERM; 3.402 3.403 - /* 3.404 - * Update of partition info, and check of usage count, is protected 3.405 - * by the per-block-device semaphore. 3.406 - */ 3.407 - down(&bd->bd_sem); 3.408 + /* 3.409 + * Update of partition info, and check of usage count, is protected 3.410 + * by the per-block-device semaphore. 3.411 + */ 3.412 + down(&bd->bd_sem); 3.413 3.414 - gd = xlvbd_get_gendisk(mi, minor, xd); 3.415 - if (mi == NULL) { 3.416 - err = -EPERM; 3.417 - goto out; 3.418 - } 3.419 + gd = xlvbd_get_gendisk(mi, minor, xd); 3.420 + if (mi == NULL) { 3.421 + err = -EPERM; 3.422 + goto out; 3.423 + } 3.424 3.425 - if (VDISK_READONLY(xd->info)) 3.426 - set_disk_ro(gd, 1); 3.427 + if (VDISK_READONLY(xd->info)) 3.428 + set_disk_ro(gd, 1); 3.429 3.430 - /* Some final fix-ups depending on the device type */ 3.431 - switch (VDISK_TYPE(xd->info)) { 3.432 - case VDISK_TYPE_CDROM: 3.433 - gd->flags |= GENHD_FL_REMOVABLE | GENHD_FL_CD; 3.434 - /* FALLTHROUGH */ 3.435 - case VDISK_TYPE_FLOPPY: 3.436 - case VDISK_TYPE_TAPE: 3.437 - gd->flags |= GENHD_FL_REMOVABLE; 3.438 - break; 3.439 + /* Some final fix-ups depending on the device type */ 3.440 + switch (VDISK_TYPE(xd->info)) { 3.441 + case VDISK_TYPE_CDROM: 3.442 + gd->flags |= GENHD_FL_REMOVABLE | GENHD_FL_CD; 3.443 + /* FALLTHROUGH */ 3.444 + case VDISK_TYPE_FLOPPY: 3.445 + case VDISK_TYPE_TAPE: 3.446 + gd->flags |= GENHD_FL_REMOVABLE; 3.447 + break; 3.448 3.449 - case VDISK_TYPE_DISK: 3.450 - break; 3.451 + case VDISK_TYPE_DISK: 3.452 + break; 3.453 3.454 - default: 3.455 - printk(KERN_ALERT "XenLinux: unknown device type %d\n", 3.456 - VDISK_TYPE(xd->info)); 3.457 - break; 3.458 - } 3.459 + default: 3.460 + printk(KERN_ALERT "XenLinux: unknown device type %d\n", 3.461 + VDISK_TYPE(xd->info)); 3.462 + break; 3.463 + } 3.464 3.465 - err = 0; 3.466 + err = 0; 3.467 out: 3.468 - up(&bd->bd_sem); 3.469 - bdput(bd); 3.470 - return err; 3.471 + up(&bd->bd_sem); 3.472 + bdput(bd); 3.473 + return err; 3.474 } 3.475 3.476 #if 0 3.477 @@ -393,7 +392,7 @@ static int xlvbd_remove_device(int devic 3.478 { 3.479 /* 1: The VBD is mapped to a partition rather than a whole unit. */ 3.480 invalidate_device(device, 1); 3.481 - gd->part[minor].start_sect = 0; 3.482 + gd->part[minor].start_sect = 0; 3.483 gd->part[minor].nr_sects = 0; 3.484 gd->sizes[minor] = 0; 3.485 3.486 @@ -531,31 +530,31 @@ void xlvbd_update_vbds(void) 3.487 */ 3.488 int xlvbd_init(void) 3.489 { 3.490 - int i; 3.491 + int i; 3.492 3.493 - /* 3.494 - * If compiled as a module, we don't support unloading yet. We 3.495 - * therefore permanently increment the reference count to 3.496 - * disallow it. 3.497 - */ 3.498 - /* MOD_INC_USE_COUNT; */ 3.499 + /* 3.500 + * If compiled as a module, we don't support unloading yet. We 3.501 + * therefore permanently increment the reference count to 3.502 + * disallow it. 3.503 + */ 3.504 + /* MOD_INC_USE_COUNT; */ 3.505 3.506 - memset(major_info, 0, sizeof(major_info)); 3.507 + memset(major_info, 0, sizeof(major_info)); 3.508 3.509 - for (i = 0; i < sizeof(major_info) / sizeof(major_info[0]); i++) { 3.510 - } 3.511 + for (i = 0; i < sizeof(major_info) / sizeof(major_info[0]); i++) { 3.512 + } 3.513 3.514 - vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL); 3.515 - nr_vbds = xlvbd_get_vbd_info(vbd_info); 3.516 + vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL); 3.517 + nr_vbds = xlvbd_get_vbd_info(vbd_info); 3.518 3.519 - if (nr_vbds < 0) { 3.520 - kfree(vbd_info); 3.521 - vbd_info = NULL; 3.522 - nr_vbds = 0; 3.523 - } else { 3.524 - for (i = 0; i < nr_vbds; i++) 3.525 - xlvbd_init_device(&vbd_info[i]); 3.526 - } 3.527 + if (nr_vbds < 0) { 3.528 + kfree(vbd_info); 3.529 + vbd_info = NULL; 3.530 + nr_vbds = 0; 3.531 + } else { 3.532 + for (i = 0; i < nr_vbds; i++) 3.533 + xlvbd_init_device(&vbd_info[i]); 3.534 + } 3.535 3.536 - return 0; 3.537 + return 0; 3.538 }