From: Rob Landley <rob@landley.net>
To: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: [PATCH] Fix bd_claim() error code.
Date: Sat, 17 Sep 2005 05:37:04 -0500 [thread overview]
Message-ID: <200509170537.04473.rob@landley.net> (raw)
Signed-off-by: Rob Landley <rob@landley.net>
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.
--- linux-2.6.13.1/mm/swapfile.c 2005-09-09 21:42:58.000000000 -0500
+++ linux-2.6.13.1-new/mm/swapfile.c 2005-09-17 02:42:45.000000000 -0500
@@ -1358,6 +1358,7 @@
error = bd_claim(bdev, sys_swapon);
if (error < 0) {
bdev = NULL;
+ error = -EINVAL;
goto bad_swap;
}
p->old_block_size = block_size(bdev);
reply other threads:[~2005-09-17 10:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200509170537.04473.rob@landley.net \
--to=rob@landley.net \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox