/* A simple wrapper so the base function doesn't need to enforce * that all swap pages go through the swap cache! */ void rw_swap_page(int rw, unsigned long entry, char *buf, int wait) { struct page *page = mem_map + MAP_NR(buf); if (page->inode && page->inode != &swapper_inode) panic ("Tried to swap a non-swapper page"); /* * Make sure that we have a swap cache association for this * page. We need this to find which swap page to unlock once * the swap IO has completed to the physical page. If the page * is not already in the cache, just overload the offset entry * as if it were: we are not allowed to manipulate the inode * hashing for locked pages. */ if (!PageSwapCache(page)) { printk("VM: swap page is not in swap cache\n"); return; } if (page->offset != entry) { printk ("swap entry mismatch"); return; } rw_swap_page_base(rw, entry, page, wait); }
/* * A simple wrapper so the base function doesn't need to enforce * that all swap pages go through the swap cache! We verify that: * - the page is locked * - it's marked as being swap-cache * - it's associated with the swap inode */ void rw_swap_page(int rw, struct page *page) { swp_entry_t entry; entry.val = page->index; if (!PageLocked(page)) PAGE_BUG(page); if (!PageSwapCache(page)) PAGE_BUG(page); if (!rw_swap_page_base(rw, entry, page)) UnlockPage(page); }
/* * shmfs needs a version that doesn't put the page in the page cache! * The swap lock map insists that pages be in the page cache! * Therefore we can't use it. Later when we can remove the need for the * lock map and we can reduce the number of functions exported. */ void rw_swap_page_nolock(int rw, unsigned long entry, char *buffer, int wait) { struct page *page = mem_map + MAP_NR((unsigned long) buffer); if (!PageLocked(page)) { printk("VM: rw_swap_page_nolock: page not locked!\n"); return; } if (PageSwapCache(page)) { printk ("VM: rw_swap_page_nolock: page in swap cache!\n"); return; } rw_swap_page_base(rw, entry, page, wait); }
/* * The swap lock map insists that pages be in the page cache! * Therefore we can't use it. Later when we can remove the need for the * lock map and we can reduce the number of functions exported. */ void rw_swap_page_nolock(int rw, swp_entry_t entry, char *buf) { struct page *page = virt_to_page(buf); if (!PageLocked(page)) PAGE_BUG(page); if (PageSwapCache(page)) PAGE_BUG(page); if (page->mapping) PAGE_BUG(page); /* needs sync_page to wait I/O completation */ page->mapping = &swapper_space; if (!rw_swap_page_base(rw, entry, page)) UnlockPage(page); wait_on_page(page); page->mapping = NULL; }