IncRemove: Set "auto-read" only after successful excl open.
PATCH 1/1 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.
--- Incremental.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
Incremental.c +10 -6
@@ -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 ) {
NeilBrown
AppliedQuoted 30 lines · On Fri, 27 Feb 2015 15:47:54 +0100 Pawel Baldysiak <[email protected]>…
"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 <[email protected]>--- Incremental.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)Incremental.c +3
-6@@ -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);
Incremental.c int IncrementalRemove(char *devname, char *id_path, int verbose) · line 1727
Quoted 10 lines
Incremental.c +7
-0+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