ia64/xen-unstable

changeset 11966:ffbd9e4668a6

[BLOCK] blkback: Fix potential grant entry leaks on error

As it stands grant entries for the actual data are mapped in bulk.
If one of the earlier entries fail to be mapped, it can cause all
subsequent entries to be leaked if they were successfully mapped.

This patch changes it so that we will continue to reap grant entries
even when an error is detected.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
author kfraser@localhost.localdomain
date Wed Oct 25 10:59:00 2006 +0100 (2006-10-25)
parents 4be49a3be040
children 72ce74a680d7 7957dffb855f
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	Wed Oct 25 10:56:50 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Oct 25 10:59:00 2006 +0100
     1.3 @@ -392,10 +392,15 @@ static void dispatch_rw_block_io(blkif_t
     1.4  	for (i = 0; i < nseg; i++) {
     1.5  		if (unlikely(map[i].status != 0)) {
     1.6  			DPRINTK("invalid buffer -- could not remap it\n");
     1.7 -			goto fail_flush;
     1.8 +			map[i].handle = BLKBACK_INVALID_HANDLE;
     1.9 +			ret |= 1;
    1.10  		}
    1.11  
    1.12  		pending_handle(pending_req, i) = map[i].handle;
    1.13 +
    1.14 +		if (ret)
    1.15 +			continue;
    1.16 +
    1.17  		set_phys_to_machine(__pa(vaddr(
    1.18  			pending_req, i)) >> PAGE_SHIFT,
    1.19  			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
    1.20 @@ -403,6 +408,9 @@ static void dispatch_rw_block_io(blkif_t
    1.21  			(req->seg[i].first_sect << 9);
    1.22  	}
    1.23  
    1.24 +	if (ret)
    1.25 +		goto fail_flush;
    1.26 +
    1.27  	if (vbd_translate(&preq, blkif, operation) != 0) {
    1.28  		DPRINTK("access denied: %s of [%llu,%llu] on dev=%04x\n", 
    1.29  			operation == READ ? "read" : "write",