Commit f53bfec8 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] swap 2/3 unsafe SwapCache check

Recent testing has shown that BUG() check in try_to_unuse is unsafe.
delete_from_swap_cache does final swap_free just after removing page
from swap cache, and add_to_swap_cache does swap_duplicate just before
putting page into swap cache, therefore swapin_readahead may resurrect
a dying swap entry and assign a new page to it.  That's fine, there's
no need to change this ordering; but it does mean that try_to_unuse's
page may have left the swap cache yet its swap_map count still be set.
That BUG() has done good service for swapoff sanity, but now abandon it.
parent 59e469ce
...@@ -684,10 +684,7 @@ static int try_to_unuse(unsigned int type) ...@@ -684,10 +684,7 @@ static int try_to_unuse(unsigned int type)
* private" pages, but they are handled by tmpfs files. * private" pages, but they are handled by tmpfs files.
* Note shmem_unuse already deleted its from swap cache. * Note shmem_unuse already deleted its from swap cache.
*/ */
swcount = *swap_map; if ((*swap_map > 1) && PageDirty(page) && PageSwapCache(page)) {
if ((swcount > 0) != PageSwapCache(page))
BUG();
if ((swcount > 1) && PageDirty(page)) {
rw_swap_page(WRITE, page); rw_swap_page(WRITE, page);
lock_page(page); lock_page(page);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment