From 230e5ab6a084ed50470f101934782dbf54b0d06b Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sat, 6 Dec 1997 23:51:34 +0000 Subject: Merge with Linux 2.1.67. --- mm/swap_state.c | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'mm/swap_state.c') diff --git a/mm/swap_state.c b/mm/swap_state.c index e0cfe1fef..75f284124 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -18,9 +18,6 @@ #include #include -#include -#include /* for cli()/sti() */ -#include /* for cop_to/from_user */ #include #include @@ -60,31 +57,47 @@ int add_to_swap_cache(struct page *page, unsigned long entry) return 0; } +/* + * If swap_map[] reaches 127, the entries are treated as "permanent". + */ void swap_duplicate(unsigned long entry) { struct swap_info_struct * p; unsigned long offset, type; if (!entry) - return; - offset = SWP_OFFSET(entry); + goto out; type = SWP_TYPE(entry); if (type & SHM_SWP_TYPE) - return; - if (type >= nr_swapfiles) { - printk("Trying to duplicate nonexistent swap-page\n"); - return; - } + goto out; + if (type >= nr_swapfiles) + goto bad_file; p = type + swap_info; - if (offset >= p->max) { - printk("swap_duplicate: weirdness\n"); - return; - } - if (!p->swap_map[offset]) { - printk("swap_duplicate: trying to duplicate unused page\n"); - return; + offset = SWP_OFFSET(entry); + if (offset >= p->max) + goto bad_offset; + if (!p->swap_map[offset]) + goto bad_unused; + if (p->swap_map[offset] < 126) + p->swap_map[offset]++; + else { + static int overflow = 0; + if (overflow++ < 5) + printk("swap_duplicate: entry %08lx map count=%d\n", + entry, p->swap_map[offset]); + p->swap_map[offset] = 127; } - p->swap_map[offset]++; +out: return; + +bad_file: + printk("swap_duplicate: Trying to duplicate nonexistent swap-page\n"); + goto out; +bad_offset: + printk("swap_duplicate: offset exceeds max\n"); + goto out; +bad_unused: + printk("swap_duplicate: unused page\n"); + goto out; } -- cgit v1.2.3