]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fixed problems that could cause infinitel loop with auto assemble.
authorNeil Brown <neilb@suse.de>
Wed, 8 Nov 2006 22:38:50 +0000 (09:38 +1100)
committerNeil Brown <neilb@suse.de>
Wed, 8 Nov 2006 22:38:50 +0000 (09:38 +1100)
If an auto-assembly attempt failes because the array cannot be
opened or because the array has already been created, then we
get into an infinite loop.

Reported-by: Dan Pascu <dan@ag-projects.com>
Fixes-debian-bug: 396582

Assemble.c
ChangeLog

index e8fec8e954cb19868351768d2630eb6163b27205..6ca54f9c35a684c579ad070ea0f2e172c27688d2 100644 (file)
@@ -185,6 +185,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
        else if (mdfd >= 0)
                inargv = 1;
 
+ try_again:
+
        tmpdev = devlist; num_devs = 0;
        while (tmpdev) {
                if (tmpdev->used)
@@ -383,14 +385,28 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                else
                        asprintf(&mddev, "/dev/md/%s", c);
                mdfd = open_mddev(mddev, ident->autof);
-               if (mdfd < 0)
-                       return mdfd;
+               if (mdfd < 0) {
+                       free(first_super);
+                       free(devices);
+                       first_super = NULL;
+                       goto try_again;
+               }
                vers = md_get_version(mdfd);
                if (ioctl(mdfd, GET_ARRAY_INFO, &inf)==0) {
+                       for (tmpdev = devlist ;
+                            tmpdev && tmpdev->used != 1;
+                            tmpdev = tmpdev->next)
+                               ;
                        fprintf(stderr, Name ": %s already active, cannot restart it!\n", mddev);
+                       if (tmpdev)
+                               fprintf(stderr, Name ":   %s needed for %s...\n",
+                                       mddev, tmpdev->devname);
                        close(mdfd);
+                       mdfd = -1;
                        free(first_super);
-                       return 1;
+                       free(devices);
+                       first_super = NULL;
+                       goto try_again;
                }
                must_close = 1;
        }
index e7a36d572478e67b5f91c35b6256c14e3bec3106..400204ccda0e8a9be28427348b594e5e61bc9904 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ Changes Prior to 2.5.6 release
     -   Fix bug which meant "bitmap=xxx" in mdadm.conf was not handled
        properly.
     -  Documentation updates.
+    -   Fix bug that caused infinite loop when doing auto-assembly,
+       in certain cases where arrays couldn't be assembled.
 
 Changes Prior to 2.5.5 release
     -   Don't #include linux/blkpg.h as that isn't safe.  Just