direct-io.hg

changeset 10568:c1119ff85f4e

[BLK] back: Only remove sysfs attributes if they were previously
added. Also check for errors during attribute creation.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Fri Jun 30 14:30:43 2006 +0100 (2006-06-30)
parents ffbdd113c74b
children 17e9daeb2c50
files linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Jun 30 14:15:12 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Jun 30 14:30:43 2006 +0100
     1.3 @@ -109,7 +109,7 @@ VBD_SHOW(mode, "%s\n", be->mode);
     1.4  
     1.5  int xenvbd_sysfs_addif(struct xenbus_device *dev)
     1.6  {
     1.7 -	int error = 0;
     1.8 +	int error;
     1.9  	
    1.10  	error = device_create_file(&dev->dev, &dev_attr_physical_device);
    1.11   	if (error)
    1.12 @@ -157,7 +157,8 @@ static int blkback_remove(struct xenbus_
    1.13  		be->blkif = NULL;
    1.14  	}
    1.15  
    1.16 -	xenvbd_sysfs_delif(dev);
    1.17 +	if (be->major || be->minor)
    1.18 +		xenvbd_sysfs_delif(dev);
    1.19  
    1.20  	kfree(be);
    1.21  	dev->dev.driver_data = NULL;
    1.22 @@ -272,13 +273,18 @@ static void backend_changed(struct xenbu
    1.23  		err = vbd_create(be->blkif, handle, major, minor,
    1.24  				 (NULL == strchr(be->mode, 'w')));
    1.25  		if (err) {
    1.26 -			be->major = 0;
    1.27 -			be->minor = 0;
    1.28 +			be->major = be->minor = 0;
    1.29  			xenbus_dev_fatal(dev, err, "creating vbd structure");
    1.30  			return;
    1.31  		}
    1.32  
    1.33 -		xenvbd_sysfs_addif(dev);
    1.34 +		err = xenvbd_sysfs_addif(dev);
    1.35 +		if (err) {
    1.36 +			vbd_free(&be->blkif->vbd);
    1.37 +			be->major = be->minor = 0;
    1.38 +			xenbus_dev_fatal(dev, err, "creating sysfs entries");
    1.39 +			return;
    1.40 +		}
    1.41  
    1.42  		/* We're potentially connected now */
    1.43  		update_blkif_status(be->blkif);