]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Manage.c
Typo in dprintf
[thirdparty/mdadm.git] / Manage.c
index 4e6afb50390e6df10e162c39a6d69c7ac600e434..5fc67d771b4456d0e6217d7c8d89d5dcc0a83e1d 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -421,7 +421,7 @@ int Manage_subdevs(char *devname, int fd,
                                dnprintable = dvname;
                                break;
                        }
-                       if (jnext == 0)
+                       if (next != dv)
                                continue;
                } else if (strcmp(dv->devname, "detached") == 0) {
                        if (dv->disposition != 'r' && dv->disposition != 'f') {
@@ -461,7 +461,7 @@ int Manage_subdevs(char *devname, int fd,
                                dnprintable = dvname;
                                break;
                        }
-                       if (jnext == 0)
+                       if (next != dv)
                                continue;
                } else if (strcmp(dv->devname, "missing") == 0) {
                        if (dv->disposition != 'a' || dv->re_add == 0) {
@@ -637,7 +637,7 @@ int Manage_subdevs(char *devname, int fd,
                                /* FIXME this is a bad test to be using */
                                if (!tst->sb) {
                                        close(tfd);
-                                       fprintf(stderr, Name ": cannot find valid superblock in this array - HELP\n");
+                                       fprintf(stderr, Name ": cannot load array metadata from %s\n", devname);
                                        return 1;
                                }
 
@@ -728,6 +728,7 @@ int Manage_subdevs(char *devname, int fd,
                                        skip_re_add:
                                                re_add_failed = 1;
                                        }
+                                       st->ss->free_super(st);
                                }
                                if (add_dev != dv->devname) {
                                        if (verbose > 0)
@@ -808,9 +809,10 @@ int Manage_subdevs(char *devname, int fd,
                                        close(dfd);
                                        return 1;
                                }
-                               /* write_init_super will close 'dfd' */
-                               if (tst->ss->write_init_super(tst))
+                               if (tst->ss->write_init_super(tst)) {
+                                       close(dfd);
                                        return 1;
+                               }
                        } else if (dv->re_add) {
                                /*  this had better be raid1.
                                 * As we are "--re-add"ing we must find a spare slot
@@ -856,6 +858,7 @@ int Manage_subdevs(char *devname, int fd,
                                        fprintf(stderr, Name ": add failed for %s:"
                                                " could not get exclusive access to container\n",
                                                dv->devname);
+                                       tst->ss->free_super(tst);
                                        return 1;
                                }
 
@@ -864,6 +867,7 @@ int Manage_subdevs(char *devname, int fd,
                                        fprintf(stderr, Name ": add failed for %s: sysfs_read failed\n",
                                                dv->devname);
                                        close(container_fd);
+                                       tst->ss->free_super(tst);
                                        return 1;
                                }
                                sra->array.level = LEVEL_CONTAINER;
@@ -872,6 +876,9 @@ int Manage_subdevs(char *devname, int fd,
                                new_mdi.disk.major = disc.major;
                                new_mdi.disk.minor = disc.minor;
                                new_mdi.recovery_start = 0;
+                               /* Make sure fds are closed as they are O_EXCL which
+                                * would block add_disk */
+                               tst->ss->free_super(tst);
                                if (sysfs_add_disk(sra, &new_mdi, 0) != 0) {
                                        fprintf(stderr, Name ": add new device to external metadata"
                                                " failed for %s\n", dv->devname);
@@ -882,10 +889,13 @@ int Manage_subdevs(char *devname, int fd,
                                ping_monitor(devnum2devname(devnum));
                                sysfs_free(sra);
                                close(container_fd);
-                       } else if (ioctl(fd, ADD_NEW_DISK, &disc)) {
-                               fprintf(stderr, Name ": add new device failed for %s as %d: %s\n",
-                                       dv->devname, j, strerror(errno));
-                               return 1;
+                       } else {
+                               tst->ss->free_super(tst);
+                               if (ioctl(fd, ADD_NEW_DISK, &disc)) {
+                                       fprintf(stderr, Name ": add new device failed for %s as %d: %s\n",
+                                               dv->devname, j, strerror(errno));
+                                       return 1;
+                               }
                        }
                        if (verbose >= 0)
                                fprintf(stderr, Name ": added %s\n", dv->devname);