ia64/xen-unstable

changeset 6275:f22bbccf64ff

Add support for multiple devices when using grant tables.
Also better support non-transactional store updates.
Also remove some extra printks.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Aug 19 10:47:48 2005 +0000 (2005-08-19)
parents 7570087c2552
children 2d7a9bae9814
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	Fri Aug 19 10:46:21 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Aug 19 10:47:48 2005 +0000
     1.3 @@ -84,6 +84,7 @@ static grant_ref_t gref_head, gref_termi
     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 +static int shmem_ref;
     1.8  #endif
     1.9  
    1.10  static struct blk_shadow {
    1.11 @@ -1168,6 +1169,16 @@ static int setup_blkring(struct xenbus_d
    1.12  	SHARED_RING_INIT(sring);
    1.13  	FRONT_RING_INIT(&blk_ring, sring, PAGE_SIZE);
    1.14  
    1.15 +#ifdef CONFIG_XEN_BLKDEV_GRANT
    1.16 +	shmem_ref = gnttab_claim_grant_reference(&gref_head,
    1.17 +						 gref_terminal);
    1.18 +	ASSERT(shmem_ref != -ENOSPC);
    1.19 +	gnttab_grant_foreign_access_ref(shmem_ref,
    1.20 +					backend_id,
    1.21 +					virt_to_machine(blk_ring.sring)
    1.22 +					>> PAGE_SHIFT, 0);
    1.23 +#endif
    1.24 +
    1.25  	op.u.alloc_unbound.dom = backend_id;
    1.26  	err = HYPERVISOR_event_channel_op(&op);
    1.27  	if (err) {
    1.28 @@ -1191,14 +1202,22 @@ static int talk_to_backend(struct xenbus
    1.29  	backend = xenbus_read(dev->nodename, "backend", NULL);
    1.30  	if (IS_ERR(backend)) {
    1.31  		err = PTR_ERR(backend);
    1.32 +		if (err == -ENOENT)
    1.33 +			goto out;
    1.34  		xenbus_dev_error(dev, err, "reading %s/backend",
    1.35  				 dev->nodename);
    1.36  		goto out;
    1.37  	}
    1.38 +	if (strlen(backend) == 0) {
    1.39 +		err = -ENOENT;
    1.40 +		goto free_backend;
    1.41 +	}
    1.42  
    1.43  	/* FIXME: This driver can't handle backends on different
    1.44  	 * domains.  Check and fail gracefully. */
    1.45  	err = xenbus_scanf(dev->nodename, "backend-id", "%i", &backend_id);
    1.46 +	if (err == -ENOENT)
    1.47 +		goto free_backend;
    1.48   	if (err < 0) {
    1.49  		xenbus_dev_error(dev, err, "reading %s/backend-id",
    1.50  				 dev->nodename);
    1.51 @@ -1219,20 +1238,10 @@ static int talk_to_backend(struct xenbus
    1.52  	}
    1.53  
    1.54  #ifdef CONFIG_XEN_BLKDEV_GRANT
    1.55 -	{
    1.56 -		int shmem_ref;
    1.57 -		shmem_ref = gnttab_claim_grant_reference(&gref_head,
    1.58 -							 gref_terminal);
    1.59 -		ASSERT(shmem_ref != -ENOSPC);
    1.60 -		gnttab_grant_foreign_access_ref(shmem_ref,
    1.61 -						backend_id,
    1.62 -						virt_to_machine(blk_ring.sring)
    1.63 -						>> PAGE_SHIFT, 0);
    1.64 -		err = xenbus_printf(dev->nodename, "grant-id","%u", shmem_ref);
    1.65 -		if (err) {
    1.66 -			message = "writing grant-id";
    1.67 -			goto abort_transaction;
    1.68 -		}
    1.69 +	err = xenbus_printf(dev->nodename, "grant-id","%u", shmem_ref);
    1.70 +	if (err) {
    1.71 +		message = "writing grant-id";
    1.72 +		goto abort_transaction;
    1.73  	}
    1.74  #else
    1.75  	err = xenbus_printf(dev->nodename, "shared-frame", "%lu",
    1.76 @@ -1292,6 +1301,8 @@ static int blkfront_probe(struct xenbus_
    1.77  
    1.78  	/* FIXME: Use dynamic device id if this is not set. */
    1.79  	err = xenbus_scanf(dev->nodename, "virtual-device", "%i", &vdevice);
    1.80 +	if (err == -ENOENT)
    1.81 +		return err;
    1.82  	if (err < 0) {
    1.83  		xenbus_dev_error(dev, err, "reading virtual-device");
    1.84  		return err;
    1.85 @@ -1325,7 +1336,6 @@ static int blkfront_remove(struct xenbus
    1.86  {
    1.87  	struct blkfront_info *info = dev->data;
    1.88  
    1.89 -	printk("blkfront_remove %s\n", dev->dev.bus_id);
    1.90  	if (info->backend)
    1.91  		unregister_xenbus_watch(&info->watch);
    1.92  
    1.93 @@ -1339,7 +1349,6 @@ static int blkfront_remove(struct xenbus
    1.94  	if (--blkif_vbds == 0)
    1.95  		blkif_free();
    1.96  
    1.97 -	printk("blkfront_remove done\n");
    1.98  	return 0;
    1.99  }
   1.100