direct-io.hg
changeset 2927:7f55ce2d0c24
bitkeeper revision 1.1159.170.4 (419215cc4aAUY_9n4TxHpJNmjqysUg)
netfront.c, blkfront.c, balloon.c:
Fix for GCC 2.4.x
netfront.c, blkfront.c, balloon.c:
Fix for GCC 2.4.x
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Wed Nov 10 13:21:16 2004 +0000 (2004-11-10) |
parents | 764b406523af |
children | a7c345b94a88 |
files | linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6.9-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.9-xen-sparse/drivers/xen/netfront/netfront.c |
line diff
1.1 --- a/linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c Mon Nov 08 19:03:43 2004 +0000 1.2 +++ b/linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c Wed Nov 10 13:21:16 2004 +0000 1.3 @@ -32,13 +32,6 @@ 1.4 #include <linux/kernel.h> 1.5 #include <linux/sched.h> 1.6 #include <linux/errno.h> 1.7 - 1.8 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 1.9 -#include <asm-xen/xen_proc.h> 1.10 -#else 1.11 -#include <asm/xen_proc.h> 1.12 -#endif 1.13 - 1.14 #include <linux/mm.h> 1.15 #include <linux/mman.h> 1.16 #include <linux/smp_lock.h> 1.17 @@ -46,20 +39,13 @@ 1.18 #include <linux/bootmem.h> 1.19 #include <linux/highmem.h> 1.20 #include <linux/vmalloc.h> 1.21 - 1.22 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 1.23 +#include <asm-xen/xen_proc.h> 1.24 #include <asm-xen/hypervisor.h> 1.25 #include <asm-xen/ctrl_if.h> 1.26 -#else 1.27 -#include <asm/hypervisor.h> 1.28 -#include <asm/ctrl_if.h> 1.29 -#endif 1.30 - 1.31 #include <asm/pgalloc.h> 1.32 #include <asm/pgtable.h> 1.33 #include <asm/uaccess.h> 1.34 #include <asm/tlb.h> 1.35 - 1.36 #include <linux/list.h> 1.37 1.38 /* USER DEFINES -- THESE SHOULD BE COPIED TO USER-SPACE TOOLS */ 1.39 @@ -89,6 +75,7 @@ static unsigned long current_pages, most 1.40 #define PAGE_TO_LIST(p) ( &p->list ) 1.41 #define LIST_TO_PAGE(l) ( list_entry(l, struct page, list) ) 1.42 #define UNLIST_PAGE(p) ( list_del(&p->list) ) 1.43 +#define pte_offset_kernel pte_offset 1.44 #endif 1.45 1.46 /* List of ballooned pages, threaded through the mem_map array. */ 1.47 @@ -128,11 +115,7 @@ static inline pte_t *get_ptep(unsigned l 1.48 pmd = pmd_offset(pgd, addr); 1.49 if ( pmd_none(*pmd) || pmd_bad(*pmd) ) BUG(); 1.50 1.51 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 1.52 ptep = pte_offset_kernel(pmd, addr); 1.53 -#else 1.54 - ptep = pte_offset(pmd, addr); 1.55 -#endif 1.56 1.57 return ptep; 1.58 } 1.59 @@ -382,11 +365,7 @@ static void pagetable_extend (int cur_lo 1.60 } 1.61 kpgd = pgd_offset_k((unsigned long)pte_base); 1.62 kpmd = pmd_offset(kpgd, (unsigned long)pte_base); 1.63 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 1.64 kpte = pte_offset_kernel(kpmd, (unsigned long)pte_base); 1.65 -#else 1.66 - kpte = pte_offset(kpmd, (unsigned long)pte_base); 1.67 -#endif 1.68 queue_l1_entry_update(kpte, 1.69 (*(unsigned long *)kpte)&~_PAGE_RW); 1.70 set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base))); 1.71 @@ -609,7 +588,8 @@ static int balloon_read(struct file *fil 1.72 if (len>count) len = count; 1.73 if (len<0) len = 0; 1.74 1.75 - copy_to_user(buffer, priv_bufp, len); 1.76 + if ( copy_to_user(buffer, priv_bufp, len) != 0 ) 1.77 + return -EFAULT; 1.78 1.79 *offp += len; 1.80 return len; 1.81 @@ -619,9 +599,9 @@ static struct file_operations balloon_fo 1.82 .read = balloon_read, 1.83 .write = balloon_write 1.84 }; 1.85 + 1.86 #else 1.87 1.88 - 1.89 static int balloon_write(struct file *file, const char *buffer, 1.90 u_long count, void *data) 1.91 { 1.92 @@ -689,7 +669,6 @@ static int balloon_write(struct file *fi 1.93 } 1.94 } 1.95 1.96 - 1.97 return len; 1.98 } 1.99 1.100 @@ -707,11 +686,8 @@ static int balloon_read(char *page, char 1.101 return len; 1.102 } 1.103 1.104 - 1.105 - 1.106 #endif 1.107 1.108 - 1.109 static int __init balloon_init(void) 1.110 { 1.111 printk(KERN_ALERT "Starting Xen Balloon driver\n");
2.1 --- a/linux-2.6.9-xen-sparse/drivers/xen/blkfront/blkfront.c Mon Nov 08 19:03:43 2004 +0000 2.2 +++ b/linux-2.6.9-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Nov 10 13:21:16 2004 +0000 2.3 @@ -75,10 +75,11 @@ static char * blkif_status_name[] = { 2.4 2.5 #if 1 2.6 #define dprintf(fmt, args...) \ 2.7 -printk(KERN_ALERT "[XEN:%s:%s:%d] " fmt, __FUNCTION__, __FILE__, __LINE__, ##args) 2.8 +printk(KERN_ALERT "[XEN:%s:%s:%d] " fmt, \ 2.9 +__FUNCTION__, __FILE__, __LINE__, ##args) 2.10 #endif 2.11 2.12 -#define WPRINTK(fmt, args...) printk(KERN_WARNING "[XEN] " fmt, ##args) 2.13 +#define WPRINTK(fmt, args...) printk(KERN_WARNING "xen_blk: " fmt, ##args) 2.14 2.15 static int blkif_handle = 0; 2.16 static unsigned int blkif_state = BLKIF_STATE_CLOSED; 2.17 @@ -102,14 +103,6 @@ static int recovery = 0; /* "R 2.18 #define BLKIF_RING_FULL (((req_prod - resp_cons) == BLKIF_RING_SIZE) || \ 2.19 (blkif_state != BLKIF_STATE_CONNECTED)) 2.20 2.21 -static inline void translate_req_to_mfn(blkif_request_t *xreq, 2.22 - blkif_request_t *req); 2.23 - 2.24 -static inline void translate_req_to_pfn(blkif_request_t *xreq, 2.25 - blkif_request_t *req); 2.26 - 2.27 -static inline void flush_requests(void); 2.28 - 2.29 static void kick_pending_request_queues(void); 2.30 2.31 int __init xlblk_init(void); 2.32 @@ -137,12 +130,61 @@ static inline void ADD_ID_TO_FREELIST( u 2.33 } 2.34 2.35 2.36 +/************************ COMMON CODE (inlined) ************************/ 2.37 + 2.38 +/* Kernel-specific definitions used in the common code */ 2.39 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 2.40 +#define DISABLE_SCATTERGATHER() 2.41 +#else 2.42 +#define DISABLE_SCATTERGATHER() (sg_operation = -1) 2.43 +#endif 2.44 + 2.45 +static inline void translate_req_to_pfn(blkif_request_t *xreq, 2.46 + blkif_request_t *req) 2.47 +{ 2.48 + int i; 2.49 + 2.50 + xreq->operation = req->operation; 2.51 + xreq->nr_segments = req->nr_segments; 2.52 + xreq->device = req->device; 2.53 + /* preserve id */ 2.54 + xreq->sector_number = req->sector_number; 2.55 + 2.56 + for ( i = 0; i < req->nr_segments; i++ ) 2.57 + xreq->frame_and_sects[i] = machine_to_phys(req->frame_and_sects[i]); 2.58 +} 2.59 + 2.60 +static inline void translate_req_to_mfn(blkif_request_t *xreq, 2.61 + blkif_request_t *req) 2.62 +{ 2.63 + int i; 2.64 + 2.65 + xreq->operation = req->operation; 2.66 + xreq->nr_segments = req->nr_segments; 2.67 + xreq->device = req->device; 2.68 + xreq->id = req->id; /* copy id (unlike above) */ 2.69 + xreq->sector_number = req->sector_number; 2.70 + 2.71 + for ( i = 0; i < req->nr_segments; i++ ) 2.72 + xreq->frame_and_sects[i] = phys_to_machine(req->frame_and_sects[i]); 2.73 +} 2.74 + 2.75 + 2.76 +static inline void flush_requests(void) 2.77 +{ 2.78 + DISABLE_SCATTERGATHER(); 2.79 + wmb(); /* Ensure that the frontend can see the requests. */ 2.80 + blk_ring->req_prod = req_prod; 2.81 + notify_via_evtchn(blkif_evtchn); 2.82 +} 2.83 + 2.84 + 2.85 + 2.86 + 2.87 /************************** KERNEL VERSION 2.6 **************************/ 2.88 2.89 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 2.90 2.91 -#define DISABLE_SCATTERGATHER() 2.92 - 2.93 __initcall(xlblk_init); 2.94 2.95 #if ENABLE_VBD_UPDATE 2.96 @@ -468,8 +510,6 @@ static request_queue_t *pending_queues[M 2.97 static int nr_pending; 2.98 2.99 2.100 -#define DISABLE_SCATTERGATHER() (sg_operation = -1) 2.101 - 2.102 #define blkif_io_lock io_request_lock 2.103 2.104 /*============================================================================*/ 2.105 @@ -1009,49 +1049,6 @@ static void blkif_int(int irq, void *dev 2.106 /***************************** COMMON CODE *******************************/ 2.107 2.108 2.109 -static inline void translate_req_to_pfn(blkif_request_t *xreq, 2.110 - blkif_request_t *req) 2.111 -{ 2.112 - int i; 2.113 - 2.114 - xreq->operation = req->operation; 2.115 - xreq->nr_segments = req->nr_segments; 2.116 - xreq->device = req->device; 2.117 - /* preserve id */ 2.118 - xreq->sector_number = req->sector_number; 2.119 - 2.120 - for ( i = 0; i < req->nr_segments; i++ ){ 2.121 - xreq->frame_and_sects[i] = machine_to_phys(req->frame_and_sects[i]); 2.122 - } 2.123 -} 2.124 - 2.125 -static inline void translate_req_to_mfn(blkif_request_t *xreq, 2.126 - blkif_request_t *req) 2.127 -{ 2.128 - int i; 2.129 - 2.130 - xreq->operation = req->operation; 2.131 - xreq->nr_segments = req->nr_segments; 2.132 - xreq->device = req->device; 2.133 - xreq->id = req->id; /* copy id (unlike above) */ 2.134 - xreq->sector_number = req->sector_number; 2.135 - 2.136 - for ( i = 0; i < req->nr_segments; i++ ){ 2.137 - xreq->frame_and_sects[i] = phys_to_machine(req->frame_and_sects[i]); 2.138 - } 2.139 -} 2.140 - 2.141 - 2.142 - 2.143 -static inline void flush_requests(void) 2.144 -{ 2.145 - DISABLE_SCATTERGATHER(); 2.146 - wmb(); /* Ensure that the frontend can see the requests. */ 2.147 - blk_ring->req_prod = req_prod; 2.148 - notify_via_evtchn(blkif_evtchn); 2.149 -} 2.150 - 2.151 - 2.152 void blkif_control_send(blkif_request_t *req, blkif_response_t *rsp) 2.153 { 2.154 unsigned long flags, id; 2.155 @@ -1096,7 +1093,8 @@ void blkif_control_send(blkif_request_t 2.156 2.157 2.158 /* Send a driver status notification to the domain controller. */ 2.159 -static void send_driver_status(int ok){ 2.160 +static void send_driver_status(int ok) 2.161 +{ 2.162 ctrl_msg_t cmsg = { 2.163 .type = CMSG_BLKIF_FE, 2.164 .subtype = CMSG_BLKIF_FE_DRIVER_STATUS, 2.165 @@ -1110,7 +1108,8 @@ static void send_driver_status(int ok){ 2.166 } 2.167 2.168 /* Tell the controller to bring up the interface. */ 2.169 -static void blkif_send_interface_connect(void){ 2.170 +static void blkif_send_interface_connect(void) 2.171 +{ 2.172 ctrl_msg_t cmsg = { 2.173 .type = CMSG_BLKIF_FE, 2.174 .subtype = CMSG_BLKIF_FE_INTERFACE_CONNECT, 2.175 @@ -1126,9 +1125,8 @@ static void blkif_send_interface_connect 2.176 2.177 static void blkif_free(void) 2.178 { 2.179 + printk(KERN_INFO "xen_blk: Recovering virtual block device driver\n"); 2.180 2.181 - printk(KERN_INFO "[XEN] Recovering virtual block device driver\n"); 2.182 - 2.183 /* Prevent new requests being issued until we fix things up. */ 2.184 spin_lock_irq(&blkif_io_lock); 2.185 recovery = 1; 2.186 @@ -1136,9 +1134,10 @@ static void blkif_free(void) 2.187 spin_unlock_irq(&blkif_io_lock); 2.188 2.189 /* Free resources associated with old device channel. */ 2.190 - if(blk_ring){ 2.191 + if ( blk_ring != NULL ) 2.192 + { 2.193 free_page((unsigned long)blk_ring); 2.194 - blk_ring = 0; 2.195 + blk_ring = NULL; 2.196 } 2.197 free_irq(blkif_irq, NULL); 2.198 blkif_irq = 0; 2.199 @@ -1147,7 +1146,8 @@ static void blkif_free(void) 2.200 blkif_evtchn = 0; 2.201 } 2.202 2.203 -static void blkif_close(void){ 2.204 +static void blkif_close(void) 2.205 +{ 2.206 } 2.207 2.208 /* Move from CLOSED to DISCONNECTED state. */ 2.209 @@ -1162,22 +1162,23 @@ static void blkif_disconnect(void) 2.210 2.211 static void blkif_reset(void) 2.212 { 2.213 - printk(KERN_INFO "[XEN] Recovering virtual block device driver\n"); 2.214 + printk(KERN_INFO "xen_blk: Recovering virtual block device driver\n"); 2.215 blkif_free(); 2.216 blkif_disconnect(); 2.217 } 2.218 2.219 static void blkif_recover(void) 2.220 { 2.221 - 2.222 int i; 2.223 2.224 /* Hmm, requests might be re-ordered when we re-issue them. 2.225 * This will need to be fixed once we have barriers */ 2.226 2.227 /* Stage 1 : Find active and move to safety. */ 2.228 - for ( i = 0; i < BLKIF_RING_SIZE; i++ ) { 2.229 - if ( rec_ring[i].id >= PAGE_OFFSET ) { 2.230 + for ( i = 0; i < BLKIF_RING_SIZE; i++ ) 2.231 + { 2.232 + if ( rec_ring[i].id >= PAGE_OFFSET ) 2.233 + { 2.234 translate_req_to_mfn( 2.235 &blk_ring->ring[req_prod].req, &rec_ring[i]); 2.236 req_prod++; 2.237 @@ -1187,16 +1188,16 @@ static void blkif_recover(void) 2.238 printk(KERN_ALERT"blkfront: recovered %d descriptors\n",req_prod); 2.239 2.240 /* Stage 2 : Set up shadow list. */ 2.241 - for ( i = 0; i < req_prod; i++ ) { 2.242 + for ( i = 0; i < req_prod; i++ ) 2.243 + { 2.244 rec_ring[i].id = blk_ring->ring[i].req.id; 2.245 blk_ring->ring[i].req.id = i; 2.246 translate_req_to_pfn(&rec_ring[i], &blk_ring->ring[i].req); 2.247 } 2.248 2.249 /* Stage 3 : Set up free list. */ 2.250 - for ( ; i < BLKIF_RING_SIZE; i++ ){ 2.251 + for ( ; i < BLKIF_RING_SIZE; i++ ) 2.252 rec_ring[i].id = i+1; 2.253 - } 2.254 rec_ring_free = req_prod; 2.255 rec_ring[BLKIF_RING_SIZE-1].id = 0x0fffffff; 2.256 2.257 @@ -1224,14 +1225,18 @@ static void blkif_connect(blkif_fe_inter 2.258 blkif_irq = bind_evtchn_to_irq(blkif_evtchn); 2.259 2.260 err = request_irq(blkif_irq, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL); 2.261 - if(err){ 2.262 - printk(KERN_ALERT "[XEN] blkfront request_irq failed (err=%d)\n", err); 2.263 + if ( err ) 2.264 + { 2.265 + printk(KERN_ALERT "xen_blk: request_irq failed (err=%d)\n", err); 2.266 return; 2.267 } 2.268 2.269 - if ( recovery ) { 2.270 + if ( recovery ) 2.271 + { 2.272 blkif_recover(); 2.273 - } else { 2.274 + } 2.275 + else 2.276 + { 2.277 /* Transition to connected in case we need to do 2.278 * a partition probe on a whole disk. */ 2.279 blkif_state = BLKIF_STATE_CONNECTED; 2.280 @@ -1255,15 +1260,17 @@ static void unexpected(blkif_fe_interfac 2.281 2.282 static void blkif_status(blkif_fe_interface_status_t *status) 2.283 { 2.284 - if (status->handle != blkif_handle) { 2.285 + if ( status->handle != blkif_handle ) 2.286 + { 2.287 WPRINTK(" Invalid blkif: handle=%u", status->handle); 2.288 return; 2.289 } 2.290 2.291 - switch (status->status) { 2.292 - 2.293 + switch ( status->status ) 2.294 + { 2.295 case BLKIF_INTERFACE_STATUS_CLOSED: 2.296 - switch(blkif_state){ 2.297 + switch ( blkif_state ) 2.298 + { 2.299 case BLKIF_STATE_CLOSED: 2.300 unexpected(status); 2.301 break; 2.302 @@ -1276,7 +1283,8 @@ static void blkif_status(blkif_fe_interf 2.303 break; 2.304 2.305 case BLKIF_INTERFACE_STATUS_DISCONNECTED: 2.306 - switch(blkif_state){ 2.307 + switch ( blkif_state ) 2.308 + { 2.309 case BLKIF_STATE_CLOSED: 2.310 blkif_disconnect(); 2.311 break; 2.312 @@ -1289,7 +1297,8 @@ static void blkif_status(blkif_fe_interf 2.313 break; 2.314 2.315 case BLKIF_INTERFACE_STATUS_CONNECTED: 2.316 - switch(blkif_state){ 2.317 + switch ( blkif_state ) 2.318 + { 2.319 case BLKIF_STATE_CLOSED: 2.320 unexpected(status); 2.321 blkif_disconnect(); 2.322 @@ -1306,7 +1315,8 @@ static void blkif_status(blkif_fe_interf 2.323 break; 2.324 2.325 case BLKIF_INTERFACE_STATUS_CHANGED: 2.326 - switch(blkif_state){ 2.327 + switch ( blkif_state ) 2.328 + { 2.329 case BLKIF_STATE_CLOSED: 2.330 case BLKIF_STATE_DISCONNECTED: 2.331 unexpected(status); 2.332 @@ -1346,7 +1356,8 @@ static void blkif_ctrlif_rx(ctrl_msg_t * 2.333 ctrl_if_send_response(msg); 2.334 } 2.335 2.336 -int wait_for_blkif(void){ 2.337 +int wait_for_blkif(void) 2.338 +{ 2.339 int err = 0; 2.340 int i; 2.341 send_driver_status(1); 2.342 @@ -1362,8 +1373,9 @@ int wait_for_blkif(void){ 2.343 schedule_timeout(1); 2.344 } 2.345 2.346 - if (blkif_state != BLKIF_STATE_CONNECTED){ 2.347 - printk(KERN_INFO "[XEN] Timeout connecting block device driver!\n"); 2.348 + if ( blkif_state != BLKIF_STATE_CONNECTED ) 2.349 + { 2.350 + printk(KERN_INFO "xen_blk: Timeout connecting to device!\n"); 2.351 err = -ENOSYS; 2.352 } 2.353 return err; 2.354 @@ -1373,17 +1385,15 @@ int __init xlblk_init(void) 2.355 { 2.356 int i; 2.357 2.358 - if ( (xen_start_info.flags & SIF_INITDOMAIN) 2.359 - || (xen_start_info.flags & SIF_BLK_BE_DOMAIN) ) 2.360 + if ( (xen_start_info.flags & SIF_INITDOMAIN) || 2.361 + (xen_start_info.flags & SIF_BLK_BE_DOMAIN) ) 2.362 return 0; 2.363 2.364 - printk(KERN_INFO "[XEN] Initialising virtual block device driver\n"); 2.365 + printk(KERN_INFO "xen_blk: Initialising virtual block device driver\n"); 2.366 2.367 rec_ring_free = 0; 2.368 - for (i=0; i<BLKIF_RING_SIZE; i++) 2.369 - { 2.370 + for ( i = 0; i < BLKIF_RING_SIZE; i++ ) 2.371 rec_ring[i].id = i+1; 2.372 - } 2.373 rec_ring[BLKIF_RING_SIZE-1].id = 0x0fffffff; 2.374 2.375 (void)ctrl_if_register_receiver(CMSG_BLKIF_FE, blkif_ctrlif_rx,
3.1 --- a/linux-2.6.9-xen-sparse/drivers/xen/netfront/netfront.c Mon Nov 08 19:03:43 2004 +0000 3.2 +++ b/linux-2.6.9-xen-sparse/drivers/xen/netfront/netfront.c Wed Nov 10 13:21:16 2004 +0000 3.3 @@ -157,14 +157,14 @@ static char *be_state_name[] = { 3.4 3.5 #if DEBUG 3.6 #define DPRINTK(fmt, args...) \ 3.7 - printk(KERN_ALERT "[XEN] (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args) 3.8 + printk(KERN_ALERT "xen_net (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args) 3.9 #else 3.10 #define DPRINTK(fmt, args...) ((void)0) 3.11 #endif 3.12 #define IPRINTK(fmt, args...) \ 3.13 - printk(KERN_INFO "[XEN] " fmt, ##args) 3.14 + printk(KERN_INFO "xen_net: " fmt, ##args) 3.15 #define WPRINTK(fmt, args...) \ 3.16 - printk(KERN_WARNING "[XEN] " fmt, ##args) 3.17 + printk(KERN_WARNING "xen_net: " fmt, ##args) 3.18 3.19 static struct net_device *find_dev_by_handle(unsigned int handle) 3.20 { 3.21 @@ -769,10 +769,6 @@ static void network_connect(struct net_d 3.22 wmb(); 3.23 np->rx->req_prod = requeue_idx; 3.24 3.25 - printk(KERN_ALERT "[XEN] Netfront recovered tx=%d rxfree=%d\n", 3.26 - np->tx->req_prod,np->rx->req_prod); 3.27 - 3.28 - 3.29 /* Step 3: All public and private state should now be sane. Get 3.30 * ready to start sending and receiving packets and give the driver 3.31 * domain a kick because we've probably just requeued some