aboutsummaryrefslogtreecommitdiffstats
path: root/mm/shmem.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/shmem.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/shmem.c')
-rw-r--r--mm/shmem.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 7be94342bf06..e577adf4ae85 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -884,7 +884,9 @@ lost2:
884found: 884found:
885 idx += offset; 885 idx += offset;
886 inode = &info->vfs_inode; 886 inode = &info->vfs_inode;
887 if (move_from_swap_cache(page, idx, inode->i_mapping) == 0) { 887 if (add_to_page_cache(page, inode->i_mapping, idx, GFP_ATOMIC) == 0) {
888 delete_from_swap_cache(page);
889 set_page_dirty(page);
888 info->flags |= SHMEM_PAGEIN; 890 info->flags |= SHMEM_PAGEIN;
889 shmem_swp_set(info, ptr + offset, 0); 891 shmem_swp_set(info, ptr + offset, 0);
890 } 892 }
@@ -972,7 +974,8 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
972 BUG_ON(!entry); 974 BUG_ON(!entry);
973 BUG_ON(entry->val); 975 BUG_ON(entry->val);
974 976
975 if (move_to_swap_cache(page, swap) == 0) { 977 if (add_to_swap_cache(page, swap, GFP_ATOMIC) == 0) {
978 remove_from_page_cache(page);
976 shmem_swp_set(info, entry, swap.val); 979 shmem_swp_set(info, entry, swap.val);
977 shmem_swp_unmap(entry); 980 shmem_swp_unmap(entry);
978 spin_unlock(&info->lock); 981 spin_unlock(&info->lock);
@@ -982,6 +985,9 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
982 list_move_tail(&info->swaplist, &shmem_swaplist); 985 list_move_tail(&info->swaplist, &shmem_swaplist);
983 spin_unlock(&shmem_swaplist_lock); 986 spin_unlock(&shmem_swaplist_lock);
984 } 987 }
988 swap_duplicate(swap);
989 page_cache_release(page); /* pagecache ref */
990 set_page_dirty(page);
985 unlock_page(page); 991 unlock_page(page);
986 return 0; 992 return 0;
987 } 993 }
@@ -1217,13 +1223,15 @@ repeat:
1217 SetPageUptodate(filepage); 1223 SetPageUptodate(filepage);
1218 set_page_dirty(filepage); 1224 set_page_dirty(filepage);
1219 swap_free(swap); 1225 swap_free(swap);
1220 } else if (!(error = move_from_swap_cache( 1226 } else if (!(error = add_to_page_cache(
1221 swappage, idx, mapping))) { 1227 swappage, mapping, idx, GFP_ATOMIC))) {
1222 info->flags |= SHMEM_PAGEIN; 1228 info->flags |= SHMEM_PAGEIN;
1223 shmem_swp_set(info, entry, 0); 1229 shmem_swp_set(info, entry, 0);
1224 shmem_swp_unmap(entry); 1230 shmem_swp_unmap(entry);
1231 delete_from_swap_cache(swappage);
1225 spin_unlock(&info->lock); 1232 spin_unlock(&info->lock);
1226 filepage = swappage; 1233 filepage = swappage;
1234 set_page_dirty(filepage);
1227 swap_free(swap); 1235 swap_free(swap);
1228 } else { 1236 } else {
1229 shmem_swp_unmap(entry); 1237 shmem_swp_unmap(entry);