Whamcloud - gitweb
LU-1576 llite: correct page usage count
authorBobi Jam <bobijam@whamcloud.com>
Mon, 2 Jul 2012 08:56:07 +0000 (16:56 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 Jul 2012 17:05:15 +0000 (13:05 -0400)
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 <bobijam@whamcloud.com>
Change-Id: Iad98aacff43beec3e7a64fd1a778f549250aa5b8
Reviewed-on: http://review.whamcloud.com/3255
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/linux/lustre_compat25.h
lustre/llite/dir.c

index abca410..922d054 100644 (file)
@@ -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_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
 
 #define ll_pagevec_lru_add_file(pv)     pagevec_lru_add_file(pv)
 #endif
 
index 2cbad3f..bd8bda6 100644 (file)
@@ -245,7 +245,6 @@ static int ll_dir_readpage(struct file *file, struct page *page0)
                                                GFP_KERNEL);
                 if (ret == 0) {
                         unlock_page(page);
                                                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 {
                         if (ll_pagevec_add(&lru_pvec, page) == 0)
                                 ll_pagevec_lru_add_file(&lru_pvec);
                 } else {