aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/blkback/blkback.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-03-01 16:26:10 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-04-14 18:26:23 -0400
commit464fb419e17083a18b636c9f4714fc49ef6857d2 (patch)
treed7465d607fc9fffb9ec91bc9c97106ea401c33d1 /drivers/xen/blkback/blkback.c
parentc35950bfa9abaaf16548a287a8d5d782a361414f (diff)
xen/blkback: Use 'vzalloc' for page arrays and pre-allocate pages.
Previously we would allocate the array for page using 'kmalloc' which we can as easily do with 'vzalloc'. The pre-allocation of pages was done a bit differently in the past - it used to be that the balloon driver would export "alloc_empty_pages_and_pagevec" which would have in one function created an array, allocated the pages, balloned the pages out (so the memory behind those pages would be non-present), and provide us those pages. This was OK as those pages were shared between other guest and the only thing we needed was to "swizzel" the MFN of those pages to point to the other guest MFN. We can still "swizzel" the MFNs using the M2P (and P2M) override API calls, but for the sake of simplicity we are dropping the balloon API calls. We can return to those later on. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/blkback/blkback.c')
-rw-r--r--drivers/xen/blkback/blkback.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/xen/blkback/blkback.c b/drivers/xen/blkback/blkback.c
index eda50646775d..d32198d1be04 100644
--- a/drivers/xen/blkback/blkback.c
+++ b/drivers/xen/blkback/blkback.c
@@ -637,18 +637,23 @@ static int __init blkif_init(void)
637 637
638 blkbk->pending_reqs = kmalloc(sizeof(blkbk->pending_reqs[0]) * 638 blkbk->pending_reqs = kmalloc(sizeof(blkbk->pending_reqs[0]) *
639 blkif_reqs, GFP_KERNEL); 639 blkif_reqs, GFP_KERNEL);
640 blkbk->pending_grant_handles = kmalloc(sizeof(blkbk->pending_grant_handles[0]) * 640 blkbk->pending_grant_handles = vzalloc(sizeof(blkbk->pending_grant_handles[0]) *
641 mmap_pages, GFP_KERNEL); 641 mmap_pages);
642 blkbk->pending_pages = alloc_empty_pages_and_pagevec(mmap_pages); 642 blkbk->pending_pages = vzalloc(sizeof(blkbk->pending_pages[0]) * mmap_pages);
643 643
644 if (!blkbk->pending_reqs || !blkbk->pending_grant_handles || !blkbk->pending_pages) { 644 if (!blkbk->pending_reqs || !blkbk->pending_grant_handles || !blkbk->pending_pages) {
645 rc = -ENOMEM; 645 rc = -ENOMEM;
646 goto out_of_memory; 646 goto out_of_memory;
647 } 647 }
648 648
649 for (i = 0; i < mmap_pages; i++) 649 for (i = 0; i < mmap_pages; i++) {
650 blkbk->pending_grant_handles[i] = BLKBACK_INVALID_HANDLE; 650 blkbk->pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
651 651 blkbk->pending_pages[i] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
652 if (blkbk->pending_pages[i] == NULL) {
653 rc = -ENOMEM;
654 goto out_of_memory;
655 }
656 }
652 rc = blkif_interface_init(); 657 rc = blkif_interface_init();
653 if (rc) 658 if (rc)
654 goto failed_init; 659 goto failed_init;
@@ -672,8 +677,12 @@ static int __init blkif_init(void)
672 printk(KERN_ERR "%s: out of memory\n", __func__); 677 printk(KERN_ERR "%s: out of memory\n", __func__);
673 failed_init: 678 failed_init:
674 kfree(blkbk->pending_reqs); 679 kfree(blkbk->pending_reqs);
675 kfree(blkbk->pending_grant_handles); 680 vfree(blkbk->pending_grant_handles);
676 free_empty_pages_and_pagevec(blkbk->pending_pages, mmap_pages); 681 for (i = 0; i < mmap_pages; i++) {
682 if (blkbk->pending_pages[i])
683 __free_page(blkbk->pending_pages[i]);
684 }
685 vfree(blkbk->pending_pages);
677 vfree(blkbk); 686 vfree(blkbk);
678 blkbk = NULL; 687 blkbk = NULL;
679 return rc; 688 return rc;