aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swap_state.c
diff options
context:
space:
mode:
authorHugh Dickins <hugh@veritas.com>2008-02-05 01:28:50 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:15 -0500
commit73b1262fa43a778b1e154deea632cdef5009d6a1 (patch)
tree409f14e78e23cd999e8c3d1e0945f0fa9b67048f /mm/swap_state.c
parentf000944d03a5b74ab3c92b2fcdf0e944cc898065 (diff)
tmpfs: move swap swizzling into shmem
move_to_swap_cache and move_from_swap_cache functions (which swizzle a page between tmpfs page cache and swap cache, to avoid page copying) are only used by shmem.c; and our subsequent fix for unionfs needs different treatments in the two instances of move_from_swap_cache. Move them from swap_state.c into their callsites shmem_writepage, shmem_unuse_inode and shmem_getpage, making add_to_swap_cache externally visible. shmem.c likes to say set_page_dirty where swap_state.c liked to say SetPageDirty: respect that diversity, which __set_page_dirty_no_writeback makes moot (and implies we should lose that "shift page from clean_pages to dirty_pages list" comment: it's on neither). Signed-off-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swap_state.c')
-rw-r--r--mm/swap_state.c35
1 files changed, 1 insertions, 34 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c
index c75eda2c9cc5..65b81c92738f 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -67,8 +67,7 @@ void show_swap_cache_info(void)
67 * add_to_swap_cache resembles add_to_page_cache on swapper_space, 67 * add_to_swap_cache resembles add_to_page_cache on swapper_space,
68 * but sets SwapCache flag and private instead of mapping and index. 68 * but sets SwapCache flag and private instead of mapping and index.
69 */ 69 */
70static int add_to_swap_cache(struct page *page, swp_entry_t entry, 70int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask)
71 gfp_t gfp_mask)
72{ 71{
73 int error; 72 int error;
74 73
@@ -183,38 +182,6 @@ void delete_from_swap_cache(struct page *page)
183 page_cache_release(page); 182 page_cache_release(page);
184} 183}
185 184
186/*
187 * Strange swizzling function only for use by shmem_writepage
188 */
189int move_to_swap_cache(struct page *page, swp_entry_t entry)
190{
191 int err = add_to_swap_cache(page, entry, GFP_ATOMIC);
192 if (!err) {
193 remove_from_page_cache(page);
194 page_cache_release(page); /* pagecache ref */
195 if (!swap_duplicate(entry))
196 BUG();
197 SetPageDirty(page);
198 }
199 return err;
200}
201
202/*
203 * Strange swizzling function for shmem_getpage (and shmem_unuse)
204 */
205int move_from_swap_cache(struct page *page, unsigned long index,
206 struct address_space *mapping)
207{
208 int err = add_to_page_cache(page, mapping, index, GFP_ATOMIC);
209 if (!err) {
210 delete_from_swap_cache(page);
211 /* shift page from clean_pages to dirty_pages list */
212 ClearPageDirty(page);
213 set_page_dirty(page);
214 }
215 return err;
216}
217
218/* 185/*
219 * If we are the only user, then try to free up the swap cache. 186 * If we are the only user, then try to free up the swap cache.
220 * 187 *