From 46b46554c01c9be10ffd80ec288449e5e61a79cc Mon Sep 17 00:00:00 2001 From: t_jeang Date: Tue, 6 Jan 2009 12:06:01 +0000 Subject: [PATCH] imported patch backend-track-pages-with-page-flags.patch --- drivers/xen/blkback/blkback.c | 3 +++ drivers/xen/blktap/blktap.c | 3 +++ drivers/xen/core/gnttab.c | 2 ++ drivers/xen/netback/netback.c | 10 ++++++++-- include/linux/page-flags.h | 10 ++++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/xen/blkback/blkback.c b/drivers/xen/blkback/blkback.c index e75c1db8..4b8b5ba6 100644 --- a/drivers/xen/blkback/blkback.c +++ b/drivers/xen/blkback/blkback.c @@ -615,6 +615,9 @@ static int __init blkif_init(void) mmap_pages, GFP_KERNEL); pending_pages = alloc_empty_pages_and_pagevec(mmap_pages); + for(i = 0; i < mmap_pages; i++) + SetPageBlkback(pending_pages[i]); + if (!pending_reqs || !pending_grant_handles || !pending_pages) goto out_of_memory; diff --git a/drivers/xen/blktap/blktap.c b/drivers/xen/blktap/blktap.c index 5b00751d..a2f51ce7 100644 --- a/drivers/xen/blktap/blktap.c +++ b/drivers/xen/blktap/blktap.c @@ -875,6 +875,9 @@ static int req_increase(void) DPRINTK("%s: reqs=%d, pages=%d\n", __FUNCTION__, blkif_reqs, mmap_pages); + for (i = 0; i < mmap_pages; i++) + SetPageBlkback(foreign_pages[mmap_alloc][i]); + for (i = 0; i < MAX_PENDING_REQS; i++) { list_add_tail(&pending_reqs[mmap_alloc][i].free_list, &pending_free); diff --git a/drivers/xen/core/gnttab.c b/drivers/xen/core/gnttab.c index fd83ea0b..9b1e4d24 100644 --- a/drivers/xen/core/gnttab.c +++ b/drivers/xen/core/gnttab.c @@ -589,6 +589,8 @@ int gnttab_copy_grant_page(grant_ref_t ref, struct page **pagep) *pagep = new_page; SetPageForeign(page, gnttab_page_free); + ClearPageNetback(page); + ClearPageBlkback(page); page->mapping = NULL; out: diff --git a/drivers/xen/netback/netback.c b/drivers/xen/netback/netback.c index 145f67db..d771bf06 100644 --- a/drivers/xen/netback/netback.c +++ b/drivers/xen/netback/netback.c @@ -863,8 +863,13 @@ static void tx_credit_callback(unsigned long data) static inline int copy_pending_req(PEND_RING_IDX pending_idx) { - return gnttab_copy_grant_page(grant_tx_handle[pending_idx], - &mmap_pages[pending_idx]); + int err = gnttab_copy_grant_page(grant_tx_handle[pending_idx], + &mmap_pages[pending_idx]); + + if (!err) + SetPageNetback(mmap_pages[pending_idx]); + + return err; } inline static void net_tx_action_dealloc(void) @@ -1590,6 +1595,7 @@ static int __init netback_init(void) for (i = 0; i < MAX_PENDING_REQS; i++) { page = mmap_pages[i]; SetPageForeign(page, netif_page_release); + SetPageNetback(page); netif_set_page_index(page, i); INIT_LIST_HEAD(&pending_inuse[i].list); } diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index cab8551b..e2f91529 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -104,6 +104,16 @@ #define PG_foreign 20 /* Page is owned by foreign allocator. */ +#define PG_netback 21 /* Page is owned by netback */ +#define PageNetback(page) test_bit(PG_netback, &(page)->flags) +#define SetPageNetback(page) set_bit(PG_netback, &(page)->flags) +#define ClearPageNetback(page) clear_bit(PG_netback, &(page)->flags) + +#define PG_blkback 22 /* Page is owned by blkback */ +#define PageBlkback(page) test_bit(PG_blkback, &(page)->flags) +#define SetPageBlkback(page) set_bit(PG_blkback, &(page)->flags) +#define ClearPageBlkback(page) clear_bit(PG_blkback, &(page)->flags) + /* * Manipulation of page state flags */ -- 2.39.5