patch-2.1.123 linux/include/linux/swap.h

Next file: linux/include/linux/tcp.h
Previous file: linux/include/linux/sunrpc/clnt.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.122/linux/include/linux/swap.h linux/include/linux/swap.h
@@ -89,6 +89,7 @@
 extern int swap_check_entry(unsigned long);
 extern struct page * read_swap_cache_async(unsigned long, int);
 #define read_swap_cache(entry) read_swap_cache_async(entry, 1);
+extern int FASTCALL(swap_count(unsigned long));
 /*
  * Make these inline later once they are working properly.
  */
@@ -146,14 +147,20 @@
  */
 static inline int is_page_shared(struct page *page)
 {
-	int count = atomic_read(&page->count);
+	unsigned int count;
 	if (PageReserved(page))
 		return 1;
-	if (page->inode == &swapper_inode)
-		count--;
+	count = atomic_read(&page->count);
+	if (PageSwapCache(page))
+	{
+		/* PARANOID */
+		if (page->inode != &swapper_inode)
+			panic("swap cache page has wrong inode\n");
+		count += swap_count(page->offset) - 2;
+	}
 	if (PageFreeAfter(page))
 		count--;
-	return (count > 1);
+	return  count > 1;
 }
 
 #endif /* __KERNEL__*/

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov