diff options
author | Neil Brown <neilb@suse.de> | 2008-05-20 16:28:48 +1000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2008-05-20 16:28:48 +1000 |
commit | 1c203a4b5a05789a0de2548294c049481bff2254 (patch) | |
tree | d435235f7fc9983584f1811014ecb4c251c6cf08 | |
parent | df5a0b92954c22128e6beceb6f5df8e303848d71 (diff) | |
download | mdadm-1c203a4b5a05789a0de2548294c049481bff2254.tar.gz |
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.
-rw-r--r-- | Assemble.c | 12 | ||||
-rw-r--r-- | mdadm.c | 6 | ||||
-rw-r--r-- | test | 2 | ||||
-rw-r--r-- | tests/07autoassemble | 23 |
4 files changed, 38 insertions, 5 deletions
@@ -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 @@ -1100,11 +1100,12 @@ int main(int argc, char *argv[]) int acnt; ident.autof = autof; do { + mddev_dev_t devlist = conf_get_devs(); acnt = 0; do { rv2 = Assemble(ss, NULL, -1, &ident, - NULL, NULL, + devlist, NULL, readonly, runstop, NULL, homehost, verbose-quiet, force); if (rv2==0) { cnt++; @@ -1138,7 +1139,8 @@ int main(int argc, char *argv[]) if (cnt == 0 && rv == 0) { fprintf(stderr, Name ": No arrays found in config file or automatically\n"); rv = 1; - } + } else if (cnt) + rv = 0; } else if (cnt == 0 && rv == 0) { fprintf(stderr, Name ": No arrays found in config file\n"); rv = 1; @@ -30,6 +30,8 @@ targetdir=/var/tmp size=20000 # super0, round down to multiple of 64 and substract 64 mdsize0=19904 +# super00 is nested, subtract 128 +mdsize00=19840 # super1.0 round down to multiple of 2, subtract 8 mdsize1=19992 # subtract another 4 for bitmaps diff --git a/tests/07autoassemble b/tests/07autoassemble new file mode 100644 index 0000000..4496476 --- /dev/null +++ b/tests/07autoassemble @@ -0,0 +1,23 @@ + +# create two raid1s, build a raid0 on top, then +# tear it down and get auto-assemble to rebuild it. + +mdadm -CR $md1 -l1 -n2 $dev0 $dev1 --homehost=testing +mdadm -CR $md2 -l1 -n2 $dev2 $dev3 --homehost=testing +mdadm -CR $md0 -l0 -n2 $md1 $md2 --homehost=testing + +mdadm -Ss +mdadm -As -c /dev/null --homehost=testing -vvv +testdev $md1 1 $mdsize0 64 +testdev $md2 1 $mdsize0 64 +testdev $md0 2 $mdsize00 64 +mdadm -Ss + +mdadm --zero-superblock $dev0 $dev1 $dev2 $dev3 +## Now the raid0 uses one stacked and one not +mdadm -CR $md1 -l1 -n2 $dev0 $dev1 --homehost=testing +mdadm -CR $md0 -l0 -n2 $md1 $dev2 --homehost=testing +mdadm -Ss +mdadm -As -c /dev/null --homehost=testing -vvv +testdev $md1 1 $mdsize0 64 +testdev $md0 1 $[mdsize0+mdsize00] 64 |