ia64/linux-2.6.18-xen.hg

changeset 865:3232c6e19bdc

blktap: fix race memory refernce with ring_ok.

fix race memory refernce with ring_ok.
ring_ok is shared by mmapping process and blktap kernel thread.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 28 13:43:06 2009 +0100 (2009-04-28)
parents 613216635ff0
children cb25b9d5a594
files drivers/xen/blktap/blktap.c
line diff
     1.1 --- a/drivers/xen/blktap/blktap.c	Tue Apr 28 13:42:32 2009 +0100
     1.2 +++ b/drivers/xen/blktap/blktap.c	Tue Apr 28 13:43:06 2009 +0100
     1.3 @@ -617,6 +617,9 @@ static int blktap_release(struct inode *
     1.4  	if (!info)
     1.5  		return 0;
     1.6  
     1.7 +	info->ring_ok = 0;
     1.8 +	smp_wmb();
     1.9 +
    1.10  	info->dev_inuse = 0;
    1.11  	DPRINTK("Freeing device [/dev/xen/blktap%d]\n",info->minor);
    1.12  
    1.13 @@ -717,6 +720,7 @@ static int blktap_mmap(struct file *filp
    1.14  #endif
    1.15  
    1.16  	info->vma = vma;
    1.17 +	smp_wmb();
    1.18  	info->ring_ok = 1;
    1.19  	return 0;
    1.20   fail:
    1.21 @@ -1390,6 +1394,7 @@ static void dispatch_rw_block_io(blkif_t
    1.22  		WPRINTK("blktap: ring not ready for requests!\n");
    1.23  		goto fail_response;
    1.24  	}
    1.25 +	smp_rmb();
    1.26  
    1.27  	if (RING_FULL(&info->ufe_ring)) {
    1.28  		WPRINTK("blktap: fe_ring is full, can't add "