ia64/xen-unstable

changeset 8117:37b93f40eb0a

Cleanup backend block device logic under save/restore; this should
fix the issues some people have seen with segfaults in vbd_translate
and/or user-space hangs.

Signed-off-by: Steven Hand <steven@xensource.com>
author smh22@firebug.cl.cam.ac.uk
date Tue Nov 29 14:50:30 2005 +0100 (2005-11-29)
parents 450c562b76aa
children 689315a7ff80
files linux-2.6-xen-sparse/drivers/xen/blkback/common.h linux-2.6-xen-sparse/drivers/xen/blkback/interface.c linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Nov 29 14:37:24 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Nov 29 14:50:30 2005 +0100
     1.3 @@ -38,6 +38,8 @@ struct vbd {
     1.4  	struct block_device *bdev;
     1.5  }; 
     1.6  
     1.7 +struct backend_info; 
     1.8 +
     1.9  typedef struct blkif_st {
    1.10  	/* Unique identifier for this interface. */
    1.11  	domid_t           domid;
    1.12 @@ -48,8 +50,10 @@ typedef struct blkif_st {
    1.13  	/* Comms information. */
    1.14  	blkif_back_ring_t blk_ring;
    1.15  	struct vm_struct *blk_ring_area;
    1.16 -	/* VBDs attached to this interface. */
    1.17 +	/* The VBD attached to this interface. */
    1.18  	struct vbd        vbd;
    1.19 +	/* Back pointer to the backend_info. */
    1.20 +	struct backend_info *be; 
    1.21  	/* Private fields. */
    1.22  	enum { DISCONNECTED, CONNECTED } status;
    1.23  #ifdef CONFIG_XEN_BLKDEV_TAP_BE
    1.24 @@ -103,6 +107,8 @@ void blkif_xenbus_init(void);
    1.25  
    1.26  irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
    1.27  
    1.28 +void update_blkif_status(blkif_t *blkif); 
    1.29 +
    1.30  #endif /* __BLKIF__BACKEND__COMMON_H__ */
    1.31  
    1.32  /*
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Nov 29 14:37:24 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Nov 29 14:50:30 2005 +0100
     2.3 @@ -112,7 +112,9 @@ int blkif_map(blkif_t *blkif, unsigned l
     2.4  
     2.5  	blkif->irq = bind_evtchn_to_irqhandler(
     2.6  		blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
     2.7 -	blkif->status = CONNECTED;
     2.8 +
     2.9 +	/* We're potentially connected now */
    2.10 +	update_blkif_status(blkif); 
    2.11  
    2.12  	return 0;
    2.13  }
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Nov 29 14:37:24 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Nov 29 14:50:30 2005 +0100
     3.3 @@ -50,6 +50,16 @@ static void backend_changed(struct xenbu
     3.4  			    unsigned int);
     3.5  
     3.6  
     3.7 +void update_blkif_status(blkif_t *blkif)
     3.8 +{ 
     3.9 +	if(blkif->irq && blkif->vbd.bdev) {
    3.10 +		blkif->status = CONNECTED; 
    3.11 +		(void)blkif_be_int(0, blkif, NULL); 
    3.12 +	}
    3.13 +	maybe_connect(blkif->be); 
    3.14 +}
    3.15 +
    3.16 +
    3.17  static ssize_t show_physical_device(struct device *_dev, char *buf)
    3.18  {
    3.19  	struct xenbus_device *dev = to_xenbus_device(_dev);
    3.20 @@ -81,6 +91,7 @@ static int blkback_remove(struct xenbus_
    3.21  		be->backend_watch.node = NULL;
    3.22  	}
    3.23  	if (be->blkif) {
    3.24 +		be->blkif->status = DISCONNECTED; 
    3.25  		blkif_put(be->blkif);
    3.26  		be->blkif = NULL;
    3.27  	}
    3.28 @@ -123,6 +134,9 @@ static int blkback_probe(struct xenbus_d
    3.29  		goto fail;
    3.30  	}
    3.31  
    3.32 +	/* setup back pointer */
    3.33 +	be->blkif->be = be; 
    3.34 +
    3.35  	err = xenbus_watch_path2(dev, dev->nodename, "physical-device",
    3.36  				 &be->backend_watch, backend_changed);
    3.37  	if (err)
    3.38 @@ -209,7 +223,8 @@ static void backend_changed(struct xenbu
    3.39  		device_create_file(&dev->dev, &dev_attr_physical_device);
    3.40  		device_create_file(&dev->dev, &dev_attr_mode);
    3.41  
    3.42 -		maybe_connect(be);
    3.43 +		/* We're potentially connected now */
    3.44 +		update_blkif_status(be->blkif); 
    3.45  	}
    3.46  }
    3.47  
    3.48 @@ -235,7 +250,7 @@ static void frontend_changed(struct xenb
    3.49  		if (err) {
    3.50  			return;
    3.51  		}
    3.52 -		maybe_connect(be);
    3.53 +		update_blkif_status(be->blkif); 
    3.54  		break;
    3.55  
    3.56  	case XenbusStateClosing: