direct-io.hg

changeset 2194:d67491ea6dcd

bitkeeper revision 1.1159.17.14 (411b1b16kI8OhQTxCf1kbM8dV6LXcA)

prepare 2.6 blkfront for suspend/resume
author iap10@labyrinth.cl.cam.ac.uk
date Thu Aug 12 07:24:06 2004 +0000 (2004-08-12)
parents 85100363043c
children 5de156da549c 62c8d53c00cf
files linux-2.6.7-xen-sparse/drivers/char/mem.c linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c tools/misc/xen-clone
line diff
     1.1 --- a/linux-2.6.7-xen-sparse/drivers/char/mem.c	Thu Aug 12 06:16:22 2004 +0000
     1.2 +++ b/linux-2.6.7-xen-sparse/drivers/char/mem.c	Thu Aug 12 07:24:06 2004 +0000
     1.3 @@ -252,7 +252,7 @@ static int mmap_mem(struct file * file, 
     1.4  	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
     1.5  	if (direct_remap_area_pages(vma->vm_mm, vma->vm_start, offset, 
     1.6  				vma->vm_end-vma->vm_start, vma->vm_page_prot,
     1.7 -				(domid_t)file->private_data))
     1.8 +				(domid_t)(unsigned long)file->private_data))
     1.9  		return -EAGAIN;
    1.10  	return 0;
    1.11  }
     2.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Aug 12 06:16:22 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Aug 12 07:24:06 2004 +0000
     2.3 @@ -50,6 +50,32 @@ static int recovery = 0;           /* "R
     2.4  static request_queue_t *pending_queues[MAX_PENDING];
     2.5  static int nr_pending;
     2.6  
     2.7 +inline void translate_req_to_pfn( blkif_request_t * xreq, blkif_request_t * req)
     2.8 +{
     2.9 +    int i;
    2.10 +    
    2.11 +    *xreq=*req; 
    2.12 +    for ( i=0; i<req->nr_segments; i++ )
    2.13 +    {	
    2.14 +	xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) |
    2.15 +	    (machine_to_phys_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<<PAGE_SHIFT);	
    2.16 +    }
    2.17 +    return xreq;
    2.18 +}
    2.19 +
    2.20 +inline void translate_req_to_mfn( blkif_request_t * xreq, blkif_request_t * req)
    2.21 +{
    2.22 +    int i;
    2.23 +
    2.24 +    *xreq=*req; 
    2.25 +    for ( i=0; i<req->nr_segments; i++ )
    2.26 +    {	
    2.27 +	xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) |
    2.28 +	    (phys_to_machine_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<<PAGE_SHIFT);
    2.29 +    }
    2.30 +    return xreq;
    2.31 +}
    2.32 +
    2.33  static inline void flush_requests(void)
    2.34  {
    2.35  
    2.36 @@ -243,8 +269,10 @@ static int blkif_queue_request(struct re
    2.37  	req_prod++;
    2.38  
    2.39          /* Keep a private copy so we can reissue requests when recovering. */
    2.40 -        blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req =
    2.41 -                *ring_req;
    2.42 +        translate_req_to_pfn(
    2.43 +	    &blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req,
    2.44 +            ring_req);
    2.45 +
    2.46          blk_ring_rec->req_prod++;
    2.47  
    2.48          return 0;
    2.49 @@ -407,9 +435,10 @@ void blkif_control_send(blkif_request_t 
    2.50          goto retry;
    2.51      }
    2.52  
    2.53 -    memcpy(&blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req, req, sizeof(*req));
    2.54 -    memcpy(&blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req,
    2.55 -           req, sizeof(*req));
    2.56 +    blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req = *req;    
    2.57 +    translate_req_to_pfn(&blk_ring_rec->ring[
    2.58 +	MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req,req);
    2.59 +
    2.60      req_prod++;
    2.61      flush_requests();
    2.62  
    2.63 @@ -497,9 +526,9 @@ static void blkif_status_change(blkif_fe
    2.64  
    2.65          if ( recovery )
    2.66          {
    2.67 -            int i;
    2.68 +            int i,j;
    2.69  
    2.70 -	    /* Shouldn't need the blkif_io_lock here - the device is
    2.71 +	    /* Shouldn't need the io_request_lock here - the device is
    2.72  	     * plugged and the recovery flag prevents the interrupt handler
    2.73  	     * changing anything. */
    2.74  
    2.75 @@ -507,18 +536,24 @@ static void blkif_status_change(blkif_fe
    2.76              for ( i = 0;
    2.77  		  resp_cons_rec < blk_ring_rec->req_prod;
    2.78                    resp_cons_rec++, i++ )
    2.79 -            {
    2.80 -                blk_ring->ring[i].req
    2.81 -                    = blk_ring_rec->ring[MASK_BLKIF_IDX(resp_cons_rec)].req;
    2.82 +            {                
    2.83 +                translate_req_to_mfn(&blk_ring->ring[i].req,
    2.84 +				     &blk_ring_rec->ring[
    2.85 +					 MASK_BLKIF_IDX(resp_cons_rec)].req);
    2.86              }
    2.87  
    2.88 -            /* Reset the private block ring to match the new ring. */
    2.89 -            memcpy(blk_ring_rec, blk_ring, sizeof(*blk_ring));
    2.90 +            /* Reset the private block ring to match the new ring. */	    
    2.91 +	    for( j=0; j<i; j++ )
    2.92 +	    {		
    2.93 +		translate_req_to_pfn(
    2.94 +		    &blk_ring_rec->ring[j].req,
    2.95 +		    &blk_ring->ring[j].req);
    2.96 +	    }
    2.97 +
    2.98              resp_cons_rec = 0;
    2.99  
   2.100              /* blk_ring->req_prod will be set when we flush_requests().*/
   2.101              blk_ring_rec->req_prod = req_prod = i;
   2.102 -
   2.103              wmb();
   2.104  
   2.105              /* Switch off recovery mode, using a memory barrier to ensure that
   2.106 @@ -677,4 +712,14 @@ void blkdev_suspend(void)
   2.107  
   2.108  void blkdev_resume(void)
   2.109  {
   2.110 +    ctrl_msg_t                       cmsg;
   2.111 +    blkif_fe_driver_status_changed_t st;    
   2.112 +
   2.113 +    /* Send a driver-UP notification to the domain controller. */
   2.114 +    cmsg.type      = CMSG_BLKIF_FE;
   2.115 +    cmsg.subtype   = CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED;
   2.116 +    cmsg.length    = sizeof(blkif_fe_driver_status_changed_t);
   2.117 +    st.status      = BLKIF_DRIVER_STATUS_UP;
   2.118 +    memcpy(cmsg.msg, &st, sizeof(st));
   2.119 +    ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
   2.120  }
     3.1 --- a/tools/misc/xen-clone	Thu Aug 12 06:16:22 2004 +0000
     3.2 +++ b/tools/misc/xen-clone	Thu Aug 12 07:24:06 2004 +0000
     3.3 @@ -72,7 +72,7 @@ then
     3.4   make -j4 world
     3.5   make -j4 linux26
     3.6   cd ../install/boot
     3.7 - [ -r vmlinuz-${LINUX_VER}-xen0 ] && ln -s vmlinuz-${LINUX_VER}-xen0 xenolinux.gz
     3.8 + [ -r vmlinuz-2.4.*-xen0 ] && ln -s vmlinuz-2.4.*-xen0 xenolinux.gz
     3.9    
    3.10  else
    3.11   # old style repository without 'make world'