linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] swap: Fix swap size in case of block devices
@ 2009-08-30 16:19 Nitin Gupta
  2009-08-31 11:27 ` Hugh Dickins
  0 siblings, 1 reply; 6+ messages in thread
From: Nitin Gupta @ 2009-08-30 16:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Rik van Riel, linux-kernel, linux-mm

During swapon, swap size is set to number of usable pages in the given
swap file/block device minus 1 (for header page). In case of block devices,
this size is incorrectly set as one page less than the actual due to an
off-by-one error. For regular files, this size is set correctly.

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
---

 mm/swapfile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 8ffdc0d..3d37b97 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1951,9 +1951,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 	if (error)
 		goto bad_swap;

+	/* excluding header page */
 	nr_good_pages = swap_header->info.last_page -
-			swap_header->info.nr_badpages -
-			1 /* header page */;
+			swap_header->info.nr_badpages;

 	if (nr_good_pages) {
 		swap_map[0] = SWAP_MAP_BAD;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-09-01  9:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-30 16:19 [PATCH] swap: Fix swap size in case of block devices Nitin Gupta
2009-08-31 11:27 ` Hugh Dickins
2009-08-31 17:21   ` Nitin Gupta
2009-08-31 19:26     ` Hugh Dickins
2009-09-01  7:11       ` Nitin Gupta
2009-09-01  9:23         ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).