From: Neil Brown Date: Wed, 8 Nov 2006 22:38:50 +0000 (+1100) Subject: Fixed problems that could cause infinitel loop with auto assemble. X-Git-Tag: mdadm-2.5.6~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60e1bc1a335f3ff010b3ea189b63e1a41ea44bde;p=thirdparty%2Fmdadm.git Fixed problems that could cause infinitel loop with auto assemble. 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 Fixes-debian-bug: 396582 --- diff --git a/Assemble.c b/Assemble.c index e8fec8e9..6ca54f9c 100644 --- a/Assemble.c +++ b/Assemble.c @@ -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; } diff --git a/ChangeLog b/ChangeLog index e7a36d57..400204cc 100644 --- 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