]> git.hungrycats.org Git - linux/commitdiff
[PATCH] swap 2/3 unsafe SwapCache check
authorHugh Dickins <hugh@veritas.com>
Thu, 13 Jun 2002 09:12:39 +0000 (02:12 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 13 Jun 2002 09:12:39 +0000 (02:12 -0700)
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.

mm/swapfile.c

index 33ac4b67bd6304eee5d69e24b2d39275db50ff29..70a517bbcc16a7d9cb45d79e2d0bc705677804f4 100644 (file)
@@ -684,10 +684,7 @@ static int try_to_unuse(unsigned int type)
                 * private" pages, but they are handled by tmpfs files.
                 * Note shmem_unuse already deleted its from swap cache.
                 */
-               swcount = *swap_map;
-               if ((swcount > 0) != PageSwapCache(page))
-                       BUG();
-               if ((swcount > 1) && PageDirty(page)) {
+               if ((*swap_map > 1) && PageDirty(page) && PageSwapCache(page)) {
                        rw_swap_page(WRITE, page);
                        lock_page(page);
                }