Commit 81e33971 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

swapfile: remove v0 SWAP-SPACE message

The kernel has not supported v0 SWAP-SPACE since 2.5.22: I think we can
now safely drop its "version 0 swap is no longer supported" message - just
say "Unable to find swap-space signature" as usual.  This removes one
level of indentation from a stretch of sys_swapon().

I'd have liked to be specific, saying "Unable to find SWAPSPACE2
signature", but it's just too confusing that the version 1 signature shows
the number 2.

Irrelevant nearby cleanup: kmap(page) already gives page_address(page).
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 886bb7e9
...@@ -1456,7 +1456,6 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1456,7 +1456,6 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
int i, prev; int i, prev;
int error; int error;
union swap_header *swap_header = NULL; union swap_header *swap_header = NULL;
int swap_header_version;
unsigned int nr_good_pages = 0; unsigned int nr_good_pages = 0;
int nr_extents = 0; int nr_extents = 0;
sector_t span; sector_t span;
...@@ -1553,26 +1552,14 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1553,26 +1552,14 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
error = PTR_ERR(page); error = PTR_ERR(page);
goto bad_swap; goto bad_swap;
} }
kmap(page); swap_header = kmap(page);
swap_header = page_address(page);
if (!memcmp("SWAP-SPACE",swap_header->magic.magic,10)) if (memcmp("SWAPSPACE2", swap_header->magic.magic, 10)) {
swap_header_version = 1;
else if (!memcmp("SWAPSPACE2",swap_header->magic.magic,10))
swap_header_version = 2;
else {
printk(KERN_ERR "Unable to find swap-space signature\n"); printk(KERN_ERR "Unable to find swap-space signature\n");
error = -EINVAL; error = -EINVAL;
goto bad_swap; goto bad_swap;
} }
switch (swap_header_version) {
case 1:
printk(KERN_ERR "version 0 swap is no longer supported. "
"Use mkswap -v1 %s\n", name);
error = -EINVAL;
goto bad_swap;
case 2:
/* swap partition endianess hack... */ /* swap partition endianess hack... */
if (swab32(swap_header->info.version) == 1) { if (swab32(swap_header->info.version) == 1) {
swab32s(&swap_header->info.version); swab32s(&swap_header->info.version);
...@@ -1581,8 +1568,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1581,8 +1568,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
for (i = 0; i < swap_header->info.nr_badpages; i++) for (i = 0; i < swap_header->info.nr_badpages; i++)
swab32s(&swap_header->info.badpages[i]); swab32s(&swap_header->info.badpages[i]);
} }
/* Check the swap header's sub-version and the size of /* Check the swap header's sub-version */
the swap file and bad block lists */
if (swap_header->info.version != 1) { if (swap_header->info.version != 1) {
printk(KERN_WARNING printk(KERN_WARNING
"Unable to handle swap header version %d\n", "Unable to handle swap header version %d\n",
...@@ -1608,7 +1594,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1608,7 +1594,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
* the swp_entry_t or the architecture definition of a * the swp_entry_t or the architecture definition of a
* swap pte. * swap pte.
*/ */
maxpages = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0,~0UL)))) - 1; maxpages = swp_offset(pte_to_swp_entry(
swp_entry_to_pte(swp_entry(0, ~0UL)))) - 1;
if (maxpages > swap_header->info.last_page) if (maxpages > swap_header->info.last_page)
maxpages = swap_header->info.last_page; maxpages = swap_header->info.last_page;
p->highest_bit = maxpages - 1; p->highest_bit = maxpages - 1;
...@@ -1633,21 +1620,18 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1633,21 +1620,18 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
goto bad_swap; goto bad_swap;
} }
error = 0;
memset(swap_map, 0, maxpages * sizeof(short)); memset(swap_map, 0, maxpages * sizeof(short));
for (i = 0; i < swap_header->info.nr_badpages; i++) { for (i = 0; i < swap_header->info.nr_badpages; i++) {
int page_nr = swap_header->info.badpages[i]; int page_nr = swap_header->info.badpages[i];
if (page_nr <= 0 || page_nr >= swap_header->info.last_page) if (page_nr <= 0 || page_nr >= swap_header->info.last_page) {
error = -EINVAL; error = -EINVAL;
else goto bad_swap;
}
swap_map[page_nr] = SWAP_MAP_BAD; swap_map[page_nr] = SWAP_MAP_BAD;
} }
nr_good_pages = swap_header->info.last_page - nr_good_pages = swap_header->info.last_page -
swap_header->info.nr_badpages - swap_header->info.nr_badpages -
1 /* header page */; 1 /* header page */;
if (error)
goto bad_swap;
}
if (nr_good_pages) { if (nr_good_pages) {
swap_map[0] = SWAP_MAP_BAD; swap_map[0] = SWAP_MAP_BAD;
......
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