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(struct mddev_dev
*devlist
, 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
;
106 char *devname
= devlist
->devname
;
108 struct createinfo
*ci
= conf_get_create_info();
110 if (stat(devname
, &stb
) < 0) {
112 pr_err("stat failed for %s: %s.\n",
113 devname
, strerror(errno
));
116 if ((stb
.st_mode
& S_IFMT
) != S_IFBLK
) {
118 pr_err("%s is not a block device.\n",
122 dfd
= dev_open(devname
, O_RDONLY
);
125 pr_err("cannot open %s: %s.\n",
126 devname
, strerror(errno
));
129 /* If the device is a container, we do something very different */
130 if (must_be_container(dfd
)) {
132 st
= super_by_fd(dfd
, NULL
);
134 st
->ignore_hw_compat
= 1;
135 if (st
&& st
->ss
->load_container
)
136 rv
= st
->ss
->load_container(st
, dfd
, NULL
);
139 if (!rv
&& st
->ss
->container_content
) {
141 pr_err("failed to get "
142 "exclusive lock on mapfile\n");
144 printf("MD_DEVNAME=%s\n", devname
);
145 rv
= Incremental_container(st
, devname
, c
, NULL
);
150 pr_err("%s is not part of an md array.\n",
155 /* 1/ Check if device is permitted by mdadm.conf */
157 for (;devlist
; devlist
= devlist
->next
)
158 if (conf_test_dev(devlist
->devname
))
161 devlist
= conf_get_devs();
162 for (;devlist
; devlist
= devlist
->next
) {
164 if (stat(devlist
->devname
, &st2
) == 0 &&
165 (st2
.st_mode
& S_IFMT
) == S_IFBLK
&&
166 st2
.st_rdev
== stb
.st_rdev
)
172 pr_err("%s not permitted by mdadm.conf.\n",
177 /* 2/ Find metadata, reject if none appropriate (check
178 * version/name from args) */
180 if (fstat(dfd
, &stb
) < 0) {
182 pr_err("fstat failed for %s: %s.\n",
183 devname
, strerror(errno
));
186 if ((stb
.st_mode
& S_IFMT
) != S_IFBLK
) {
188 pr_err("%s is not a block device.\n",
193 dinfo
.disk
.major
= major(stb
.st_rdev
);
194 dinfo
.disk
.minor
= minor(stb
.st_rdev
);
196 policy
= disk_policy(&dinfo
);
197 have_target
= policy_check_path(&dinfo
, &target_array
);
199 if (st
== NULL
&& (st
= guess_super(dfd
)) == NULL
) {
201 pr_err("no recognisable superblock on %s.\n",
203 rv
= try_spare(devname
, &dfd
, policy
,
204 have_target
? &target_array
: NULL
,
208 st
->ignore_hw_compat
= 1;
209 if (st
->ss
->compare_super
== NULL
||
210 st
->ss
->load_super(st
, dfd
, NULL
)) {
212 pr_err("no RAID superblock on %s.\n",
214 rv
= try_spare(devname
, &dfd
, policy
,
215 have_target
? &target_array
: NULL
,
220 close (dfd
); dfd
= -1;
222 st
->ss
->getinfo_super(st
, &info
, NULL
);
224 /* 3/ Check if there is a match in mdadm.conf */
225 match
= conf_match(st
, &info
, devname
, c
->verbose
, &rv
);
226 if (!match
&& rv
== 2)
229 if (match
&& match
->devname
230 && strcasecmp(match
->devname
, "<ignore>") == 0) {
232 pr_err("array containing %s is explicitly"
233 " ignored by mdadm.conf\n",
238 /* 3a/ if not, check for homehost match. If no match, continue
239 * but don't trust the 'name' in the array. Thus a 'random' minor
240 * number will be assigned, and the device name will be based
244 else if (st
->ss
->match_home(st
, c
->homehost
) == 1)
246 else if (st
->ss
->match_home(st
, "any") == 1)
247 trustworthy
= LOCAL_ANY
;
249 trustworthy
= FOREIGN
;
251 if (!match
&& !conf_test_metadata(st
->ss
->name
, policy
,
252 (trustworthy
== LOCAL
))) {
254 pr_err("%s has metadata type %s for which "
255 "auto-assembly is disabled\n",
256 devname
, st
->ss
->name
);
259 if (trustworthy
== LOCAL_ANY
)
262 /* There are three possible sources for 'autof': command line,
263 * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
264 * ARRAY takes precedence, then command line, then
267 if (match
&& match
->autof
)
268 c
->autof
= match
->autof
;
270 c
->autof
= ci
->autof
;
272 name_to_use
= info
.name
;
273 if (name_to_use
[0] == 0 &&
274 info
.array
.level
== LEVEL_CONTAINER
) {
275 name_to_use
= info
.text_version
;
276 trustworthy
= METADATA
;
278 if (name_to_use
[0] && trustworthy
!= LOCAL
&&
279 ! c
->require_homehost
&&
280 conf_name_is_free(name_to_use
))
283 /* strip "hostname:" prefix from name if we have decided
284 * to treat it as LOCAL
286 if (trustworthy
== LOCAL
&& strchr(name_to_use
, ':') != NULL
)
287 name_to_use
= strchr(name_to_use
, ':')+1;
289 /* 4/ Check if array exists.
292 pr_err("failed to get exclusive lock on "
294 /* Now check we can get O_EXCL. If not, probably "mdadm -A" has
297 dfd
= dev_open(devname
, O_RDONLY
|O_EXCL
);
300 pr_err("cannot reopen %s: %s.\n",
301 devname
, strerror(errno
));
304 /* Cannot hold it open while we add the device to the array,
305 * so we must release the O_EXCL and depend on the map_lock()
306 * So now is the best time to remove any partitions.
308 remove_partitions(dfd
);
312 mp
= map_by_uuid(&map
, info
.uuid
);
314 mdfd
= open_dev(mp
->devnm
);
320 /* Couldn't find an existing array, maybe make a new one */
321 mdfd
= create_mddev(match
? match
->devname
: NULL
,
322 name_to_use
, c
->autof
, trustworthy
, chosen_name
);
327 sysfs_init(&info
, mdfd
, NULL
);
329 if (set_array_info(mdfd
, st
, &info
) != 0) {
330 pr_err("failed to set array info for %s: %s\n",
331 chosen_name
, strerror(errno
));
337 dinfo
.disk
.major
= major(stb
.st_rdev
);
338 dinfo
.disk
.minor
= minor(stb
.st_rdev
);
339 if (add_disk(mdfd
, st
, &info
, &dinfo
) != 0) {
340 pr_err("failed to add %s to new array %s: %s.\n",
341 devname
, chosen_name
, strerror(errno
));
342 ioctl(mdfd
, STOP_ARRAY
, 0);
346 sra
= sysfs_read(mdfd
, NULL
, (GET_DEVS
| GET_STATE
|
347 GET_OFFSET
| GET_SIZE
));
349 if (!sra
|| !sra
->devs
|| sra
->devs
->disk
.raid_disk
>= 0) {
350 /* It really should be 'none' - must be old buggy
351 * kernel, and mdadm -I may not be able to complete.
354 ioctl(mdfd
, STOP_ARRAY
, NULL
);
355 pr_err("You have an old buggy kernel which cannot support\n"
356 " --incremental reliably. Aborting.\n");
360 info
.array
.working_disks
= 1;
361 /* 6/ Make sure /var/run/mdadm.map contains this array. */
362 map_update(&map
, fd2devnm(mdfd
),
364 info
.uuid
, chosen_name
);
367 /* - check one drive in array to make sure metadata is a reasonably */
368 /* close match. Reject if not (e.g. different type) */
369 /* - add the device */
373 struct supertype
*st2
;
374 struct mdinfo info2
, *d
;
376 sra
= sysfs_read(mdfd
, NULL
, (GET_DEVS
| GET_STATE
|
377 GET_OFFSET
| GET_SIZE
));
380 strcpy(chosen_name
, mp
->path
);
382 strcpy(chosen_name
, mp
->devnm
);
384 /* It is generally not OK to add non-spare drives to a
385 * running array as they are probably missing because
386 * they failed. However if runstop is 1, then the
387 * array was possibly started early and our best bet is
388 * to add this anyway.
389 * Also if action policy is re-add or better we allow
391 * This doesn't apply to containers as the 'non-spare'
392 * flag has a different meaning. The test has to happen
393 * at the device level there
395 if (!st
->ss
->external
396 && (info
.disk
.state
& (1<<MD_DISK_SYNC
)) != 0
397 && ! policy_action_allows(policy
, st
->ss
->name
,
400 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ainf
) == 0) {
401 pr_err("not adding %s to active array (without --run) %s\n",
402 devname
, chosen_name
);
412 sprintf(dn
, "%d:%d", sra
->devs
->disk
.major
,
413 sra
->devs
->disk
.minor
);
414 dfd2
= dev_open(dn
, O_RDONLY
);
416 pr_err("unable to open %s\n", devname
);
421 if (st2
->ss
->load_super(st2
, dfd2
, NULL
) ||
422 st
->ss
->compare_super(st
, st2
) != 0) {
423 pr_err("metadata mismatch between %s and "
425 devname
, chosen_name
);
431 st2
->ss
->getinfo_super(st2
, &info2
, NULL
);
432 st2
->ss
->free_super(st2
);
433 if (info
.array
.level
!= info2
.array
.level
||
434 memcmp(info
.uuid
, info2
.uuid
, 16) != 0 ||
435 info
.array
.raid_disks
!= info2
.array
.raid_disks
) {
436 pr_err("unexpected difference between %s and %s.\n",
437 chosen_name
, devname
);
442 info
.disk
.major
= major(stb
.st_rdev
);
443 info
.disk
.minor
= minor(stb
.st_rdev
);
444 /* add disk needs to know about containers */
445 if (st
->ss
->external
)
446 sra
->array
.level
= LEVEL_CONTAINER
;
447 err
= add_disk(mdfd
, st
, sra
, &info
);
448 if (err
< 0 && errno
== EBUSY
) {
449 /* could be another device present with the same
450 * disk.number. Find and reject any such
452 find_reject(mdfd
, st
, sra
, info
.disk
.number
,
453 info
.events
, c
->verbose
, chosen_name
);
454 err
= add_disk(mdfd
, st
, sra
, &info
);
456 if (err
< 0 && errno
== EINVAL
&&
457 info
.disk
.state
& (1<<MD_DISK_SYNC
)) {
458 /* Maybe it needs to be added as a spare */
459 if (policy_action_allows(policy
, st
->ss
->name
,
461 info
.disk
.state
&= ~(1<<MD_DISK_SYNC
);
462 err
= add_disk(mdfd
, st
, sra
, &info
);
465 pr_err("can only add %s to %s as a spare, and force-spare is not set.\n",
466 devname
, chosen_name
);
469 pr_err("failed to add %s to existing array %s: %s.\n",
470 devname
, chosen_name
, strerror(errno
));
474 info
.array
.working_disks
= 0;
475 for (d
= sra
->devs
; d
; d
=d
->next
)
476 info
.array
.working_disks
++;
479 if (strncmp(chosen_name
, "/dev/md/", 8) == 0)
480 md_devname
= chosen_name
+8;
482 md_devname
= chosen_name
;
484 printf("MD_DEVICE=%s\n", fd2devnm(mdfd
));
485 printf("MD_DEVNAME=%s\n", md_devname
);
486 printf("MD_FOREIGN=%s\n", trustworthy
== FOREIGN
? "yes" : "no");
489 /* 7/ Is there enough devices to possibly start the array? */
490 /* 7a/ if not, finish with success. */
491 if (info
.array
.level
== LEVEL_CONTAINER
) {
493 /* Try to assemble within the container */
494 sysfs_uevent(sra
, "change");
495 if (!c
->export
&& c
->verbose
>= 0)
496 pr_err("container %s now has %d device%s\n",
497 chosen_name
, info
.array
.working_disks
,
498 info
.array
.working_disks
== 1?"":"s");
499 wait_for(chosen_name
, mdfd
);
500 if (st
->ss
->external
)
501 strcpy(devnm
, fd2devnm(mdfd
));
502 if (st
->ss
->load_container
)
503 rv
= st
->ss
->load_container(st
, mdfd
, NULL
);
507 rv
= Incremental_container(st
, chosen_name
, c
, NULL
);
509 /* after spare is added, ping monitor for external metadata
510 * so that it can eg. try to rebuild degraded array */
511 if (st
->ss
->external
)
516 /* We have added something to the array, so need to re-read the
517 * state. Eventually this state should be kept up-to-date as
521 sra
= sysfs_read(mdfd
, NULL
, (GET_DEVS
| GET_STATE
|
522 GET_OFFSET
| GET_SIZE
));
523 active_disks
= count_active(st
, sra
, mdfd
, &avail
, &info
);
524 if (enough(info
.array
.level
, info
.array
.raid_disks
,
525 info
.array
.layout
, info
.array
.state
& 1,
528 printf("MD_STARTED=no\n");
529 } else if (c
->verbose
>= 0)
530 pr_err("%s attached to %s, not enough to start (%d).\n",
531 devname
, chosen_name
, active_disks
);
537 /* - if number of OK devices match expected, or -R and there */
539 /* + add any bitmap file */
540 /* + start the array (auto-readonly). */
542 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ainf
) == 0) {
544 printf("MD_STARTED=already\n");
545 } else if (c
->verbose
>= 0)
546 pr_err("%s attached to %s which is already active.\n",
547 devname
, chosen_name
);
553 if (c
->runstop
> 0 || active_disks
>= info
.array
.working_disks
) {
555 /* Let's try to start it */
557 if (info
.reshape_active
&& !(info
.reshape_active
& RESHAPE_NO_BACKUP
)) {
558 pr_err("%s: This array is being reshaped and cannot be started\n",
560 cont_err("by --incremental. Please use --assemble\n");
563 if (match
&& match
->bitmap_file
) {
564 int bmfd
= open(match
->bitmap_file
, O_RDWR
);
566 pr_err("Could not open bitmap file %s.\n",
570 if (ioctl(mdfd
, SET_BITMAP_FILE
, bmfd
) != 0) {
572 pr_err("Failed to set bitmapfile for %s.\n",
578 /* Need to remove from the array any devices which
579 * 'count_active' discerned were too old or inappropriate
581 for (d
= sra
? sra
->devs
: NULL
; d
; d
= d
->next
)
582 if (d
->disk
.state
& (1<<MD_DISK_REMOVED
))
583 remove_disk(mdfd
, st
, sra
, d
);
585 if ((sra
== NULL
|| active_disks
>= info
.array
.working_disks
)
586 && trustworthy
!= FOREIGN
)
587 rv
= ioctl(mdfd
, RUN_ARRAY
, NULL
);
589 rv
= sysfs_set_str(sra
, NULL
,
590 "array_state", "read-auto");
593 printf("MD_STARTED=yes\n");
594 } else if (c
->verbose
>= 0)
595 pr_err("%s attached to %s, which has been started.\n",
596 devname
, chosen_name
);
598 wait_for(chosen_name
, mdfd
);
599 /* We just started the array, so some devices
600 * might have been evicted from the array
601 * because their event counts were too old.
602 * If the action=re-add policy is in-force for
603 * those devices we should re-add them now.
605 for (dsk
= sra
->devs
; dsk
; dsk
= dsk
->next
) {
606 if (disk_action_allows(dsk
, st
->ss
->name
, act_re_add
) &&
607 add_disk(mdfd
, st
, sra
, dsk
) == 0)
608 pr_err("%s re-added to %s\n",
609 dsk
->sys_name
, chosen_name
);
612 pr_err("%s attached to %s, but failed to start: %s.\n",
613 devname
, chosen_name
, strerror(errno
));
618 printf("MD_STARTED=unsafe\n");
619 } else if (c
->verbose
>= 0)
620 pr_err("%s attached to %s, not enough to start safely.\n",
621 devname
, chosen_name
);
631 dev_policy_free(policy
);
640 static void find_reject(int mdfd
, struct supertype
*st
, struct mdinfo
*sra
,
641 int number
, __u64 events
, int verbose
,
644 /* Find a device attached to this array with a disk.number of number
645 * and events less than the passed events, and remove the device.
650 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ra
) == 0)
651 return; /* not safe to remove from active arrays
652 * without thinking more */
654 for (d
= sra
->devs
; d
; d
= d
->next
) {
658 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
659 dfd
= dev_open(dn
, O_RDONLY
);
662 if (st
->ss
->load_super(st
, dfd
, NULL
)) {
666 st
->ss
->getinfo_super(st
, &info
, NULL
);
667 st
->ss
->free_super(st
);
670 if (info
.disk
.number
!= number
||
671 info
.events
>= events
)
674 if (d
->disk
.raid_disk
> -1)
675 sysfs_set_str(sra
, d
, "slot", "none");
676 if (sysfs_set_str(sra
, d
, "state", "remove") == 0)
678 pr_err("removing old device %s from %s\n",
679 d
->sys_name
+4, array_name
);
683 static int count_active(struct supertype
*st
, struct mdinfo
*sra
,
684 int mdfd
, char **availp
,
685 struct mdinfo
*bestinfo
)
687 /* count how many devices in sra think they are active */
691 __u64 max_events
= 0;
703 for (d
= sra
->devs
; d
; d
= d
->next
)
705 for (d
= sra
->devs
, devnum
= 0 ; d
; d
= d
->next
, devnum
++) {
711 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
712 dfd
= dev_open(dn
, O_RDONLY
);
715 ok
= st
->ss
->load_super(st
, dfd
, NULL
);
719 info
.array
.raid_disks
= raid_disks
;
720 st
->ss
->getinfo_super(st
, &info
, devmap
+ raid_disks
* devnum
);
722 raid_disks
= info
.array
.raid_disks
;
723 avail
= xcalloc(raid_disks
, 1);
726 best
= xcalloc(raid_disks
, sizeof(int));
727 devmap
= xcalloc(raid_disks
, numdevs
);
729 st
->ss
->getinfo_super(st
, &info
, devmap
);
732 if (info
.disk
.state
& (1<<MD_DISK_SYNC
))
736 max_events
= info
.events
;
737 avail
[info
.disk
.raid_disk
] = 2;
738 best
[info
.disk
.raid_disk
] = devnum
;
739 st
->ss
->getinfo_super(st
, bestinfo
, NULL
);
740 } else if (info
.events
== max_events
) {
741 avail
[info
.disk
.raid_disk
] = 2;
742 best
[info
.disk
.raid_disk
] = devnum
;
743 } else if (info
.events
== max_events
-1) {
744 if (avail
[info
.disk
.raid_disk
] == 0) {
745 avail
[info
.disk
.raid_disk
] = 1;
746 best
[info
.disk
.raid_disk
] = devnum
;
748 } else if (info
.events
< max_events
- 1)
750 else if (info
.events
== max_events
+1) {
752 max_events
= info
.events
;
753 for (i
= 0; i
< raid_disks
; i
++)
756 avail
[info
.disk
.raid_disk
] = 2;
757 best
[info
.disk
.raid_disk
] = devnum
;
758 st
->ss
->getinfo_super(st
, bestinfo
, NULL
);
759 } else { /* info.events much bigger */
760 memset(avail
, 0, raid_disks
);
761 max_events
= info
.events
;
762 avail
[info
.disk
.raid_disk
] = 2;
763 best
[info
.disk
.raid_disk
] = devnum
;
764 st
->ss
->getinfo_super(st
, bestinfo
, NULL
);
766 } else if (info
.disk
.state
& (1<<MD_DISK_REPLACEMENT
))
768 st
->ss
->free_super(st
);
772 /* We need to reject any device that thinks the best device is
773 * failed or missing */
774 for (b
= 0; b
< raid_disks
; b
++)
778 for (i
= 0 ; i
< raid_disks
; i
++) {
779 if (i
!= b
&& avail
[i
])
780 if (devmap
[raid_disks
* best
[i
] + b
] == 0) {
781 /* This device thinks 'b' is failed -
784 for (d
=sra
->devs
; devnum
; d
= d
->next
)
786 d
->disk
.state
|= (1 << MD_DISK_REMOVED
);
792 /* Also need to reject any spare device with an event count that
795 for (d
= sra
->devs
; d
; d
= d
->next
) {
796 if (!(d
->disk
.state
& (1<<MD_DISK_SYNC
)) &&
797 d
->events
> max_events
)
798 d
->disk
.state
|= (1 << MD_DISK_REMOVED
);
802 return cnt
+ replcnt
;
805 /* test if container has degraded member(s) */
806 static int container_members_max_degradation(struct map_ent
*map
, struct map_ent
*me
)
808 mdu_array_info_t array
;
810 int max_degraded
= 0;
812 for(; map
; map
= map
->next
) {
813 if (!metadata_container_matches(map
->metadata
, me
->devnm
))
815 afd
= open_dev(map
->devnm
);
818 /* most accurate information regarding array degradation */
819 if (ioctl(afd
, GET_ARRAY_INFO
, &array
) >= 0) {
820 int degraded
= array
.raid_disks
- array
.active_disks
-
822 if (degraded
> max_degraded
)
823 max_degraded
= degraded
;
827 return (max_degraded
);
830 static int array_try_spare(char *devname
, int *dfdp
, struct dev_policy
*pol
,
831 struct map_ent
*target
, int bare
,
832 struct supertype
*st
, int verbose
)
834 /* This device doesn't have any md metadata
835 * The device policy allows 'spare' and if !bare, it allows spare-same-slot.
836 * If 'st' is not set, then we only know that some metadata allows this,
837 * others possibly don't.
838 * So look for a container or array to attach the device to.
839 * Prefer 'target' if that is set and the array is found.
841 * If st is set, then only arrays of that type are considered
842 * Return 0 on success, or some exit code on failure, probably 1.
846 struct map_ent
*mp
, *map
= NULL
;
847 struct mdinfo
*chosen
= NULL
;
850 if (fstat(dfd
, &stb
) != 0)
854 * Now we need to find a suitable array to add this to.
855 * We only accept arrays that:
857 * - are in the same domains as the device
858 * - are of an size for which the device will be useful
859 * and we choose the one that is the most degraded
862 if (map_lock(&map
)) {
863 pr_err("failed to get exclusive lock on "
867 for (mp
= map
; mp
; mp
= mp
->next
) {
868 struct supertype
*st2
;
869 struct domainlist
*dl
= NULL
;
871 unsigned long long devsize
;
872 unsigned long long component_size
= 0;
874 if (is_subarray(mp
->metadata
))
877 st2
= st
->ss
->match_metadata_desc(mp
->metadata
);
879 (st
->minor_version
>= 0 &&
880 st
->minor_version
!= st2
->minor_version
)) {
882 pr_err("not adding %s to %s as metadata type doesn't match\n",
889 sra
= sysfs_read(-1, mp
->devnm
,
890 GET_DEVS
|GET_OFFSET
|GET_SIZE
|GET_STATE
|
891 GET_DEGRADED
|GET_COMPONENT
|GET_VERSION
);
893 /* Probably a container - no degraded info */
894 sra
= sysfs_read(-1, mp
->devnm
,
895 GET_DEVS
|GET_OFFSET
|GET_SIZE
|GET_STATE
|
896 GET_COMPONENT
|GET_VERSION
);
898 sra
->array
.failed_disks
= -1;
905 for(i
= 0; !st2
&& superlist
[i
]; i
++)
906 st2
= superlist
[i
]->match_metadata_desc(
910 pr_err("not adding %s to %s"
911 " as metadata not recognised.\n",
915 /* Need to double check the 'act_spare' permissions applies
918 if (!policy_action_allows(pol
, st2
->ss
->name
, act_spare
))
920 if (!bare
&& !policy_action_allows(pol
, st2
->ss
->name
,
921 act_spare_same_slot
))
925 /* update number of failed disks for mostly degraded
926 * container member */
927 if (sra
->array
.failed_disks
== -1)
928 sra
->array
.failed_disks
= container_members_max_degradation(map
, mp
);
930 get_dev_size(dfd
, NULL
, &devsize
);
931 if (sra
->component_size
== 0) {
932 /* true for containers, here we must read superblock
933 * to obtain minimum spare size */
934 struct supertype
*st3
= dup_super(st2
);
935 int mdfd
= open_dev(mp
->devnm
);
940 if (st3
->ss
->load_container
&&
941 !st3
->ss
->load_container(st3
, mdfd
, mp
->path
)) {
942 component_size
= st3
->ss
->min_acceptable_spare_size(st3
);
943 st3
->ss
->free_super(st3
);
948 if ((sra
->component_size
> 0 &&
949 st2
->ss
->avail_size(st2
, devsize
,
951 ? sra
->devs
->data_offset
953 < sra
->component_size
)
955 (sra
->component_size
== 0 && devsize
< component_size
)) {
957 pr_err("not adding %s to %s as it is too small\n",
961 /* test against target.
962 * If 'target' is set and 'bare' is false, we only accept
963 * arrays/containers that match 'target'.
964 * If 'target' is set and 'bare' is true, we prefer the
965 * array which matches 'target'.
966 * target is considered only if we deal with degraded array
968 if (target
&& policy_action_allows(pol
, st2
->ss
->name
,
969 act_spare_same_slot
)) {
970 if (strcmp(target
->metadata
, mp
->metadata
) == 0 &&
971 memcmp(target
->uuid
, mp
->uuid
,
972 sizeof(target
->uuid
)) == 0 &&
973 sra
->array
.failed_disks
> 0) {
974 /* This is our target!! */
979 /* skip to end so we don't check any more */
989 dl
= domain_from_array(sra
, st2
->ss
->name
);
990 if (domain_test(dl
, pol
, st2
->ss
->name
) != 1) {
991 /* domain test fails */
993 pr_err("not adding %s to %s as"
994 " it is not in a compatible domain\n",
999 /* all tests passed, OK to add to this array */
1003 } else if (chosen
->array
.failed_disks
< sra
->array
.failed_disks
) {
1017 /* add current device to chosen array as a spare */
1018 int mdfd
= open_dev(chosen
->sys_name
);
1020 struct mddev_dev devlist
;
1022 devlist
.next
= NULL
;
1024 devlist
.writemostly
= 0;
1025 devlist
.devname
= devname
;
1026 sprintf(devname
, "%d:%d", major(stb
.st_rdev
),
1027 minor(stb
.st_rdev
));
1028 devlist
.disposition
= 'a';
1031 rv
= Manage_subdevs(chosen
->sys_name
, mdfd
, &devlist
,
1037 pr_err("added %s as spare for %s\n",
1038 devname
, chosen
->sys_name
);
1040 pr_err("failed to add %s as spare for %s\n",
1041 devname
, chosen
->sys_name
);
1049 static int partition_try_spare(char *devname
, int *dfdp
, struct dev_policy
*pol
,
1050 struct supertype
*st
, int verbose
)
1052 /* we know that at least one partition virtual-metadata is
1053 * allowed to incorporate spares like this device. We need to
1054 * find a suitable device to copy partition information from.
1056 * Getting a list of all disk (not partition) devices is
1057 * slightly non-trivial. We could look at /sys/block, but
1058 * that is theoretically due to be removed. Maybe best to use
1059 * /dev/disk/by-path/?* and ignore names ending '-partNN' as
1060 * we depend on this directory of 'path' info. But that fails
1061 * to find loop devices and probably others. Maybe don't
1062 * worry about that, they aren't the real target.
1064 * So: check things in /dev/disk/by-path to see if they are in
1065 * a compatible domain, then load the partition table and see
1066 * if it is OK for the new device, and choose the largest
1067 * partition table that fits.
1071 char *chosen
= NULL
;
1072 unsigned long long chosen_size
= 0;
1073 struct supertype
*chosen_st
= NULL
;
1076 dir
= opendir("/dev/disk/by-path");
1079 while ((de
= readdir(dir
)) != NULL
) {
1081 struct dev_policy
*pol2
= NULL
;
1082 struct domainlist
*domlist
= NULL
;
1085 struct supertype
*st2
= NULL
;
1086 char *devname
= NULL
;
1087 unsigned long long devsectors
;
1089 if (de
->d_ino
== 0 ||
1090 de
->d_name
[0] == '.' ||
1091 (de
->d_type
!= DT_LNK
&& de
->d_type
!= DT_UNKNOWN
))
1094 ep
= de
->d_name
+ strlen(de
->d_name
);
1095 while (ep
> de
->d_name
&&
1098 if (ep
> de
->d_name
+ 5 &&
1099 strncmp(ep
-5, "-part", 5) == 0)
1100 /* This is a partition - skip it */
1103 pol2
= path_policy(de
->d_name
, type_disk
);
1105 domain_merge(&domlist
, pol2
, st
? st
->ss
->name
: NULL
);
1106 if (domain_test(domlist
, pol
, st
? st
->ss
->name
: NULL
) != 1)
1107 /* new device is incompatible with this device. */
1110 domain_free(domlist
);
1113 if (asprintf(&devname
, "/dev/disk/by-path/%s", de
->d_name
) != 1) {
1117 fd
= open(devname
, O_RDONLY
);
1120 if (get_dev_size(fd
, devname
, &devsectors
) == 0)
1125 st2
= dup_super(st
);
1127 st2
= guess_super_type(fd
, guess_partitions
);
1129 st2
->ss
->load_super(st2
, fd
, NULL
) < 0)
1133 /* Check domain policy again, this time referring to metadata */
1134 domain_merge(&domlist
, pol2
, st2
->ss
->name
);
1135 if (domain_test(domlist
, pol
, st2
->ss
->name
) != 1)
1136 /* Incompatible devices for this metadata type */
1138 if (!policy_action_allows(pol
, st2
->ss
->name
, act_spare
))
1139 /* Some partition types allow sparing, but not
1145 st2
->ss
->getinfo_super(st2
, &info
, NULL
);
1146 if (info
.component_size
> devsectors
)
1147 /* This partitioning doesn't fit in the device */
1150 /* This is an acceptable device to copy partition
1151 * metadata from. We could just stop here, but I
1152 * think I want to keep looking incase a larger
1153 * metadata which makes better use of the device can
1156 if (chosen
== NULL
||
1157 chosen_size
< info
.component_size
) {
1158 chosen_size
= info
.component_size
;
1163 chosen_st
->ss
->free_super(chosen_st
);
1172 domain_free(domlist
);
1173 dev_policy_free(pol2
);
1175 st2
->ss
->free_super(st2
);
1187 /* 'chosen' is the best device we can find. Let's write its
1188 * metadata to devname dfd is read-only so don't use that
1190 fd
= open(devname
, O_RDWR
);
1192 chosen_st
->ss
->store_super(chosen_st
, fd
);
1196 chosen_st
->ss
->free_super(chosen_st
);
1201 static int is_bare(int dfd
)
1203 unsigned long long size
= 0;
1204 char bufpad
[4096 + 4096];
1205 char *buf
= (char*)(((long)bufpad
+ 4096) & ~4095);
1207 if (lseek(dfd
, 0, SEEK_SET
) != 0 ||
1208 read(dfd
, buf
, 4096) != 4096)
1211 if (buf
[0] != '\0' && buf
[0] != '\x5a' && buf
[0] != '\xff')
1213 if (memcmp(buf
, buf
+1, 4095) != 0)
1216 /* OK, first 4K appear blank, try the end. */
1217 get_dev_size(dfd
, NULL
, &size
);
1218 if (lseek(dfd
, size
-4096, SEEK_SET
) < 0 ||
1219 read(dfd
, buf
, 4096) != 4096)
1222 if (buf
[0] != '\0' && buf
[0] != '\x5a' && buf
[0] != '\xff')
1224 if (memcmp(buf
, buf
+1, 4095) != 0)
1230 /* adding a spare to a regular array is quite different from adding one to
1231 * a set-of-partitions virtual array.
1232 * This function determines which is worth trying and tries as appropriate.
1233 * Arrays are given priority over partitions.
1235 static int try_spare(char *devname
, int *dfdp
, struct dev_policy
*pol
,
1236 struct map_ent
*target
,
1237 struct supertype
*st
, int verbose
)
1242 int partitions_ok
= 0;
1246 /* Can only add a spare if device has at least one domain */
1247 if (pol_find(pol
, pol_domain
) == NULL
)
1249 /* And only if some action allows spares */
1250 if (!policy_action_allows(pol
, st
?st
->ss
->name
:NULL
, act_spare
))
1253 /* Now check if the device is bare.
1254 * bare devices can always be added as a spare
1255 * non-bare devices can only be added if spare-same-slot is permitted,
1256 * and this device is replacing a previous device - in which case 'target'
1259 if (!is_bare(dfd
)) {
1260 /* Must have a target and allow same_slot */
1261 /* Later - may allow force_spare without target */
1263 !policy_action_allows(pol
, st
?st
->ss
->name
:NULL
,
1264 act_spare_same_slot
)) {
1266 pr_err("%s is not bare, so not "
1267 "considering as a spare\n",
1275 /* It might be OK to add this device to an array - need to see
1276 * what arrays might be candidates.
1279 /* just try try 'array' or 'partition' based on this metadata */
1280 if (st
->ss
->add_to_super
)
1281 return array_try_spare(devname
, dfdp
, pol
, target
, bare
,
1284 return partition_try_spare(devname
, dfdp
, pol
,
1287 /* No metadata was specified or found so options are open.
1288 * Check for whether any array metadata, or any partition metadata
1289 * might allow adding the spare. This check is just help to avoid
1290 * a more costly scan of all arrays when we can be sure that will
1293 for (i
= 0; (!arrays_ok
|| !partitions_ok
) && superlist
[i
] ; i
++) {
1294 if (superlist
[i
]->add_to_super
&& !arrays_ok
&&
1295 policy_action_allows(pol
, superlist
[i
]->name
, act_spare
))
1297 if (superlist
[i
]->add_to_super
== NULL
&& !partitions_ok
&&
1298 policy_action_allows(pol
, superlist
[i
]->name
, act_spare
))
1303 rv
= array_try_spare(devname
, dfdp
, pol
, target
, bare
,
1305 if (rv
!= 0 && partitions_ok
)
1306 rv
= partition_try_spare(devname
, dfdp
, pol
, st
, verbose
);
1310 int IncrementalScan(struct context
*c
, char *devnm
)
1312 /* look at every device listed in the 'map' file.
1313 * If one is found that is not running then:
1314 * look in mdadm.conf for bitmap file.
1315 * if one exists, but array has none, add it.
1316 * try to start array in auto-readonly mode
1318 struct map_ent
*mapl
= NULL
;
1320 struct mddev_ident
*devs
, *mddev
;
1326 devs
= conf_get_ident(NULL
);
1329 for (me
= mapl
; me
; me
= me
->next
) {
1330 mdu_array_info_t array
;
1331 mdu_bitmap_file_t bmf
;
1335 if (devnm
&& strcmp(devnm
, me
->devnm
) != 0)
1337 if (devnm
&& me
->metadata
[0] == '/') {
1339 /* member array, need to work on container */
1340 strncpy(container
, me
->metadata
+1, 32);
1342 sl
= strchr(container
, '/');
1349 mdfd
= open_dev(me
->devnm
);
1353 if (!isdigit(me
->metadata
[0])) {
1354 /* must be a container */
1355 struct supertype
*st
= super_by_fd(mdfd
, NULL
);
1357 struct map_ent
*map
= NULL
;
1359 st
->ignore_hw_compat
= 1;
1360 if (st
&& st
->ss
->load_container
)
1361 ret
= st
->ss
->load_container(st
, mdfd
, NULL
);
1363 if (!ret
&& st
->ss
->container_content
) {
1365 pr_err("failed to get exclusive lock on mapfile\n");
1366 ret
= Incremental_container(st
, me
->path
, c
, only
);
1373 if (ioctl(mdfd
, GET_ARRAY_INFO
, &array
) == 0 ||
1378 /* Ok, we can try this one. Maybe it needs a bitmap */
1379 for (mddev
= devs
; mddev
; mddev
= mddev
->next
)
1380 if (mddev
->devname
&& me
->path
1381 && devname_matches(mddev
->devname
, me
->path
))
1383 if (mddev
&& mddev
->bitmap_file
) {
1385 * Note: early kernels will wrongly fail this, so it
1389 if (ioctl(mdfd
, GET_ARRAY_INFO
, &bmf
) < 0) {
1390 int bmfd
= open(mddev
->bitmap_file
, O_RDWR
);
1392 added
= ioctl(mdfd
, SET_BITMAP_FILE
,
1397 if (c
->verbose
>= 0) {
1399 pr_err("Added bitmap %s to %s\n",
1400 mddev
->bitmap_file
, me
->path
);
1401 else if (errno
!= EEXIST
)
1402 pr_err("Failed to add bitmap to %s: %s\n",
1403 me
->path
, strerror(errno
));
1406 /* FIXME check for reshape_active and consider not
1409 sra
= sysfs_read(mdfd
, NULL
, 0);
1411 if (sysfs_set_str(sra
, NULL
,
1412 "array_state", "read-auto") == 0) {
1413 if (c
->verbose
>= 0)
1414 pr_err("started array %s\n",
1415 me
->path
?: me
->devnm
);
1417 pr_err("failed to start array %s: %s\n",
1418 me
->path
?: me
->devnm
,
1428 static char *container2devname(char *devname
)
1430 char *mdname
= NULL
;
1432 if (devname
[0] == '/') {
1433 int fd
= open(devname
, O_RDONLY
);
1435 mdname
= xstrdup(fd2devnm(fd
));
1440 struct map_ent
*mp
, *map
= NULL
;
1442 if (!parse_uuid(devname
, uuid
))
1444 mp
= map_by_uuid(&map
, uuid
);
1446 mdname
= xstrdup(mp
->devnm
);
1453 static int Incremental_container(struct supertype
*st
, char *devname
,
1454 struct context
*c
, char *only
)
1456 /* Collect the contents of this container and for each
1457 * array, choose a device name and assemble the array.
1460 struct mdinfo
*list
;
1462 struct map_ent
*map
= NULL
;
1465 struct mddev_ident
*match
;
1467 struct domainlist
*domains
;
1468 struct map_ent
*smp
;
1475 st
->ss
->getinfo_super(st
, &info
, NULL
);
1477 if ((c
->runstop
> 0 && info
.container_enough
>= 0) ||
1478 info
.container_enough
> 0)
1482 printf("MD_STARTED=no\n");
1483 } else if (c
->verbose
)
1484 pr_err("not enough devices to start the container\n");
1488 match
= conf_match(st
, &info
, devname
, c
->verbose
, &rv
);
1489 if (match
== NULL
&& rv
== 2)
1492 /* Need to compute 'trustworthy' */
1494 trustworthy
= LOCAL
;
1495 else if (st
->ss
->match_home(st
, c
->homehost
) == 1)
1496 trustworthy
= LOCAL
;
1497 else if (st
->ss
->match_home(st
, "any") == 1)
1498 trustworthy
= LOCAL
;
1500 trustworthy
= FOREIGN
;
1502 list
= st
->ss
->container_content(st
, NULL
);
1503 /* when nothing to activate - quit */
1506 printf("MD_STARTED=nothing\n");
1510 for (ra
= list
; ra
; ra
= ra
->next
) {
1512 char chosen_name
[1024];
1514 struct mddev_ident
*match
= NULL
;
1517 /* do not activate arrays blocked by metadata handler */
1518 if (ra
->array
.state
& (1 << MD_SB_BLOCK_VOLUME
)) {
1519 pr_err("Cannot activate array %s in %s.\n",
1520 ra
->text_version
, devname
);
1524 mp
= map_by_uuid(&map
, ra
->uuid
);
1527 mdfd
= open_dev(mp
->devnm
);
1529 strcpy(chosen_name
, mp
->path
);
1531 strcpy(chosen_name
, mp
->devnm
);
1534 /* Check in mdadm.conf for container == devname and
1535 * member == ra->text_version after second slash.
1537 char *sub
= strchr(ra
->text_version
+1, '/');
1538 struct mddev_ident
*array_list
;
1541 array_list
= conf_get_ident(NULL
);
1544 for(; array_list
; array_list
= array_list
->next
) {
1546 if (array_list
->member
== NULL
||
1547 array_list
->container
== NULL
)
1549 if (strcmp(array_list
->member
, sub
) != 0)
1551 if (array_list
->uuid_set
&&
1552 !same_uuid(ra
->uuid
, array_list
->uuid
, st
->ss
->swapuuid
))
1554 dn
= container2devname(array_list
->container
);
1557 if (strncmp(dn
, ra
->text_version
+1,
1559 ra
->text_version
[strlen(dn
)+1] != '/') {
1564 /* we have a match */
1567 pr_err("match found for member %s\n",
1568 array_list
->member
);
1572 if (match
&& match
->devname
&&
1573 strcasecmp(match
->devname
, "<ignore>") == 0) {
1575 pr_err("array %s/%s is "
1576 "explicitly ignored by mdadm.conf\n",
1577 match
->container
, match
->member
);
1581 trustworthy
= LOCAL
;
1583 mdfd
= create_mddev(match
? match
->devname
: NULL
,
1589 if (only
&& (!mp
|| strcmp(mp
->devnm
, only
) != 0))
1593 pr_err("failed to open %s: %s.\n",
1594 chosen_name
, strerror(errno
));
1598 assemble_container_content(st
, mdfd
, ra
, c
,
1599 chosen_name
, &result
);
1602 if (c
->export
&& result
) {
1604 printf("MD_STARTED");
1605 if (result
& INCR_NO
) {
1606 printf("%cno", sep
);
1609 if (result
& INCR_UNSAFE
) {
1610 printf("%cunsafe", sep
);
1613 if (result
& INCR_ALREADY
) {
1614 printf("%calready", sep
);
1617 if (result
& INCR_YES
) {
1618 printf("%cyes", sep
);
1624 /* don't move spares to container with volume being activated
1625 when all volumes are blocked */
1626 if (ra_all
== ra_blocked
)
1629 /* Now move all suitable spares from spare container */
1630 domains
= domain_from_array(list
, st
->ss
->name
);
1631 memcpy(suuid
, uuid_zero
, sizeof(int[4]));
1633 (smp
= map_by_uuid(&map
, suuid
)) != NULL
&&
1634 (sfd
= open(smp
->path
, O_RDONLY
)) >= 0) {
1635 /* spare container found */
1636 struct supertype
*sst
=
1637 super_imsm
.match_metadata_desc("imsm");
1638 struct mdinfo
*sinfo
;
1639 unsigned long long min_size
= 0;
1640 if (st
->ss
->min_acceptable_spare_size
)
1641 min_size
= st
->ss
->min_acceptable_spare_size(st
);
1642 if (!sst
->ss
->load_container(sst
, sfd
, NULL
)) {
1644 sinfo
= container_choose_spares(sst
, min_size
,
1647 sst
->ss
->free_super(sst
);
1650 struct mdinfo
*disks
= sinfo
->devs
;
1652 /* move spare from spare
1653 * container to currently
1659 makedev(disks
->disk
.major
,
1660 disks
->disk
.minor
)))
1662 disks
= disks
->next
;
1665 pr_err("Added %d spare%s to %s\n",
1666 count
, count
>1?"s":"", devname
);
1672 domain_free(domains
);
1676 static void run_udisks(char *arg1
, char *arg2
)
1681 execl("/usr/bin/udisks", "udisks", arg1
, arg2
, NULL
);
1682 execl("/bin/udisks", "udisks", arg1
, arg2
, NULL
);
1685 while (pid
> 0 && wait(&status
) != pid
)
1690 * IncrementalRemove - Attempt to see if the passed in device belongs to any
1691 * raid arrays, and if so first fail (if needed) and then remove the device.
1693 * @devname - The device we want to remove
1694 * @id_path - name as found in /dev/disk/by-path for this device
1696 * Note: the device name must be a kernel name like "sda", so
1697 * that we can find it in /proc/mdstat
1699 int IncrementalRemove(char *devname
, char *id_path
, int verbose
)
1703 struct mdstat_ent
*ent
;
1704 struct mddev_dev devlist
;
1709 dprintf(Name
": incremental removal without --path <id_path> "
1710 "lacks the possibility to re-add new device in this "
1713 if (strchr(devname
, '/')) {
1714 pr_err("incremental removal requires a "
1715 "kernel device name, not a file: %s\n", devname
);
1718 ent
= mdstat_by_component(devname
);
1721 pr_err("%s does not appear to be a component "
1722 "of any array\n", devname
);
1725 sysfs_init(&mdi
, -1, ent
->devnm
);
1726 if (sysfs_get_str(&mdi
, NULL
, "array_state",
1727 buf
, sizeof(buf
)) > 0) {
1728 if (strncmp(buf
, "active", 6) == 0 ||
1729 strncmp(buf
, "clean", 5) == 0)
1730 sysfs_set_str(&mdi
, NULL
,
1731 "array_state", "read-auto");
1733 mdfd
= open_dev(ent
->devnm
);
1736 pr_err("Cannot open array %s!!\n", ent
->dev
);
1742 struct map_ent
*map
= NULL
, *me
;
1743 me
= map_by_devnm(&map
, ent
->devnm
);
1745 policy_save_path(id_path
, me
);
1749 memset(&devlist
, 0, sizeof(devlist
));
1750 devlist
.devname
= devname
;
1751 devlist
.disposition
= 'f';
1752 /* for a container, we must fail each member array */
1753 if (ent
->metadata_version
&&
1754 strncmp(ent
->metadata_version
, "external:", 9) == 0) {
1755 struct mdstat_ent
*mdstat
= mdstat_read(0, 0);
1756 struct mdstat_ent
*memb
;
1757 for (memb
= mdstat
; memb
; memb
= memb
->next
)
1758 if (is_container_member(memb
, ent
->dev
)) {
1759 int subfd
= open_dev(memb
->devnm
);
1761 rv
|= Manage_subdevs(
1763 &devlist
, verbose
, 0,
1768 free_mdstat(mdstat
);
1770 rv
|= Manage_subdevs(ent
->dev
, mdfd
, &devlist
,
1771 verbose
, 0, NULL
, 0);
1773 /* Failed due to EBUSY, try to stop the array.
1774 * Give udisks a chance to unmount it first.
1776 int devid
= devnm2devid(ent
->devnm
);
1777 run_udisks("--unmount", map_dev(major(devid
),minor(devid
), 0));
1778 rv
= Manage_stop(ent
->dev
, mdfd
, verbose
, 1);
1780 /* At least we can try to trigger a 'remove' */
1781 sysfs_uevent(&mdi
, "remove");
1784 pr_err("Fail to stop %s too.\n", ent
->devnm
);
1787 devlist
.disposition
= 'r';
1788 rv
= Manage_subdevs(ent
->dev
, mdfd
, &devlist
,
1789 verbose
, 0, NULL
, 0);