Skip to contentSkip to conversation

nfs: use add_to_page_cache_lru, use __page_cache_alloc

PATCH New Nick Piggin 1 participant 1 message Mar 17, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs: use add_to_page_cache_lru, use __page_cache_alloc

nfs: use add_to_page_cache_lru, use __page_cache_alloc

Pagecache pages should be allocated with __page_cache_alloc, so they obey pagecache memory policies.

add_to_page_cache_lru is exported, so it should be used. Benefits over using a private pagevec: neater code, 128 bytes fewer stack used, percpu lru ordering is preserved, and finally don't need to flush pagevec before returning so batching may be shared with other LRU insertions.

---
 fs/nfs/dir.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
fs/nfs/dir.c +2 -7
Index: linux-2.6/fs/nfs/dir.c
===================================================================
@@ -29,7 +29,6 @@
 #include <linux/nfs_fs.h>
 #include <linux/nfs_mount.h>
 #include <linux/pagemap.h>
-#include <linux/pagevec.h>
 #include <linux/namei.h>
 #include <linux/mount.h>
 #include <linux/sched.h>
@@ -1473,7 +1472,6 @@ static int nfs_unlink(struct inode *dir,
  */
 static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
 {
-	struct pagevec lru_pvec;
 	struct page *page;
 	char *kaddr;
 	struct iattr attr;
@@ -1489,7 +1487,7 @@ static int nfs_symlink(struct inode *dir
 	attr.ia_mode = S_IFLNK | S_IRWXUGO;
 	attr.ia_valid = ATTR_MODE;
 
-	page = alloc_page(GFP_HIGHUSER);
+	page = __page_cache_alloc(GFP_HIGHUSER);
 	if (!page)
 		return -ENOMEM;
 
@@ -1513,11 +1511,8 @@ static int nfs_symlink(struct inode *dir
 	 * No big deal if we can't add this page to the page cache here.
 	 * READLINK will get the missing page from the server if needed.
 	 */
-	pagevec_init(&lru_pvec, 0);
-	if (!add_to_page_cache(page, dentry->d_inode->i_mapping, 0,
+	if (!add_to_page_cache_lru(page, dentry->d_inode->i_mapping, 0,
 							GFP_KERNEL)) {
-		pagevec_add(&lru_pvec, page);
-		pagevec_lru_add_file(&lru_pvec);
 		SetPageUptodate(page);
 		unlock_page(page);
 	} else

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html