ia64/xen-unstable

changeset 270:565a9104c380

bitkeeper revision 1.116 (3e6bd5fanPF3nYb2uWLHO7p0PnxDhg)

xl_block.c, blkdev.h, xen_block.c:
Improved error handling for blkdev data accesses. Added sanity checking for read requests -- test if buffer modified.
author kaf24@labyrinth.cl.cam.ac.uk
date Mon Mar 10 00:02:02 2003 +0000 (2003-03-10)
parents f51eab080fa1
children 0bd810c3a05e
files xen/drivers/block/xen_block.c xen/include/xeno/blkdev.h xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c
line diff
     1.1 --- a/xen/drivers/block/xen_block.c	Sun Mar 09 20:51:18 2003 +0000
     1.2 +++ b/xen/drivers/block/xen_block.c	Mon Mar 10 00:02:02 2003 +0000
     1.3 @@ -17,8 +17,10 @@
     1.4  #include <xeno/keyhandler.h>
     1.5  #include <xeno/interrupt.h>
     1.6  #include <xeno/segment.h>
     1.7 +#include <asm/domain_page.h> /* TEST_READ_VALIDITY */
     1.8  
     1.9  #if 1
    1.10 +#define TEST_READ_VALIDITY
    1.11  #define DPRINTK(_f, _a...) printk( _f , ## _a )
    1.12  #else
    1.13  #define DPRINTK(_f, _a...) ((void)0)
    1.14 @@ -198,6 +200,23 @@ static void end_block_io_op(struct buffe
    1.15      unsigned long flags;
    1.16      pending_req_t *pending_req = bh->pending_req;
    1.17  
    1.18 +    /* An error fails the entire request. */
    1.19 +    if ( !uptodate )
    1.20 +    {
    1.21 +        DPRINTK("Buffer not up-to-date at end of operation\n");
    1.22 +        pending_req->status = 1;
    1.23 +    }
    1.24 +#ifdef TEST_READ_VALIDITY
    1.25 +    else
    1.26 +    {
    1.27 +        unsigned long *buff = map_domain_mem(virt_to_phys(bh->b_data));
    1.28 +        if ( (buff[  0] == 0xdeadbeef) &&
    1.29 +             (buff[127] == 0xdeadbeef) )
    1.30 +            printk("A really fucked buffer at %ld\n", bh->b_rsector);
    1.31 +        unmap_domain_mem(buff);
    1.32 +    }
    1.33 +#endif
    1.34 +
    1.35      unlock_buffer(pending_req->domain, 
    1.36                    virt_to_phys(bh->b_data), 
    1.37                    bh->b_size, 
    1.38 @@ -206,7 +225,7 @@ static void end_block_io_op(struct buffe
    1.39      if ( atomic_dec_and_test(&pending_req->pendcnt) )
    1.40      {
    1.41          make_response(pending_req->domain, pending_req->id,
    1.42 -                      pending_req->operation, uptodate ? 0 : 1);
    1.43 +                      pending_req->operation, pending_req->status);
    1.44          spin_lock_irqsave(&pend_prod_lock, flags);
    1.45          pending_ring[pending_prod] = pending_req - pending_reqs;
    1.46          PENDREQ_IDX_INC(pending_prod);
    1.47 @@ -572,6 +591,7 @@ static void dispatch_rw_block_io(struct 
    1.48      pending_req->domain    = p;
    1.49      pending_req->id        = req->id;
    1.50      pending_req->operation = operation;
    1.51 +    pending_req->status    = 0;
    1.52      atomic_set(&pending_req->pendcnt, nr_psegs);
    1.53  
    1.54      /* Now we pass each segment down to the real blkdev layer. */
    1.55 @@ -595,6 +615,12 @@ static void dispatch_rw_block_io(struct 
    1.56          } 
    1.57          else
    1.58          {
    1.59 +#ifdef TEST_READ_VALIDITY
    1.60 +            unsigned long *buff = map_domain_mem(phys_seg[i].buffer);
    1.61 +            buff[  0] = 0xdeadbeef;
    1.62 +            buff[127] = 0xdeadbeef;
    1.63 +            unmap_domain_mem(buff);
    1.64 +#endif
    1.65              bh->b_state = (1 << BH_Mapped) | (1 << BH_Read);
    1.66          }
    1.67  
     2.1 --- a/xen/include/xeno/blkdev.h	Sun Mar 09 20:51:18 2003 +0000
     2.2 +++ b/xen/include/xeno/blkdev.h	Mon Mar 10 00:02:02 2003 +0000
     2.3 @@ -20,6 +20,7 @@ typedef struct {
     2.4      unsigned long       id;
     2.5      atomic_t            pendcnt;
     2.6      unsigned short      operation;
     2.7 +    unsigned short      status;
     2.8  } pending_req_t;
     2.9  
    2.10  extern kdev_t xendev_to_physdev(unsigned short xendev);
     3.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Sun Mar 09 20:51:18 2003 +0000
     3.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Mon Mar 10 00:02:02 2003 +0000
     3.3 @@ -440,13 +440,15 @@ static void xlblk_response_int(int irq, 
     3.4  	{
     3.5          case XEN_BLOCK_READ:
     3.6          case XEN_BLOCK_WRITE:
     3.7 +            if ( bret->status )
     3.8 +                printk(KERN_ALERT "Bad return from blkdev data request\n");
     3.9              for ( bh = (struct buffer_head *)bret->id; 
    3.10                    bh != NULL; 
    3.11                    bh = next_bh )
    3.12              {
    3.13                  next_bh = bh->b_reqnext;
    3.14                  bh->b_reqnext = NULL;
    3.15 -                bh->b_end_io(bh, 1);
    3.16 +                bh->b_end_io(bh, !bret->status);
    3.17              }
    3.18  	    break;
    3.19  	    
    3.20 @@ -454,6 +456,8 @@ static void xlblk_response_int(int irq, 
    3.21          case XEN_BLOCK_SEG_DELETE:
    3.22          case XEN_BLOCK_PROBE_SEG:
    3.23          case XEN_BLOCK_PROBE_BLK:
    3.24 +            if ( bret->status )
    3.25 +                printk(KERN_ALERT "Bad return from blkdev control request\n");
    3.26              xlblk_control_msg_pending = 0;
    3.27              break;
    3.28  	  
    3.29 @@ -488,7 +492,7 @@ int xenolinux_control_msg(int operation,
    3.30      char *aligned_buf;
    3.31  
    3.32      /* We copy from an aligned buffer, as interface needs sector alignment. */
    3.33 -    aligned_buf = get_free_page(GFP_KERNEL);
    3.34 +    aligned_buf = (char *)get_free_page(GFP_KERNEL);
    3.35      if ( aligned_buf == NULL ) BUG();
    3.36  
    3.37      xlblk_control_msg_pending = 1;
    3.38 @@ -501,7 +505,7 @@ int xenolinux_control_msg(int operation,
    3.39      while ( xlblk_control_msg_pending ) barrier();
    3.40  
    3.41      memcpy(buffer, aligned_buf, size);
    3.42 -    free_page(aligned_buf);
    3.43 +    free_page((unsigned long)aligned_buf);
    3.44      
    3.45      return 0;
    3.46  }