ia64/xen-unstable

changeset 9735:83eb8d81c96f

Read the message type out of the message before sending it to xenstored, and
use that saved value when handling the reply. Xenstored will leave the
message type intact, _except_ when returning an error, in which case it will
change the type to XS_ERROR. This meant that we failed to remove a
transaction from our internal list if xenstored returned EAGAIN, as we did not
realise that the message was XS_TRANSACTION_END. This manifested itself as
the intended behaviour until the connection was closed, at which point all of
those failed transactions would erroneously be aborted.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sat Apr 15 19:25:09 2006 +0100 (2006-04-15)
parents 19c55935580f
children 91da9a1b7196
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Wed Apr 12 18:53:38 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Sat Apr 15 19:25:09 2006 +0100
     1.3 @@ -114,6 +114,7 @@ static ssize_t xenbus_dev_write(struct f
     1.4  {
     1.5  	struct xenbus_dev_data *u = filp->private_data;
     1.6  	struct xenbus_dev_transaction *trans = NULL;
     1.7 +	uint32_t msg_type;
     1.8  	void *reply;
     1.9  
    1.10  	if ((len + u->len) > sizeof(u->u.buffer))
    1.11 @@ -126,7 +127,9 @@ static ssize_t xenbus_dev_write(struct f
    1.12  	if (u->len < (sizeof(u->u.msg) + u->u.msg.len))
    1.13  		return len;
    1.14  
    1.15 -	switch (u->u.msg.type) {
    1.16 +	msg_type = u->u.msg.type;
    1.17 +
    1.18 +	switch (msg_type) {
    1.19  	case XS_TRANSACTION_START:
    1.20  	case XS_TRANSACTION_END:
    1.21  	case XS_DIRECTORY:
    1.22 @@ -138,7 +141,7 @@ static ssize_t xenbus_dev_write(struct f
    1.23  	case XS_MKDIR:
    1.24  	case XS_RM:
    1.25  	case XS_SET_PERMS:
    1.26 -		if (u->u.msg.type == XS_TRANSACTION_START) {
    1.27 +		if (msg_type == XS_TRANSACTION_START) {
    1.28  			trans = kmalloc(sizeof(*trans), GFP_KERNEL);
    1.29  			if (!trans)
    1.30  				return -ENOMEM;
    1.31 @@ -150,10 +153,10 @@ static ssize_t xenbus_dev_write(struct f
    1.32  			return PTR_ERR(reply);
    1.33  		}
    1.34  
    1.35 -		if (u->u.msg.type == XS_TRANSACTION_START) {
    1.36 +		if (msg_type == XS_TRANSACTION_START) {
    1.37  			trans->handle = simple_strtoul(reply, NULL, 0);
    1.38  			list_add(&trans->list, &u->transactions);
    1.39 -		} else if (u->u.msg.type == XS_TRANSACTION_END) {
    1.40 +		} else if (msg_type == XS_TRANSACTION_END) {
    1.41  			list_for_each_entry(trans, &u->transactions, list)
    1.42  				if (trans->handle == u->u.msg.tx_id)
    1.43  					break;