WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 1 of 2] Small changes to blktap: free memory on relea

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [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
From: Geoffrey Lefebvre <geoffrey@xxxxxxxxx>
Date: Mon, 21 May 2007 16:23:39 -0700
Cc: Jake.Wires@xxxxxxxxxxxxx, andrew.warfield@xxxxxxxxxxxx
Delivery-date: Wed, 23 May 2007 02:13:13 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1179789818@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>