* [PATCH] IncRemove: Set "auto-read" only after successful excl open.
@ 2015-02-27 14:47 Pawel Baldysiak
2015-03-04 5:01 ` NeilBrown
0 siblings, 1 reply; 2+ messages in thread
From: Pawel Baldysiak @ 2015-02-27 14:47 UTC (permalink / raw)
To: neilb; +Cc: linux-raid, pawel.baldysiak, artur.paszkiewicz
"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) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] IncRemove: Set "auto-read" only after successful excl open.
2015-02-27 14:47 [PATCH] IncRemove: Set "auto-read" only after successful excl open Pawel Baldysiak
@ 2015-03-04 5:01 ` NeilBrown
0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2015-03-04 5:01 UTC (permalink / raw)
To: Pawel Baldysiak; +Cc: linux-raid, artur.paszkiewicz
[-- 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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-04 5:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-27 14:47 [PATCH] IncRemove: Set "auto-read" only after successful excl open Pawel Baldysiak
2015-03-04 5:01 ` NeilBrown
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.