direct-io.hg

changeset 6287:5e8123554d15

merge.
author kaf24@firebug.cl.cam.ac.uk
date Fri Aug 19 17:57:00 2005 +0000 (2005-08-19)
parents fd28bf8825a8 1872e09bfba3
children eb9df2c3a478
files linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c linux-2.6-xen-sparse/arch/xen/i386/mm/init.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c linux-2.6-xen-sparse/drivers/xen/blkback/common.h linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h linux-2.6-xen-sparse/drivers/xen/netback/common.h linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h linux-2.6-xen-sparse/include/asm-xen/xenbus.h tools/debugger/libxendebug/xendebug.c tools/debugger/libxendebug/xendebug.h tools/debugger/pdb/linux-2.6-module/debug.c tools/debugger/pdb/linux-2.6-module/module.c tools/debugger/pdb/linux-2.6-module/pdb_debug.h tools/debugger/pdb/pdb_caml_domain.c tools/debugger/pdb/pdb_caml_process.c tools/debugger/pdb/pdb_caml_xcs.c tools/libxc/xc.h tools/libxc/xc_gnttab.c tools/python/xen/lowlevel/xu/xu.c tools/xentrace/xentrace.c xen/arch/x86/physdev.c xen/common/trace.c xen/include/public/arch-ia64.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h xen/include/public/dom0_ops.h xen/include/public/grant_table.h xen/include/public/io/domain_controller.h xen/include/public/io/netif.h xen/include/public/physdev.h xen/include/public/xen.h
line diff
    10.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Aug 19 17:56:20 2005 +0000
    10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Aug 19 17:57:00 2005 +0000
    10.3 @@ -182,16 +182,20 @@ static void backend_changed(struct xenbu
    10.4  			    "frontend-id", "%li", &be->frontend_id,
    10.5  			    "frontend", NULL, &frontend,
    10.6  			    NULL);
    10.7 -	if (err == -ENOENT || err == -ERANGE ||
    10.8 +	if (XENBUS_EXIST_ERR(err) ||
    10.9  	    strlen(frontend) == 0 || !xenbus_exists(frontend, "")) {
   10.10 -		if (frontend)
   10.11 -			kfree(frontend);
   10.12  		/* If we can't get a frontend path and a frontend-id,
   10.13  		 * then our bus-id is no longer valid and we need to
   10.14  		 * destroy the backend device.
   10.15  		 */
   10.16  		goto device_fail;
   10.17  	}
   10.18 +	if (err < 0) {
   10.19 +		xenbus_dev_error(dev, err,
   10.20 +				 "reading %s/frontend or frontend-id",
   10.21 +				 dev->nodename);
   10.22 +		goto device_fail;
   10.23 +	}
   10.24  
   10.25  	if (!be->frontpath || strcmp(frontend, be->frontpath)) {
   10.26  		if (be->watch.node)
   10.27 @@ -199,6 +203,7 @@ static void backend_changed(struct xenbu
   10.28  		if (be->frontpath)
   10.29  			kfree(be->frontpath);
   10.30  		be->frontpath = frontend;
   10.31 +		frontend = NULL;
   10.32  		be->watch.node = be->frontpath;
   10.33  		be->watch.callback = frontend_changed;
   10.34  		err = register_xenbus_watch(&be->watch);
   10.35 @@ -206,14 +211,13 @@ static void backend_changed(struct xenbu
   10.36  			be->watch.node = NULL;
   10.37  			goto device_fail;
   10.38  		}
   10.39 -	} else
   10.40 -		kfree(frontend);
   10.41 +	}
   10.42  
   10.43  	err = xenbus_scanf(dev->nodename, "physical-device", "%li", &pdev);
   10.44 -	if (err == -ENOENT || err == -ERANGE)
   10.45 +	if (XENBUS_EXIST_ERR(err))
   10.46  		goto out;
   10.47  	if (err < 0) {
   10.48 -		xenbus_dev_error(dev, err, "Reading physical-device");
   10.49 +		xenbus_dev_error(dev, err, "reading physical-device");
   10.50  		goto device_fail;
   10.51  	}
   10.52  	if (be->pdev && be->pdev != pdev) {
   10.53 @@ -253,12 +257,14 @@ static void backend_changed(struct xenbu
   10.54  		frontend_changed(&be->watch, be->frontpath);
   10.55  	}
   10.56  
   10.57 + out:
   10.58 +	if (frontend)
   10.59 +		kfree(frontend);
   10.60  	return;
   10.61  
   10.62   device_fail:
   10.63  	device_unregister(&be->dev->dev);
   10.64 - out:
   10.65 -	return;
   10.66 +	goto out;
   10.67  }
   10.68  
   10.69  static int blkback_probe(struct xenbus_device *dev,
    11.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Aug 19 17:56:20 2005 +0000
    11.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Aug 19 17:57:00 2005 +0000
    11.3 @@ -1134,25 +1134,24 @@ static void watch_for_status(struct xenb
    11.4  			    "info", "%u", &binfo,
    11.5  			    "sector-size", "%lu", &sector_size,
    11.6  			    NULL);
    11.7 -
    11.8 -	if (err)
    11.9 +	if (err) {
   11.10  		xenbus_dev_error(info->dev, err, "reading backend fields");
   11.11 -	else {
   11.12 -		xlvbd_add(sectors, info->vdevice, info->handle, binfo,
   11.13 -			  sector_size);
   11.14 -		info->connected = 1;
   11.15 +		return;
   11.16 +	}
   11.17 +
   11.18 +	xlvbd_add(sectors, info->vdevice, info->handle, binfo, sector_size);
   11.19 +	info->connected = 1;
   11.20  
   11.21 -		/* First to connect?  blkif is now connected. */
   11.22 -		if (blkif_vbds_connected++ == 0)
   11.23 -			blkif_state = BLKIF_STATE_CONNECTED;
   11.24 -
   11.25 -		xenbus_dev_ok(info->dev);
   11.26 +	/* First to connect?  blkif is now connected. */
   11.27 +	if (blkif_vbds_connected++ == 0)
   11.28 +		blkif_state = BLKIF_STATE_CONNECTED;
   11.29  
   11.30 -		/* Kick pending requests. */
   11.31 -		spin_lock_irq(&blkif_io_lock);
   11.32 -		kick_pending_request_queues();
   11.33 -		spin_unlock_irq(&blkif_io_lock);
   11.34 -	}
   11.35 +	xenbus_dev_ok(info->dev);
   11.36 +
   11.37 +	/* Kick pending requests. */
   11.38 +	spin_lock_irq(&blkif_io_lock);
   11.39 +	kick_pending_request_queues();
   11.40 +	spin_unlock_irq(&blkif_io_lock);
   11.41  }
   11.42  
   11.43  static int setup_blkring(struct xenbus_device *dev, unsigned int backend_id)
   11.44 @@ -1199,36 +1198,28 @@ static int talk_to_backend(struct xenbus
   11.45  	const char *message;
   11.46  	int err, backend_id;
   11.47  
   11.48 -	backend = xenbus_read(dev->nodename, "backend", NULL);
   11.49 -	if (IS_ERR(backend)) {
   11.50 -		err = PTR_ERR(backend);
   11.51 -		if (err == -ENOENT)
   11.52 -			goto out;
   11.53 -		xenbus_dev_error(dev, err, "reading %s/backend",
   11.54 +	backend = NULL;
   11.55 +	err = xenbus_gather(dev->nodename,
   11.56 +			    "backend-id", "%i", &backend_id,
   11.57 +			    "backend", NULL, &backend,
   11.58 +			    NULL);
   11.59 +	if (XENBUS_EXIST_ERR(err))
   11.60 +		goto out;
   11.61 +	if (backend && strlen(backend) == 0) {
   11.62 +		err = -ENOENT;
   11.63 +		goto out;
   11.64 +	}
   11.65 +	if (err < 0) {
   11.66 +		xenbus_dev_error(dev, err, "reading %s/backend or backend-id",
   11.67  				 dev->nodename);
   11.68  		goto out;
   11.69  	}
   11.70 -	if (strlen(backend) == 0) {
   11.71 -		err = -ENOENT;
   11.72 -		goto free_backend;
   11.73 -	}
   11.74 -
   11.75 -	/* FIXME: This driver can't handle backends on different
   11.76 -	 * domains.  Check and fail gracefully. */
   11.77 -	err = xenbus_scanf(dev->nodename, "backend-id", "%i", &backend_id);
   11.78 -	if (err == -ENOENT)
   11.79 -		goto free_backend;
   11.80 - 	if (err < 0) {
   11.81 -		xenbus_dev_error(dev, err, "reading %s/backend-id",
   11.82 -				 dev->nodename);
   11.83 - 		goto free_backend;
   11.84 - 	}
   11.85  
   11.86  	/* First device?  We create shared ring, alloc event channel. */
   11.87  	if (blkif_vbds == 0) {
   11.88  		err = setup_blkring(dev, backend_id);
   11.89  		if (err)
   11.90 -			goto free_backend;
   11.91 +			goto out;
   11.92  	}
   11.93  
   11.94  	err = xenbus_transaction_start(dev->nodename);
   11.95 @@ -1258,9 +1249,11 @@ static int talk_to_backend(struct xenbus
   11.96  		goto abort_transaction;
   11.97  	}
   11.98  
   11.99 -	info->watch.node = info->backend = backend;
  11.100 +	info->backend = backend;
  11.101 +	backend = NULL;
  11.102 +
  11.103 +	info->watch.node = info->backend;
  11.104  	info->watch.callback = watch_for_status;
  11.105 -
  11.106  	err = register_xenbus_watch(&info->watch);
  11.107  	if (err) {
  11.108  		message = "registering watch on backend";
  11.109 @@ -1272,20 +1265,20 @@ static int talk_to_backend(struct xenbus
  11.110  		xenbus_dev_error(dev, err, "completing transaction");
  11.111  		goto destroy_blkring;
  11.112  	}
  11.113 -	return 0;
  11.114  
  11.115 -abort_transaction:
  11.116 + out:
  11.117 +	if (backend)
  11.118 +		kfree(backend);
  11.119 +	return err;
  11.120 +
  11.121 + abort_transaction:
  11.122  	xenbus_transaction_end(1);
  11.123  	/* Have to do this *outside* transaction.  */
  11.124  	xenbus_dev_error(dev, err, "%s", message);
  11.125 -destroy_blkring:
  11.126 + destroy_blkring:
  11.127  	if (blkif_vbds == 0)
  11.128  		blkif_free();
  11.129 -free_backend:
  11.130 -	kfree(backend);
  11.131 -out:
  11.132 -	printk("%s:%u = %i\n", __FILE__, __LINE__, err);
  11.133 -	return err;
  11.134 +	goto out;
  11.135  }
  11.136  
  11.137  /* Setup supplies the backend dir, virtual device.
  11.138 @@ -1301,7 +1294,7 @@ static int blkfront_probe(struct xenbus_
  11.139  
  11.140  	/* FIXME: Use dynamic device id if this is not set. */
  11.141  	err = xenbus_scanf(dev->nodename, "virtual-device", "%i", &vdevice);
  11.142 -	if (err == -ENOENT)
  11.143 +	if (XENBUS_EXIST_ERR(err))
  11.144  		return err;
  11.145  	if (err < 0) {
  11.146  		xenbus_dev_error(dev, err, "reading virtual-device");
  11.147 @@ -1316,6 +1309,7 @@ static int blkfront_probe(struct xenbus_
  11.148  	info->dev = dev;
  11.149  	info->vdevice = vdevice;
  11.150  	info->connected = 0;
  11.151 +
  11.152  	/* Front end dir is a number, which is used as the id. */
  11.153  	info->handle = simple_strtoul(strrchr(dev->nodename,'/')+1, NULL, 0);
  11.154  	dev->data = info;
  11.155 @@ -1427,8 +1421,8 @@ static int __init xlblk_init(void)
  11.156  
  11.157  #ifdef CONFIG_XEN_BLKDEV_GRANT
  11.158      /* A grant for every ring slot, plus one for the ring itself. */
  11.159 -    if ( 0 > gnttab_alloc_grant_references(MAXIMUM_OUTSTANDING_BLOCK_REQS + 1,
  11.160 -                                           &gref_head, &gref_terminal) )
  11.161 +    if (gnttab_alloc_grant_references(MAXIMUM_OUTSTANDING_BLOCK_REQS + 1,
  11.162 +				      &gref_head, &gref_terminal) < 0)
  11.163          return 1;
  11.164      printk(KERN_ALERT "Blkif frontend is using grant tables.\n");
  11.165  #endif
    17.1 --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Fri Aug 19 17:56:20 2005 +0000
    17.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Fri Aug 19 17:57:00 2005 +0000
    17.3 @@ -128,4 +128,14 @@ void reregister_xenbus_watches(void);
    17.4  void xenbus_suspend(void);
    17.5  void xenbus_resume(void);
    17.6  
    17.7 +#define XENBUS_IS_ERR_READ(str) ({			\
    17.8 +	if (!IS_ERR(str) && strlen(str) == 0) {		\
    17.9 +		kfree(str);				\
   17.10 +		str = ERR_PTR(-ERANGE);			\
   17.11 +	}						\
   17.12 +	IS_ERR(str);					\
   17.13 +})
   17.14 +
   17.15 +#define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)
   17.16 +
   17.17  #endif /* _ASM_XEN_XENBUS_H */