From: NeilBrown Make it easy to --re-add any faulty devices with mdadm /dev/mdXX --re-add faulty This keeps the array frozen against recovery for the whole time so a single recovery operation will process all of the faulty devices that were --re-added. This is useful for a RAID10 when one whole side has gone on-line and needs to be recovered. Signed-off-by: NeilBrown --- Manage.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- mdadm-3.2.6.orig/Manage.c +++ mdadm-3.2.6/Manage.c @@ -456,9 +456,11 @@ int Manage_subdevs(char *devname, int fd if (strcmp(dv->devname, "failed")==0 || strcmp(dv->devname, "faulty")==0) { int remaining_disks = array.nr_disks; - if (dv->disposition != 'r') { + if (dv->disposition == 'a' && dv->re_add) + /* This is OK */; + else if (dv->disposition != 'r') { fprintf(stderr, Name ": %s only meaningful " - "with -r, not -%c\n", + "with -r or --re-add, not -%c\n", dv->devname, dv->disposition); goto abort; } @@ -483,6 +485,7 @@ int Manage_subdevs(char *devname, int fd jnext = j; sprintf(dvname,"%d:%d", disc.major, disc.minor); dnprintable = dvname; + add_dev = dvname; break; } if (next != dv) @@ -623,6 +626,11 @@ int Manage_subdevs(char *devname, int fd " operation on the parent container\n"); goto abort; } + if (add_dev != dv->devname && + strncmp(dv->devname, "fa", 2) == 0) + /* Need to remove first */ + ioctl(fd, HOT_REMOVE_DISK, + (unsigned long)stb.st_rdev); /* Make sure it isn't in use (in 2.6 or later) */ tfd = dev_open(add_dev, O_RDONLY|O_EXCL|O_DIRECT); if (tfd < 0 && add_dev != dv->devname)