ia64/xen-unstable

changeset 7640:55194bd55b86

Fix error path in blkback driver where a grant mapping in the
middle of a batch fails. Spotted by Harry Butterworth (IBM).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Nov 06 17:50:24 2005 +0100 (2005-11-06)
parents c352591ebfdf
children 270469d40f02
files linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Sun Nov 06 16:40:33 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Sun Nov 06 17:50:24 2005 +0100
     1.3 @@ -340,7 +340,7 @@ static void dispatch_rw_block_io(blkif_t
     1.4  	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     1.5  	int nbio = 0;
     1.6  	request_queue_t *q;
     1.7 -	int ret;
     1.8 +	int ret, errors = 0;
     1.9  
    1.10  	/* Check that number of segments is sane. */
    1.11  	nseg = req->nr_segments;
    1.12 @@ -374,23 +374,23 @@ static void dispatch_rw_block_io(blkif_t
    1.13  	BUG_ON(ret);
    1.14  
    1.15  	for (i = 0; i < nseg; i++) {
    1.16 -		if (unlikely(map[i].handle < 0)) {
    1.17 -			DPRINTK("invalid buffer -- could not remap it\n");
    1.18 -			fast_flush_area(pending_idx, nseg);
    1.19 -			goto bad_descriptor;
    1.20 +		if (likely(map[i].handle >= 0)) {
    1.21 +			pending_handle(pending_idx, i) = map[i].handle;
    1.22 +			phys_to_machine_mapping[__pa(MMAP_VADDR(
    1.23 +				pending_idx, i)) >> PAGE_SHIFT] =
    1.24 +				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
    1.25 +			fas        = req->frame_and_sects[i];
    1.26 +			seg[i].buf = map[i].dev_bus_addr | 
    1.27 +				(blkif_first_sect(fas) << 9);
    1.28 +		} else {
    1.29 +			errors++;
    1.30  		}
    1.31 -
    1.32 -		phys_to_machine_mapping[__pa(MMAP_VADDR(
    1.33 -			pending_idx, i)) >> PAGE_SHIFT] =
    1.34 -			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
    1.35 -
    1.36 -		pending_handle(pending_idx, i) = map[i].handle;
    1.37  	}
    1.38  
    1.39 -	for (i = 0; i < nseg; i++) {
    1.40 -		fas         = req->frame_and_sects[i];
    1.41 -		seg[i].buf  = map[i].dev_bus_addr | 
    1.42 -			(blkif_first_sect(fas) << 9);
    1.43 +	if (errors) {
    1.44 +		DPRINTK("invalid buffer -- could not remap it\n");
    1.45 +		fast_flush_area(pending_idx, nseg);
    1.46 +		goto bad_descriptor;
    1.47  	}
    1.48  
    1.49  	if (vbd_translate(&preq, blkif, operation) != 0) {