]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Incremental.c
2 * Incremental.c - support --incremental. Part of:
3 * mdadm - manage Linux "md" devices aka RAID arrays.
5 * Copyright (C) 2006 Neil Brown <neilb@suse.de>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Email: <neilb@suse.de>
27 * QVB Post Office, NSW 1230
33 static int count_active(struct supertype
*st
, int mdfd
, char **availp
,
35 static void find_reject(int mdfd
, struct supertype
*st
, struct mdinfo
*sra
,
36 int number
, __u64 events
, int verbose
,
39 int Incremental(char *devname
, int verbose
, int runstop
,
40 struct supertype
*st
, char *homehost
, int autof
)
42 /* Add this device to an array, creating the array if necessary
43 * and starting the array if sensible or - if runstop>0 - if possible.
45 * This has several steps:
47 * 1/ Check if device is permitted by mdadm.conf, reject if not.
48 * 2/ Find metadata, reject if none appropriate (check
49 * version/name from args)
50 * 3/ Check if there is a match in mdadm.conf
51 * 3a/ if not, check for homehost match. If no match, reject.
52 * 4/ Determine device number.
53 * - If in mdadm.conf with std name, use that
54 * - UUID in /var/run/mdadm.map use that
55 * - If name is suggestive, use that. unless in use with different uuid.
56 * - Choose a free, high number.
57 * - Use a partitioned device unless strong suggestion not to.
59 * Don't choose partitioned for containers.
60 * 5/ Find out if array already exists
62 * - choose a name, from mdadm.conf or 'name' field in array.
66 * - check one drive in array to make sure metadata is a reasonably
67 * close match. Reject if not (e.g. different type)
69 * 6/ Make sure /var/run/mdadm.map contains this array.
70 * 7/ Is there enough devices to possibly start the array?
71 * For a container, this means running Incremental_container.
72 * 7a/ if not, finish with success.
74 * - read all metadata and arrange devices like -A does
75 * - if number of OK devices match expected, or -R and there are enough,
76 * start the array (auto-readonly).
80 struct mddev_ident_s
*array_list
, *match
;
81 char chosen_name
[1024];
84 struct map_ent
*mp
, *map
= NULL
;
88 int uuid_for_name
= 0;
92 struct createinfo
*ci
= conf_get_create_info();
95 /* 1/ Check if device is permitted by mdadm.conf */
97 if (!conf_test_dev(devname
)) {
100 ": %s not permitted by mdadm.conf.\n",
105 /* 2/ Find metadata, reject if none appropriate (check
106 * version/name from args) */
108 dfd
= dev_open(devname
, O_RDONLY
|O_EXCL
);
111 fprintf(stderr
, Name
": cannot open %s: %s.\n",
112 devname
, strerror(errno
));
115 if (fstat(dfd
, &stb
) < 0) {
117 fprintf(stderr
, Name
": fstat failed for %s: %s.\n",
118 devname
, strerror(errno
));
122 if ((stb
.st_mode
& S_IFMT
) != S_IFBLK
) {
124 fprintf(stderr
, Name
": %s is not a block device.\n",
130 if (st
== NULL
&& (st
= guess_super(dfd
)) == NULL
) {
133 ": no recognisable superblock on %s.\n",
138 if (st
->ss
->load_super(st
, dfd
, NULL
)) {
140 fprintf(stderr
, Name
": no RAID superblock on %s.\n",
147 if (st
->ss
->container_content
&& st
->loaded_container
) {
148 /* This is a pre-built container array, so we do something
151 return Incremental_container(st
, devname
, verbose
, runstop
,
155 memset(&info
, 0, sizeof(info
));
156 st
->ss
->getinfo_super(st
, &info
);
157 /* 3/ Check if there is a match in mdadm.conf */
159 array_list
= conf_get_ident(NULL
);
161 for (; array_list
; array_list
= array_list
->next
) {
162 if (array_list
->uuid_set
&&
163 same_uuid(array_list
->uuid
, info
.uuid
, st
->ss
->swapuuid
)
167 ": UUID differs from %s.\n",
168 array_list
->devname
);
171 if (array_list
->name
[0] &&
172 strcasecmp(array_list
->name
, info
.name
) != 0) {
175 ": Name differs from %s.\n",
176 array_list
->devname
);
179 if (array_list
->devices
&&
180 !match_oneof(array_list
->devices
, devname
)) {
183 ": Not a listed device for %s.\n",
184 array_list
->devname
);
187 if (array_list
->super_minor
!= UnSet
&&
188 array_list
->super_minor
!= info
.array
.md_minor
) {
191 ": Different super-minor to %s.\n",
192 array_list
->devname
);
195 if (!array_list
->uuid_set
&&
196 !array_list
->name
[0] &&
197 !array_list
->devices
&&
198 array_list
->super_minor
== UnSet
) {
201 ": %s doesn't have any identifying information.\n",
202 array_list
->devname
);
205 /* FIXME, should I check raid_disks and level too?? */
210 ": we match both %s and %s - cannot decide which to use.\n",
211 match
->devname
, array_list
->devname
);
217 /* 3a/ if not, check for homehost match. If no match, continue
218 * but don't trust the 'name' in the array. Thus a 'random' minor
219 * number will be assigned, and the device name will be based
222 if (homehost
== NULL
||
223 st
->ss
->match_home(st
, homehost
) != 1)
226 /* 4/ Determine device number. */
227 /* - If in mdadm.conf with std name, get number from name. */
228 /* - UUID in /var/run/mdadm.map get number from mapping */
229 /* - If name is suggestive, use that. unless in use with */
230 /* different uuid. */
231 /* - Choose a free, high number. */
232 /* - Use a partitioned device unless strong suggestion not to. */
234 mp
= map_by_uuid(&map
, info
.uuid
);
236 if (uuid_for_name
&& ! mp
) {
237 name_to_use
= fname_from_uuid(st
, &info
, nbuf
, '-');
240 ": not found in mdadm.conf and not identified by homehost"
241 " - using uuid based name\n");
243 name_to_use
= info
.name
;
245 /* There are three possible sources for 'autof': command line,
246 * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
247 * They have precedence in that order.
249 if (autof
== 0 && match
)
250 autof
= match
->autof
;
254 if (match
&& (rv
= is_standard(match
->devname
, &devnum
))) {
255 devnum
= (rv
> 0) ? (-1-devnum
) : devnum
;
256 } else if (mp
!= NULL
)
259 /* Have to guess a bit. */
260 int use_partitions
= 1;
262 char *nm
, nbuf
[1024];
265 if ((autof
&7) == 3 || (autof
&7) == 5)
267 if (st
->ss
->external
)
269 np
= strchr(name_to_use
, ':');
274 devnum
= strtoul(np
, &ep
, 10);
275 if (ep
> np
&& *ep
== 0) {
276 /* This is a number. Let check that it is unused. */
277 if (mddev_busy(use_partitions
? (-1-devnum
) : devnum
))
285 sprintf(nbuf
, "/dev/md/%s", np
);
288 if (stat(nm
, &stb2
) == 0 &&
289 S_ISBLK(stb2
.st_mode
) &&
290 major(stb2
.st_rdev
) == (use_partitions
?
291 get_mdp_major() : MD_MAJOR
)) {
293 devnum
= minor(stb2
.st_rdev
) >> MdpMinorShift
;
295 devnum
= minor(stb2
.st_rdev
);
296 if (mddev_busy(use_partitions
? (-1-devnum
) : devnum
))
301 /* Haven't found anything yet, choose something free */
302 devnum
= find_free_devnum(use_partitions
);
304 if (devnum
== NoMdDev
) {
306 ": No spare md devices!!\n");
310 devnum
= use_partitions
? (-1-devnum
) : devnum
;
313 mdfd
= open_mddev_devnum(match
? match
->devname
: mp
? mp
->path
: NULL
,
316 chosen_name
, autof
>> 3);
318 fprintf(stderr
, Name
": failed to open %s: %s.\n",
319 chosen_name
, strerror(errno
));
322 sysfs_init(&info
, mdfd
, 0);
324 /* 5/ Find out if array already exists */
325 if (! mddev_busy(devnum
)) {
326 /* 5a/ if it does not */
327 /* - choose a name, from mdadm.conf or 'name' field in array. */
328 /* - create the array */
329 /* - add the device */
333 if (set_array_info(mdfd
, st
, &info
) != 0) {
334 fprintf(stderr
, Name
": failed to set array info for %s: %s\n",
335 chosen_name
, strerror(errno
));
341 dinfo
.disk
.major
= major(stb
.st_rdev
);
342 dinfo
.disk
.minor
= minor(stb
.st_rdev
);
343 if (add_disk(mdfd
, st
, &info
, &dinfo
) != 0) {
344 fprintf(stderr
, Name
": failed to add %s to %s: %s.\n",
345 devname
, chosen_name
, strerror(errno
));
346 ioctl(mdfd
, STOP_ARRAY
, 0);
350 sra
= sysfs_read(mdfd
, devnum
, GET_DEVS
);
351 if (!sra
|| !sra
->devs
|| sra
->devs
->disk
.raid_disk
>= 0) {
352 /* It really should be 'none' - must be old buggy
353 * kernel, and mdadm -I may not be able to complete.
356 ioctl(mdfd
, STOP_ARRAY
, NULL
);
358 ": You have an old buggy kernel which cannot support\n"
359 " --incremental reliably. Aborting.\n");
364 info
.array
.working_disks
= 1;
368 /* - check one drive in array to make sure metadata is a reasonably */
369 /* close match. Reject if not (e.g. different type) */
370 /* - add the device */
375 struct supertype
*st2
;
376 struct mdinfo info2
, *d
;
377 sra
= sysfs_read(mdfd
, devnum
, (GET_DEVS
| GET_STATE
));
379 sprintf(dn
, "%d:%d", sra
->devs
->disk
.major
,
380 sra
->devs
->disk
.minor
);
381 dfd2
= dev_open(dn
, O_RDONLY
);
383 if (st2
->ss
->load_super(st2
, dfd2
, NULL
) ||
384 st
->ss
->compare_super(st
, st2
) != 0) {
386 ": metadata mismatch between %s and "
388 devname
, chosen_name
);
394 memset(&info2
, 0, sizeof(info2
));
395 st2
->ss
->getinfo_super(st2
, &info2
);
396 st2
->ss
->free_super(st2
);
397 if (info
.array
.level
!= info2
.array
.level
||
398 memcmp(info
.uuid
, info2
.uuid
, 16) != 0 ||
399 info
.array
.raid_disks
!= info2
.array
.raid_disks
) {
401 ": unexpected difference between %s and %s.\n",
402 chosen_name
, devname
);
406 info2
.disk
.major
= major(stb
.st_rdev
);
407 info2
.disk
.minor
= minor(stb
.st_rdev
);
408 /* add disk needs to know about containers */
409 if (st
->ss
->external
)
410 sra
->array
.level
= LEVEL_CONTAINER
;
411 err
= add_disk(mdfd
, st2
, sra
, &info2
);
412 if (err
< 0 && errno
== EBUSY
) {
413 /* could be another device present with the same
414 * disk.number. Find and reject any such
416 find_reject(mdfd
, st
, sra
, info
.disk
.number
,
417 info
.events
, verbose
, chosen_name
);
418 err
= add_disk(mdfd
, st2
, sra
, &info2
);
421 fprintf(stderr
, Name
": failed to add %s to %s: %s.\n",
422 devname
, chosen_name
, strerror(errno
));
426 info
.array
.working_disks
= 0;
427 for (d
= sra
->devs
; d
; d
=d
->next
)
428 info
.array
.working_disks
++;
431 /* 6/ Make sure /var/run/mdadm.map contains this array. */
432 map_update(&map
, devnum
,
434 info
.uuid
, chosen_name
);
436 /* 7/ Is there enough devices to possibly start the array? */
437 /* 7a/ if not, finish with success. */
438 if (info
.array
.level
== LEVEL_CONTAINER
) {
439 /* Try to assemble within the container */
443 ": container %s now has %d devices\n",
444 chosen_name
, info
.array
.working_disks
);
445 return Incremental(chosen_name
, verbose
, runstop
,
446 NULL
, homehost
, autof
);
449 active_disks
= count_active(st
, mdfd
, &avail
, &info
);
450 if (enough(info
.array
.level
, info
.array
.raid_disks
,
451 info
.array
.layout
, info
.array
.state
& 1,
452 avail
, active_disks
) == 0) {
456 ": %s attached to %s, not enough to start (%d).\n",
457 devname
, chosen_name
, active_disks
);
464 /* - if number of OK devices match expected, or -R and there */
466 /* + add any bitmap file */
467 /* + start the array (auto-readonly). */
469 mdu_array_info_t ainf
;
471 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ainf
) == 0) {
474 ": %s attached to %s which is already active.\n",
475 devname
, chosen_name
);
480 if (runstop
> 0 || active_disks
>= info
.array
.working_disks
) {
482 /* Let's try to start it */
483 if (match
&& match
->bitmap_file
) {
484 int bmfd
= open(match
->bitmap_file
, O_RDWR
);
487 ": Could not open bitmap file %s.\n",
492 if (ioctl(mdfd
, SET_BITMAP_FILE
, bmfd
) != 0) {
495 ": Failed to set bitmapfile for %s.\n",
502 sra
= sysfs_read(mdfd
, devnum
, 0);
503 if ((sra
== NULL
|| active_disks
>= info
.array
.working_disks
)
504 && uuid_for_name
== 0)
505 rv
= ioctl(mdfd
, RUN_ARRAY
, NULL
);
507 rv
= sysfs_set_str(sra
, NULL
,
508 "array_state", "read-auto");
512 ": %s attached to %s, which has been started.\n",
513 devname
, chosen_name
);
517 ": %s attached to %s, but failed to start: %s.\n",
518 devname
, chosen_name
, strerror(errno
));
524 ": %s attached to %s, not enough to start safely.\n",
525 devname
, chosen_name
);
532 static void find_reject(int mdfd
, struct supertype
*st
, struct mdinfo
*sra
,
533 int number
, __u64 events
, int verbose
,
536 /* Find a device attached to this array with a disk.number of number
537 * and events less than the passed events, and remove the device.
542 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ra
) == 0)
543 return; /* not safe to remove from active arrays
544 * without thinking more */
546 for (d
= sra
->devs
; d
; d
= d
->next
) {
550 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
551 dfd
= dev_open(dn
, O_RDONLY
);
554 if (st
->ss
->load_super(st
, dfd
, NULL
)) {
558 st
->ss
->getinfo_super(st
, &info
);
559 st
->ss
->free_super(st
);
562 if (info
.disk
.number
!= number
||
563 info
.events
>= events
)
566 if (d
->disk
.raid_disk
> -1)
567 sysfs_set_str(sra
, d
, "slot", "none");
568 if (sysfs_set_str(sra
, d
, "state", "remove") == 0)
571 ": removing old device %s from %s\n",
572 d
->sys_name
+4, array_name
);
576 static int count_active(struct supertype
*st
, int mdfd
, char **availp
,
577 struct mdinfo
*bestinfo
)
579 /* count how many devices in sra think they are active */
581 int cnt
= 0, cnt1
= 0;
582 __u64 max_events
= 0;
583 struct mdinfo
*sra
= sysfs_read(mdfd
, -1, GET_DEVS
| GET_STATE
);
586 for (d
= sra
->devs
; d
; d
= d
->next
) {
592 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
593 dfd
= dev_open(dn
, O_RDONLY
);
596 ok
= st
->ss
->load_super(st
, dfd
, NULL
);
600 st
->ss
->getinfo_super(st
, &info
);
602 avail
= malloc(info
.array
.raid_disks
);
604 fprintf(stderr
, Name
": out of memory.\n");
607 memset(avail
, 0, info
.array
.raid_disks
);
611 if (info
.disk
.state
& (1<<MD_DISK_SYNC
))
615 max_events
= info
.events
;
616 avail
[info
.disk
.raid_disk
] = 2;
617 st
->ss
->getinfo_super(st
, bestinfo
);
618 } else if (info
.events
== max_events
) {
620 avail
[info
.disk
.raid_disk
] = 2;
621 } else if (info
.events
== max_events
-1) {
623 avail
[info
.disk
.raid_disk
] = 1;
624 } else if (info
.events
< max_events
- 1)
626 else if (info
.events
== max_events
+1) {
630 max_events
= info
.events
;
631 for (i
=0; i
<info
.array
.raid_disks
; i
++)
634 avail
[info
.disk
.raid_disk
] = 2;
635 st
->ss
->getinfo_super(st
, bestinfo
);
636 } else { /* info.events much bigger */
638 memset(avail
, 0, info
.disk
.raid_disk
);
639 max_events
= info
.events
;
640 st
->ss
->getinfo_super(st
, bestinfo
);
643 st
->ss
->free_super(st
);
648 void RebuildMap(void)
650 struct mdstat_ent
*mdstat
= mdstat_read(0, 0);
651 struct mdstat_ent
*md
;
652 struct map_ent
*map
= NULL
;
653 int mdp
= get_mdp_major();
655 for (md
= mdstat
; md
; md
= md
->next
) {
656 struct mdinfo
*sra
= sysfs_read(-1, md
->devnum
, GET_DEVS
);
659 for (sd
= sra
->devs
; sd
; sd
= sd
->next
) {
663 struct supertype
*st
;
667 sprintf(dn
, "%d:%d", sd
->disk
.major
, sd
->disk
.minor
);
668 dfd
= dev_open(dn
, O_RDONLY
);
671 st
= guess_super(dfd
);
675 ok
= st
->ss
->load_super(st
, dfd
, NULL
);
679 st
->ss
->getinfo_super(st
, &info
);
681 path
= map_dev(MD_MAJOR
, md
->devnum
, 0);
683 path
= map_dev(mdp
, (-1-md
->devnum
)<< 6, 0);
684 map_add(&map
, md
->devnum
,
686 info
.uuid
, path
? : "/unknown");
687 st
->ss
->free_super(st
);
695 int IncrementalScan(int verbose
)
697 /* look at every device listed in the 'map' file.
698 * If one is found that is not running then:
699 * look in mdadm.conf for bitmap file.
700 * if one exists, but array has none, add it.
701 * try to start array in auto-readonly mode
703 struct map_ent
*mapl
= NULL
;
705 mddev_ident_t devs
, mddev
;
709 devs
= conf_get_ident(NULL
);
711 for (me
= mapl
; me
; me
= me
->next
) {
713 mdu_array_info_t array
;
714 mdu_bitmap_file_t bmf
;
716 int mdfd
= open_mddev_devnum(me
->path
, me
->devnum
,
720 if (ioctl(mdfd
, GET_ARRAY_INFO
, &array
) == 0 ||
725 /* Ok, we can try this one. Maybe it needs a bitmap */
726 for (mddev
= devs
; mddev
; mddev
= mddev
->next
)
727 if (strcmp(mddev
->devname
, me
->path
) == 0)
729 if (mddev
&& mddev
->bitmap_file
) {
731 * Note: early kernels will wrongly fail this, so it
735 if (ioctl(mdfd
, GET_ARRAY_INFO
, &bmf
) < 0) {
736 int bmfd
= open(mddev
->bitmap_file
, O_RDWR
);
738 added
= ioctl(mdfd
, SET_BITMAP_FILE
,
746 ": Added bitmap %s to %s\n",
747 mddev
->bitmap_file
, me
->path
);
748 else if (errno
!= EEXIST
)
750 ": Failed to add bitmap to %s: %s\n",
751 me
->path
, strerror(errno
));
754 sra
= sysfs_read(mdfd
, 0, 0);
756 if (sysfs_set_str(sra
, NULL
,
757 "array_state", "read-auto") == 0) {
760 ": started array %s\n",
764 ": failed to start array %s: %s\n",
765 me
->path
, strerror(errno
));
773 static char *container2devname(char *devname
)
775 int fd
= open(devname
, O_RDONLY
);
779 mdname
= devnum2devname(fd2devnum(fd
));
786 int Incremental_container(struct supertype
*st
, char *devname
, int verbose
,
787 int runstop
, int autof
)
789 /* Collect the contents of this container and for each
790 * array, choose a device name and assemble the array.
793 struct mdinfo
*list
= st
->ss
->container_content(st
);
795 char *mdname
= container2devname(devname
);
798 fprintf(stderr
, Name
": failed to determine device name\n");
802 for (ra
= list
; ra
; ra
= ra
->next
) {
803 struct mdinfo
*dev
, *sra
;
806 char chosen_name
[1024];
809 int working
= 0, preexist
= 0;
810 struct map_ent
*mp
, *map
= NULL
;
813 struct mddev_ident_s
*match
= NULL
;
815 if ((autof
&7) == 3 || (autof
&7) == 5)
818 mp
= map_by_uuid(&map
, ra
->uuid
);
820 name_to_use
= ra
->name
;
823 (*devname
!= '/' || strncmp("UUID-", strrchr(devname
,'/')+1,5) == 0)
825 name_to_use
= fname_from_uuid(st
, ra
, nbuf
, '-');
829 /* Check in mdadm.conf for devices == devname and
830 * member == ra->text_version after second slash.
832 char *sub
= strchr(ra
->text_version
+1, '/');
833 struct mddev_ident_s
*array_list
;
836 array_list
= conf_get_ident(NULL
);
839 for(; array_list
; array_list
= array_list
->next
) {
842 if (array_list
->member
== NULL
||
843 array_list
->container
== NULL
)
845 if (strcmp(array_list
->member
, sub
) != 0)
847 if (array_list
->uuid_set
&&
848 !same_uuid(ra
->uuid
, array_list
->uuid
, st
->ss
->swapuuid
))
850 fd
= open(array_list
->container
, O_RDONLY
);
853 dn
= devnum2devname(fd2devnum(fd
));
855 if (strncmp(dn
, ra
->text_version
+1,
857 ra
->text_version
[strlen(dn
)+1] != '/') {
862 /* we have a match */
865 fprintf(stderr
, Name
": match found for member %s\n",
871 if (match
&& is_standard(match
->devname
, &devnum
))
872 /* we have devnum now */;
875 else if (is_standard(name_to_use
, &devnum
))
881 if (*n
&& devnum
< 0) {
882 devnum
= strtoul(n
, &n
, 10);
883 if (devnum
>= 0 && (*n
== 0 || *n
== ' ')) {
884 /* Use this devnum */
885 usepart
= (name_to_use
[0] == 'd');
886 if (mddev_busy(usepart
? (-1-devnum
) : devnum
))
893 char *nm
= name_to_use
;
897 nm
= strchr(nm
, ':')+1;
898 sprintf(nbuf
, "/dev/md/%s", nm
);
900 if (stat(nbuf
, &stb
) == 0 &&
901 S_ISBLK(stb
.st_mode
) &&
902 major(stb
.st_rdev
) == (usepart
?
903 get_mdp_major() : MD_MAJOR
)){
905 devnum
= minor(stb
.st_rdev
)
908 devnum
= minor(stb
.st_rdev
);
909 if (mddev_busy(usepart
? (-1-devnum
) : devnum
))
915 devnum
= usepart
? (-1-devnum
) : devnum
;
917 devnum
= find_free_devnum(usepart
);
919 mdfd
= open_mddev_devnum(mp
? mp
->path
: match
? match
->devname
: NULL
,
921 chosen_name
, autof
>>3);
924 fprintf(stderr
, Name
": failed to open %s: %s.\n",
925 chosen_name
, strerror(errno
));
930 sysfs_init(ra
, mdfd
, 0);
932 sra
= sysfs_read(mdfd
, 0, GET_VERSION
);
933 if (sra
== NULL
|| strcmp(sra
->text_version
, ra
->text_version
) != 0)
934 if (sysfs_set_array(ra
, md_get_version(mdfd
)) != 0)
939 for (dev
= ra
->devs
; dev
; dev
= dev
->next
)
940 if (sysfs_add_disk(ra
, dev
) == 0)
942 else if (errno
== EEXIST
)
945 /* Nothing new, don't try to start */ ;
946 else if (runstop
> 0 ||
947 (working
+ preexist
) >= ra
->array
.working_disks
) {
948 switch(ra
->array
.level
) {
950 case LEVEL_MULTIPATH
:
952 sysfs_set_str(ra
, NULL
, "array_state",
956 sysfs_set_str(ra
, NULL
, "array_state",
958 /* start mdmon if needed. */
959 if (!mdmon_running(st
->container_dev
))
960 start_mdmon(st
->container_dev
);
961 ping_monitor(devnum2devname(st
->container_dev
));
964 sysfs_set_safemode(ra
, ra
->safe_mode_delay
);
967 ": Started %s with %d devices",
968 chosen_name
, working
+ preexist
);
970 fprintf(stderr
, " (%d new)", working
);
971 fprintf(stderr
, "\n");
973 /* FIXME should have an O_EXCL and wait for read-auto */
977 ": %s assembled with %d devices but "
979 chosen_name
, working
);
981 map_update(&map
, devnum
,
983 ra
->uuid
, chosen_name
);