ia64/xen-unstable

changeset 9248:36cf47cfea4e

Clean up block-device hotplug routines in xenlinux.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Mar 13 15:06:58 2006 +0100 (2006-03-13)
parents 68915c4893ee
children d14cb80574ee
files linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Mar 13 13:03:51 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Mar 13 15:06:58 2006 +0100
     1.3 @@ -352,11 +352,7 @@ static void blkfront_closing(struct xenb
     1.4  
     1.5  	DPRINTK("blkfront_closing: %s removed\n", dev->nodename);
     1.6  
     1.7 -	if (info->mi) {
     1.8 -		DPRINTK("Calling xlvbd_del\n");
     1.9 -		xlvbd_del(info);
    1.10 -		info->mi = NULL;
    1.11 -	}
    1.12 +	xlvbd_del(info);
    1.13  
    1.14  	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosed);
    1.15  }
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Mon Mar 13 13:03:51 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Mon Mar 13 15:06:58 2006 +0100
     2.3 @@ -216,6 +216,10 @@ xlvbd_alloc_gendisk(int minor, blkif_sec
     2.4  	int nr_minors = 1;
     2.5  	int err = -ENODEV;
     2.6  
     2.7 +	BUG_ON(info->gd != NULL);
     2.8 +	BUG_ON(info->mi != NULL);
     2.9 +	BUG_ON(info->rq != NULL);
    2.10 +
    2.11  	mi = xlbd_get_major_info(vdevice);
    2.12  	if (mi == NULL)
    2.13  		goto out;
    2.14 @@ -268,6 +272,7 @@ xlvbd_alloc_gendisk(int minor, blkif_sec
    2.15   out:
    2.16  	if (mi)
    2.17  		xlbd_put_major_info(mi);
    2.18 +	info->mi = NULL;
    2.19  	return err;
    2.20  }
    2.21  
    2.22 @@ -294,22 +299,20 @@ xlvbd_add(blkif_sector_t capacity, int v
    2.23  void
    2.24  xlvbd_del(struct blkfront_info *info)
    2.25  {
    2.26 -	struct block_device *bd;
    2.27 -
    2.28 -	bd = bdget(info->dev);
    2.29 -	if (bd == NULL)
    2.30 +	if (info->mi == NULL)
    2.31  		return;
    2.32  
    2.33 -	if (info->gd == NULL)
    2.34 -		return;
    2.35 -
    2.36 +	BUG_ON(info->gd == NULL);
    2.37  	del_gendisk(info->gd);
    2.38  	put_disk(info->gd);
    2.39 +	info->gd = NULL;
    2.40 +
    2.41  	xlbd_put_major_info(info->mi);
    2.42  	info->mi = NULL;
    2.43 +
    2.44 +	BUG_ON(info->rq == NULL);
    2.45  	blk_cleanup_queue(info->rq);
    2.46 -
    2.47 -	bdput(bd);
    2.48 +	info->rq = NULL;
    2.49  }
    2.50  
    2.51  /*