direct-io.hg

changeset 7258:c45c3d6b1a60

Update kernel watch API to pass the array of watch arguments to the callback
instead of just passing the node.

This allows us to extend watches to have additional arguments (like domids).

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Oct 07 15:52:43 2005 +0100 (2005-10-07)
parents 402b5eb85905
children 62d815160f01
files linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c 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/xenbus.c linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c linux-2.6-xen-sparse/include/asm-xen/xenbus.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Oct 07 15:51:53 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Oct 07 15:52:43 2005 +0100
     1.3 @@ -351,7 +351,8 @@ static struct xenbus_watch target_watch 
     1.4  };
     1.5  
     1.6  /* React to a change in the target key */
     1.7 -static void watch_target(struct xenbus_watch *watch, const char *node)
     1.8 +static void watch_target(struct xenbus_watch *watch,
     1.9 +			 const char **vec, unsigned int len)
    1.10  {
    1.11  	unsigned long long new_target;
    1.12  	int err;
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Oct 07 15:51:53 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Oct 07 15:52:43 2005 +0100
     2.3 @@ -55,7 +55,8 @@ static int blkback_remove(struct xenbus_
     2.4  }
     2.5  
     2.6  /* Front end tells us frame. */
     2.7 -static void frontend_changed(struct xenbus_watch *watch, const char *node)
     2.8 +static void frontend_changed(struct xenbus_watch *watch,
     2.9 +			     const char **vec, unsigned int len)
    2.10  {
    2.11  	unsigned long ring_ref;
    2.12  	unsigned int evtchn;
    2.13 @@ -64,7 +65,7 @@ static void frontend_changed(struct xenb
    2.14  		= container_of(watch, struct backend_info, watch);
    2.15  
    2.16  	/* If other end is gone, delete ourself. */
    2.17 -	if (node && !xenbus_exists(be->frontpath, "")) {
    2.18 +	if (vec && !xenbus_exists(be->frontpath, "")) {
    2.19  		device_unregister(&be->dev->dev);
    2.20  		return;
    2.21  	}
    2.22 @@ -143,7 +144,8 @@ again:
    2.23     We provide event channel and device details to front end.
    2.24     Frontend supplies shared frame and event channel.
    2.25   */
    2.26 -static void backend_changed(struct xenbus_watch *watch, const char *node)
    2.27 +static void backend_changed(struct xenbus_watch *watch,
    2.28 +			    const char **vec, unsigned int len)
    2.29  {
    2.30  	int err;
    2.31  	char *p;
    2.32 @@ -195,7 +197,7 @@ static void backend_changed(struct xenbu
    2.33  		}
    2.34  
    2.35  		/* Pass in NULL node to skip exist test. */
    2.36 -		frontend_changed(&be->watch, NULL);
    2.37 +		frontend_changed(&be->watch, NULL, 0);
    2.38  	}
    2.39  }
    2.40  
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Oct 07 15:51:53 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Oct 07 15:52:43 2005 +0100
     3.3 @@ -442,12 +442,16 @@ static struct xenbus_device_id blkfront_
     3.4  	{ "" }
     3.5  };
     3.6  
     3.7 -static void watch_for_status(struct xenbus_watch *watch, const char *node)
     3.8 +static void watch_for_status(struct xenbus_watch *watch,
     3.9 +			     const char **vec, unsigned int len)
    3.10  {
    3.11  	struct blkfront_info *info;
    3.12  	unsigned int binfo;
    3.13  	unsigned long sectors, sector_size;
    3.14  	int err;
    3.15 +	const char *node;
    3.16 +
    3.17 +	node = vec[XS_WATCH_PATH];
    3.18  
    3.19  	info = container_of(watch, struct blkfront_info, watch);
    3.20  	node += strlen(watch->node);
    3.21 @@ -652,8 +656,17 @@ static int blkfront_probe(struct xenbus_
    3.22  		return err;
    3.23  	}
    3.24  
    3.25 -	/* Call once in case entries already there. */
    3.26 -	watch_for_status(&info->watch, info->watch.node);
    3.27 +	{
    3.28 +		unsigned int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1;
    3.29 +		const char *vec[len];
    3.30 +
    3.31 +		vec[XS_WATCH_PATH] = info->watch.node;
    3.32 +		vec[XS_WATCH_TOKEN] = NULL;
    3.33 +
    3.34 +		/* Call once in case entries already there. */
    3.35 +		watch_for_status(&info->watch, vec, len);
    3.36 +	}
    3.37 +
    3.38  	return 0;
    3.39  }
    3.40  
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Fri Oct 07 15:51:53 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Fri Oct 07 15:52:43 2005 +0100
     4.3 @@ -59,7 +59,8 @@ static int blkback_remove(struct xenbus_
     4.4  }
     4.5  
     4.6  /* Front end tells us frame. */
     4.7 -static void frontend_changed(struct xenbus_watch *watch, const char *node)
     4.8 +static void frontend_changed(struct xenbus_watch *watch,
     4.9 +			     const char **vec, unsigned int len)
    4.10  {
    4.11  	unsigned long ring_ref;
    4.12  	unsigned int evtchn;
    4.13 @@ -68,7 +69,7 @@ static void frontend_changed(struct xenb
    4.14  		= container_of(watch, struct backend_info, watch);
    4.15  
    4.16  	/* If other end is gone, delete ourself. */
    4.17 -	if (node && !xenbus_exists(be->frontpath, "")) {
    4.18 +	if (vec && !xenbus_exists(be->frontpath, "")) {
    4.19  		xenbus_rm(be->dev->nodename, "");
    4.20  		device_unregister(&be->dev->dev);
    4.21  		return;
    4.22 @@ -106,7 +107,8 @@ abort:
    4.23     We provide event channel and device details to front end.
    4.24     Frontend supplies shared frame and event channel.
    4.25   */
    4.26 -static void backend_changed(struct xenbus_watch *watch, const char *node)
    4.27 +static void backend_changed(struct xenbus_watch *watch,
    4.28 +			    const char **vec, unsigned int len)
    4.29  {
    4.30  	int err;
    4.31  	char *p;
    4.32 @@ -129,7 +131,7 @@ static void backend_changed(struct xenbu
    4.33  		}
    4.34  
    4.35  		/* Pass in NULL node to skip exist test. */
    4.36 -		frontend_changed(&be->watch, NULL);
    4.37 +		frontend_changed(&be->watch, NULL, 0);
    4.38  	}
    4.39  }
    4.40  
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Fri Oct 07 15:51:53 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Fri Oct 07 15:52:43 2005 +0100
     5.3 @@ -57,7 +57,8 @@ static int netback_remove(struct xenbus_
     5.4  }
     5.5  
     5.6  /* Front end tells us frame. */
     5.7 -static void frontend_changed(struct xenbus_watch *watch, const char *node)
     5.8 +static void frontend_changed(struct xenbus_watch *watch, 
     5.9 +			     const char **vec, unsigned int len)
    5.10  {
    5.11  	unsigned long tx_ring_ref, rx_ring_ref;
    5.12  	unsigned int evtchn;
    5.13 @@ -68,7 +69,7 @@ static void frontend_changed(struct xenb
    5.14  	int i;
    5.15  
    5.16  	/* If other end is gone, delete ourself. */
    5.17 -	if (node && !xenbus_exists(be->frontpath, "")) {
    5.18 +	if (vec && !xenbus_exists(be->frontpath, "")) {
    5.19  		xenbus_rm(be->dev->nodename, "");
    5.20  		device_unregister(&be->dev->dev);
    5.21  		return;
    5.22 @@ -126,7 +127,8 @@ static void frontend_changed(struct xenb
    5.23     We provide event channel and device details to front end.
    5.24     Frontend supplies shared frame and event channel.
    5.25   */
    5.26 -static void backend_changed(struct xenbus_watch *watch, const char *node)
    5.27 +static void backend_changed(struct xenbus_watch *watch,
    5.28 +			    const char **vec, unsigned int len)
    5.29  {
    5.30  	int err;
    5.31  	long int handle;
    5.32 @@ -163,7 +165,7 @@ static void backend_changed(struct xenbu
    5.33  		kobject_hotplug(&dev->dev.kobj, KOBJ_ONLINE);
    5.34  
    5.35  		/* Pass in NULL node to skip exist test. */
    5.36 -		frontend_changed(&be->watch, NULL);
    5.37 +		frontend_changed(&be->watch, NULL, 0);
    5.38  	}
    5.39  }
    5.40  
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Oct 07 15:51:53 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Oct 07 15:52:43 2005 +0100
     6.3 @@ -963,7 +963,8 @@ static struct xenbus_device_id netfront_
     6.4  	{ "" }
     6.5  };
     6.6  
     6.7 -static void watch_for_status(struct xenbus_watch *watch, const char *node)
     6.8 +static void watch_for_status(struct xenbus_watch *watch,
     6.9 +			     const char **vec, unsigned int len)
    6.10  {
    6.11  }
    6.12  
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Fri Oct 07 15:51:53 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Fri Oct 07 15:52:43 2005 +0100
     7.3 @@ -59,7 +59,8 @@ static int tpmback_remove(struct xenbus_
     7.4  }
     7.5  
     7.6  
     7.7 -static void frontend_changed(struct xenbus_watch *watch, const char *node)
     7.8 +static void frontend_changed(struct xenbus_watch *watch,
     7.9 +			     const char **vec, unsigned int len)
    7.10  {
    7.11  	unsigned long ringref;
    7.12  	unsigned int evtchn;
    7.13 @@ -69,7 +70,7 @@ static void frontend_changed(struct xenb
    7.14  		= container_of(watch, struct backend_info, watch);
    7.15  
    7.16  	/* If other end is gone, delete ourself. */
    7.17 -	if (node && !xenbus_exists(be->frontpath, "")) {
    7.18 +	if (vec && !xenbus_exists(be->frontpath, "")) {
    7.19  		xenbus_rm(be->dev->nodename, "");
    7.20  		device_unregister(&be->dev->dev);
    7.21  		return;
    7.22 @@ -142,7 +143,8 @@ abort:
    7.23  }
    7.24  
    7.25  
    7.26 -static void backend_changed(struct xenbus_watch *watch, const char *node)
    7.27 +static void backend_changed(struct xenbus_watch *watch,
    7.28 +			    const char **vec, unsigned int len)
    7.29  {
    7.30  	int err;
    7.31  	long int instance;
    7.32 @@ -166,6 +168,9 @@ static void backend_changed(struct xenbu
    7.33  	be->instance = instance;
    7.34  
    7.35  	if (be->tpmif == NULL) {
    7.36 +		unsigned int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1;
    7.37 +		const char *vec[len];
    7.38 +
    7.39  		be->tpmif = tpmif_find(be->frontend_id,
    7.40  		                       instance);
    7.41  		if (IS_ERR(be->tpmif)) {
    7.42 @@ -175,8 +180,11 @@ static void backend_changed(struct xenbu
    7.43  			return;
    7.44  		}
    7.45  
    7.46 +		vec[XS_WATCH_PATH] = be->frontpath;
    7.47 +		vec[XS_WATCH_TOKEN] = NULL;
    7.48 +
    7.49  		/* Pass in NULL node to skip exist test. */
    7.50 -		frontend_changed(&be->watch, be->frontpath);
    7.51 +		frontend_changed(&be->watch, vec, len);
    7.52  	}
    7.53  }
    7.54  
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Fri Oct 07 15:51:53 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Fri Oct 07 15:52:43 2005 +0100
     8.3 @@ -211,12 +211,14 @@ static int tpm_fe_send_upperlayer(const 
     8.4   XENBUS support code
     8.5  **************************************************************/
     8.6  
     8.7 -static void watch_for_status(struct xenbus_watch *watch, const char *node)
     8.8 +static void watch_for_status(struct xenbus_watch *watch,
     8.9 +			     const char **vec, unsigned int len)
    8.10  {
    8.11  	struct tpmfront_info *info;
    8.12  	int err;
    8.13  	unsigned long ready;
    8.14  	struct tpm_private *tp = &my_private;
    8.15 +	const char *node = vec[XS_WATCH_PATH];
    8.16  
    8.17  	info = container_of(watch, struct tpmfront_info, watch);
    8.18  	node += strlen(watch->node);
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Oct 07 15:51:53 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Oct 07 15:52:43 2005 +0100
     9.3 @@ -562,14 +562,16 @@ static void dev_changed(const char *node
     9.4  	kfree(root);
     9.5  }
     9.6  
     9.7 -static void frontend_changed(struct xenbus_watch *watch, const char *node)
     9.8 +static void frontend_changed(struct xenbus_watch *watch,
     9.9 +			     const char **vec, unsigned int len)
    9.10  {
    9.11 -	dev_changed(node, &xenbus_frontend);
    9.12 +	dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
    9.13  }
    9.14  
    9.15 -static void backend_changed(struct xenbus_watch *watch, const char *node)
    9.16 +static void backend_changed(struct xenbus_watch *watch,
    9.17 +			    const char **vec, unsigned int len)
    9.18  {
    9.19 -	dev_changed(node, &xenbus_backend);
    9.20 +	dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
    9.21  }
    9.22  
    9.23  /* We watch for devices appearing and vanishing. */
    10.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Fri Oct 07 15:51:53 2005 +0100
    10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Fri Oct 07 15:52:43 2005 +0100
    10.3 @@ -551,7 +551,7 @@ static int watch_thread(void *unused)
    10.4  				       vec[XS_WATCH_TOKEN], err);
    10.5  			w = find_watch(vec[XS_WATCH_TOKEN]);
    10.6  			BUG_ON(!w);
    10.7 -			w->callback(w, vec[XS_WATCH_PATH]);
    10.8 +			w->callback(w, (const char **)vec, num);
    10.9  			kfree(vec);
   10.10  		} else if (vec)
   10.11  			printk(KERN_WARNING "XENBUS xs_read_watch: %li\n",
    11.1 --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Fri Oct 07 15:51:53 2005 +0100
    11.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Fri Oct 07 15:52:43 2005 +0100
    11.3 @@ -34,6 +34,9 @@
    11.4  #include <linux/notifier.h>
    11.5  #include <asm/semaphore.h>
    11.6  
    11.7 +/* FIXME there's got to be a better way to get at the XS_WATCH macros */
    11.8 +#include <asm-xen/linux-public/xenstored.h>
    11.9 +
   11.10  /* A xenbus device. */
   11.11  struct xenbus_device {
   11.12  	char *devicetype;
   11.13 @@ -113,7 +116,8 @@ struct xenbus_watch
   11.14  {
   11.15  	struct list_head list;
   11.16  	char *node;
   11.17 -	void (*callback)(struct xenbus_watch *, const char *node);
   11.18 +	void (*callback)(struct xenbus_watch *,
   11.19 +			 const char **vec, unsigned int len);
   11.20  };
   11.21  
   11.22  /* notifer routines for when the xenstore comes up */