Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Roger Pau Monne and committed by
Konrad Rzeszutek Wilk
087ffecd f84adf49

+4 -2
+4 -2
drivers/block/xen-blkback/blkback.c
··· 46 46 #include <xen/xen.h> 47 47 #include <asm/xen/hypervisor.h> 48 48 #include <asm/xen/hypercall.h> 49 + #include <xen/balloon.h> 49 50 #include "common.h" 50 51 51 52 /* ··· 240 239 ret = gnttab_unmap_refs(unmap, NULL, pages, 241 240 segs_to_unmap); 242 241 BUG_ON(ret); 242 + free_xenballooned_pages(segs_to_unmap, pages); 243 243 segs_to_unmap = 0; 244 244 } 245 245 ··· 529 527 GFP_KERNEL); 530 528 if (!persistent_gnt) 531 529 return -ENOMEM; 532 - persistent_gnt->page = alloc_page(GFP_KERNEL); 533 - if (!persistent_gnt->page) { 530 + if (alloc_xenballooned_pages(1, &persistent_gnt->page, 531 + false)) { 534 532 kfree(persistent_gnt); 535 533 return -ENOMEM; 536 534 }