]> git.ipfire.org Git - thirdparty/mdadm.git/blame - Create.c
Change write_init_super to be called only once.
[thirdparty/mdadm.git] / Create.c
CommitLineData
64c4757e 1/*
9a9dab36 2 * mdadm - manage Linux "md" devices aka RAID arrays.
64c4757e 3 *
4f589ad0 4 * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
64c4757e
NB
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Author: Neil Brown
22 * Email: <neilb@cse.unsw.edu.au>
23 * Paper: Neil Brown
24 * School of Computer Science and Engineering
25 * The University of New South Wales
26 * Sydney, 2052
27 * Australia
28 */
29
9a9dab36 30#include "mdadm.h"
682c7051
NB
31#include "md_u.h"
32#include "md_p.h"
60248f74 33#include <ctype.h>
64c4757e 34
82d9eba6 35int Create(struct supertype *st, char *mddev, int mdfd,
5dd497ee 36 int chunk, int level, int layout, unsigned long long size, int raiddisks, int sparedisks,
3d3dd91e 37 char *name, char *homehost, int *uuid,
cd29a5c8 38 int subdevs, mddev_dev_t devlist,
47d79ef8 39 int runstop, int verbose, int force, int assume_clean,
dfd4d8ee 40 char *bitmap_file, int bitmap_chunk, int write_behind, int delay)
64c4757e 41{
682c7051
NB
42 /*
43 * Create a new raid array.
44 *
45 * First check that necessary details are available
46 * (i.e. level, raid-disks)
47 *
48 * Then check each disk to see what might be on it
49 * and report anything interesting.
50 *
51 * If anything looks odd, and runstop not set,
52 * abort.
53 *
54 * SET_ARRAY_INFO and ADD_NEW_DISK, and
82d9eba6 55 * if runstop==run, or raiddisks disks were used,
682c7051
NB
56 * RUN_ARRAY
57 */
b5e64645 58 unsigned long long minsize=0, maxsize=0;
cd29a5c8
NB
59 char *mindisc = NULL;
60 char *maxdisc = NULL;
c913b90e 61 int dnum;
cd29a5c8 62 mddev_dev_t dv;
682c7051 63 int fail=0, warn=0;
82b27616 64 struct stat stb;
82d9eba6 65 int first_missing = subdevs * 2;
6fb79233 66 int second_missing = subdevs * 2;
52826846 67 int missing_disks = 0;
82d9eba6 68 int insert_point = subdevs * 2; /* where to insert a missing drive */
4b1ac34b 69 int pass;
82d9eba6
NB
70 int vers;
71 int rv;
c82f047c 72 int bitmap_fd;
f9c25f1d 73 unsigned long long bitmapsize;
06c7f68e 74 struct mdinfo info;
682c7051 75
943eafef 76 int major_num = BITMAP_MAJOR_HI;
dcec9ee5 77
06c7f68e 78 memset(&info, 0, sizeof(info));
29e766a5 79
82d9eba6
NB
80 vers = md_get_version(mdfd);
81 if (vers < 9000) {
dd0781e5 82 fprintf(stderr, Name ": Create requires md driver version 0.90.0 or later\n");
52826846 83 return 1;
32e5a4ee
DL
84 } else {
85 mdu_array_info_t inf;
86 memset(&inf, 0, sizeof(inf));
87 ioctl(mdfd, GET_ARRAY_INFO, &inf);
88 if (inf.working_disks != 0) {
89 fprintf(stderr, Name ": another array by this name"
90 " is already running.\n");
91 return 1;
92 }
682c7051 93 }
98c6faba 94 if (level == UnSet) {
682c7051
NB
95 fprintf(stderr,
96 Name ": a RAID level is needed to create an array.\n");
97 return 1;
98 }
98c6faba
NB
99 if (raiddisks < 4 && level == 6) {
100 fprintf(stderr,
101 Name ": at least 4 raid-devices needed for level 6\n");
102 return 1;
103 }
104 if (raiddisks > 256 && level == 6) {
105 fprintf(stderr,
106 Name ": no more than 256 raid-devices supported for level 6\n");
107 return 1;
108 }
52826846
NB
109 if (raiddisks < 2 && level >= 4) {
110 fprintf(stderr,
98c6faba 111 Name ": at least 2 raid-devices needed for level 4 or 5\n");
52826846
NB
112 return 1;
113 }
570510ba
NB
114 if (level <= 0 && sparedisks) {
115 fprintf(stderr,
116 Name ": This level does not support spare devices\n");
117 return 1;
118 }
682c7051 119 if (subdevs > raiddisks+sparedisks) {
b83d95f3 120 fprintf(stderr, Name ": You have listed more devices (%d) than are in the array(%d)!\n", subdevs, raiddisks+sparedisks);
52826846 121 return 1;
682c7051 122 }
cd29a5c8 123 if (subdevs < raiddisks+sparedisks) {
52826846
NB
124 fprintf(stderr, Name ": You haven't given enough devices (real or missing) to create this array\n");
125 return 1;
126 }
5b28bd56
NB
127 if (bitmap_file && level <= 0) {
128 fprintf(stderr, Name ": bitmaps not meaningful with level %s\n",
129 map_num(pers, level)?:"given");
130 return 1;
131 }
52826846 132
682c7051 133 /* now set some defaults */
98c6faba 134 if (layout == UnSet)
682c7051
NB
135 switch(level) {
136 default: /* no layout */
137 layout = 0;
138 break;
e5329c37
NB
139 case 10:
140 layout = 0x102; /* near=2, far=1 */
dab6685f 141 if (verbose > 0)
e5329c37
NB
142 fprintf(stderr,
143 Name ": layout defaults to n1\n");
144 break;
682c7051 145 case 5:
98c6faba 146 case 6:
682c7051 147 layout = map_name(r5layout, "default");
dab6685f 148 if (verbose > 0)
682c7051
NB
149 fprintf(stderr,
150 Name ": layout defaults to %s\n", map_num(r5layout, layout));
151 break;
b5e64645
NB
152 case LEVEL_FAULTY:
153 layout = map_name(faultylayout, "default");
154
dab6685f 155 if (verbose > 0)
b5e64645
NB
156 fprintf(stderr,
157 Name ": layout defaults to %s\n", map_num(faultylayout, layout));
158 break;
682c7051
NB
159 }
160
e5329c37
NB
161 if (level == 10)
162 /* check layout fits in array*/
163 if ((layout&255) * ((layout>>8)&255) > raiddisks) {
164 fprintf(stderr, Name ": that layout requires at least %d devices\n",
165 (layout&255) * ((layout>>8)&255));
166 return 1;
167 }
168
aa88f531
NB
169 switch(level) {
170 case 4:
171 case 5:
e5329c37 172 case 10:
98c6faba 173 case 6:
aa88f531 174 case 0:
570510ba 175 case LEVEL_LINEAR: /* linear */
aa88f531
NB
176 if (chunk == 0) {
177 chunk = 64;
dab6685f 178 if (verbose > 0)
aa88f531
NB
179 fprintf(stderr, Name ": chunk size defaults to 64K\n");
180 }
181 break;
570510ba 182 case 1:
08e43379 183 case LEVEL_FAULTY:
570510ba 184 case LEVEL_MULTIPATH:
17f25ca6 185 case LEVEL_CONTAINER:
aa88f531
NB
186 if (chunk) {
187 chunk = 0;
dab6685f 188 if (verbose > 0)
aa88f531
NB
189 fprintf(stderr, Name ": chunk size ignored for this level\n");
190 }
191 break;
570510ba
NB
192 default:
193 fprintf(stderr, Name ": unknown level %d\n", level);
194 return 1;
682c7051
NB
195 }
196
17f25ca6
NB
197 if (st && ! st->ss->validate_geometry(st, level, layout, raiddisks,
198 chunk, size, NULL, NULL))
199 return 1;
200
682c7051 201 /* now look at the subdevs */
06c7f68e
NB
202 info.array.active_disks = 0;
203 info.array.working_disks = 0;
c913b90e
NB
204 dnum = 0;
205 for (dv=devlist; dv; dv=dv->next, dnum++) {
cd29a5c8 206 char *dname = dv->devname;
17f25ca6 207 unsigned long long freesize;
cd29a5c8 208 if (strcasecmp(dname, "missing")==0) {
c913b90e
NB
209 if (first_missing > dnum)
210 first_missing = dnum;
6fb79233
NB
211 if (second_missing > dnum && dnum > first_missing)
212 second_missing = dnum;
52826846
NB
213 missing_disks ++;
214 continue;
215 }
06c7f68e 216 info.array.working_disks++;
c913b90e 217 if (dnum < raiddisks)
06c7f68e 218 info.array.active_disks++;
058574b1 219 if (st == NULL) {
8aec876d 220 struct createinfo *ci = conf_get_create_info();
058574b1
NB
221 if (ci)
222 st = ci->supertype;
223 }
576d6d83
NB
224 if (st == NULL) {
225 /* Need to choose a default metadata, which is different
17f25ca6 226 * depending on geometry of array.
576d6d83
NB
227 */
228 int i;
229 char *name = "default";
17f25ca6 230 for(i=0; !st && superlist[i]; i++) {
576d6d83 231 st = superlist[i]->match_metadata_desc(name);
17f25ca6
NB
232 if (st && !st->ss->validate_geometry
233 (st, level, layout, raiddisks,
234 chunk, size, dname, &freesize))
235 st = NULL;
236 }
576d6d83
NB
237
238 if (!st) {
17f25ca6
NB
239 fprintf(stderr, Name ": device %s not suitable "
240 "for any style of array\n",
241 dname);
576d6d83
NB
242 exit(2);
243 }
244 if (st->ss->major != 0 ||
245 st->minor_version != 90)
32e5a4ee
DL
246 fprintf(stderr, Name ": Defaulting to version"
247 " %d.%d metadata\n",
576d6d83
NB
248 st->ss->major,
249 st->minor_version);
17f25ca6
NB
250 } else {
251 if (!st->ss->validate_geometry(st, level, layout,
252 raiddisks,
253 chunk, size, dname,
254 &freesize)) {
255
256 fprintf(stderr,
257 Name ": %s is not suitable for "
258 "this array.\n",
259 dname);
260 fail = 1;
261 continue;
262 }
682c7051 263 }
82d9eba6
NB
264
265 freesize /= 2; /* convert to K */
d2cd3ffc
NB
266 if (chunk) {
267 /* round to chunk size */
268 freesize = freesize & ~(chunk-1);
269 }
682c7051
NB
270
271 if (size && freesize < size) {
52826846 272 fprintf(stderr, Name ": %s is smaller that given size."
17f25ca6
NB
273 " %lluK < %lluK + metadata\n",
274 dname, freesize, size);
52826846 275 fail = 1;
52826846 276 continue;
682c7051 277 }
cd29a5c8
NB
278 if (maxdisc == NULL || (maxdisc && freesize > maxsize)) {
279 maxdisc = dname;
52826846 280 maxsize = freesize;
682c7051 281 }
cd29a5c8
NB
282 if (mindisc ==NULL || (mindisc && freesize < minsize)) {
283 mindisc = dname;
52826846 284 minsize = freesize;
682c7051 285 }
dab6685f 286 if (runstop != 1 || verbose >= 0) {
b6e63da4
NB
287 int fd = open(dname, O_RDONLY, 0);
288 if (fd <0 ) {
289 fprintf(stderr, Name ": Cannot open %s: %s\n",
290 dname, strerror(errno));
291 fail=1;
292 continue;
293 }
dab6685f
NB
294 warn |= check_ext2(fd, dname);
295 warn |= check_reiser(fd, dname);
296 warn |= check_raid(fd, dname);
b6e63da4 297 close(fd);
dab6685f 298 }
682c7051
NB
299 }
300 if (fail) {
52826846
NB
301 fprintf(stderr, Name ": create aborted\n");
302 return 1;
682c7051
NB
303 }
304 if (size == 0) {
cd29a5c8 305 if (mindisc == NULL) {
52826846
NB
306 fprintf(stderr, Name ": no size and no drives given - aborting create.\n");
307 return 1;
308 }
c13c45e9 309 if (level > 0 || level == LEVEL_MULTIPATH || level == LEVEL_FAULTY) {
b5e64645 310 /* size is meaningful */
5dd497ee 311 if (minsize > 0x100000000ULL && st->ss->major == 0) {
aba69144 312 fprintf(stderr, Name ": devices too large for RAID level %d\n", level);
b5e64645
NB
313 return 1;
314 }
315 size = minsize;
dab6685f 316 if (verbose > 0)
5dd497ee 317 fprintf(stderr, Name ": size set to %lluK\n", size);
b5e64645 318 }
682c7051 319 }
b5e64645 320 if (level > 0 && ((maxsize-size)*100 > maxsize)) {
dab6685f 321 if (runstop != 1 || verbose >= 0)
5dd497ee 322 fprintf(stderr, Name ": largest drive (%s) exceed size (%lluK) by more than 1%%\n",
dab6685f 323 maxdisc, size);
52826846 324 warn = 1;
682c7051
NB
325 }
326
327 if (warn) {
52826846
NB
328 if (runstop!= 1) {
329 if (!ask("Continue creating array? ")) {
330 fprintf(stderr, Name ": create aborted.\n");
331 return 1;
332 }
333 } else {
dab6685f 334 if (verbose > 0)
52826846 335 fprintf(stderr, Name ": creation continuing despite oddities due to --run\n");
682c7051 336 }
682c7051
NB
337 }
338
66f8bbbe 339 /* If this is raid4/5, we want to configure the last active slot
52826846 340 * as missing, so that a reconstruct happens (faster than re-parity)
98c6faba 341 * FIX: Can we do this for raid6 as well?
52826846 342 */
47d79ef8 343 if (assume_clean==0 && force == 0 && first_missing >= raiddisks) {
98c6faba 344 switch ( level ) {
66f8bbbe 345 case 4:
98c6faba
NB
346 case 5:
347 insert_point = raiddisks-1;
348 sparedisks++;
06c7f68e 349 info.array.active_disks--;
98c6faba
NB
350 missing_disks++;
351 break;
352 default:
353 break;
354 }
52826846 355 }
6fb79233
NB
356 /* For raid6, if creating with 1 missing drive, make a good drive
357 * into a spare, else the create will fail
358 */
359 if (assume_clean == 0 && force == 0 && first_missing < raiddisks &&
360 second_missing >= raiddisks && level == 6) {
361 insert_point = raiddisks - 1;
362 if (insert_point == first_missing)
363 insert_point--;
364 sparedisks ++;
365 info.array.active_disks--;
366 missing_disks++;
367 }
570510ba
NB
368
369 if (level <= 0 && first_missing != subdevs * 2) {
370 fprintf(stderr,
371 Name ": This level does not support missing devices\n");
372 return 1;
373 }
aba69144 374
682c7051
NB
375 /* Ok, lets try some ioctls */
376
06c7f68e
NB
377 info.array.level = level;
378 info.array.size = size;
379 info.array.raid_disks = raiddisks;
82b27616
NB
380 /* The kernel should *know* what md_minor we are dealing
381 * with, but it chooses to trust me instead. Sigh
382 */
06c7f68e 383 info.array.md_minor = 0;
82b27616 384 if (fstat(mdfd, &stb)==0)
06c7f68e
NB
385 info.array.md_minor = minor(stb.st_rdev);
386 info.array.not_persistent = 0;
6fb79233 387
66f8bbbe 388 if ( ( (level == 4 || level == 5) &&
b5e64645
NB
389 (insert_point < raiddisks || first_missing < raiddisks) )
390 ||
6fb79233
NB
391 ( level == 6 && (insert_point < raiddisks
392 || second_missing < raiddisks))
47d79ef8
NB
393 ||
394 assume_clean
b5e64645 395 )
06c7f68e 396 info.array.state = 1; /* clean, but one+ drive will be missing*/
82b27616 397 else
06c7f68e 398 info.array.state = 0; /* not clean, but no errors */
82b27616 399
f9c25f1d
NB
400 if (level == 10) {
401 /* for raid10, the bitmap size is the capacity of the array,
402 * which is array.size * raid_disks / ncopies;
403 * .. but convert to sectors.
404 */
702b557b 405 int ncopies = ((layout>>8) & 255) * (layout & 255);
5dd497ee
NB
406 bitmapsize = (unsigned long long)size * raiddisks / ncopies * 2;
407/* printf("bms=%llu as=%d rd=%d nc=%d\n", bitmapsize, size, raiddisks, ncopies);*/
f9c25f1d 408 } else
5dd497ee 409 bitmapsize = (unsigned long long)size * 2;
f9c25f1d 410
82b27616
NB
411 /* There is lots of redundancy in these disk counts,
412 * raid_disks is the most meaningful value
413 * it describes the geometry of the array
414 * it is constant
415 * nr_disks is total number of used slots.
416 * it should be raid_disks+spare_disks
417 * spare_disks is the number of extra disks present
418 * see above
419 * active_disks is the number of working disks in
420 * active slots. (With raid_disks)
421 * working_disks is the total number of working disks,
422 * including spares
423 * failed_disks is the number of disks marked failed
424 *
425 * Ideally, the kernel would keep these (except raid_disks)
426 * up-to-date as we ADD_NEW_DISK, but it doesn't (yet).
427 * So for now, we assume that all raid and spare
428 * devices will be given.
429 */
06c7f68e
NB
430 info.array.spare_disks=sparedisks;
431 info.array.failed_disks=missing_disks;
432 info.array.nr_disks = info.array.working_disks
433 + info.array.failed_disks;
434 info.array.layout = layout;
435 info.array.chunk_size = chunk*1024;
436 info.array.major_version = st->ss->major;
82d9eba6 437
b3b33eb5
NB
438 if (name == NULL || *name == 0) {
439 /* base name on mddev */
d1e80164
NB
440 /* /dev/md0 -> 0
441 * /dev/md_d0 -> d0
442 * /dev/md/1 -> 1
443 * /dev/md/d1 -> d1
444 * /dev/md/home -> home
445 * /dev/mdhome -> home
446 */
b3b33eb5
NB
447 name = strrchr(mddev, '/');
448 if (name) {
449 name++;
60248f74
NB
450 if (strncmp(name, "md_d", 4)==0 &&
451 strlen(name) > 4 &&
452 isdigit(name[4]) &&
b3b33eb5 453 (name-mddev) == 5 /* /dev/ */)
d1e80164 454 name += 3;
60248f74
NB
455 else if (strncmp(name, "md", 2)==0 &&
456 strlen(name) > 2 &&
457 isdigit(name[2]) &&
458 (name-mddev) == 5 /* /dev/ */)
b3b33eb5
NB
459 name += 2;
460 }
461 }
06c7f68e 462 if (!st->ss->init_super(st, &info.array, size, name, homehost, uuid))
82d9eba6 463 return 1;
682c7051 464
dcec9ee5 465 if (bitmap_file && vers < 9003) {
943eafef 466 major_num = BITMAP_MAJOR_HOSTENDIAN;
dcec9ee5
NB
467#ifdef __BIG_ENDIAN
468 fprintf(stderr, Name ": Warning - bitmaps created on this kernel are not portable\n"
469 " between different architectured. Consider upgrading the Linux kernel.\n");
470#endif
471 }
472
55935d51
NB
473 if (bitmap_file && strcmp(bitmap_file, "internal")==0) {
474 if ((vers%100) < 2) {
475 fprintf(stderr, Name ": internal bitmaps not supported by this kernel.\n");
476 return 1;
477 }
3da92f27 478 if (!st->ss->add_internal_bitmap(st, &bitmap_chunk,
199171a2 479 delay, write_behind,
943eafef 480 bitmapsize, 1, major_num)) {
55935d51
NB
481 fprintf(stderr, Name ": Given bitmap chunk size not supported.\n");
482 return 1;
483 }
484 bitmap_file = NULL;
485 }
486
487
488
82d9eba6
NB
489 if ((vers % 100) >= 1) { /* can use different versions */
490 mdu_array_info_t inf;
491 memset(&inf, 0, sizeof(inf));
492 inf.major_version = st->ss->major;
493 inf.minor_version = st->minor_version;
494 rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
aba69144 495 } else
82d9eba6
NB
496 rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
497 if (rv) {
52826846
NB
498 fprintf(stderr, Name ": SET_ARRAY_INFO failed for %s: %s\n",
499 mddev, strerror(errno));
500 return 1;
682c7051 501 }
52826846 502
c82f047c
NB
503 if (bitmap_file) {
504 int uuid[4];
55935d51 505
3da92f27 506 st->ss->uuid_from_super(st, uuid);
dfd4d8ee 507 if (CreateBitmap(bitmap_file, force, (char*)uuid, bitmap_chunk,
dcec9ee5 508 delay, write_behind,
f9c25f1d 509 bitmapsize,
943eafef 510 major_num)) {
c82f047c
NB
511 return 1;
512 }
513 bitmap_fd = open(bitmap_file, O_RDWR);
514 if (bitmap_fd < 0) {
515 fprintf(stderr, Name ": weird: %s cannot be openned\n",
dcec9ee5 516 bitmap_file);
c82f047c
NB
517 return 1;
518 }
519 if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
520 fprintf(stderr, Name ": Cannot set bitmap file for %s: %s\n",
521 mddev, strerror(errno));
522 return 1;
523 }
524 }
525
4b1ac34b
NB
526
527
528 for (pass=1; pass <=2 ; pass++) {
529 mddev_dev_t moved_disk = NULL; /* the disk that was moved out of the insert point */
530
531 for (dnum=0, dv = devlist ; dv ;
532 dv=(dv->next)?(dv->next):moved_disk, dnum++) {
533 int fd;
534 struct stat stb;
4b1ac34b 535
06c7f68e 536 info.disk.number = dnum;
4b1ac34b
NB
537 if (dnum == insert_point) {
538 moved_disk = dv;
52826846 539 }
06c7f68e
NB
540 info.disk.raid_disk = info.disk.number;
541 if (info.disk.raid_disk < raiddisks)
542 info.disk.state = (1<<MD_DISK_ACTIVE) |
dfd4d8ee 543 (1<<MD_DISK_SYNC);
4b1ac34b 544 else
06c7f68e 545 info.disk.state = 0;
dfd4d8ee 546 if (dv->writemostly)
06c7f68e 547 info.disk.state |= (1<<MD_DISK_WRITEMOSTLY);
dfd4d8ee 548
4b1ac34b 549 if (dnum == insert_point ||
111d01fc
NB
550 strcasecmp(dv->devname, "missing")==0)
551 continue;
552
553 fd = open(dv->devname, O_RDWR|O_EXCL, 0);
554 if (fd < 0) {
555 fprintf(stderr, Name ": failed to open %s "
556 "after earlier success - aborting\n",
557 dv->devname);
558 return 1;
4b1ac34b 559 }
111d01fc
NB
560 fstat(fd, &stb);
561 info.disk.major = major(stb.st_rdev);
562 info.disk.minor = minor(stb.st_rdev);
563
4b1ac34b
NB
564 switch(pass){
565 case 1:
111d01fc
NB
566 remove_partitions(fd);
567 st->ss->add_to_super(st, &info.disk,
568 fd, dv->devname);
4b1ac34b
NB
569 break;
570 case 2:
111d01fc 571 close(fd);
4b1ac34b 572
06c7f68e 573 if (ioctl(mdfd, ADD_NEW_DISK, &info.disk)) {
4b1ac34b
NB
574 fprintf(stderr, Name ": ADD_NEW_DISK for %s failed: %s\n",
575 dv->devname, strerror(errno));
3da92f27 576 st->ss->free_super(st);
4b1ac34b
NB
577 return 1;
578 }
579
580 break;
581 }
582 if (dv == moved_disk && dnum != insert_point) break;
52826846 583 }
111d01fc
NB
584 if (pass == 1)
585 st->ss->write_init_super(st);
5e52ae9e 586 }
3da92f27 587 st->ss->free_super(st);
5e52ae9e 588
682c7051 589 /* param is not actually used */
17f25ca6
NB
590 if (level == LEVEL_CONTAINER)
591 /* No need to start */
592 ;
593 else if (runstop == 1 || subdevs >= raiddisks) {
82b27616 594 mdu_param_t param;
682c7051
NB
595 if (ioctl(mdfd, RUN_ARRAY, &param)) {
596 fprintf(stderr, Name ": RUN_ARRAY failed: %s\n",
597 strerror(errno));
91f068bf 598 Manage_runstop(mddev, mdfd, -1, 0);
682c7051
NB
599 return 1;
600 }
dab6685f
NB
601 if (verbose >= 0)
602 fprintf(stderr, Name ": array %s started.\n", mddev);
682c7051 603 } else {
b83d95f3 604 fprintf(stderr, Name ": not starting array - not enough devices.\n");
682c7051
NB
605 }
606 return 0;
64c4757e 607}