From 01bd9accf1f2edcafe63aaf923b173642a88840f Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Mon, 2 Jul 2012 16:56:07 +0800 Subject: [PATCH] LU-1576 llite: correct page usage count If kernel has add_to_page_cache_lru(), the ll_pagevec_add() is defined as an empty function, while page_cache_get(page) only makes sense if ll_pagevec_add() is defined. This patch moves page_cache_get into ll_pagevec_add() macro definition. Signed-off-by: Bobi Jam Change-Id: Iad98aacff43beec3e7a64fd1a778f549250aa5b8 Reviewed-on: http://review.whamcloud.com/3255 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/include/linux/lustre_compat25.h | 8 +++++++- lustre/llite/dir.c | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index abca410..922d054 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -822,7 +822,13 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) #define ll_add_to_page_cache_lru(pg, mapping, off, gfp) \ add_to_page_cache(pg, mapping, off, gfp) #define ll_pagevec_init(pv, cold) pagevec_init(&lru_pvec, cold); -#define ll_pagevec_add(pv, pg) pagevec_add(pv, pg) +#define ll_pagevec_add(pv, pg) \ +({ \ + int __ret; \ + \ + page_cache_get(pg); \ + __ret = pagevec_add(pv, pg); \ +}) #define ll_pagevec_lru_add_file(pv) pagevec_lru_add_file(pv) #endif diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 2cbad3f..bd8bda6 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -245,7 +245,6 @@ static int ll_dir_readpage(struct file *file, struct page *page0) GFP_KERNEL); if (ret == 0) { unlock_page(page); - page_cache_get(page); if (ll_pagevec_add(&lru_pvec, page) == 0) ll_pagevec_lru_add_file(&lru_pvec); } else { -- 1.8.3.1