ia64/xen-unstable

changeset 396:d7ae20d6346a

bitkeeper revision 1.187 (3ead25859Pbawg2pQ_-rP3ATdde0_Q)

additional debugging
author ach61@labyrinth.cl.cam.ac.uk
date Mon Apr 28 12:58:45 2003 +0000 (2003-04-28)
parents c6e4ce25ebc1
children b42c882f9076
files xen/drivers/block/xen_block.c xen/drivers/block/xen_segment.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h
line diff
     1.1 --- a/xen/drivers/block/xen_block.c	Thu Apr 24 15:20:37 2003 +0000
     1.2 +++ b/xen/drivers/block/xen_block.c	Mon Apr 28 12:58:45 2003 +0000
     1.3 @@ -210,11 +210,6 @@ static void end_block_io_op(struct buffe
     1.4          pending_req->status = 2;
     1.5      }
     1.6  
     1.7 -    if (pending_req->status)
     1.8 -    {
     1.9 -      printk ("Hey! status is %d\n", pending_req->status);
    1.10 -    }
    1.11 -
    1.12      unlock_buffer(pending_req->domain, 
    1.13                    virt_to_phys(bh->b_data), 
    1.14                    bh->b_size, 
    1.15 @@ -568,7 +563,10 @@ static void dispatch_rw_block_io(struct 
    1.16          }
    1.17  
    1.18          if ( !__buffer_is_valid(p, buffer, nr_sects<<9, (operation==READ)) )
    1.19 +	{
    1.20 +            DPRINTK("invalid buffer\n");
    1.21              goto bad_descriptor;
    1.22 +	}
    1.23  
    1.24          /* Get the physical device and block index. */
    1.25          if ( (req->device & XENDEV_TYPE_MASK) == XENDEV_VIRTUAL )
    1.26 @@ -578,7 +576,11 @@ static void dispatch_rw_block_io(struct 
    1.27                  req->device, 
    1.28                  req->sector_number + tot_sects,
    1.29                  buffer, nr_sects);
    1.30 -            if ( new_segs <= 0 ) goto bad_descriptor;
    1.31 +            if ( new_segs <= 0 ) 
    1.32 +	    {
    1.33 +	        DPRINTK("bogus xen_segment_map_request\n");
    1.34 +		goto bad_descriptor;
    1.35 +	    }
    1.36          }
    1.37          else
    1.38          {
    1.39 @@ -586,7 +588,11 @@ static void dispatch_rw_block_io(struct 
    1.40              phys_seg[nr_psegs].sector_number = req->sector_number + tot_sects;
    1.41              phys_seg[nr_psegs].buffer        = buffer;
    1.42              phys_seg[nr_psegs].nr_sects      = nr_sects;
    1.43 -            if ( phys_seg[nr_psegs].dev == 0 ) goto bad_descriptor;
    1.44 +            if ( phys_seg[nr_psegs].dev == 0 ) 
    1.45 +	    {
    1.46 +	        DPRINTK("bad device\n");
    1.47 +	        goto bad_descriptor;
    1.48 +	    }
    1.49              new_segs = 1;
    1.50          }
    1.51          
    1.52 @@ -690,11 +696,6 @@ static void make_response(struct task_st
    1.53      int position;
    1.54      blk_ring_t *blk_ring;
    1.55  
    1.56 -    if (st != 0)
    1.57 -    {
    1.58 -      printk("status is %ld\n", st);
    1.59 -    }
    1.60 -
    1.61      /* Place on the response ring for the relevant domain. */ 
    1.62      spin_lock_irqsave(&p->blk_ring_lock, flags);
    1.63      blk_ring = p->blk_ring_base;
     2.1 --- a/xen/drivers/block/xen_segment.c	Thu Apr 24 15:20:37 2003 +0000
     2.2 +++ b/xen/drivers/block/xen_segment.c	Mon Apr 28 12:58:45 2003 +0000
     2.3 @@ -17,6 +17,12 @@
     2.4  
     2.5  segment_t xsegments[XEN_MAX_SEGMENTS];
     2.6  
     2.7 +#if 0
     2.8 +#define DPRINTK(_f, _a...) printk( _f , ## _a )
     2.9 +#else
    2.10 +#define DPRINTK(_f, _a...) ((void)0)
    2.11 +#endif
    2.12 +
    2.13  /*
    2.14   * xen_segment_map_request
    2.15   *
    2.16 @@ -37,18 +43,36 @@ int xen_segment_map_request(
    2.17      int sum, i;
    2.18  
    2.19      segment_number &= XENDEV_IDX_MASK;
    2.20 -    if ( segment_number >= XEN_MAX_SEGMENTS ) goto fail;
    2.21 +    if ( segment_number >= XEN_MAX_SEGMENTS )
    2.22 +    {
    2.23 +      DPRINTK("invalid segment number. %d %d\n",
    2.24 +	      segment_number, XEN_MAX_SEGMENTS);
    2.25 +      goto fail;
    2.26 +    }
    2.27  
    2.28      seg = p->segment_list[segment_number];
    2.29 -    if ( seg == NULL ) goto fail;
    2.30 +    if ( seg == NULL ) 
    2.31 +    {
    2.32 +      DPRINTK("segment is null. %d\n", segment_number);
    2.33 +      goto fail;
    2.34 +    }
    2.35  
    2.36      /* check domain permissions */
    2.37 -    if ( seg->domain != p->domain ) goto fail;
    2.38 +    if ( seg->domain != p->domain )
    2.39 +    {
    2.40 +      DPRINTK("segment is for another domain. %d %d\n",
    2.41 +	      seg->domain, p->domain);
    2.42 +      goto fail;
    2.43 +    }
    2.44  
    2.45      /* check rw access */
    2.46      if ((operation == WRITE && seg->mode != XEN_SEGMENT_RW) ||
    2.47          (operation == READ  && seg->mode == XEN_SEGMENT_UNUSED))
    2.48 +    {
    2.49 +        DPRINTK("illegal operation: %d %d\n",
    2.50 +		operation, seg->mode);
    2.51          goto fail;
    2.52 +    }
    2.53  
    2.54      /* find extent, check size */
    2.55      sum = 0; 
    2.56 @@ -60,36 +84,88 @@ int xen_segment_map_request(
    2.57          ext++; i++;
    2.58      }
    2.59  
    2.60 -    if ( (sum + ext->size) <= sect_nr ) goto fail;
    2.61 +    if ( (sum + ext->size) <= sect_nr ) 
    2.62 +    {
    2.63 +      DPRINTK("extent size mismatch: %d %d : %d %ld %ld\n",
    2.64 +	      i, seg->num_extents, sum, ext->size, sect_nr);
    2.65 +      goto fail;
    2.66 +    }
    2.67  
    2.68 -    pseg->sector_number = sect_nr + ext->offset - sum;
    2.69 +    pseg->sector_number = (sect_nr - sum) + ext->offset;
    2.70      pseg->buffer        = buffer;
    2.71      pseg->nr_sects      = nr_sects;
    2.72      pseg->dev           = xendev_to_physdev(ext->disk);
    2.73 -    if ( pseg->dev == 0 ) goto fail;
    2.74 +    if ( pseg->dev == 0 ) 
    2.75 +    {
    2.76 +        DPRINTK ("invalid device 0x%x 0x%lx 0x%lx\n", 
    2.77 +		 ext->disk, ext->offset, ext->size);
    2.78 +	goto fail;
    2.79 +    }
    2.80  
    2.81      /* We're finished if the virtual extent didn't overrun the phys extent. */
    2.82      if ( (sum + ext->size) >= (sect_nr + nr_sects) )
    2.83 -        return 1; /* Just one more physical extent. */
    2.84 +        return 1;                         /* entire read fits in this extent */
    2.85  
    2.86      /* Hmmm... make sure there's another extent to overrun onto! */
    2.87 -    if ( (i+1) == seg->num_extents ) goto fail;
    2.88 +    if ( (i+1) == seg->num_extents ) 
    2.89 +    {
    2.90 +        DPRINTK ("not enough extents %d %d\n",
    2.91 +		 i, seg->num_extents);
    2.92 +	goto fail;
    2.93 +    }
    2.94  
    2.95      pseg[1].nr_sects = (sect_nr + nr_sects) - (sum + ext->size);
    2.96      pseg[0].nr_sects = sum + ext->size - sect_nr;
    2.97      pseg[1].buffer = buffer + (pseg->nr_sects << 9);
    2.98      pseg[1].sector_number = ext[1].offset;
    2.99      pseg[1].dev = xendev_to_physdev(ext[1].disk);
   2.100 -    if ( pseg[1].dev == 0 ) goto fail;
   2.101 +    if ( pseg[1].dev == 0 ) 
   2.102 +    {
   2.103 +        DPRINTK ("bogus device for pseg[1] \n");
   2.104 +	goto fail;
   2.105 +    }
   2.106  
   2.107      /* We don't allow overrun onto a third physical extent. */
   2.108      if ( (sum + ext[0].size + ext[1].size) < 
   2.109           (pseg[1].sector_number + pseg[1].nr_sects) )
   2.110 +    {
   2.111 +        DPRINTK ("third extent\n");
   2.112 +        DPRINTK (" sum:%d, e0:%ld, e1:%ld   p1.sect:%ld p1.nr:%d\n",
   2.113 +		 sum, ext[0].size, ext[1].size, 
   2.114 +		 pseg[1].sector_number, pseg[1].nr_sects);
   2.115          goto fail;    
   2.116 +    }
   2.117  
   2.118 -    return 2; /* We overran onto a second physical es\xtent. */
   2.119 +    return 2;                   /* We overran onto a second physical extent. */
   2.120  
   2.121   fail:
   2.122 +
   2.123 +    DPRINTK ("xen_segment_map_request failure\n");
   2.124 +    DPRINTK ("operation: %d\n", operation);
   2.125 +    DPRINTK ("segment number: %d\n", segment_number);
   2.126 +    DPRINTK ("sect_nr: %ld 0x%lx\n", sect_nr, sect_nr);
   2.127 +    DPRINTK ("nr_sects: %d 0x%x\n", nr_sects, nr_sects);
   2.128 +
   2.129 +    if (0)
   2.130 +    {
   2.131 +      segment_t *xseg;
   2.132 +      extent_t  *xext;
   2.133 +      int xsum, xi;
   2.134 +
   2.135 +      xseg = p->segment_list[segment_number];
   2.136 +
   2.137 +      xsum = 0; xi = 0;
   2.138 +      xext = xseg->extents;
   2.139 +
   2.140 +      while ( (xi < xseg->num_extents) && ((xsum + xext->size) <= sect_nr) )
   2.141 +      {
   2.142 +	DPRINTK (" xi:%d, num_ext:%d, xsum:%d, size:%lx, sect_nr:%lx\n",
   2.143 +		 xi, xseg->num_extents, xsum, xext->size, sect_nr);
   2.144 +	xsum += xext->size;
   2.145 +        xext++; xi++;
   2.146 +      }
   2.147 +    }
   2.148 +
   2.149      return -1;
   2.150  }
   2.151  
     3.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Thu Apr 24 15:20:37 2003 +0000
     3.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Mon Apr 28 12:58:45 2003 +0000
     3.3 @@ -120,6 +120,11 @@ int xenolinux_block_release(struct inode
     3.4      return 0;
     3.5  }
     3.6  
     3.7 +/*
     3.8 + * handle ioctl calls
     3.9 + *
    3.10 + * individual ioctls are defined in /usr/include/linux/fs.h
    3.11 + */
    3.12  
    3.13  int xenolinux_block_ioctl(struct inode *inode, struct file *filep,
    3.14  			  unsigned command, unsigned long argument)
    3.15 @@ -299,6 +304,7 @@ static int hypervisor_request(unsigned l
    3.16      case XEN_BLOCK_WRITE:
    3.17          phys_device = xldev_to_physdev(device);
    3.18  	gd = xldev_to_gendisk(device); 
    3.19 +
    3.20  	sector_number += gd->part[MINOR(device)].start_sect;
    3.21          if ( (sg_operation == operation) &&
    3.22               (sg_dev == phys_device) &&
     4.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h	Thu Apr 24 15:20:37 2003 +0000
     4.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h	Mon Apr 28 12:58:45 2003 +0000
     4.3 @@ -29,9 +29,13 @@
     4.4  
     4.5  #if 0
     4.6  #define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
     4.7 +#else
     4.8 +#define DPRINTK(_f, _a...) ((void)0)
     4.9 +#endif
    4.10 +
    4.11 +#if 0
    4.12  #define DPRINTK_IOCTL(_f, _a...) printk ( KERN_ALERT _f , ## _a )
    4.13  #else
    4.14 -#define DPRINTK(_f, _a...) ((void)0)
    4.15  #define DPRINTK_IOCTL(_f, _a...) ((void)0)
    4.16  #endif
    4.17