]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Manage.c
Don't attempt a re-add if the device is marked as faulty.
[thirdparty/mdadm.git] / Manage.c
index fb9b9723bac28d0f9e8df72f2035729fe34a0004..1ca371db230df16c186784cf2cf1e0443f2ceb6f 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -565,7 +565,10 @@ int Manage_subdevs(char *devname, int fd,
                                                        disc.state |= 1 << MD_DISK_WRITEMOSTLY;
                                                if (dv->writemostly == 2)
                                                        disc.state &= ~(1 << MD_DISK_WRITEMOSTLY);
-                                               if (ioctl(fd, ADD_NEW_DISK, &disc) == 0) {
+                                               /* don't even try if disk is marked as faulty */
+                                               errno = 0;
+                                               if ((disc.state & 1) == 0 &&
+                                                   ioctl(fd, ADD_NEW_DISK, &disc) == 0) {
                                                        if (verbose >= 0)
                                                                fprintf(stderr, Name ": re-added %s\n", dv->devname);
                                                        continue;