From 1c203a4b5a05789a0de2548294c049481bff2254 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 20 May 2008 16:28:48 +1000 Subject: Fix autoassemble for stack arrays. If you have stacked arrays, then mdadm -As --homehost=fred should work but doesn't. It gets into an infinite loop! So write some tests, and fix the bugs. --- Assemble.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Assemble.c') diff --git a/Assemble.c b/Assemble.c index 8621203..4cea760 100644 --- a/Assemble.c +++ b/Assemble.c @@ -377,7 +377,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, */ mdu_array_info_t inf; char *c; - if (!st->sb) { + if (!st || !st->sb) { return 2; } st->ss->getinfo_super(st, &info); @@ -975,7 +975,10 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, "start the array while not clean " "- consider --force.\n"); - if (must_close) close(mdfd); + if (must_close) { + ioctl(mdfd, STOP_ARRAY, NULL); + close(mdfd); + } return 1; } if (runstop == -1) { @@ -1009,7 +1012,10 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, fprintf(stderr, " (use --run to insist).\n"); } } - if (must_close) close(mdfd); + if (must_close) { + ioctl(mdfd, STOP_ARRAY, NULL); + close(mdfd); + } return 1; } else { /* The "chosen_drive" is a good choice, and if necessary, the superblock has -- cgit