2 * Incremental.c - support --incremental. Part of:
3 * mdadm - manage Linux "md" devices aka RAID arrays.
5 * Copyright (C) 2006-2013 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
36 static int count_active(struct supertype
*st
, struct mdinfo
*sra
,
37 int mdfd
, char **availp
,
39 static void find_reject(int mdfd
, struct supertype
*st
, struct mdinfo
*sra
,
40 int number
, __u64 events
, int verbose
,
42 static int try_spare(char *devname
, int *dfdp
, struct dev_policy
*pol
,
43 struct map_ent
*target
,
44 struct supertype
*st
, int verbose
);
46 static int Incremental_container(struct supertype
*st
, char *devname
,
47 struct context
*c
, char *only
);
49 int Incremental(char *devname
, struct context
*c
,
52 /* Add this device to an array, creating the array if necessary
53 * and starting the array if sensible or - if runstop>0 - if possible.
55 * This has several steps:
57 * 1/ Check if device is permitted by mdadm.conf, reject if not.
58 * 2/ Find metadata, reject if none appropriate (check
59 * version/name from args)
60 * 3/ Check if there is a match in mdadm.conf
61 * 3a/ if not, check for homehost match. If no match, assemble as
63 * 4/ Determine device number.
64 * - If in mdadm.conf with std name, use that
65 * - UUID in /var/run/mdadm.map use that
66 * - If name is suggestive, use that. unless in use with different uuid.
67 * - Choose a free, high number.
68 * - Use a partitioned device unless strong suggestion not to.
70 * Don't choose partitioned for containers.
71 * 5/ Find out if array already exists
73 * - choose a name, from mdadm.conf or 'name' field in array.
77 * - check one drive in array to make sure metadata is a reasonably
78 * close match. Reject if not (e.g. different type)
80 * 6/ Make sure /var/run/mdadm.map contains this array.
81 * 7/ Is there enough devices to possibly start the array?
82 * For a container, this means running Incremental_container.
83 * 7a/ if not, finish with success.
85 * - read all metadata and arrange devices like -A does
86 * - if number of OK devices match expected, or -R and there are enough,
87 * start the array (auto-readonly).
90 struct mdinfo info
, dinfo
;
91 struct mdinfo
*sra
= NULL
, *d
;
92 struct mddev_ident
*match
;
93 char chosen_name
[1024];
96 struct map_ent
*mp
, *map
= NULL
;
97 int dfd
= -1, mdfd
= -1;
102 mdu_array_info_t ainf
;
103 struct dev_policy
*policy
= NULL
;
104 struct map_ent target_array
;
107 struct createinfo
*ci
= conf_get_create_info();
109 if (stat(devname
, &stb
) < 0) {
111 pr_err("stat failed for %s: %s.\n",
112 devname
, strerror(errno
));
115 if ((stb
.st_mode
& S_IFMT
) != S_IFBLK
) {
117 pr_err("%s is not a block device.\n",
121 dfd
= dev_open(devname
, O_RDONLY
);
124 pr_err("cannot open %s: %s.\n",
125 devname
, strerror(errno
));
128 /* If the device is a container, we do something very different */
129 if (must_be_container(dfd
)) {
131 st
= super_by_fd(dfd
, NULL
);
133 st
->ignore_hw_compat
= 1;
134 if (st
&& st
->ss
->load_container
)
135 rv
= st
->ss
->load_container(st
, dfd
, NULL
);
138 if (!rv
&& st
->ss
->container_content
) {
140 pr_err("failed to get "
141 "exclusive lock on mapfile\n");
143 printf("MD_DEVNAME=%s\n", devname
);
144 rv
= Incremental_container(st
, devname
, c
, NULL
);
149 pr_err("%s is not part of an md array.\n",
154 /* 1/ Check if device is permitted by mdadm.conf */
156 if (!conf_test_dev(devname
)) {
158 pr_err("%s not permitted by mdadm.conf.\n",
163 /* 2/ Find metadata, reject if none appropriate (check
164 * version/name from args) */
166 if (fstat(dfd
, &stb
) < 0) {
168 pr_err("fstat failed for %s: %s.\n",
169 devname
, strerror(errno
));
172 if ((stb
.st_mode
& S_IFMT
) != S_IFBLK
) {
174 pr_err("%s is not a block device.\n",
179 dinfo
.disk
.major
= major(stb
.st_rdev
);
180 dinfo
.disk
.minor
= minor(stb
.st_rdev
);
182 policy
= disk_policy(&dinfo
);
183 have_target
= policy_check_path(&dinfo
, &target_array
);
185 if (st
== NULL
&& (st
= guess_super(dfd
)) == NULL
) {
187 pr_err("no recognisable superblock on %s.\n",
189 rv
= try_spare(devname
, &dfd
, policy
,
190 have_target
? &target_array
: NULL
,
194 st
->ignore_hw_compat
= 1;
195 if (st
->ss
->compare_super
== NULL
||
196 st
->ss
->load_super(st
, dfd
, NULL
)) {
198 pr_err("no RAID superblock on %s.\n",
200 rv
= try_spare(devname
, &dfd
, policy
,
201 have_target
? &target_array
: NULL
,
206 close (dfd
); dfd
= -1;
208 st
->ss
->getinfo_super(st
, &info
, NULL
);
210 /* 3/ Check if there is a match in mdadm.conf */
211 match
= conf_match(st
, &info
, devname
, c
->verbose
, &rv
);
212 if (!match
&& rv
== 2)
215 if (match
&& match
->devname
216 && strcasecmp(match
->devname
, "<ignore>") == 0) {
218 pr_err("array containing %s is explicitly"
219 " ignored by mdadm.conf\n",
224 /* 3a/ if not, check for homehost match. If no match, continue
225 * but don't trust the 'name' in the array. Thus a 'random' minor
226 * number will be assigned, and the device name will be based
230 else if (st
->ss
->match_home(st
, c
->homehost
) == 1)
232 else if (st
->ss
->match_home(st
, "any") == 1)
233 trustworthy
= LOCAL_ANY
;
235 trustworthy
= FOREIGN
;
237 if (!match
&& !conf_test_metadata(st
->ss
->name
, policy
,
238 (trustworthy
== LOCAL
))) {
240 pr_err("%s has metadata type %s for which "
241 "auto-assembly is disabled\n",
242 devname
, st
->ss
->name
);
245 if (trustworthy
== LOCAL_ANY
)
248 /* There are three possible sources for 'autof': command line,
249 * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
250 * ARRAY takes precedence, then command line, then
253 if (match
&& match
->autof
)
254 c
->autof
= match
->autof
;
256 c
->autof
= ci
->autof
;
258 name_to_use
= info
.name
;
259 if (name_to_use
[0] == 0 &&
260 info
.array
.level
== LEVEL_CONTAINER
) {
261 name_to_use
= info
.text_version
;
262 trustworthy
= METADATA
;
264 if (name_to_use
[0] && trustworthy
!= LOCAL
&&
265 ! c
->require_homehost
&&
266 conf_name_is_free(name_to_use
))
269 /* strip "hostname:" prefix from name if we have decided
270 * to treat it as LOCAL
272 if (trustworthy
== LOCAL
&& strchr(name_to_use
, ':') != NULL
)
273 name_to_use
= strchr(name_to_use
, ':')+1;
275 /* 4/ Check if array exists.
278 pr_err("failed to get exclusive lock on "
280 /* Now check we can get O_EXCL. If not, probably "mdadm -A" has
283 dfd
= dev_open(devname
, O_RDONLY
|O_EXCL
);
286 pr_err("cannot reopen %s: %s.\n",
287 devname
, strerror(errno
));
290 /* Cannot hold it open while we add the device to the array,
291 * so we must release the O_EXCL and depend on the map_lock()
292 * So now is the best time to remove any partitions.
294 remove_partitions(dfd
);
298 mp
= map_by_uuid(&map
, info
.uuid
);
300 mdfd
= open_dev(mp
->devnm
);
306 /* Couldn't find an existing array, maybe make a new one */
307 mdfd
= create_mddev(match
? match
->devname
: NULL
,
308 name_to_use
, c
->autof
, trustworthy
, chosen_name
);
313 sysfs_init(&info
, mdfd
, NULL
);
315 if (set_array_info(mdfd
, st
, &info
) != 0) {
316 pr_err("failed to set array info for %s: %s\n",
317 chosen_name
, strerror(errno
));
323 dinfo
.disk
.major
= major(stb
.st_rdev
);
324 dinfo
.disk
.minor
= minor(stb
.st_rdev
);
325 if (add_disk(mdfd
, st
, &info
, &dinfo
) != 0) {
326 pr_err("failed to add %s to new array %s: %s.\n",
327 devname
, chosen_name
, strerror(errno
));
328 ioctl(mdfd
, STOP_ARRAY
, 0);
332 sra
= sysfs_read(mdfd
, NULL
, (GET_DEVS
| GET_STATE
|
333 GET_OFFSET
| GET_SIZE
));
335 if (!sra
|| !sra
->devs
|| sra
->devs
->disk
.raid_disk
>= 0) {
336 /* It really should be 'none' - must be old buggy
337 * kernel, and mdadm -I may not be able to complete.
340 ioctl(mdfd
, STOP_ARRAY
, NULL
);
341 pr_err("You have an old buggy kernel which cannot support\n"
342 " --incremental reliably. Aborting.\n");
346 info
.array
.working_disks
= 1;
347 /* 6/ Make sure /var/run/mdadm.map contains this array. */
348 map_update(&map
, fd2devnm(mdfd
),
350 info
.uuid
, chosen_name
);
353 /* - check one drive in array to make sure metadata is a reasonably */
354 /* close match. Reject if not (e.g. different type) */
355 /* - add the device */
359 struct supertype
*st2
;
360 struct mdinfo info2
, *d
;
362 sra
= sysfs_read(mdfd
, NULL
, (GET_DEVS
| GET_STATE
|
363 GET_OFFSET
| GET_SIZE
));
366 strcpy(chosen_name
, mp
->path
);
368 strcpy(chosen_name
, mp
->devnm
);
370 /* It is generally not OK to add non-spare drives to a
371 * running array as they are probably missing because
372 * they failed. However if runstop is 1, then the
373 * array was possibly started early and our best bet is
374 * to add this anyway.
375 * Also if action policy is re-add or better we allow
377 * This doesn't apply to containers as the 'non-spare'
378 * flag has a different meaning. The test has to happen
379 * at the device level there
381 if (!st
->ss
->external
382 && (info
.disk
.state
& (1<<MD_DISK_SYNC
)) != 0
383 && ! policy_action_allows(policy
, st
->ss
->name
,
386 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ainf
) == 0) {
387 pr_err("not adding %s to active array (without --run) %s\n",
388 devname
, chosen_name
);
398 sprintf(dn
, "%d:%d", sra
->devs
->disk
.major
,
399 sra
->devs
->disk
.minor
);
400 dfd2
= dev_open(dn
, O_RDONLY
);
402 pr_err("unable to open %s\n", devname
);
407 if (st2
->ss
->load_super(st2
, dfd2
, NULL
) ||
408 st
->ss
->compare_super(st
, st2
) != 0) {
409 pr_err("metadata mismatch between %s and "
411 devname
, chosen_name
);
417 st2
->ss
->getinfo_super(st2
, &info2
, NULL
);
418 st2
->ss
->free_super(st2
);
419 if (info
.array
.level
!= info2
.array
.level
||
420 memcmp(info
.uuid
, info2
.uuid
, 16) != 0 ||
421 info
.array
.raid_disks
!= info2
.array
.raid_disks
) {
422 pr_err("unexpected difference between %s and %s.\n",
423 chosen_name
, devname
);
428 info
.disk
.major
= major(stb
.st_rdev
);
429 info
.disk
.minor
= minor(stb
.st_rdev
);
430 /* add disk needs to know about containers */
431 if (st
->ss
->external
)
432 sra
->array
.level
= LEVEL_CONTAINER
;
433 err
= add_disk(mdfd
, st
, sra
, &info
);
434 if (err
< 0 && errno
== EBUSY
) {
435 /* could be another device present with the same
436 * disk.number. Find and reject any such
438 find_reject(mdfd
, st
, sra
, info
.disk
.number
,
439 info
.events
, c
->verbose
, chosen_name
);
440 err
= add_disk(mdfd
, st
, sra
, &info
);
442 if (err
< 0 && errno
== EINVAL
&&
443 info
.disk
.state
& (1<<MD_DISK_SYNC
)) {
444 /* Maybe it needs to be added as a spare */
445 if (policy_action_allows(policy
, st
->ss
->name
,
447 info
.disk
.state
&= ~(1<<MD_DISK_SYNC
);
448 err
= add_disk(mdfd
, st
, sra
, &info
);
451 pr_err("can only add %s to %s as a spare, and force-spare is not set.\n",
452 devname
, chosen_name
);
455 pr_err("failed to add %s to existing array %s: %s.\n",
456 devname
, chosen_name
, strerror(errno
));
460 info
.array
.working_disks
= 0;
461 for (d
= sra
->devs
; d
; d
=d
->next
)
462 info
.array
.working_disks
++;
465 if (strncmp(chosen_name
, "/dev/md/", 8) == 0)
466 md_devname
= chosen_name
+8;
468 md_devname
= chosen_name
;
470 printf("MD_DEVICE=%s\n", fd2devnm(mdfd
));
471 printf("MD_DEVNAME=%s\n", md_devname
);
472 printf("MD_FOREIGN=%s\n", trustworthy
== FOREIGN
? "yes" : "no");
475 /* 7/ Is there enough devices to possibly start the array? */
476 /* 7a/ if not, finish with success. */
477 if (info
.array
.level
== LEVEL_CONTAINER
) {
479 /* Try to assemble within the container */
480 sysfs_uevent(sra
, "change");
481 if (!c
->export
&& c
->verbose
>= 0)
482 pr_err("container %s now has %d device%s\n",
483 chosen_name
, info
.array
.working_disks
,
484 info
.array
.working_disks
== 1?"":"s");
485 wait_for(chosen_name
, mdfd
);
486 if (st
->ss
->external
)
487 strcpy(devnm
, fd2devnm(mdfd
));
488 if (st
->ss
->load_container
)
489 rv
= st
->ss
->load_container(st
, mdfd
, NULL
);
493 rv
= Incremental_container(st
, chosen_name
, c
, NULL
);
495 /* after spare is added, ping monitor for external metadata
496 * so that it can eg. try to rebuild degraded array */
497 if (st
->ss
->external
)
502 /* We have added something to the array, so need to re-read the
503 * state. Eventually this state should be kept up-to-date as
507 sra
= sysfs_read(mdfd
, NULL
, (GET_DEVS
| GET_STATE
|
508 GET_OFFSET
| GET_SIZE
));
509 active_disks
= count_active(st
, sra
, mdfd
, &avail
, &info
);
510 if (enough(info
.array
.level
, info
.array
.raid_disks
,
511 info
.array
.layout
, info
.array
.state
& 1,
514 printf("MD_STARTED=no\n");
515 } else if (c
->verbose
>= 0)
516 pr_err("%s attached to %s, not enough to start (%d).\n",
517 devname
, chosen_name
, active_disks
);
523 /* - if number of OK devices match expected, or -R and there */
525 /* + add any bitmap file */
526 /* + start the array (auto-readonly). */
528 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ainf
) == 0) {
530 printf("MD_STARTED=already\n");
531 } else if (c
->verbose
>= 0)
532 pr_err("%s attached to %s which is already active.\n",
533 devname
, chosen_name
);
539 if (c
->runstop
> 0 || active_disks
>= info
.array
.working_disks
) {
541 /* Let's try to start it */
543 if (info
.reshape_active
&& !(info
.reshape_active
& RESHAPE_NO_BACKUP
)) {
544 pr_err("%s: This array is being reshaped and cannot be started\n",
546 cont_err("by --incremental. Please use --assemble\n");
549 if (match
&& match
->bitmap_file
) {
550 int bmfd
= open(match
->bitmap_file
, O_RDWR
);
552 pr_err("Could not open bitmap file %s.\n",
556 if (ioctl(mdfd
, SET_BITMAP_FILE
, bmfd
) != 0) {
558 pr_err("Failed to set bitmapfile for %s.\n",
564 /* Need to remove from the array any devices which
565 * 'count_active' discerned were too old or inappropriate
567 for (d
= sra
? sra
->devs
: NULL
; d
; d
= d
->next
)
568 if (d
->disk
.state
& (1<<MD_DISK_REMOVED
))
569 remove_disk(mdfd
, st
, sra
, d
);
571 if ((sra
== NULL
|| active_disks
>= info
.array
.working_disks
)
572 && trustworthy
!= FOREIGN
)
573 rv
= ioctl(mdfd
, RUN_ARRAY
, NULL
);
575 rv
= sysfs_set_str(sra
, NULL
,
576 "array_state", "read-auto");
579 printf("MD_STARTED=yes\n");
580 } else if (c
->verbose
>= 0)
581 pr_err("%s attached to %s, which has been started.\n",
582 devname
, chosen_name
);
584 wait_for(chosen_name
, mdfd
);
585 /* We just started the array, so some devices
586 * might have been evicted from the array
587 * because their event counts were too old.
588 * If the action=re-add policy is in-force for
589 * those devices we should re-add them now.
591 for (dsk
= sra
->devs
; dsk
; dsk
= dsk
->next
) {
592 if (disk_action_allows(dsk
, st
->ss
->name
, act_re_add
) &&
593 add_disk(mdfd
, st
, sra
, dsk
) == 0)
594 pr_err("%s re-added to %s\n",
595 dsk
->sys_name
, chosen_name
);
598 pr_err("%s attached to %s, but failed to start: %s.\n",
599 devname
, chosen_name
, strerror(errno
));
604 printf("MD_STARTED=unsafe\n");
605 } else if (c
->verbose
>= 0)
606 pr_err("%s attached to %s, not enough to start safely.\n",
607 devname
, chosen_name
);
617 dev_policy_free(policy
);
626 static void find_reject(int mdfd
, struct supertype
*st
, struct mdinfo
*sra
,
627 int number
, __u64 events
, int verbose
,
630 /* Find a device attached to this array with a disk.number of number
631 * and events less than the passed events, and remove the device.
636 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ra
) == 0)
637 return; /* not safe to remove from active arrays
638 * without thinking more */
640 for (d
= sra
->devs
; d
; d
= d
->next
) {
644 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
645 dfd
= dev_open(dn
, O_RDONLY
);
648 if (st
->ss
->load_super(st
, dfd
, NULL
)) {
652 st
->ss
->getinfo_super(st
, &info
, NULL
);
653 st
->ss
->free_super(st
);
656 if (info
.disk
.number
!= number
||
657 info
.events
>= events
)
660 if (d
->disk
.raid_disk
> -1)
661 sysfs_set_str(sra
, d
, "slot", "none");
662 if (sysfs_set_str(sra
, d
, "state", "remove") == 0)
664 pr_err("removing old device %s from %s\n",
665 d
->sys_name
+4, array_name
);
669 static int count_active(struct supertype
*st
, struct mdinfo
*sra
,
670 int mdfd
, char **availp
,
671 struct mdinfo
*bestinfo
)
673 /* count how many devices in sra think they are active */
677 __u64 max_events
= 0;
689 for (d
= sra
->devs
; d
; d
= d
->next
)
691 for (d
= sra
->devs
, devnum
= 0 ; d
; d
= d
->next
, devnum
++) {
697 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
698 dfd
= dev_open(dn
, O_RDONLY
);
701 ok
= st
->ss
->load_super(st
, dfd
, NULL
);
705 info
.array
.raid_disks
= raid_disks
;
706 st
->ss
->getinfo_super(st
, &info
, devmap
+ raid_disks
* devnum
);
708 raid_disks
= info
.array
.raid_disks
;
709 avail
= xcalloc(raid_disks
, 1);
712 best
= xcalloc(raid_disks
, sizeof(int));
713 devmap
= xcalloc(raid_disks
, numdevs
);
715 st
->ss
->getinfo_super(st
, &info
, devmap
);
718 if (info
.disk
.state
& (1<<MD_DISK_SYNC
))
722 max_events
= info
.events
;
723 avail
[info
.disk
.raid_disk
] = 2;
724 best
[info
.disk
.raid_disk
] = devnum
;
725 st
->ss
->getinfo_super(st
, bestinfo
, NULL
);
726 } else if (info
.events
== max_events
) {
727 avail
[info
.disk
.raid_disk
] = 2;
728 best
[info
.disk
.raid_disk
] = devnum
;
729 } else if (info
.events
== max_events
-1) {
730 if (avail
[info
.disk
.raid_disk
] == 0) {
731 avail
[info
.disk
.raid_disk
] = 1;
732 best
[info
.disk
.raid_disk
] = devnum
;
734 } else if (info
.events
< max_events
- 1)
736 else if (info
.events
== max_events
+1) {
738 max_events
= info
.events
;
739 for (i
= 0; i
< raid_disks
; i
++)
742 avail
[info
.disk
.raid_disk
] = 2;
743 best
[info
.disk
.raid_disk
] = devnum
;
744 st
->ss
->getinfo_super(st
, bestinfo
, NULL
);
745 } else { /* info.events much bigger */
746 memset(avail
, 0, raid_disks
);
747 max_events
= info
.events
;
748 avail
[info
.disk
.raid_disk
] = 2;
749 best
[info
.disk
.raid_disk
] = devnum
;
750 st
->ss
->getinfo_super(st
, bestinfo
, NULL
);
752 } else if (info
.disk
.state
& (1<<MD_DISK_REPLACEMENT
))
754 st
->ss
->free_super(st
);
758 /* We need to reject any device that thinks the best device is
759 * failed or missing */
760 for (b
= 0; b
< raid_disks
; b
++)
764 for (i
= 0 ; i
< raid_disks
; i
++) {
765 if (i
!= b
&& avail
[i
])
766 if (devmap
[raid_disks
* best
[i
] + b
] == 0) {
767 /* This device thinks 'b' is failed -
770 for (d
=sra
->devs
; devnum
; d
= d
->next
)
772 d
->disk
.state
|= (1 << MD_DISK_REMOVED
);
778 /* Also need to reject any spare device with an event count that
781 for (d
= sra
->devs
; d
; d
= d
->next
) {
782 if (!(d
->disk
.state
& (1<<MD_DISK_SYNC
)) &&
783 d
->events
> max_events
)
784 d
->disk
.state
|= (1 << MD_DISK_REMOVED
);
788 return cnt
+ replcnt
;
791 /* test if container has degraded member(s) */
792 static int container_members_max_degradation(struct map_ent
*map
, struct map_ent
*me
)
794 mdu_array_info_t array
;
796 int max_degraded
= 0;
798 for(; map
; map
= map
->next
) {
799 if (!metadata_container_matches(map
->metadata
, me
->devnm
))
801 afd
= open_dev(map
->devnm
);
804 /* most accurate information regarding array degradation */
805 if (ioctl(afd
, GET_ARRAY_INFO
, &array
) >= 0) {
806 int degraded
= array
.raid_disks
- array
.active_disks
-
808 if (degraded
> max_degraded
)
809 max_degraded
= degraded
;
813 return (max_degraded
);
816 static int array_try_spare(char *devname
, int *dfdp
, struct dev_policy
*pol
,
817 struct map_ent
*target
, int bare
,
818 struct supertype
*st
, int verbose
)
820 /* This device doesn't have any md metadata
821 * The device policy allows 'spare' and if !bare, it allows spare-same-slot.
822 * If 'st' is not set, then we only know that some metadata allows this,
823 * others possibly don't.
824 * So look for a container or array to attach the device to.
825 * Prefer 'target' if that is set and the array is found.
827 * If st is set, then only arrays of that type are considered
828 * Return 0 on success, or some exit code on failure, probably 1.
832 struct map_ent
*mp
, *map
= NULL
;
833 struct mdinfo
*chosen
= NULL
;
836 if (fstat(dfd
, &stb
) != 0)
840 * Now we need to find a suitable array to add this to.
841 * We only accept arrays that:
843 * - are in the same domains as the device
844 * - are of an size for which the device will be useful
845 * and we choose the one that is the most degraded
848 if (map_lock(&map
)) {
849 pr_err("failed to get exclusive lock on "
853 for (mp
= map
; mp
; mp
= mp
->next
) {
854 struct supertype
*st2
;
855 struct domainlist
*dl
= NULL
;
857 unsigned long long devsize
;
858 unsigned long long component_size
= 0;
860 if (is_subarray(mp
->metadata
))
863 st2
= st
->ss
->match_metadata_desc(mp
->metadata
);
865 (st
->minor_version
>= 0 &&
866 st
->minor_version
!= st2
->minor_version
)) {
868 pr_err("not adding %s to %s as metadata type doesn't match\n",
875 sra
= sysfs_read(-1, mp
->devnm
,
876 GET_DEVS
|GET_OFFSET
|GET_SIZE
|GET_STATE
|
877 GET_DEGRADED
|GET_COMPONENT
|GET_VERSION
);
879 /* Probably a container - no degraded info */
880 sra
= sysfs_read(-1, mp
->devnm
,
881 GET_DEVS
|GET_OFFSET
|GET_SIZE
|GET_STATE
|
882 GET_COMPONENT
|GET_VERSION
);
884 sra
->array
.failed_disks
= -1;
891 for(i
= 0; !st2
&& superlist
[i
]; i
++)
892 st2
= superlist
[i
]->match_metadata_desc(
896 pr_err("not adding %s to %s"
897 " as metadata not recognised.\n",
901 /* Need to double check the 'act_spare' permissions applies
904 if (!policy_action_allows(pol
, st2
->ss
->name
, act_spare
))
906 if (!bare
&& !policy_action_allows(pol
, st2
->ss
->name
,
907 act_spare_same_slot
))
911 /* update number of failed disks for mostly degraded
912 * container member */
913 if (sra
->array
.failed_disks
== -1)
914 sra
->array
.failed_disks
= container_members_max_degradation(map
, mp
);
916 get_dev_size(dfd
, NULL
, &devsize
);
917 if (sra
->component_size
== 0) {
918 /* true for containers, here we must read superblock
919 * to obtain minimum spare size */
920 struct supertype
*st3
= dup_super(st2
);
921 int mdfd
= open_dev(mp
->devnm
);
926 if (st3
->ss
->load_container
&&
927 !st3
->ss
->load_container(st3
, mdfd
, mp
->path
)) {
928 component_size
= st3
->ss
->min_acceptable_spare_size(st3
);
929 st3
->ss
->free_super(st3
);
934 if ((sra
->component_size
> 0 &&
935 st2
->ss
->avail_size(st2
, devsize
,
937 ? sra
->devs
->data_offset
939 < sra
->component_size
)
941 (sra
->component_size
== 0 && devsize
< component_size
)) {
943 pr_err("not adding %s to %s as it is too small\n",
947 /* test against target.
948 * If 'target' is set and 'bare' is false, we only accept
949 * arrays/containers that match 'target'.
950 * If 'target' is set and 'bare' is true, we prefer the
951 * array which matches 'target'.
952 * target is considered only if we deal with degraded array
954 if (target
&& policy_action_allows(pol
, st2
->ss
->name
,
955 act_spare_same_slot
)) {
956 if (strcmp(target
->metadata
, mp
->metadata
) == 0 &&
957 memcmp(target
->uuid
, mp
->uuid
,
958 sizeof(target
->uuid
)) == 0 &&
959 sra
->array
.failed_disks
> 0) {
960 /* This is our target!! */
965 /* skip to end so we don't check any more */
975 dl
= domain_from_array(sra
, st2
->ss
->name
);
976 if (domain_test(dl
, pol
, st2
->ss
->name
) != 1) {
977 /* domain test fails */
979 pr_err("not adding %s to %s as"
980 " it is not in a compatible domain\n",
985 /* all tests passed, OK to add to this array */
989 } else if (chosen
->array
.failed_disks
< sra
->array
.failed_disks
) {
1003 /* add current device to chosen array as a spare */
1004 int mdfd
= open_dev(chosen
->sys_name
);
1006 struct mddev_dev devlist
;
1008 devlist
.next
= NULL
;
1010 devlist
.writemostly
= 0;
1011 devlist
.devname
= devname
;
1012 sprintf(devname
, "%d:%d", major(stb
.st_rdev
),
1013 minor(stb
.st_rdev
));
1014 devlist
.disposition
= 'a';
1017 rv
= Manage_subdevs(chosen
->sys_name
, mdfd
, &devlist
,
1023 pr_err("added %s as spare for %s\n",
1024 devname
, chosen
->sys_name
);
1026 pr_err("failed to add %s as spare for %s\n",
1027 devname
, chosen
->sys_name
);
1035 static int partition_try_spare(char *devname
, int *dfdp
, struct dev_policy
*pol
,
1036 struct supertype
*st
, int verbose
)
1038 /* we know that at least one partition virtual-metadata is
1039 * allowed to incorporate spares like this device. We need to
1040 * find a suitable device to copy partition information from.
1042 * Getting a list of all disk (not partition) devices is
1043 * slightly non-trivial. We could look at /sys/block, but
1044 * that is theoretically due to be removed. Maybe best to use
1045 * /dev/disk/by-path/?* and ignore names ending '-partNN' as
1046 * we depend on this directory of 'path' info. But that fails
1047 * to find loop devices and probably others. Maybe don't
1048 * worry about that, they aren't the real target.
1050 * So: check things in /dev/disk/by-path to see if they are in
1051 * a compatible domain, then load the partition table and see
1052 * if it is OK for the new device, and choose the largest
1053 * partition table that fits.
1057 char *chosen
= NULL
;
1058 unsigned long long chosen_size
= 0;
1059 struct supertype
*chosen_st
= NULL
;
1062 dir
= opendir("/dev/disk/by-path");
1065 while ((de
= readdir(dir
)) != NULL
) {
1067 struct dev_policy
*pol2
= NULL
;
1068 struct domainlist
*domlist
= NULL
;
1071 struct supertype
*st2
= NULL
;
1072 char *devname
= NULL
;
1073 unsigned long long devsectors
;
1075 if (de
->d_ino
== 0 ||
1076 de
->d_name
[0] == '.' ||
1077 (de
->d_type
!= DT_LNK
&& de
->d_type
!= DT_UNKNOWN
))
1080 ep
= de
->d_name
+ strlen(de
->d_name
);
1081 while (ep
> de
->d_name
&&
1084 if (ep
> de
->d_name
+ 5 &&
1085 strncmp(ep
-5, "-part", 5) == 0)
1086 /* This is a partition - skip it */
1089 pol2
= path_policy(de
->d_name
, type_disk
);
1091 domain_merge(&domlist
, pol2
, st
? st
->ss
->name
: NULL
);
1092 if (domain_test(domlist
, pol
, st
? st
->ss
->name
: NULL
) != 1)
1093 /* new device is incompatible with this device. */
1096 domain_free(domlist
);
1099 if (asprintf(&devname
, "/dev/disk/by-path/%s", de
->d_name
) != 1) {
1103 fd
= open(devname
, O_RDONLY
);
1106 if (get_dev_size(fd
, devname
, &devsectors
) == 0)
1111 st2
= dup_super(st
);
1113 st2
= guess_super_type(fd
, guess_partitions
);
1115 st2
->ss
->load_super(st2
, fd
, NULL
) < 0)
1119 /* Check domain policy again, this time referring to metadata */
1120 domain_merge(&domlist
, pol2
, st2
->ss
->name
);
1121 if (domain_test(domlist
, pol
, st2
->ss
->name
) != 1)
1122 /* Incompatible devices for this metadata type */
1124 if (!policy_action_allows(pol
, st2
->ss
->name
, act_spare
))
1125 /* Some partition types allow sparing, but not
1131 st2
->ss
->getinfo_super(st2
, &info
, NULL
);
1132 if (info
.component_size
> devsectors
)
1133 /* This partitioning doesn't fit in the device */
1136 /* This is an acceptable device to copy partition
1137 * metadata from. We could just stop here, but I
1138 * think I want to keep looking incase a larger
1139 * metadata which makes better use of the device can
1142 if (chosen
== NULL
||
1143 chosen_size
< info
.component_size
) {
1144 chosen_size
= info
.component_size
;
1149 chosen_st
->ss
->free_super(chosen_st
);
1158 domain_free(domlist
);
1159 dev_policy_free(pol2
);
1161 st2
->ss
->free_super(st2
);
1173 /* 'chosen' is the best device we can find. Let's write its
1174 * metadata to devname dfd is read-only so don't use that
1176 fd
= open(devname
, O_RDWR
);
1178 chosen_st
->ss
->store_super(chosen_st
, fd
);
1182 chosen_st
->ss
->free_super(chosen_st
);
1187 static int is_bare(int dfd
)
1189 unsigned long long size
= 0;
1190 char bufpad
[4096 + 4096];
1191 char *buf
= (char*)(((long)bufpad
+ 4096) & ~4095);
1193 if (lseek(dfd
, 0, SEEK_SET
) != 0 ||
1194 read(dfd
, buf
, 4096) != 4096)
1197 if (buf
[0] != '\0' && buf
[0] != '\x5a' && buf
[0] != '\xff')
1199 if (memcmp(buf
, buf
+1, 4095) != 0)
1202 /* OK, first 4K appear blank, try the end. */
1203 get_dev_size(dfd
, NULL
, &size
);
1204 if (lseek(dfd
, size
-4096, SEEK_SET
) < 0 ||
1205 read(dfd
, buf
, 4096) != 4096)
1208 if (buf
[0] != '\0' && buf
[0] != '\x5a' && buf
[0] != '\xff')
1210 if (memcmp(buf
, buf
+1, 4095) != 0)
1216 /* adding a spare to a regular array is quite different from adding one to
1217 * a set-of-partitions virtual array.
1218 * This function determines which is worth trying and tries as appropriate.
1219 * Arrays are given priority over partitions.
1221 static int try_spare(char *devname
, int *dfdp
, struct dev_policy
*pol
,
1222 struct map_ent
*target
,
1223 struct supertype
*st
, int verbose
)
1228 int partitions_ok
= 0;
1232 /* Can only add a spare if device has at least one domain */
1233 if (pol_find(pol
, pol_domain
) == NULL
)
1235 /* And only if some action allows spares */
1236 if (!policy_action_allows(pol
, st
?st
->ss
->name
:NULL
, act_spare
))
1239 /* Now check if the device is bare.
1240 * bare devices can always be added as a spare
1241 * non-bare devices can only be added if spare-same-slot is permitted,
1242 * and this device is replacing a previous device - in which case 'target'
1245 if (!is_bare(dfd
)) {
1246 /* Must have a target and allow same_slot */
1247 /* Later - may allow force_spare without target */
1249 !policy_action_allows(pol
, st
?st
->ss
->name
:NULL
,
1250 act_spare_same_slot
)) {
1252 pr_err("%s is not bare, so not "
1253 "considering as a spare\n",
1261 /* It might be OK to add this device to an array - need to see
1262 * what arrays might be candidates.
1265 /* just try try 'array' or 'partition' based on this metadata */
1266 if (st
->ss
->add_to_super
)
1267 return array_try_spare(devname
, dfdp
, pol
, target
, bare
,
1270 return partition_try_spare(devname
, dfdp
, pol
,
1273 /* No metadata was specified or found so options are open.
1274 * Check for whether any array metadata, or any partition metadata
1275 * might allow adding the spare. This check is just help to avoid
1276 * a more costly scan of all arrays when we can be sure that will
1279 for (i
= 0; (!arrays_ok
|| !partitions_ok
) && superlist
[i
] ; i
++) {
1280 if (superlist
[i
]->add_to_super
&& !arrays_ok
&&
1281 policy_action_allows(pol
, superlist
[i
]->name
, act_spare
))
1283 if (superlist
[i
]->add_to_super
== NULL
&& !partitions_ok
&&
1284 policy_action_allows(pol
, superlist
[i
]->name
, act_spare
))
1289 rv
= array_try_spare(devname
, dfdp
, pol
, target
, bare
,
1291 if (rv
!= 0 && partitions_ok
)
1292 rv
= partition_try_spare(devname
, dfdp
, pol
, st
, verbose
);
1296 int IncrementalScan(struct context
*c
, char *devnm
)
1298 /* look at every device listed in the 'map' file.
1299 * If one is found that is not running then:
1300 * look in mdadm.conf for bitmap file.
1301 * if one exists, but array has none, add it.
1302 * try to start array in auto-readonly mode
1304 struct map_ent
*mapl
= NULL
;
1306 struct mddev_ident
*devs
, *mddev
;
1312 devs
= conf_get_ident(NULL
);
1315 for (me
= mapl
; me
; me
= me
->next
) {
1316 mdu_array_info_t array
;
1317 mdu_bitmap_file_t bmf
;
1321 if (devnm
&& strcmp(devnm
, me
->devnm
) != 0)
1323 if (devnm
&& me
->metadata
[0] == '/') {
1325 /* member array, need to work on container */
1326 strncpy(container
, me
->metadata
+1, 32);
1328 sl
= strchr(container
, '/');
1335 mdfd
= open_dev(me
->devnm
);
1339 if (!isdigit(me
->metadata
[0])) {
1340 /* must be a container */
1341 struct supertype
*st
= super_by_fd(mdfd
, NULL
);
1343 struct map_ent
*map
= NULL
;
1345 st
->ignore_hw_compat
= 1;
1346 if (st
&& st
->ss
->load_container
)
1347 ret
= st
->ss
->load_container(st
, mdfd
, NULL
);
1349 if (!ret
&& st
->ss
->container_content
) {
1351 pr_err("failed to get exclusive lock on mapfile\n");
1352 ret
= Incremental_container(st
, me
->path
, c
, only
);
1359 if (ioctl(mdfd
, GET_ARRAY_INFO
, &array
) == 0 ||
1364 /* Ok, we can try this one. Maybe it needs a bitmap */
1365 for (mddev
= devs
; mddev
; mddev
= mddev
->next
)
1366 if (mddev
->devname
&& me
->path
1367 && devname_matches(mddev
->devname
, me
->path
))
1369 if (mddev
&& mddev
->bitmap_file
) {
1371 * Note: early kernels will wrongly fail this, so it
1375 if (ioctl(mdfd
, GET_ARRAY_INFO
, &bmf
) < 0) {
1376 int bmfd
= open(mddev
->bitmap_file
, O_RDWR
);
1378 added
= ioctl(mdfd
, SET_BITMAP_FILE
,
1383 if (c
->verbose
>= 0) {
1385 pr_err("Added bitmap %s to %s\n",
1386 mddev
->bitmap_file
, me
->path
);
1387 else if (errno
!= EEXIST
)
1388 pr_err("Failed to add bitmap to %s: %s\n",
1389 me
->path
, strerror(errno
));
1392 /* FIXME check for reshape_active and consider not
1395 sra
= sysfs_read(mdfd
, NULL
, 0);
1397 if (sysfs_set_str(sra
, NULL
,
1398 "array_state", "read-auto") == 0) {
1399 if (c
->verbose
>= 0)
1400 pr_err("started array %s\n",
1401 me
->path
?: me
->devnm
);
1403 pr_err("failed to start array %s: %s\n",
1404 me
->path
?: me
->devnm
,
1414 static char *container2devname(char *devname
)
1416 char *mdname
= NULL
;
1418 if (devname
[0] == '/') {
1419 int fd
= open(devname
, O_RDONLY
);
1421 mdname
= xstrdup(fd2devnm(fd
));
1426 struct map_ent
*mp
, *map
= NULL
;
1428 if (!parse_uuid(devname
, uuid
))
1430 mp
= map_by_uuid(&map
, uuid
);
1432 mdname
= xstrdup(mp
->devnm
);
1439 static int Incremental_container(struct supertype
*st
, char *devname
,
1440 struct context
*c
, char *only
)
1442 /* Collect the contents of this container and for each
1443 * array, choose a device name and assemble the array.
1446 struct mdinfo
*list
;
1448 struct map_ent
*map
= NULL
;
1451 struct mddev_ident
*match
;
1453 struct domainlist
*domains
;
1454 struct map_ent
*smp
;
1461 st
->ss
->getinfo_super(st
, &info
, NULL
);
1463 if ((c
->runstop
> 0 && info
.container_enough
>= 0) ||
1464 info
.container_enough
> 0)
1468 printf("MD_STARTED=no\n");
1469 } else if (c
->verbose
)
1470 pr_err("not enough devices to start the container\n");
1474 match
= conf_match(st
, &info
, devname
, c
->verbose
, &rv
);
1475 if (match
== NULL
&& rv
== 2)
1478 /* Need to compute 'trustworthy' */
1480 trustworthy
= LOCAL
;
1481 else if (st
->ss
->match_home(st
, c
->homehost
) == 1)
1482 trustworthy
= LOCAL
;
1483 else if (st
->ss
->match_home(st
, "any") == 1)
1484 trustworthy
= LOCAL
;
1486 trustworthy
= FOREIGN
;
1488 list
= st
->ss
->container_content(st
, NULL
);
1489 /* when nothing to activate - quit */
1492 printf("MD_STARTED=nothing\n");
1496 for (ra
= list
; ra
; ra
= ra
->next
) {
1498 char chosen_name
[1024];
1500 struct mddev_ident
*match
= NULL
;
1503 /* do not activate arrays blocked by metadata handler */
1504 if (ra
->array
.state
& (1 << MD_SB_BLOCK_VOLUME
)) {
1505 pr_err("Cannot activate array %s in %s.\n",
1506 ra
->text_version
, devname
);
1510 mp
= map_by_uuid(&map
, ra
->uuid
);
1513 mdfd
= open_dev(mp
->devnm
);
1515 strcpy(chosen_name
, mp
->path
);
1517 strcpy(chosen_name
, mp
->devnm
);
1520 /* Check in mdadm.conf for container == devname and
1521 * member == ra->text_version after second slash.
1523 char *sub
= strchr(ra
->text_version
+1, '/');
1524 struct mddev_ident
*array_list
;
1527 array_list
= conf_get_ident(NULL
);
1530 for(; array_list
; array_list
= array_list
->next
) {
1532 if (array_list
->member
== NULL
||
1533 array_list
->container
== NULL
)
1535 if (strcmp(array_list
->member
, sub
) != 0)
1537 if (array_list
->uuid_set
&&
1538 !same_uuid(ra
->uuid
, array_list
->uuid
, st
->ss
->swapuuid
))
1540 dn
= container2devname(array_list
->container
);
1543 if (strncmp(dn
, ra
->text_version
+1,
1545 ra
->text_version
[strlen(dn
)+1] != '/') {
1550 /* we have a match */
1553 pr_err("match found for member %s\n",
1554 array_list
->member
);
1558 if (match
&& match
->devname
&&
1559 strcasecmp(match
->devname
, "<ignore>") == 0) {
1561 pr_err("array %s/%s is "
1562 "explicitly ignored by mdadm.conf\n",
1563 match
->container
, match
->member
);
1567 trustworthy
= LOCAL
;
1569 mdfd
= create_mddev(match
? match
->devname
: NULL
,
1575 if (only
&& (!mp
|| strcmp(mp
->devnm
, only
) != 0))
1579 pr_err("failed to open %s: %s.\n",
1580 chosen_name
, strerror(errno
));
1584 assemble_container_content(st
, mdfd
, ra
, c
,
1585 chosen_name
, &result
);
1588 if (c
->export
&& result
) {
1590 printf("MD_STARTED");
1591 if (result
& INCR_NO
) {
1592 printf("%cno", sep
);
1595 if (result
& INCR_UNSAFE
) {
1596 printf("%cunsafe", sep
);
1599 if (result
& INCR_ALREADY
) {
1600 printf("%calready", sep
);
1603 if (result
& INCR_YES
) {
1604 printf("%cyes", sep
);
1610 /* don't move spares to container with volume being activated
1611 when all volumes are blocked */
1612 if (ra_all
== ra_blocked
)
1615 /* Now move all suitable spares from spare container */
1616 domains
= domain_from_array(list
, st
->ss
->name
);
1617 memcpy(suuid
, uuid_zero
, sizeof(int[4]));
1619 (smp
= map_by_uuid(&map
, suuid
)) != NULL
&&
1620 (sfd
= open(smp
->path
, O_RDONLY
)) >= 0) {
1621 /* spare container found */
1622 struct supertype
*sst
=
1623 super_imsm
.match_metadata_desc("imsm");
1624 struct mdinfo
*sinfo
;
1625 unsigned long long min_size
= 0;
1626 if (st
->ss
->min_acceptable_spare_size
)
1627 min_size
= st
->ss
->min_acceptable_spare_size(st
);
1628 if (!sst
->ss
->load_container(sst
, sfd
, NULL
)) {
1630 sinfo
= container_choose_spares(sst
, min_size
,
1633 sst
->ss
->free_super(sst
);
1636 struct mdinfo
*disks
= sinfo
->devs
;
1638 /* move spare from spare
1639 * container to currently
1645 makedev(disks
->disk
.major
,
1646 disks
->disk
.minor
)))
1648 disks
= disks
->next
;
1651 pr_err("Added %d spare%s to %s\n",
1652 count
, count
>1?"s":"", devname
);
1658 domain_free(domains
);
1662 static void run_udisks(char *arg1
, char *arg2
)
1667 execl("/usr/bin/udisks", "udisks", arg1
, arg2
, NULL
);
1668 execl("/bin/udisks", "udisks", arg1
, arg2
, NULL
);
1671 while (pid
> 0 && wait(&status
) != pid
)
1676 * IncrementalRemove - Attempt to see if the passed in device belongs to any
1677 * raid arrays, and if so first fail (if needed) and then remove the device.
1679 * @devname - The device we want to remove
1680 * @id_path - name as found in /dev/disk/by-path for this device
1682 * Note: the device name must be a kernel name like "sda", so
1683 * that we can find it in /proc/mdstat
1685 int IncrementalRemove(char *devname
, char *id_path
, int verbose
)
1689 struct mdstat_ent
*ent
;
1690 struct mddev_dev devlist
;
1695 dprintf(Name
": incremental removal without --path <id_path> "
1696 "lacks the possibility to re-add new device in this "
1699 if (strchr(devname
, '/')) {
1700 pr_err("incremental removal requires a "
1701 "kernel device name, not a file: %s\n", devname
);
1704 ent
= mdstat_by_component(devname
);
1707 pr_err("%s does not appear to be a component "
1708 "of any array\n", devname
);
1711 sysfs_init(&mdi
, -1, ent
->devnm
);
1712 if (sysfs_get_str(&mdi
, NULL
, "array_state",
1713 buf
, sizeof(buf
)) > 0) {
1714 if (strncmp(buf
, "active", 6) == 0 ||
1715 strncmp(buf
, "clean", 5) == 0)
1716 sysfs_set_str(&mdi
, NULL
,
1717 "array_state", "read-auto");
1719 mdfd
= open_dev(ent
->devnm
);
1722 pr_err("Cannot open array %s!!\n", ent
->dev
);
1728 struct map_ent
*map
= NULL
, *me
;
1729 me
= map_by_devnm(&map
, ent
->devnm
);
1731 policy_save_path(id_path
, me
);
1735 memset(&devlist
, 0, sizeof(devlist
));
1736 devlist
.devname
= devname
;
1737 devlist
.disposition
= 'f';
1738 /* for a container, we must fail each member array */
1739 if (ent
->metadata_version
&&
1740 strncmp(ent
->metadata_version
, "external:", 9) == 0) {
1741 struct mdstat_ent
*mdstat
= mdstat_read(0, 0);
1742 struct mdstat_ent
*memb
;
1743 for (memb
= mdstat
; memb
; memb
= memb
->next
)
1744 if (is_container_member(memb
, ent
->dev
)) {
1745 int subfd
= open_dev(memb
->devnm
);
1747 rv
|= Manage_subdevs(
1749 &devlist
, verbose
, 0,
1754 free_mdstat(mdstat
);
1756 rv
|= Manage_subdevs(ent
->dev
, mdfd
, &devlist
,
1757 verbose
, 0, NULL
, 0);
1759 /* Failed due to EBUSY, try to stop the array.
1760 * Give udisks a chance to unmount it first.
1762 int devid
= devnm2devid(ent
->devnm
);
1763 run_udisks("--unmount", map_dev(major(devid
),minor(devid
), 0));
1764 rv
= Manage_stop(ent
->dev
, mdfd
, verbose
, 1);
1766 /* At least we can try to trigger a 'remove' */
1767 sysfs_uevent(&mdi
, "remove");
1770 pr_err("Fail to stop %s too.\n", ent
->devnm
);
1773 devlist
.disposition
= 'r';
1774 rv
= Manage_subdevs(ent
->dev
, mdfd
, &devlist
,
1775 verbose
, 0, NULL
, 0);