ia64/xen-unstable

changeset 6634:85aca042b802

Free grant reference when block device shuts down.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Sep 05 08:23:05 2005 +0000 (2005-09-05)
parents 4594827336ad
children bd9af523a598 79658ef58925
files linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Sep 05 08:22:21 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Sep 05 08:23:05 2005 +0000
     1.3 @@ -58,6 +58,7 @@ static unsigned int blkif_state = BLKIF_
     1.4  #define MAXIMUM_OUTSTANDING_BLOCK_REQS \
     1.5      (BLKIF_MAX_SEGMENTS_PER_REQUEST * BLKIF_RING_SIZE)
     1.6  #define GRANTREF_INVALID (1<<15)
     1.7 +#define GRANT_INVALID_REF	(0xFFFF)
     1.8  
     1.9  static int recovery = 0; /* Recovery in progress: protected by blkif_io_lock */
    1.10  
    1.11 @@ -368,6 +369,9 @@ static void blkif_free(struct blkfront_i
    1.12  		free_page((unsigned long)info->ring.sring);
    1.13  		info->ring.sring = NULL;
    1.14  	}
    1.15 +	if (info->ring_ref != GRANT_INVALID_REF)
    1.16 +		gnttab_end_foreign_access(info->ring_ref, 0);
    1.17 +	info->ring_ref = GRANT_INVALID_REF;
    1.18  	unbind_evtchn_from_irqhandler(info->evtchn, info); 
    1.19  	info->evtchn = 0;
    1.20  }
    1.21 @@ -502,6 +506,8 @@ static int setup_blkring(struct xenbus_d
    1.22  	evtchn_op_t op = { .cmd = EVTCHNOP_alloc_unbound };
    1.23  	int err;
    1.24  
    1.25 +	info->ring_ref = GRANT_INVALID_REF;
    1.26 +
    1.27  	sring = (void *)__get_free_page(GFP_KERNEL);
    1.28  	if (!sring) {
    1.29  		xenbus_dev_error(dev, -ENOMEM, "allocating shared ring");
    1.30 @@ -524,6 +530,7 @@ static int setup_blkring(struct xenbus_d
    1.31  	err = HYPERVISOR_event_channel_op(&op);
    1.32  	if (err) {
    1.33  		gnttab_end_foreign_access(info->ring_ref, 0);
    1.34 +		info->ring_ref = GRANT_INVALID_REF;
    1.35  		free_page((unsigned long)info->ring.sring);
    1.36  		info->ring.sring = 0;
    1.37  		xenbus_dev_error(dev, err, "allocating event channel");