[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1 of 2] Small changes to blktap: free memory on release, invalidate p2m entry when unmapping grants, check for alloc failure of idx_map, added DONTCOPY flag
# HG changeset patch # User Geoffrey Lefebvre <geoffrey@xxxxxxxxx> # Date 1179788512 25200 # Node ID f5218394705702c1aaa02520be2ba5a9f2648f37 # Parent 9cf9027ec568929946a1ee9094821fdec1eb68ff Small changes to blktap: free memory on release, invalidate p2m entry when unmapping grants, check for alloc failure of idx_map, added DONTCOPY flag. diff -r 9cf9027ec568 -r f52183947057 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Sat May 19 16:41:48 2007 -0700 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Mon May 21 16:01:52 2007 -0700 @@ -477,6 +477,11 @@ static int blktap_open(struct inode *ino info->idx_map = kmalloc(sizeof(unsigned long) * MAX_PENDING_REQS, GFP_KERNEL); + if (info->idx_map == NULL) { + goto fail_nomem; + } + + if (idx > 0) { init_waitqueue_head(&info->wait); for (i = 0; i < MAX_PENDING_REQS; i++) @@ -510,16 +515,24 @@ static int blktap_release(struct inode * zap_page_range( info->vma, info->vma->vm_start, info->vma->vm_end - info->vma->vm_start, NULL); + + kfree(info->vma->vm_private_data); + info->vma = NULL; } - + + if (info->idx_map) { + kfree(info->idx_map); + info->idx_map = NULL; + } + if ( (info->status != CLEANSHUTDOWN) && (info->blkif != NULL) ) { if (info->blkif->xenblkd != NULL) { kthread_stop(info->blkif->xenblkd); info->blkif->xenblkd = NULL; } info->status = CLEANSHUTDOWN; - } + } return 0; } @@ -590,6 +603,7 @@ static int blktap_mmap(struct file *filp vma->vm_private_data = map; vma->vm_flags |= VM_FOREIGN; + vma->vm_flags |= VM_DONTCOPY; info->vma = vma; info->ring_ok = 1; @@ -885,6 +899,10 @@ static void fast_flush_area(pending_req_ idx_to_kaddr(mmap_idx, k_idx, i), GNTMAP_host_map, khandle->kernel); invcount++; + + set_phys_to_machine( + __pa(idx_to_kaddr(mmap_idx, k_idx, i)) + >> PAGE_SHIFT, INVALID_P2M_ENTRY); } if (khandle->user != INVALID_GRANT_HANDLE) { _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |