diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2009-03-31 18:23:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-01 11:59:15 -0400 |
commit | 2678958e1225f350806d90f211a3b475f64aee80 (patch) | |
tree | d4aeb116c78f31f96ffb0760e36b95424e7f9494 | |
parent | 88c3bd707c2552bcef93cc3724647903aece159d (diff) |
ramfs-nommu: use generic lru cache
Instead of open-coding the lru-list-add pagevec batching when expanding a
file mapping from zero, defer to the appropriate page cache function that
also takes care of adding the page to the lru list.
This is cleaner, saves code and reduces the stack footprint by 16 words
worth of pagevec.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: David Howells <dhowells@redhat.com>
Cc: Nick Piggin <npiggin@suse.de>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.com>
Cc: MinChan Kim <minchan.kim@gmail.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Cc: Greg Ungerer <gerg@snapgear.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/ramfs/file-nommu.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 995ef1d6686c..ebb2c417912c 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c | |||
@@ -59,7 +59,6 @@ const struct inode_operations ramfs_file_inode_operations = { | |||
59 | */ | 59 | */ |
60 | int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) | 60 | int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) |
61 | { | 61 | { |
62 | struct pagevec lru_pvec; | ||
63 | unsigned long npages, xpages, loop, limit; | 62 | unsigned long npages, xpages, loop, limit; |
64 | struct page *pages; | 63 | struct page *pages; |
65 | unsigned order; | 64 | unsigned order; |
@@ -102,24 +101,20 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) | |||
102 | memset(data, 0, newsize); | 101 | memset(data, 0, newsize); |
103 | 102 | ||
104 | /* attach all the pages to the inode's address space */ | 103 | /* attach all the pages to the inode's address space */ |
105 | pagevec_init(&lru_pvec, 0); | ||
106 | for (loop = 0; loop < npages; loop++) { | 104 | for (loop = 0; loop < npages; loop++) { |
107 | struct page *page = pages + loop; | 105 | struct page *page = pages + loop; |
108 | 106 | ||
109 | ret = add_to_page_cache(page, inode->i_mapping, loop, GFP_KERNEL); | 107 | ret = add_to_page_cache_lru(page, inode->i_mapping, loop, |
108 | GFP_KERNEL); | ||
110 | if (ret < 0) | 109 | if (ret < 0) |
111 | goto add_error; | 110 | goto add_error; |
112 | 111 | ||
113 | if (!pagevec_add(&lru_pvec, page)) | ||
114 | __pagevec_lru_add_file(&lru_pvec); | ||
115 | |||
116 | /* prevent the page from being discarded on memory pressure */ | 112 | /* prevent the page from being discarded on memory pressure */ |
117 | SetPageDirty(page); | 113 | SetPageDirty(page); |
118 | 114 | ||
119 | unlock_page(page); | 115 | unlock_page(page); |
120 | } | 116 | } |
121 | 117 | ||
122 | pagevec_lru_add_file(&lru_pvec); | ||
123 | return 0; | 118 | return 0; |
124 | 119 | ||
125 | fsize_exceeded: | 120 | fsize_exceeded: |
@@ -128,10 +123,8 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) | |||
128 | return -EFBIG; | 123 | return -EFBIG; |
129 | 124 | ||
130 | add_error: | 125 | add_error: |
131 | pagevec_lru_add_file(&lru_pvec); | 126 | while (loop < npages) |
132 | page_cache_release(pages + loop); | 127 | __free_page(pages + loop++); |
133 | for (loop++; loop < npages; loop++) | ||
134 | __free_page(pages + loop); | ||
135 | return ret; | 128 | return ret; |
136 | } | 129 | } |
137 | 130 | ||