[PATCH] fix to make swap format #2 actually work

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Sat, 31 Oct 1998 21:54:20 +0100 (MET)


Hi!

I realized new swap format does not work at all at least on sparc64, but I
think on alpha it is the same.
The reason is that swap_header->info.nr_badpages-1 is an integer, while the
address of the object is obviously a pointer (and thus long). So, with
nr_badpages 0 (I guess that's the common case anyway), I end up with
0x3fffffffcL being added to the pointer, which obviously makes the test
fail.
I have changed it also, so that the 0x7fffffffL/PAGE_SIZE check is done on
32bit archs only, as I think it has no reason to limit swap space to 2GB on
sparc64/alpha, and the swap space will be there limited by PAGE_SIZE<<32
anyway, as last_page is an 32bit integer.

--- mm/swapfile.c.jj Wed Sep 23 15:13:34 1998
+++ mm/swapfile.c Sat Oct 31 21:42:31 1998
@@ -626,8 +626,9 @@
p->highest_bit = swap_header->info.last_page - 1;
p->max = swap_header->info.last_page;

- if (p->max >= 0x7fffffffL/PAGE_SIZE ||
- (void *) &swap_header->info.badpages[swap_header->info.nr_badpages-1] >= (void *) swap_header->magic.magic) {
+ if ((BITS_PER_LONG == 32 && p->max >= 0x7fffffffL/PAGE_SIZE) ||
+ (swap_header->info.nr_badpages &&
+ (void *) &swap_header->info.badpages[swap_header->info.nr_badpages-1] >= (void *) swap_header->magic.magic)) {
error = -EINVAL;
goto bad_swap;
}

Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
Ultralinux - first 64bit OS to take full power of the UltraSparc
Linux version 2.1.126 on a sparc64 machine (498.80 BogoMips).
___________________________________________________________________

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/