ceph: use __page_cache_alloc and add_to_page_cache_lru
authorYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 17 Mar 2010 20:54:02 +0000 (13:54 -0700)
committerSage Weil <sage@newdream.net>
Mon, 17 May 2010 22:25:12 +0000 (15:25 -0700)
Following Nick Piggin patches in btrfs, pagecache pages should be
allocated with __page_cache_alloc, so they obey pagecache memory
policies.

Also, using add_to_page_cache_lru instead of using a private
pagevec where applicable.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/addr.c
fs/ceph/file.c
fs/ceph/messenger.c
fs/ceph/pagelist.c
fs/ceph/xattr.c

index a9005d862ed4b7e415f03ddf25fc241420cb2d48..caf76c7fa77c1cba95db83cf1ddcd69584c8ca6e 100644 (file)
@@ -274,7 +274,6 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
        struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc;
        int rc = 0;
        struct page **pages;
-       struct pagevec pvec;
        loff_t offset;
        u64 len;
 
@@ -297,8 +296,6 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
        if (rc < 0)
                goto out;
 
-       /* set uptodate and add to lru in pagevec-sized chunks */
-       pagevec_init(&pvec, 0);
        for (; !list_empty(page_list) && len > 0;
             rc -= PAGE_CACHE_SIZE, len -= PAGE_CACHE_SIZE) {
                struct page *page =
@@ -312,7 +309,7 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
                        zero_user_segment(page, s, PAGE_CACHE_SIZE);
                }
 
-               if (add_to_page_cache(page, mapping, page->index, GFP_NOFS)) {
+               if (add_to_page_cache_lru(page, mapping, page->index, GFP_NOFS)) {
                        page_cache_release(page);
                        dout("readpages %p add_to_page_cache failed %p\n",
                             inode, page);
@@ -323,10 +320,8 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
                flush_dcache_page(page);
                SetPageUptodate(page);
                unlock_page(page);
-               if (pagevec_add(&pvec, page) == 0)
-                       pagevec_lru_add_file(&pvec);   /* add to lru */
+               page_cache_release(page);
        }
-       pagevec_lru_add_file(&pvec);
        rc = 0;
 
 out:
index ed6f19721d6e56d661ac7f11fe2aac04ba18e1a5..6230c3de1f06357cb1c46b9588209ae88810fe76 100644 (file)
@@ -326,7 +326,7 @@ static struct page **alloc_page_vector(int num_pages)
        if (!pages)
                return ERR_PTR(-ENOMEM);
        for (i = 0; i < num_pages; i++) {
-               pages[i] = alloc_page(GFP_NOFS);
+               pages[i] = __page_cache_alloc(GFP_NOFS);
                if (pages[i] == NULL) {
                        ceph_release_page_vector(pages, i);
                        return ERR_PTR(-ENOMEM);
index cd4fadb6491afe3a48ad5081b5f4ab2a41e4b0bf..af3b143fbf02f51b8255fa613d246317678f1f85 100644 (file)
@@ -1947,7 +1947,7 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr)
 
        /* the zero page is needed if a request is "canceled" while the message
         * is being written over the socket */
-       msgr->zero_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+       msgr->zero_page = __page_cache_alloc(GFP_KERNEL | __GFP_ZERO);
        if (!msgr->zero_page) {
                kfree(msgr);
                return ERR_PTR(-ENOMEM);
index 5f8dbf7c745a7c7a1864ff97cd646a497a9e08e6..b6859f47d364ba2134121d48fa6cc720f3b6b1a4 100644 (file)
@@ -20,7 +20,7 @@ int ceph_pagelist_release(struct ceph_pagelist *pl)
 
 static int ceph_pagelist_addpage(struct ceph_pagelist *pl)
 {
-       struct page *page = alloc_page(GFP_NOFS);
+       struct page *page = __page_cache_alloc(GFP_NOFS);
        if (!page)
                return -ENOMEM;
        pl->room += PAGE_SIZE;
index 2845422907fc7cd3c01360c3d2be99a35a455361..8938934c4c9336525a84a67a05cf1aa90831f175 100644 (file)
@@ -641,7 +641,7 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
                        return -ENOMEM;
                err = -ENOMEM;
                for (i = 0; i < nr_pages; i++) {
-                       pages[i] = alloc_page(GFP_NOFS);
+                       pages[i] = __page_cache_alloc(GFP_NOFS);
                        if (!pages[i]) {
                                nr_pages = i;
                                goto out;