]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Create.c
2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
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.
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.
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
22 * Email: <neilb@suse.de>
30 static int default_layout(struct supertype
*st
, int level
, int verbose
)
34 if (st
&& st
->ss
->default_geometry
)
35 st
->ss
->default_geometry(st
, &level
, &layout
, NULL
);
39 default: /* no layout */
43 layout
= 0x102; /* near=2, far=1 */
46 Name
": layout defaults to n2\n");
50 layout
= map_name(r5layout
, "default");
53 Name
": layout defaults to %s\n", map_num(r5layout
, layout
));
56 layout
= map_name(faultylayout
, "default");
60 Name
": layout defaults to %s\n", map_num(faultylayout
, layout
));
68 int Create(struct supertype
*st
, char *mddev
,
69 int chunk
, int level
, int layout
, unsigned long long size
,
70 int raiddisks
, int sparedisks
,
71 char *name
, char *homehost
, int *uuid
,
72 int subdevs
, struct mddev_dev
*devlist
,
73 int runstop
, int verbose
, int force
, int assume_clean
,
74 char *bitmap_file
, int bitmap_chunk
, int write_behind
,
78 * Create a new raid array.
80 * First check that necessary details are available
81 * (i.e. level, raid-disks)
83 * Then check each disk to see what might be on it
84 * and report anything interesting.
86 * If anything looks odd, and runstop not set,
89 * SET_ARRAY_INFO and ADD_NEW_DISK, and
90 * if runstop==run, or raiddisks disks were used,
94 unsigned long long minsize
=0, maxsize
=0;
101 int first_missing
= subdevs
* 2;
102 int second_missing
= subdevs
* 2;
103 int missing_disks
= 0;
104 int insert_point
= subdevs
* 2; /* where to insert a missing drive */
110 int have_container
= 0;
111 int container_fd
= -1;
113 unsigned long long bitmapsize
;
114 struct mdinfo info
, *infos
;
116 int do_default_layout
= 0;
117 int do_default_chunk
= 0;
118 unsigned long safe_mode_delay
= 0;
119 char chosen_name
[1024];
120 struct map_ent
*map
= NULL
;
121 unsigned long long newsize
;
123 int major_num
= BITMAP_MAJOR_HI
;
125 memset(&info
, 0, sizeof(info
));
126 if (level
== UnSet
&& st
&& st
->ss
->default_geometry
)
127 st
->ss
->default_geometry(st
, &level
, NULL
, NULL
);
128 if (level
== UnSet
) {
130 Name
": a RAID level is needed to create an array.\n");
133 if (raiddisks
< 4 && level
== 6) {
135 Name
": at least 4 raid-devices needed for level 6\n");
138 if (raiddisks
> 256 && level
== 6) {
140 Name
": no more than 256 raid-devices supported for level 6\n");
143 if (raiddisks
< 2 && level
>= 4) {
145 Name
": at least 2 raid-devices needed for level 4 or 5\n");
148 if (level
<= 0 && sparedisks
) {
150 Name
": This level does not support spare devices\n");
154 if (subdevs
== 1 && strcmp(devlist
->devname
, "missing") != 0) {
155 /* If given a single device, it might be a container, and we can
156 * extract a device list from there
158 mdu_array_info_t inf
;
161 memset(&inf
, 0, sizeof(inf
));
162 fd
= open(devlist
->devname
, O_RDONLY
);
164 ioctl(fd
, GET_ARRAY_INFO
, &inf
) == 0 &&
165 inf
.raid_disks
== 0) {
166 /* yep, looks like a container */
168 rv
= st
->ss
->load_container(st
, fd
,
173 st
= super_by_fd(fd
, NULL
);
174 if (st
&& !(rv
= st
->ss
->
175 load_container(st
, fd
,
181 if (have_container
) {
183 first_missing
= subdevs
* 2;
184 second_missing
= subdevs
* 2;
185 insert_point
= subdevs
* 2;
191 if (st
&& st
->ss
->external
&& sparedisks
) {
193 Name
": This metadata type does not support "
194 "spare disks at create time\n");
197 if (subdevs
> raiddisks
+sparedisks
) {
198 fprintf(stderr
, Name
": You have listed more devices (%d) than are in the array(%d)!\n", subdevs
, raiddisks
+sparedisks
);
201 if (!have_container
&& subdevs
< raiddisks
+sparedisks
) {
202 fprintf(stderr
, Name
": You haven't given enough devices (real or missing) to create this array\n");
205 if (bitmap_file
&& level
<= 0) {
206 fprintf(stderr
, Name
": bitmaps not meaningful with level %s\n",
207 map_num(pers
, level
)?:"given");
211 /* now set some defaults */
214 if (layout
== UnSet
) {
215 do_default_layout
= 1;
216 layout
= default_layout(st
, level
, verbose
);
220 /* check layout fits in array*/
221 if ((layout
&255) * ((layout
>>8)&255) > raiddisks
) {
222 fprintf(stderr
, Name
": that layout requires at least %d devices\n",
223 (layout
&255) * ((layout
>>8)&255));
233 if (chunk
== 0 || chunk
== UnSet
) {
235 do_default_chunk
= 1;
236 /* chunk will be set later */
240 /* a chunksize of zero 0s perfectly valid (and preferred) since 2.6.16 */
241 if (get_linux_version() < 2006016 && chunk
== 0) {
244 fprintf(stderr
, Name
": chunk size defaults to 64K\n");
249 case LEVEL_MULTIPATH
:
250 case LEVEL_CONTAINER
:
254 fprintf(stderr
, Name
": chunk size ignored for this level\n");
258 fprintf(stderr
, Name
": unknown level %d\n", level
);
262 if (size
&& chunk
&& chunk
!= UnSet
)
263 size
&= ~(unsigned long long)(chunk
- 1);
265 if (st
&& ! st
->ss
->validate_geometry(st
, level
, layout
, raiddisks
,
266 &chunk
, size
*2, NULL
, &newsize
, verbose
>=0))
269 if (chunk
&& chunk
!= UnSet
) {
270 newsize
&= ~(unsigned long long)(chunk
*2 - 1);
271 if (do_default_chunk
) {
272 /* default chunk was just set */
274 fprintf(stderr
, Name
": chunk size "
275 "defaults to %dK\n", chunk
);
276 size
&= ~(unsigned long long)(chunk
- 1);
277 do_default_chunk
= 0;
283 if (size
&& verbose
> 0)
284 fprintf(stderr
, Name
": setting size to %lluK\n",
285 (unsigned long long)size
);
288 /* now look at the subdevs */
289 info
.array
.active_disks
= 0;
290 info
.array
.working_disks
= 0;
292 for (dv
=devlist
; dv
&& !have_container
; dv
=dv
->next
, dnum
++) {
293 char *dname
= dv
->devname
;
294 unsigned long long freesize
;
297 if (strcasecmp(dname
, "missing")==0) {
298 if (first_missing
> dnum
)
299 first_missing
= dnum
;
300 if (second_missing
> dnum
&& dnum
> first_missing
)
301 second_missing
= dnum
;
305 dfd
= open(dname
, O_RDONLY
);
307 fprintf(stderr
, Name
": cannot open %s: %s\n",
308 dname
, strerror(errno
));
311 if (fstat(dfd
, &stb
) != 0 ||
312 (stb
.st_mode
& S_IFMT
) != S_IFBLK
) {
314 fprintf(stderr
, Name
": %s is not a block device\n",
319 info
.array
.working_disks
++;
320 if (dnum
< raiddisks
)
321 info
.array
.active_disks
++;
323 struct createinfo
*ci
= conf_get_create_info();
328 /* Need to choose a default metadata, which is different
329 * depending on geometry of array.
332 char *name
= "default";
333 for(i
=0; !st
&& superlist
[i
]; i
++) {
334 st
= superlist
[i
]->match_metadata_desc(name
);
337 if (do_default_layout
)
338 layout
= default_layout(st
, level
, verbose
);
339 switch (st
->ss
->validate_geometry(
340 st
, level
, layout
, raiddisks
,
341 &chunk
, size
*2, dname
, &freesize
,
343 case -1: /* Not valid, message printed, and not
344 * worth checking any further */
347 case 0: /* Geometry not valid */
350 chunk
= do_default_chunk
? UnSet
: chunk
;
352 case 1: /* All happy */
358 int dfd
= open(dname
, O_RDONLY
|O_EXCL
);
360 fprintf(stderr
, Name
": cannot open %s: %s\n",
361 dname
, strerror(errno
));
364 fprintf(stderr
, Name
": device %s not suitable "
365 "for any style of array\n",
369 if (st
->ss
!= &super0
||
370 st
->minor_version
!= 90)
373 if (do_default_layout
)
374 layout
= default_layout(st
, level
, verbose
);
375 if (!st
->ss
->validate_geometry(st
, level
, layout
,
377 &chunk
, size
*2, dname
,
382 Name
": %s is not suitable for "
390 freesize
/= 2; /* convert to K */
391 if (chunk
&& chunk
!= UnSet
) {
392 /* round to chunk size */
393 freesize
= freesize
& ~(chunk
-1);
394 if (do_default_chunk
) {
395 /* default chunk was just set */
397 fprintf(stderr
, Name
": chunk size "
398 "defaults to %dK\n", chunk
);
399 size
&= ~(unsigned long long)(chunk
- 1);
400 do_default_chunk
= 0;
404 if (size
&& freesize
< size
) {
405 fprintf(stderr
, Name
": %s is smaller than given size."
406 " %lluK < %lluK + metadata\n",
407 dname
, freesize
, size
);
411 if (maxdisc
== NULL
|| (maxdisc
&& freesize
> maxsize
)) {
415 if (mindisc
==NULL
|| (mindisc
&& freesize
< minsize
)) {
419 if (runstop
!= 1 || verbose
>= 0) {
420 int fd
= open(dname
, O_RDONLY
);
422 fprintf(stderr
, Name
": Cannot open %s: %s\n",
423 dname
, strerror(errno
));
427 warn
|= check_ext2(fd
, dname
);
428 warn
|= check_reiser(fd
, dname
);
429 warn
|= check_raid(fd
, dname
);
430 if (strcmp(st
->ss
->name
, "1.x") == 0 &&
431 st
->minor_version
>= 1)
432 /* metadata at front */
433 warn
|= check_partitions(fd
, dname
, 0, 0);
434 else if (level
== 1 || level
== LEVEL_CONTAINER
435 || (level
== 0 && raiddisks
== 1))
436 /* partitions could be meaningful */
437 warn
|= check_partitions(fd
, dname
, freesize
*2, size
*2);
439 /* partitions cannot be meaningful */
440 warn
|= check_partitions(fd
, dname
, 0, 0);
441 if (strcmp(st
->ss
->name
, "1.x") == 0 &&
442 st
->minor_version
>= 1 &&
445 (warn
& 1024) == 0) {
447 fprintf(stderr
, Name
": Note: this array has metadata at the start and\n"
448 " may not be suitable as a boot device. If you plan to\n"
449 " store '/boot' on this device please ensure that\n"
450 " your boot-loader understands md/v1.x metadata, or use\n"
451 " --metadata=0.90\n");
456 if (raiddisks
+ sparedisks
> st
->max_devs
) {
457 fprintf(stderr
, Name
": Too many devices:"
458 " %s metadata only supports %d\n",
459 st
->ss
->name
, st
->max_devs
);
463 info
.array
.working_disks
= raiddisks
;
465 fprintf(stderr
, Name
": create aborted\n");
469 if (mindisc
== NULL
&& !have_container
) {
470 fprintf(stderr
, Name
": no size and no drives given - aborting create.\n");
473 if (level
> 0 || level
== LEVEL_MULTIPATH
474 || level
== LEVEL_FAULTY
475 || st
->ss
->external
) {
476 /* size is meaningful */
477 if (!st
->ss
->validate_geometry(st
, level
, layout
,
481 fprintf(stderr
, Name
": devices too large for RAID level %d\n", level
);
486 fprintf(stderr
, Name
": size set to %lluK\n", size
);
489 if (!have_container
&& level
> 0 && ((maxsize
-size
)*100 > maxsize
)) {
490 if (runstop
!= 1 || verbose
>= 0)
491 fprintf(stderr
, Name
": largest drive (%s) exceeds size (%lluK) by more than 1%%\n",
496 if (st
->ss
->detail_platform
&& st
->ss
->detail_platform(0, 1) != 0) {
497 if (runstop
!= 1 || verbose
>= 0)
498 fprintf(stderr
, Name
": %s unable to enumerate platform support\n"
499 " array may not be compatible with hardware/firmware\n",
506 if (!ask("Continue creating array? ")) {
507 fprintf(stderr
, Name
": create aborted.\n");
512 fprintf(stderr
, Name
": creation continuing despite oddities due to --run\n");
516 /* If this is raid4/5, we want to configure the last active slot
517 * as missing, so that a reconstruct happens (faster than re-parity)
518 * FIX: Can we do this for raid6 as well?
520 if (st
->ss
->external
== 0 &&
521 assume_clean
==0 && force
== 0 && first_missing
>= raiddisks
) {
525 insert_point
= raiddisks
-1;
527 info
.array
.active_disks
--;
534 /* For raid6, if creating with 1 missing drive, make a good drive
535 * into a spare, else the create will fail
537 if (assume_clean
== 0 && force
== 0 && first_missing
< raiddisks
&&
538 st
->ss
->external
== 0 &&
539 second_missing
>= raiddisks
&& level
== 6) {
540 insert_point
= raiddisks
- 1;
541 if (insert_point
== first_missing
)
544 info
.array
.active_disks
--;
548 if (level
<= 0 && first_missing
< subdevs
* 2) {
550 Name
": This level does not support missing devices\n");
554 /* We need to create the device */
556 mdfd
= create_mddev(mddev
, name
, autof
, LOCAL
, chosen_name
);
563 vers
= md_get_version(mdfd
);
565 fprintf(stderr
, Name
": Create requires md driver version 0.90.0 or later\n");
568 mdu_array_info_t inf
;
569 memset(&inf
, 0, sizeof(inf
));
570 ioctl(mdfd
, GET_ARRAY_INFO
, &inf
);
571 if (inf
.working_disks
!= 0) {
572 fprintf(stderr
, Name
": another array by this name"
573 " is already running.\n");
578 /* Ok, lets try some ioctls */
580 info
.array
.level
= level
;
581 info
.array
.size
= size
;
582 info
.array
.raid_disks
= raiddisks
;
583 /* The kernel should *know* what md_minor we are dealing
584 * with, but it chooses to trust me instead. Sigh
586 info
.array
.md_minor
= 0;
587 if (fstat(mdfd
, &stb
)==0)
588 info
.array
.md_minor
= minor(stb
.st_rdev
);
589 info
.array
.not_persistent
= 0;
591 if ( ( (level
== 4 || level
== 5) &&
592 (insert_point
< raiddisks
|| first_missing
< raiddisks
) )
594 ( level
== 6 && (insert_point
< raiddisks
595 || second_missing
< raiddisks
))
601 info
.array
.state
= 1; /* clean, but one+ drive will be missing*/
602 info
.resync_start
= MaxSector
;
604 info
.array
.state
= 0; /* not clean, but no errors */
605 info
.resync_start
= 0;
608 /* for raid10, the bitmap size is the capacity of the array,
609 * which is array.size * raid_disks / ncopies;
610 * .. but convert to sectors.
612 int ncopies
= ((layout
>>8) & 255) * (layout
& 255);
613 bitmapsize
= (unsigned long long)size
* raiddisks
/ ncopies
* 2;
614 /* printf("bms=%llu as=%d rd=%d nc=%d\n", bitmapsize, size, raiddisks, ncopies);*/
616 bitmapsize
= (unsigned long long)size
* 2;
618 /* There is lots of redundancy in these disk counts,
619 * raid_disks is the most meaningful value
620 * it describes the geometry of the array
622 * nr_disks is total number of used slots.
623 * it should be raid_disks+spare_disks
624 * spare_disks is the number of extra disks present
626 * active_disks is the number of working disks in
627 * active slots. (With raid_disks)
628 * working_disks is the total number of working disks,
630 * failed_disks is the number of disks marked failed
632 * Ideally, the kernel would keep these (except raid_disks)
633 * up-to-date as we ADD_NEW_DISK, but it doesn't (yet).
634 * So for now, we assume that all raid and spare
635 * devices will be given.
637 info
.array
.spare_disks
=sparedisks
;
638 info
.array
.failed_disks
=missing_disks
;
639 info
.array
.nr_disks
= info
.array
.working_disks
640 + info
.array
.failed_disks
;
641 info
.array
.layout
= layout
;
642 info
.array
.chunk_size
= chunk
*1024;
644 if (name
== NULL
|| *name
== 0) {
645 /* base name on mddev */
650 * /dev/md/home -> home
651 * /dev/mdhome -> home
653 /* FIXME compare this with rules in create_mddev */
654 name
= strrchr(mddev
, '/');
657 if (strncmp(name
, "md_d", 4)==0 &&
660 (name
-mddev
) == 5 /* /dev/ */)
662 else if (strncmp(name
, "md", 2)==0 &&
665 (name
-mddev
) == 5 /* /dev/ */)
669 if (!st
->ss
->init_super(st
, &info
.array
, size
, name
, homehost
, uuid
))
672 total_slots
= info
.array
.nr_disks
;
673 st
->ss
->getinfo_super(st
, &info
, NULL
);
674 sysfs_init(&info
, mdfd
, 0);
676 if (did_default
&& verbose
>= 0) {
677 if (is_subarray(info
.text_version
)) {
678 int dnum
= devname2devnum(info
.text_version
+1);
680 int mdp
= get_mdp_major();
683 path
= map_dev(MD_MAJOR
, dnum
, 1);
685 path
= map_dev(mdp
, (-1-dnum
)<< 6, 1);
687 mdi
= sysfs_read(-1, dnum
, GET_VERSION
);
689 fprintf(stderr
, Name
": Creating array inside "
691 mdi
?mdi
->text_version
:"managed", path
);
694 fprintf(stderr
, Name
": Defaulting to version"
695 " %s metadata\n", info
.text_version
);
698 map_update(&map
, fd2devnum(mdfd
), info
.text_version
,
699 info
.uuid
, chosen_name
);
702 if (bitmap_file
&& vers
< 9003) {
703 major_num
= BITMAP_MAJOR_HOSTENDIAN
;
705 fprintf(stderr
, Name
": Warning - bitmaps created on this kernel are not portable\n"
706 " between different architectured. Consider upgrading the Linux kernel.\n");
710 if (bitmap_file
&& strcmp(bitmap_file
, "internal")==0) {
711 if ((vers
%100) < 2) {
712 fprintf(stderr
, Name
": internal bitmaps not supported by this kernel.\n");
715 if (!st
->ss
->add_internal_bitmap
) {
716 fprintf(stderr
, Name
": internal bitmaps not supported with %s metadata\n",
720 if (!st
->ss
->add_internal_bitmap(st
, &bitmap_chunk
,
722 bitmapsize
, 1, major_num
)) {
723 fprintf(stderr
, Name
": Given bitmap chunk size not supported.\n");
730 sysfs_init(&info
, mdfd
, 0);
732 if (st
->ss
->external
&& st
->container_dev
!= NoMdDev
) {
735 /* When creating a member, we need to be careful
736 * to negotiate with mdmon properly.
737 * If it is already running, we cannot write to
738 * the devices and must ask it to do that part.
739 * If it isn't running, we write to the devices,
741 * We hold an exclusive open on the container
742 * device to make sure mdmon doesn't exit after
743 * we checked that it is running.
745 * For now, fail if it is already running.
747 container_fd
= open_dev_excl(st
->container_dev
);
748 if (container_fd
< 0) {
749 fprintf(stderr
, Name
": Cannot get exclusive "
750 "open on container - weird.\n");
753 if (mdmon_running(st
->container_dev
)) {
755 fprintf(stderr
, Name
": reusing mdmon "
757 devnum2devname(st
->container_dev
));
758 st
->update_tail
= &st
->updates
;
762 rv
= set_array_info(mdfd
, st
, &info
);
764 fprintf(stderr
, Name
": failed to set array info for %s: %s\n",
765 mddev
, strerror(errno
));
772 st
->ss
->uuid_from_super(st
, uuid
);
773 if (CreateBitmap(bitmap_file
, force
, (char*)uuid
, bitmap_chunk
,
779 bitmap_fd
= open(bitmap_file
, O_RDWR
);
781 fprintf(stderr
, Name
": weird: %s cannot be openned\n",
785 if (ioctl(mdfd
, SET_BITMAP_FILE
, bitmap_fd
) < 0) {
786 fprintf(stderr
, Name
": Cannot set bitmap file for %s: %s\n",
787 mddev
, strerror(errno
));
792 infos
= malloc(sizeof(*infos
) * total_slots
);
794 fprintf(stderr
, Name
": Unable to allocate memory\n");
798 for (pass
=1; pass
<=2 ; pass
++) {
799 struct mddev_dev
*moved_disk
= NULL
; /* the disk that was moved out of the insert point */
801 for (dnum
=0, dv
= devlist
; dv
;
802 dv
=(dv
->next
)?(dv
->next
):moved_disk
, dnum
++) {
805 struct mdinfo
*inf
= &infos
[dnum
];
807 if (dnum
>= total_slots
)
809 if (dnum
== insert_point
) {
813 if (strcasecmp(dv
->devname
, "missing")==0)
817 if (have_container
&& dnum
< info
.array
.raid_disks
- 1)
818 /* repeatedly use the container */
825 inf
->disk
.number
= dnum
;
826 inf
->disk
.raid_disk
= dnum
;
827 if (inf
->disk
.raid_disk
< raiddisks
)
828 inf
->disk
.state
= (1<<MD_DISK_ACTIVE
) |
833 if (dv
->writemostly
== 1)
834 inf
->disk
.state
|= (1<<MD_DISK_WRITEMOSTLY
);
839 if (st
->ss
->external
&&
840 st
->container_dev
!= NoMdDev
)
841 fd
= open(dv
->devname
, O_RDWR
);
843 fd
= open(dv
->devname
, O_RDWR
|O_EXCL
);
846 fprintf(stderr
, Name
": failed to open %s "
847 "after earlier success - aborting\n",
852 inf
->disk
.major
= major(stb
.st_rdev
);
853 inf
->disk
.minor
= minor(stb
.st_rdev
);
856 remove_partitions(fd
);
857 if (st
->ss
->add_to_super(st
, &inf
->disk
,
859 ioctl(mdfd
, STOP_ARRAY
, NULL
);
862 st
->ss
->getinfo_super(st
, inf
, NULL
);
863 safe_mode_delay
= inf
->safe_mode_delay
;
865 if (have_container
&& verbose
> 0)
866 fprintf(stderr
, Name
": Using %s for device %d\n",
867 map_dev(inf
->disk
.major
,
871 if (!have_container
) {
872 /* getinfo_super might have lost these ... */
873 inf
->disk
.major
= major(stb
.st_rdev
);
874 inf
->disk
.minor
= minor(stb
.st_rdev
);
880 rv
= add_disk(mdfd
, st
, &info
, inf
);
884 Name
": ADD_NEW_DISK for %s "
886 dv
->devname
, strerror(errno
));
891 if (!have_container
&&
892 dv
== moved_disk
&& dnum
!= insert_point
) break;
895 struct mdinfo info_new
;
896 struct map_ent
*me
= NULL
;
898 /* check to see if the uuid has changed due to these
899 * metadata changes, and if so update the member array
900 * and container uuid. Note ->write_init_super clears
901 * the subarray cursor such that ->getinfo_super once
902 * again returns container info.
905 st
->ss
->getinfo_super(st
, &info_new
, NULL
);
906 if (st
->ss
->external
&& level
!= LEVEL_CONTAINER
&&
907 !same_uuid(info_new
.uuid
, info
.uuid
, 0)) {
908 map_update(&map
, fd2devnum(mdfd
),
909 info_new
.text_version
,
910 info_new
.uuid
, chosen_name
);
911 me
= map_by_devnum(&map
, st
->container_dev
);
914 if (st
->ss
->write_init_super(st
)) {
916 Name
": Failed to write metadata to %s\n",
918 st
->ss
->free_super(st
);
922 /* update parent container uuid */
924 char *path
= strdup(me
->path
);
926 st
->ss
->getinfo_super(st
, &info_new
, NULL
);
927 map_update(&map
, st
->container_dev
,
928 info_new
.text_version
,
929 info_new
.uuid
, path
);
934 flush_metadata_updates(st
);
935 st
->ss
->free_super(st
);
940 if (level
== LEVEL_CONTAINER
) {
941 /* No need to start. But we should signal udev to
943 sysfs_uevent(&info
, "change");
945 fprintf(stderr
, Name
": container %s prepared.\n", mddev
);
946 wait_for(chosen_name
, mdfd
);
947 } else if (runstop
== 1 || subdevs
>= raiddisks
) {
948 if (st
->ss
->external
) {
952 case LEVEL_MULTIPATH
:
954 err
= sysfs_set_str(&info
, NULL
, "array_state",
959 err
= sysfs_set_str(&info
, NULL
, "array_state",
963 sysfs_set_safemode(&info
, safe_mode_delay
);
965 fprintf(stderr
, Name
": failed to"
966 " activate array.\n");
967 ioctl(mdfd
, STOP_ARRAY
, NULL
);
971 /* param is not actually used */
973 if (ioctl(mdfd
, RUN_ARRAY
, ¶m
)) {
974 fprintf(stderr
, Name
": RUN_ARRAY failed: %s\n",
976 if (info
.array
.chunk_size
& (info
.array
.chunk_size
-1)) {
977 fprintf(stderr
, " : Problem may be that "
978 "chunk size is not a power of 2\n");
980 ioctl(mdfd
, STOP_ARRAY
, NULL
);
985 fprintf(stderr
, Name
": array %s started.\n", mddev
);
986 if (st
->ss
->external
&& st
->container_dev
!= NoMdDev
) {
988 start_mdmon(st
->container_dev
);
990 ping_monitor_by_id(st
->container_dev
);
993 wait_for(chosen_name
, mdfd
);
995 fprintf(stderr
, Name
": not starting array - not enough devices.\n");
1003 map_remove(&map
, fd2devnum(mdfd
));