Skip to content

Commit 087ffec

Browse files
roygerkonradwilk
authored andcommitted
xen-blkback: use balloon pages for persistent grants
With current persistent grants implementation we are not freeing the persistent grants after we disconnect the device. Since grant map operations change the mfn of the allocated page, and we can no longer pass it to __free_page without setting the mfn to a sane value, use balloon grant pages instead, as the gntdev device does. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: stable@vger.kernel.org Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent f84adf4 commit 087ffec

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/block/xen-blkback/blkback.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <xen/xen.h>
4747
#include <asm/xen/hypervisor.h>
4848
#include <asm/xen/hypercall.h>
49+
#include <xen/balloon.h>
4950
#include "common.h"
5051

5152
/*
@@ -239,6 +240,7 @@ static void free_persistent_gnts(struct rb_root *root, unsigned int num)
239240
ret = gnttab_unmap_refs(unmap, NULL, pages,
240241
segs_to_unmap);
241242
BUG_ON(ret);
243+
free_xenballooned_pages(segs_to_unmap, pages);
242244
segs_to_unmap = 0;
243245
}
244246

@@ -527,8 +529,8 @@ static int xen_blkbk_map(struct blkif_request *req,
527529
GFP_KERNEL);
528530
if (!persistent_gnt)
529531
return -ENOMEM;
530-
persistent_gnt->page = alloc_page(GFP_KERNEL);
531-
if (!persistent_gnt->page) {
532+
if (alloc_xenballooned_pages(1, &persistent_gnt->page,
533+
false)) {
532534
kfree(persistent_gnt);
533535
return -ENOMEM;
534536
}

0 commit comments

Comments
 (0)