aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-09-23 00:44:27 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-23 01:17:37 -0400
commitf7b3a4359b25311fb5894c8809478a2df6bed480 (patch)
treeef2e2a707f1b5d5095c9e2e1e6d760d77ad2b31b
parent8bdac5d1ed892da54b6b2069e50a47b3aa39460f (diff)
[PATCH] Fix bd_claim() error code.
Problem: In some circumstances, bd_claim() is returning the wrong error code. If we try to swapon an unused block device that isn't swap formatted, we get -EINVAL. But if that same block device is already mounted, we instead get -EBUSY, even though it still isn't a valid swap device. This issue came up on the busybox list trying to get the error message from "swapon -a" right. If a swap device is already enabled, we get -EBUSY, and we shouldn't report this as an error. But we can't distinguish the two -EBUSY conditions, which are very different errors. In the code, bd_claim() returns either 0 or -EBUSY, but in this case busy means "somebody other than sys_swapon has already claimed this", and _that_ means this block device can't be a valid swap device. So return -EINVAL there. Signed-off-by: Rob Landley <rob@landley.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--mm/swapfile.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 0184f510aace..1dcaeda039f4 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1381,6 +1381,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
1381 error = bd_claim(bdev, sys_swapon); 1381 error = bd_claim(bdev, sys_swapon);
1382 if (error < 0) { 1382 if (error < 0) {
1383 bdev = NULL; 1383 bdev = NULL;
1384 error = -EINVAL;
1384 goto bad_swap; 1385 goto bad_swap;
1385 } 1386 }
1386 p->old_block_size = block_size(bdev); 1387 p->old_block_size = block_size(bdev);