direct-io.hg

changeset 7288:03d69dbea152

Fire watch callbacks on their own workqueue. Mainly this is
to make debugging easier (it's hard if an error takes out
the default workqueue!). Also, watch callbacks can be
arbitrarily long-lived, so it's more polite.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Oct 10 16:57:41 2005 +0100 (2005-10-10)
parents f9bd8df8a098
children 5134f3c512c8
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Oct 10 16:16:41 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Oct 10 16:57:41 2005 +0100
     1.3 @@ -79,6 +79,7 @@ static struct xs_handle xs_state;
     1.4  
     1.5  static LIST_HEAD(watches);
     1.6  static DEFINE_SPINLOCK(watches_lock);
     1.7 +static struct workqueue_struct *watches_workq;
     1.8  
     1.9  static int get_error(const char *errorstring)
    1.10  {
    1.11 @@ -626,7 +627,7 @@ void unregister_xenbus_watch(struct xenb
    1.12  	up_read(&xs_state.suspend_mutex);
    1.13  
    1.14  	/* Make sure watch is not in use. */
    1.15 -	flush_scheduled_work();
    1.16 +	flush_workqueue(watches_workq);
    1.17  }
    1.18  EXPORT_SYMBOL(unregister_xenbus_watch);
    1.19  
    1.20 @@ -708,7 +709,7 @@ static int process_msg(void)
    1.21  		msg->u.watch.handle = find_watch(
    1.22  			msg->u.watch.vec[XS_WATCH_TOKEN]);
    1.23  		if (msg->u.watch.handle != NULL) {
    1.24 -			schedule_work(&msg->u.watch.work);
    1.25 +			queue_work(watches_workq, &msg->u.watch.work);
    1.26  		} else {
    1.27  			kfree(msg->u.watch.vec);
    1.28  			kfree(msg);
    1.29 @@ -737,9 +738,6 @@ static int read_thread(void *unused)
    1.30  	}
    1.31  }
    1.32  
    1.33 -/*
    1.34 -** Initialize the interface to xenstore. 
    1.35 -*/
    1.36  int xs_init(void)
    1.37  {
    1.38  	int err;
    1.39 @@ -756,8 +754,12 @@ int xs_init(void)
    1.40  	err = xb_init_comms();
    1.41  	if (err)
    1.42  		return err;
    1.43 -	
    1.44 -	reader = kthread_run(read_thread, NULL, "xenbusd");
    1.45 +
    1.46 +	/* Create our own workqueue for executing watch callbacks. */
    1.47 +	watches_workq = create_singlethread_workqueue("xenwatch");
    1.48 +	BUG_ON(watches_workq == NULL);
    1.49 +
    1.50 +	reader = kthread_run(read_thread, NULL, "xenbus");
    1.51  	if (IS_ERR(reader))
    1.52  		return PTR_ERR(reader);
    1.53