From: Brendan Hide <brendan@swiftspirit.co.za>
To: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3] Btrfs-progs: check out if the swap device
Date: Sun, 03 Mar 2013 18:47:46 +0200 [thread overview]
Message-ID: <51337EB2.7090607@swiftspirit.co.za> (raw)
In-Reply-To: <201302140753.AA00021@FM-323941448.jp.fujitsu.com>
On 2013/02/14 09:53 AM, Tsutomu Itoh wrote:
> + if (ret < 0) {
> + fprintf(stderr, "error checking %s status: %s\n", file,
> + strerror(-ret));
> + exit(1);
> + }
>
> ...
>
> + /* check if the device is busy */
> + fd = open(file, O_RDWR|O_EXCL);
> + if (fd < 0) {
> + fprintf(stderr, "unable to open %s: %s\n", file,
> + strerror(errno));
> + exit(1);
> + }
This is fine and works (as tested by David) - but I'm not sure if the
below suggestions from Zach were taken into account.
1. If the check with "open(file, O_RDWR|O_EXCL)" shows that the device
is available, there's no point in checking if it is mounted as a swap
device. A preliminary check using this could precede all other checks
which should be skipped if it shows success.
2. If there's an error checking the status (for example lets say
/proc/swaps is deprecated), we should print the informational message
but not error out.
On 2013/02/13 11:58 AM, Zach Brown wrote:
> - First always open with O_EXCL. If it succeeds then there's no reason
> to check /proc/swaps at all. (Maybe it doesn't need to try
> check_mounted() there either? Not sure if it's protecting against
> accidentally mounting mounted shared storage or not.)
>
> ...
>
> - At no point is failure of any of the /proc/swaps parsing fatal. It'd
> carry on ignoring errors until it doesnt have work to do. It'd only
> ever print the nice message when it finds a match.
--
__________
Brendan Hide
http://swiftspirit.co.za/
http://www.webafrica.co.za/?AFF1E97
next prev parent reply other threads:[~2013-03-03 16:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-14 7:53 [PATCH v3] Btrfs-progs: check out if the swap device Tsutomu Itoh
2013-02-14 12:22 ` David Sterba
2013-03-03 16:47 ` Brendan Hide [this message]
2013-03-05 1:18 ` Tsutomu Itoh
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=51337EB2.7090607@swiftspirit.co.za \
--to=brendan@swiftspirit.co.za \
--cc=linux-btrfs@vger.kernel.org \
--cc=t-itoh@jp.fujitsu.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.