diff -urN v2.4.6-pre3/mm/filemap.c swaprace/mm/filemap.c --- v2.4.6-pre3/mm/filemap.c Mon Jun 18 21:51:03 2001 +++ swaprace/mm/filemap.c Mon Jun 18 22:09:00 2001 @@ -714,16 +714,16 @@ * The SwapCache check is protected by the pagecache lock. */ struct page * __find_get_swapcache_page(struct address_space *mapping, - unsigned long offset, struct page **hash) + unsigned long index, struct page **hash) { struct page *page; /* * We need the LRU lock to protect against page_launder(). */ - +try_again: spin_lock(&pagecache_lock); - page = __find_page_nolock(mapping, offset, *hash); + page = __find_page_nolock(mapping, index, *hash); if (page) { spin_lock(&pagemap_lru_lock); if (PageSwapCache(page)) @@ -733,6 +733,17 @@ spin_unlock(&pagemap_lru_lock); } spin_unlock(&pagecache_lock); + + if (page) { + lock_page(page); + if (!PageSwapCache(page) || page->mapping != mapping || + page->index != index) { + UnlockPage(page); + page_cache_release(page); + goto try_again; + } + UnlockPage(page); + } return page; }