From: Bobi Jam Date: Mon, 2 Jul 2012 08:56:07 +0000 (+0800) Subject: LU-1576 llite: correct page usage count X-Git-Tag: 2.1.3-RC1~17 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7cd8b93461905334d227f3e6203b2862965f411f;p=fs%2Flustre-release.git 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 --- diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index b9513c5..e0ee1c4 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -857,7 +857,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 067788b..e2979f5 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -254,7 +254,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 {