diff options
author | Pawel Baldysiak <pawel.baldysiak@intel.com> | 2015-02-27 15:47:54 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2015-03-04 15:59:53 +1100 |
commit | 4d149ab5178e21422a9bdb9a5489ed3381a0d136 (patch) | |
tree | 4eb6dd5159706fd3bb02fe39eafecc06c8c8ef1d | |
parent | f666bcc6528326c3431b013f47803db904ff65c0 (diff) | |
download | mdadm-4d149ab5178e21422a9bdb9a5489ed3381a0d136.tar.gz |
IncRemove: Set "auto-read" only after successful excl open.
"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>
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | Incremental.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Incremental.c b/Incremental.c index 33c0d7f..0c9a9a4 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) { |