linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Pawel Baldysiak <pawel.baldysiak@intel.com>
Cc: linux-raid@vger.kernel.org, artur.paszkiewicz@intel.com
Subject: Re: [PATCH] IncRemove: Set "auto-read" only after successful excl open.
Date: Wed, 4 Mar 2015 16:01:11 +1100	[thread overview]
Message-ID: <20150304160111.0f0c3c78@notabene.brown> (raw)
In-Reply-To: <20150227144754.9507.71855.stgit@gklab-154-222.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1655 bytes --]

On Fri, 27 Feb 2015 15:47:54 +0100 Pawel Baldysiak
<pawel.baldysiak@intel.com> wrote:

> "mdadm -If" - triggered from udev rules when disk is removed from OS -
> tries to set array in auto-read-only mode. This can interrupt rebuild
> process which is started automatically, e.g. if array is mounted and
> spare disk is available (I/O error is detected faster than removing
> failed disk by mdadm).
> This patch prevents "mdadm -If" from setting array into "auto-read-only",
> by requiring exclusive open to succeed.
> 
> Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
> ---
>  Incremental.c |   16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/Incremental.c b/Incremental.c
> index 87d9114..b12f144 100644
> --- a/Incremental.c
> +++ b/Incremental.c
> @@ -1712,12 +1712,16 @@ int IncrementalRemove(char *devname, char *id_path, int verbose)
>  		return 1;
>  	}
>  	sysfs_init(&mdi, -1, ent->devnm);
> -	if (sysfs_get_str(&mdi, NULL, "array_state",
> -			  buf, sizeof(buf)) > 0) {
> -		if (strncmp(buf, "active", 6) == 0 ||
> -		    strncmp(buf, "clean", 5) == 0)
> -			sysfs_set_str(&mdi, NULL,
> -				      "array_state", "read-auto");
> +	mdfd = open_dev_excl(ent->devnm);
> +	if (mdfd > 0) {
> +		close(mdfd);
> +		if (sysfs_get_str(&mdi, NULL, "array_state",
> +				  buf, sizeof(buf)) > 0) {
> +			if (strncmp(buf, "active", 6) == 0 ||
> +			    strncmp(buf, "clean", 5) == 0)
> +				sysfs_set_str(&mdi, NULL,
> +					      "array_state", "read-auto");
> +		}
>  	}
>  	mdfd = open_dev(ent->devnm);
>  	if (mdfd < 0) {


Applied, thanks.
NeilBrown

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

      reply	other threads:[~2015-03-04  5:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 14:47 [PATCH] IncRemove: Set "auto-read" only after successful excl open Pawel Baldysiak
2015-03-04  5:01 ` NeilBrown [this message]

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=20150304160111.0f0c3c78@notabene.brown \
    --to=neilb@suse.de \
    --cc=artur.paszkiewicz@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=pawel.baldysiak@intel.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 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).