lkml.org 
[lkml]   [1998]   [Mar]   [9]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From(Paul Gortmaker)
SubjectBug/patch for swapon system call
DateMon, 9 Mar 1998 22:37:55 +1100 (EST)
Needless to say, this is a Bad Thing(tm).

------------------------------------------------------------------
# cat /proc/swaps
Filename                        Type            Size    Used    Priority
# swapon ./swap
# swapon ./swap
# cat /proc/swaps
Filename                        Type            Size    Used    Priority
/mnt/tmp/swap                   file            1020    0       -9
/mnt/tmp/swap                   file            1020    0       -10
#
-------------------------------------------------------------------
I got bitten by this since some distributions do 2 "swapon -a" during
boot. Once it touches the lower priority one, it obviously stomps all
over the 1st usage, and when it tries to swap back in stuff from the
1st one...

Problem is that the EBUSY test is mistakenly included in the S_ISBLK
code, so swapfiles slip through. Patch below. (2.1.89)

Paul.


--- linux/mm/swapfile.c~	Mon Mar  9 11:19:57 1998
+++ linux/mm/swapfile.c	Mon Mar  9 11:20:47 1998
@@ -534,15 +534,15 @@
 		    (blk_size[MAJOR(p->swap_device)] &&
 		     !blk_size[MAJOR(p->swap_device)][MINOR(p->swap_device)]))
 			goto bad_swap;
-		error = -EBUSY;
-		for (i = 0 ; i < nr_swapfiles ; i++) {
-			if (i == type)
-				continue;
-			if (p->swap_device == swap_info[i].swap_device)
-				goto bad_swap;
-		}
 	} else if (!S_ISREG(swap_dentry->d_inode->i_mode))
 		goto bad_swap;
+	error = -EBUSY;
+	for (i = 0 ; i < nr_swapfiles ; i++) {
+		if (i == type)
+			continue;
+		if (p->swap_device == swap_info[i].swap_device)
+			goto bad_swap;
+	}
 	avail_map = (unsigned char *) get_free_page(GFP_USER);
 	if (!avail_map) {
 		printk("Unable to start swapping: out of memory :-)\n");
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 12:41    [from the cache]
©2003-2008