direct-io.hg

changeset 14404:422a61ebac54

xenbus: Clarify and simplify barrier usage.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Mar 16 10:42:25 2007 +0000 (2007-03-16)
parents 26a1378d5ece
children 8e76e1b95b12
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Fri Mar 16 10:24:56 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Fri Mar 16 10:42:25 2007 +0000
     1.3 @@ -110,7 +110,6 @@ int xb_write(const void *data, unsigned 
     1.4  		/* Read indexes, then verify. */
     1.5  		cons = intf->req_cons;
     1.6  		prod = intf->req_prod;
     1.7 -		mb();
     1.8  		if (!check_indexes(cons, prod)) {
     1.9  			intf->req_cons = intf->req_prod = 0;
    1.10  			return -EIO;
    1.11 @@ -122,15 +121,18 @@ int xb_write(const void *data, unsigned 
    1.12  		if (avail > len)
    1.13  			avail = len;
    1.14  
    1.15 +		/* Must write data /after/ reading the consumer index. */
    1.16 +		mb();
    1.17 +
    1.18  		memcpy(dst, data, avail);
    1.19  		data += avail;
    1.20  		len -= avail;
    1.21  
    1.22 -		/* Other side must not see new header until data is there. */
    1.23 +		/* Other side must not see new producer until data is there. */
    1.24  		wmb();
    1.25  		intf->req_prod += avail;
    1.26  
    1.27 -		/* This implies mb() before other side sees interrupt. */
    1.28 +		/* Implies mb(): other side will see the updated producer. */
    1.29  		notify_remote_via_evtchn(xen_store_evtchn);
    1.30  	}
    1.31  
    1.32 @@ -165,7 +167,6 @@ int xb_read(void *data, unsigned len)
    1.33  		/* Read indexes, then verify. */
    1.34  		cons = intf->rsp_cons;
    1.35  		prod = intf->rsp_prod;
    1.36 -		mb();
    1.37  		if (!check_indexes(cons, prod)) {
    1.38  			intf->rsp_cons = intf->rsp_prod = 0;
    1.39  			return -EIO;
    1.40 @@ -177,7 +178,7 @@ int xb_read(void *data, unsigned len)
    1.41  		if (avail > len)
    1.42  			avail = len;
    1.43  
    1.44 -		/* We must read header before we read data. */
    1.45 +		/* Must read data /after/ reading the producer index. */
    1.46  		rmb();
    1.47  
    1.48  		memcpy(data, src, avail);
    1.49 @@ -190,7 +191,7 @@ int xb_read(void *data, unsigned len)
    1.50  
    1.51  		pr_debug("Finished read of %i bytes (%i to go)\n", avail, len);
    1.52  
    1.53 -		/* Implies mb(): they will see new header. */
    1.54 +		/* Implies mb(): other side will see the updated consumer. */
    1.55  		notify_remote_via_evtchn(xen_store_evtchn);
    1.56  	}
    1.57