ia64/linux-2.6.18-xen.hg

changeset 866:cb25b9d5a594

blktap: don't use vma->vm_start to calculate offset.

struct vma can be split by partial munmap(), we can't depend on
vm_start. Instead, use tap_blkif_t::rings_vstart.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 28 13:43:46 2009 +0100 (2009-04-28)
parents 3232c6e19bdc
children 978499ee4f39
files drivers/xen/blktap/blktap.c
line diff
     1.1 --- a/drivers/xen/blktap/blktap.c	Tue Apr 28 13:43:06 2009 +0100
     1.2 +++ b/drivers/xen/blktap/blktap.c	Tue Apr 28 13:43:46 2009 +0100
     1.3 @@ -317,7 +317,7 @@ static pte_t blktap_clear_pte(struct vm_
     1.4  	pte_t copy;
     1.5  	tap_blkif_t *info;
     1.6  	int offset, seg, usr_idx, pending_idx, mmap_idx;
     1.7 -	unsigned long uvstart = vma->vm_start + (RING_PAGES << PAGE_SHIFT);
     1.8 +	unsigned long uvstart;
     1.9  	unsigned long kvaddr;
    1.10  	struct tap_vma_priv *priv;
    1.11  	struct page *pg;
    1.12 @@ -329,11 +329,15 @@ static pte_t blktap_clear_pte(struct vm_
    1.13  	 * If the address is before the start of the grant mapped region or
    1.14  	 * if vm_file is NULL (meaning mmap failed and we have nothing to do)
    1.15  	 */
    1.16 -	if (uvaddr < uvstart || vma->vm_file == NULL)
    1.17 +	if (vma->vm_file != NULL) {
    1.18 +		info = vma->vm_file->private_data;
    1.19 +		uvstart = info->rings_vstart + (RING_PAGES << PAGE_SHIFT);
    1.20 +	} else
    1.21 +		uvstart = uvaddr;	/* make the following if clause true */
    1.22 +	if (uvaddr < uvstart)
    1.23  		return ptep_get_and_clear_full(vma->vm_mm, uvaddr, 
    1.24  					       ptep, is_fullmm);
    1.25  
    1.26 -	info = vma->vm_file->private_data;
    1.27  	priv = vma->vm_private_data;
    1.28  
    1.29  	/* TODO Should these be changed to if statements? */
    1.30 @@ -1200,8 +1204,7 @@ static int blktap_read_ufe_ring(tap_blki
    1.31  
    1.32  			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
    1.33  			ClearPageReserved(pg);
    1.34 -			offset = (uvaddr - info->vma->vm_start) 
    1.35 -				>> PAGE_SHIFT;
    1.36 +			offset = (uvaddr - info->rings_vstart) >> PAGE_SHIFT;
    1.37  			priv->map[offset] = NULL;
    1.38  		}
    1.39  		fast_flush_area(pending_req, pending_idx, usr_idx, info->minor);
    1.40 @@ -1492,7 +1495,7 @@ static void dispatch_rw_block_io(blkif_t
    1.41  			set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
    1.42  					    FOREIGN_FRAME(map[i].dev_bus_addr
    1.43  							  >> PAGE_SHIFT));
    1.44 -			offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
    1.45 +			offset = (uvaddr - info->rings_vstart) >> PAGE_SHIFT;
    1.46  			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
    1.47  			priv->map[offset] = pg;
    1.48  		}
    1.49 @@ -1519,7 +1522,7 @@ static void dispatch_rw_block_io(blkif_t
    1.50  			if (ret)
    1.51  				continue;
    1.52  
    1.53 -			offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
    1.54 +			offset = (uvaddr - info->rings_vstart) >> PAGE_SHIFT;
    1.55  			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
    1.56  			priv->map[offset] = pg;
    1.57  		}