]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Incremental.c
2 * Incremental.c - support --incremental. Part of:
3 * mdadm - manage Linux "md" devices aka RAID arrays.
5 * Copyright (C) 2006-2009 Neil Brown <neilb@suse.de>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Email: <neilb@suse.de>
27 * QVB Post Office, NSW 1230
33 static int count_active(struct supertype
*st
, int mdfd
, char **availp
,
35 static void find_reject(int mdfd
, struct supertype
*st
, struct mdinfo
*sra
,
36 int number
, __u64 events
, int verbose
,
39 int Incremental(char *devname
, int verbose
, int runstop
,
40 struct supertype
*st
, char *homehost
, int require_homehost
,
43 /* Add this device to an array, creating the array if necessary
44 * and starting the array if sensible or - if runstop>0 - if possible.
46 * This has several steps:
48 * 1/ Check if device is permitted by mdadm.conf, reject if not.
49 * 2/ Find metadata, reject if none appropriate (check
50 * version/name from args)
51 * 3/ Check if there is a match in mdadm.conf
52 * 3a/ if not, check for homehost match. If no match, assemble as
54 * 4/ Determine device number.
55 * - If in mdadm.conf with std name, use that
56 * - UUID in /var/run/mdadm.map use that
57 * - If name is suggestive, use that. unless in use with different uuid.
58 * - Choose a free, high number.
59 * - Use a partitioned device unless strong suggestion not to.
61 * Don't choose partitioned for containers.
62 * 5/ Find out if array already exists
64 * - choose a name, from mdadm.conf or 'name' field in array.
68 * - check one drive in array to make sure metadata is a reasonably
69 * close match. Reject if not (e.g. different type)
71 * 6/ Make sure /var/run/mdadm.map contains this array.
72 * 7/ Is there enough devices to possibly start the array?
73 * For a container, this means running Incremental_container.
74 * 7a/ if not, finish with success.
76 * - read all metadata and arrange devices like -A does
77 * - if number of OK devices match expected, or -R and there are enough,
78 * start the array (auto-readonly).
81 struct mdinfo info
, dinfo
;
82 struct mddev_ident_s
*array_list
, *match
;
83 char chosen_name
[1024];
85 struct map_ent
*mp
, *map
= NULL
;
86 int dfd
= -1, mdfd
= -1;
89 int trustworthy
= FOREIGN
;
91 mdu_array_info_t ainf
;
92 struct dev_policy
*policy
= NULL
;
94 struct createinfo
*ci
= conf_get_create_info();
97 /* 1/ Check if device is permitted by mdadm.conf */
99 if (!conf_test_dev(devname
)) {
102 ": %s not permitted by mdadm.conf.\n",
107 /* 2/ Find metadata, reject if none appropriate (check
108 * version/name from args) */
110 dfd
= dev_open(devname
, O_RDONLY
|O_EXCL
);
113 fprintf(stderr
, Name
": cannot open %s: %s.\n",
114 devname
, strerror(errno
));
117 if (fstat(dfd
, &stb
) < 0) {
119 fprintf(stderr
, Name
": fstat failed for %s: %s.\n",
120 devname
, strerror(errno
));
123 if ((stb
.st_mode
& S_IFMT
) != S_IFBLK
) {
125 fprintf(stderr
, Name
": %s is not a block device.\n",
130 dinfo
.disk
.major
= major(stb
.st_rdev
);
131 dinfo
.disk
.minor
= minor(stb
.st_rdev
);
133 policy
= disk_policy(&dinfo
);
135 if (st
== NULL
&& (st
= guess_super(dfd
)) == NULL
) {
138 ": no recognisable superblock on %s.\n",
142 if (st
->ss
->load_super(st
, dfd
, NULL
)) {
144 fprintf(stderr
, Name
": no RAID superblock on %s.\n",
148 close (dfd
); dfd
= -1;
150 memset(&info
, 0, sizeof(info
));
151 st
->ss
->getinfo_super(st
, &info
);
152 /* 3/ Check if there is a match in mdadm.conf */
154 array_list
= conf_get_ident(NULL
);
156 for (; array_list
; array_list
= array_list
->next
) {
157 if (array_list
->uuid_set
&&
158 same_uuid(array_list
->uuid
, info
.uuid
, st
->ss
->swapuuid
)
160 if (verbose
>= 2 && array_list
->devname
)
162 ": UUID differs from %s.\n",
163 array_list
->devname
);
166 if (array_list
->name
[0] &&
167 strcasecmp(array_list
->name
, info
.name
) != 0) {
168 if (verbose
>= 2 && array_list
->devname
)
170 ": Name differs from %s.\n",
171 array_list
->devname
);
174 if (array_list
->devices
&&
175 !match_oneof(array_list
->devices
, devname
)) {
176 if (verbose
>= 2 && array_list
->devname
)
178 ": Not a listed device for %s.\n",
179 array_list
->devname
);
182 if (array_list
->super_minor
!= UnSet
&&
183 array_list
->super_minor
!= info
.array
.md_minor
) {
184 if (verbose
>= 2 && array_list
->devname
)
186 ": Different super-minor to %s.\n",
187 array_list
->devname
);
190 if (!array_list
->uuid_set
&&
191 !array_list
->name
[0] &&
192 !array_list
->devices
&&
193 array_list
->super_minor
== UnSet
) {
194 if (verbose
>= 2 && array_list
->devname
)
196 ": %s doesn't have any identifying information.\n",
197 array_list
->devname
);
200 /* FIXME, should I check raid_disks and level too?? */
204 if (match
->devname
&& array_list
->devname
)
206 ": we match both %s and %s - cannot decide which to use.\n",
207 match
->devname
, array_list
->devname
);
210 ": multiple lines in mdadm.conf match\n");
218 if (match
&& match
->devname
219 && strcasecmp(match
->devname
, "<ignore>") == 0) {
221 fprintf(stderr
, Name
": array containing %s is explicitly"
222 " ignored by mdadm.conf\n",
227 /* 3a/ if not, check for homehost match. If no match, continue
228 * but don't trust the 'name' in the array. Thus a 'random' minor
229 * number will be assigned, and the device name will be based
233 else if (st
->ss
->match_home(st
, homehost
) == 1)
235 else if (st
->ss
->match_home(st
, "any") == 1)
236 trustworthy
= LOCAL_ANY
;
238 trustworthy
= FOREIGN
;
241 if (!match
&& !conf_test_metadata(st
->ss
->name
,
242 (trustworthy
== LOCAL
))) {
245 ": %s has metadata type %s for which "
246 "auto-assembly is disabled\n",
247 devname
, st
->ss
->name
);
250 if (trustworthy
== LOCAL_ANY
)
253 /* There are three possible sources for 'autof': command line,
254 * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
255 * ARRAY takes precedence, then command line, then
258 if (match
&& match
->autof
)
259 autof
= match
->autof
;
263 if (st
->ss
->container_content
&& st
->loaded_container
) {
264 if ((runstop
> 0 && info
.container_enough
>= 0) ||
265 info
.container_enough
> 0)
269 fprintf(stderr
, Name
": not enough devices to start the container\n");
274 /* This is a pre-built container array, so we do something
277 rv
= Incremental_container(st
, devname
, verbose
, runstop
,
282 name_to_use
= info
.name
;
283 if (name_to_use
[0] == 0 &&
284 info
.array
.level
== LEVEL_CONTAINER
&&
285 trustworthy
== LOCAL
) {
286 name_to_use
= info
.text_version
;
287 trustworthy
= METADATA
;
289 if (name_to_use
[0] && trustworthy
!= LOCAL
&&
290 ! require_homehost
&&
291 conf_name_is_free(name_to_use
))
294 /* strip "hostname:" prefix from name if we have decided
295 * to treat it as LOCAL
297 if (trustworthy
== LOCAL
&& strchr(name_to_use
, ':') != NULL
)
298 name_to_use
= strchr(name_to_use
, ':')+1;
300 /* 4/ Check if array exists.
303 fprintf(stderr
, Name
": failed to get exclusive lock on "
305 mp
= map_by_uuid(&map
, info
.uuid
);
307 mdfd
= open_dev(mp
->devnum
);
314 /* Couldn't find an existing array, maybe make a new one */
315 mdfd
= create_mddev(match
? match
->devname
: NULL
,
316 name_to_use
, autof
, trustworthy
, chosen_name
);
321 sysfs_init(&info
, mdfd
, 0);
323 if (set_array_info(mdfd
, st
, &info
) != 0) {
324 fprintf(stderr
, Name
": failed to set array info for %s: %s\n",
325 chosen_name
, strerror(errno
));
331 dinfo
.disk
.major
= major(stb
.st_rdev
);
332 dinfo
.disk
.minor
= minor(stb
.st_rdev
);
333 if (add_disk(mdfd
, st
, &info
, &dinfo
) != 0) {
334 fprintf(stderr
, Name
": failed to add %s to %s: %s.\n",
335 devname
, chosen_name
, strerror(errno
));
336 ioctl(mdfd
, STOP_ARRAY
, 0);
340 sra
= sysfs_read(mdfd
, fd2devnum(mdfd
), GET_DEVS
);
341 if (!sra
|| !sra
->devs
|| sra
->devs
->disk
.raid_disk
>= 0) {
342 /* It really should be 'none' - must be old buggy
343 * kernel, and mdadm -I may not be able to complete.
346 ioctl(mdfd
, STOP_ARRAY
, NULL
);
348 ": You have an old buggy kernel which cannot support\n"
349 " --incremental reliably. Aborting.\n");
354 info
.array
.working_disks
= 1;
356 /* 6/ Make sure /var/run/mdadm.map contains this array. */
357 map_update(&map
, fd2devnum(mdfd
),
359 info
.uuid
, chosen_name
);
362 /* - check one drive in array to make sure metadata is a reasonably */
363 /* close match. Reject if not (e.g. different type) */
364 /* - add the device */
369 struct supertype
*st2
;
370 struct mdinfo info2
, *d
;
373 strcpy(chosen_name
, mp
->path
);
375 strcpy(chosen_name
, devnum2devname(mp
->devnum
));
377 /* It is generally not OK to add non-spare drives to a
378 * running array as they are probably missing because
379 * they failed. However if runstop is 1, then the
380 * array was possibly started early and our best bet is
381 * to add this anyway.
382 * Also if action policy is re-add or better we allow
385 if ((info
.disk
.state
& (1<<MD_DISK_SYNC
)) != 0
386 && ! policy_action_allows(policy
, st
->ss
->name
,
391 if (st
->ss
->external
) {
392 char *devname
= devnum2devname(fd2devnum(mdfd
));
394 active
= devname
&& is_container_active(devname
);
396 } else if (ioctl(mdfd
, GET_ARRAY_INFO
, &ainf
) == 0)
400 ": not adding %s to active array (without --run) %s\n",
401 devname
, chosen_name
);
406 sra
= sysfs_read(mdfd
, fd2devnum(mdfd
), (GET_DEVS
| GET_STATE
));
412 sprintf(dn
, "%d:%d", sra
->devs
->disk
.major
,
413 sra
->devs
->disk
.minor
);
414 dfd2
= dev_open(dn
, O_RDONLY
);
416 if (st2
->ss
->load_super(st2
, dfd2
, NULL
) ||
417 st
->ss
->compare_super(st
, st2
) != 0) {
419 ": metadata mismatch between %s and "
421 devname
, chosen_name
);
427 memset(&info2
, 0, sizeof(info2
));
428 st2
->ss
->getinfo_super(st2
, &info2
);
429 st2
->ss
->free_super(st2
);
430 if (info
.array
.level
!= info2
.array
.level
||
431 memcmp(info
.uuid
, info2
.uuid
, 16) != 0 ||
432 info
.array
.raid_disks
!= info2
.array
.raid_disks
) {
434 ": unexpected difference between %s and %s.\n",
435 chosen_name
, devname
);
440 info2
.disk
.major
= major(stb
.st_rdev
);
441 info2
.disk
.minor
= minor(stb
.st_rdev
);
442 /* add disk needs to know about containers */
443 if (st
->ss
->external
)
444 sra
->array
.level
= LEVEL_CONTAINER
;
445 err
= add_disk(mdfd
, st
, sra
, &info2
);
446 if (err
< 0 && errno
== EBUSY
) {
447 /* could be another device present with the same
448 * disk.number. Find and reject any such
450 find_reject(mdfd
, st
, sra
, info
.disk
.number
,
451 info
.events
, verbose
, chosen_name
);
452 err
= add_disk(mdfd
, st
, sra
, &info2
);
455 fprintf(stderr
, Name
": failed to add %s to %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
++;
466 /* 7/ Is there enough devices to possibly start the array? */
467 /* 7a/ if not, finish with success. */
468 if (info
.array
.level
== LEVEL_CONTAINER
) {
469 /* Try to assemble within the container */
471 sysfs_uevent(&info
, "change");
474 ": container %s now has %d devices\n",
475 chosen_name
, info
.array
.working_disks
);
476 wait_for(chosen_name
, mdfd
);
478 rv
= Incremental(chosen_name
, verbose
, runstop
,
479 NULL
, homehost
, require_homehost
, autof
);
481 /* Don't fail the whole -I if a subarray didn't
482 * have enough devices to start yet
488 active_disks
= count_active(st
, mdfd
, &avail
, &info
);
489 if (enough(info
.array
.level
, info
.array
.raid_disks
,
490 info
.array
.layout
, info
.array
.state
& 1,
491 avail
, active_disks
) == 0) {
495 ": %s attached to %s, not enough to start (%d).\n",
496 devname
, chosen_name
, active_disks
);
504 /* - if number of OK devices match expected, or -R and there */
506 /* + add any bitmap file */
507 /* + start the array (auto-readonly). */
509 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ainf
) == 0) {
512 ": %s attached to %s which is already active.\n",
513 devname
, chosen_name
);
520 if (runstop
> 0 || active_disks
>= info
.array
.working_disks
) {
521 struct mdinfo
*sra
, *dsk
;
522 /* Let's try to start it */
523 if (match
&& match
->bitmap_file
) {
524 int bmfd
= open(match
->bitmap_file
, O_RDWR
);
527 ": Could not open bitmap file %s.\n",
531 if (ioctl(mdfd
, SET_BITMAP_FILE
, bmfd
) != 0) {
534 ": Failed to set bitmapfile for %s.\n",
540 /* GET_* needed so add_disk works below */
541 sra
= sysfs_read(mdfd
, fd2devnum(mdfd
),
542 GET_DEVS
|GET_OFFSET
|GET_SIZE
|GET_STATE
);
543 if ((sra
== NULL
|| active_disks
>= info
.array
.working_disks
)
544 && trustworthy
!= FOREIGN
)
545 rv
= ioctl(mdfd
, RUN_ARRAY
, NULL
);
547 rv
= sysfs_set_str(sra
, NULL
,
548 "array_state", "read-auto");
552 ": %s attached to %s, which has been started.\n",
553 devname
, chosen_name
);
555 wait_for(chosen_name
, mdfd
);
556 /* We just started the array, so some devices
557 * might have been evicted from the array
558 * because their event counts were too old.
559 * If the action=re-add policy is in-force for
560 * those devices we should re-add them now.
562 for (dsk
= sra
->devs
; dsk
; dsk
= dsk
->next
) {
563 if (disk_action_allows(dsk
, st
->ss
->name
, act_re_add
) &&
564 add_disk(mdfd
, st
, sra
, dsk
) == 0)
566 ": %s re-added to %s\n",
567 dsk
->sys_name
, chosen_name
);
571 ": %s attached to %s, but failed to start: %s.\n",
572 devname
, chosen_name
, strerror(errno
));
578 ": %s attached to %s, not enough to start safely.\n",
579 devname
, chosen_name
);
588 dev_policy_free(policy
);
592 static void find_reject(int mdfd
, struct supertype
*st
, struct mdinfo
*sra
,
593 int number
, __u64 events
, int verbose
,
596 /* Find a device attached to this array with a disk.number of number
597 * and events less than the passed events, and remove the device.
602 if (ioctl(mdfd
, GET_ARRAY_INFO
, &ra
) == 0)
603 return; /* not safe to remove from active arrays
604 * without thinking more */
606 for (d
= sra
->devs
; d
; d
= d
->next
) {
610 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
611 dfd
= dev_open(dn
, O_RDONLY
);
614 if (st
->ss
->load_super(st
, dfd
, NULL
)) {
618 st
->ss
->getinfo_super(st
, &info
);
619 st
->ss
->free_super(st
);
622 if (info
.disk
.number
!= number
||
623 info
.events
>= events
)
626 if (d
->disk
.raid_disk
> -1)
627 sysfs_set_str(sra
, d
, "slot", "none");
628 if (sysfs_set_str(sra
, d
, "state", "remove") == 0)
631 ": removing old device %s from %s\n",
632 d
->sys_name
+4, array_name
);
636 static int count_active(struct supertype
*st
, int mdfd
, char **availp
,
637 struct mdinfo
*bestinfo
)
639 /* count how many devices in sra think they are active */
641 int cnt
= 0, cnt1
= 0;
642 __u64 max_events
= 0;
643 struct mdinfo
*sra
= sysfs_read(mdfd
, -1, GET_DEVS
| GET_STATE
);
649 for (d
= sra
->devs
; d
; d
= d
->next
) {
655 sprintf(dn
, "%d:%d", d
->disk
.major
, d
->disk
.minor
);
656 dfd
= dev_open(dn
, O_RDONLY
);
659 ok
= st
->ss
->load_super(st
, dfd
, NULL
);
663 st
->ss
->getinfo_super(st
, &info
);
665 avail
= malloc(info
.array
.raid_disks
);
667 fprintf(stderr
, Name
": out of memory.\n");
670 memset(avail
, 0, info
.array
.raid_disks
);
674 if (info
.disk
.state
& (1<<MD_DISK_SYNC
))
678 max_events
= info
.events
;
679 avail
[info
.disk
.raid_disk
] = 2;
680 st
->ss
->getinfo_super(st
, bestinfo
);
681 } else if (info
.events
== max_events
) {
683 avail
[info
.disk
.raid_disk
] = 2;
684 } else if (info
.events
== max_events
-1) {
686 avail
[info
.disk
.raid_disk
] = 1;
687 } else if (info
.events
< max_events
- 1)
689 else if (info
.events
== max_events
+1) {
693 max_events
= info
.events
;
694 for (i
=0; i
<info
.array
.raid_disks
; i
++)
697 avail
[info
.disk
.raid_disk
] = 2;
698 st
->ss
->getinfo_super(st
, bestinfo
);
699 } else { /* info.events much bigger */
701 memset(avail
, 0, info
.disk
.raid_disk
);
702 max_events
= info
.events
;
703 st
->ss
->getinfo_super(st
, bestinfo
);
706 st
->ss
->free_super(st
);
711 int IncrementalScan(int verbose
)
713 /* look at every device listed in the 'map' file.
714 * If one is found that is not running then:
715 * look in mdadm.conf for bitmap file.
716 * if one exists, but array has none, add it.
717 * try to start array in auto-readonly mode
719 struct map_ent
*mapl
= NULL
;
721 mddev_ident_t devs
, mddev
;
725 devs
= conf_get_ident(NULL
);
727 for (me
= mapl
; me
; me
= me
->next
) {
728 mdu_array_info_t array
;
729 mdu_bitmap_file_t bmf
;
731 int mdfd
= open_dev(me
->devnum
);
735 if (ioctl(mdfd
, GET_ARRAY_INFO
, &array
) == 0 ||
740 /* Ok, we can try this one. Maybe it needs a bitmap */
741 for (mddev
= devs
; mddev
; mddev
= mddev
->next
)
742 if (mddev
->devname
&& me
->path
743 && devname_matches(mddev
->devname
, me
->path
))
745 if (mddev
&& mddev
->bitmap_file
) {
747 * Note: early kernels will wrongly fail this, so it
751 if (ioctl(mdfd
, GET_ARRAY_INFO
, &bmf
) < 0) {
752 int bmfd
= open(mddev
->bitmap_file
, O_RDWR
);
754 added
= ioctl(mdfd
, SET_BITMAP_FILE
,
762 ": Added bitmap %s to %s\n",
763 mddev
->bitmap_file
, me
->path
);
764 else if (errno
!= EEXIST
)
766 ": Failed to add bitmap to %s: %s\n",
767 me
->path
, strerror(errno
));
770 sra
= sysfs_read(mdfd
, 0, 0);
772 if (sysfs_set_str(sra
, NULL
,
773 "array_state", "read-auto") == 0) {
776 ": started array %s\n",
777 me
->path
?: devnum2devname(me
->devnum
));
780 ": failed to start array %s: %s\n",
781 me
->path
?: devnum2devname(me
->devnum
),
790 static char *container2devname(char *devname
)
794 if (devname
[0] == '/') {
795 int fd
= open(devname
, O_RDONLY
);
797 mdname
= devnum2devname(fd2devnum(fd
));
802 struct map_ent
*mp
, *map
= NULL
;
804 if (!parse_uuid(devname
, uuid
))
806 mp
= map_by_uuid(&map
, uuid
);
808 mdname
= devnum2devname(mp
->devnum
);
815 int Incremental_container(struct supertype
*st
, char *devname
, int verbose
,
816 int runstop
, int autof
, int trustworthy
)
818 /* Collect the contents of this container and for each
819 * array, choose a device name and assemble the array.
822 struct mdinfo
*list
= st
->ss
->container_content(st
);
824 struct map_ent
*map
= NULL
;
827 fprintf(stderr
, Name
": failed to get exclusive lock on "
830 for (ra
= list
; ra
; ra
= ra
->next
) {
832 char chosen_name
[1024];
834 struct mddev_ident_s
*match
= NULL
;
836 mp
= map_by_uuid(&map
, ra
->uuid
);
839 mdfd
= open_dev(mp
->devnum
);
841 strcpy(chosen_name
, mp
->path
);
843 strcpy(chosen_name
, devnum2devname(mp
->devnum
));
846 /* Check in mdadm.conf for container == devname and
847 * member == ra->text_version after second slash.
849 char *sub
= strchr(ra
->text_version
+1, '/');
850 struct mddev_ident_s
*array_list
;
853 array_list
= conf_get_ident(NULL
);
856 for(; array_list
; array_list
= array_list
->next
) {
858 if (array_list
->member
== NULL
||
859 array_list
->container
== NULL
)
861 if (strcmp(array_list
->member
, sub
) != 0)
863 if (array_list
->uuid_set
&&
864 !same_uuid(ra
->uuid
, array_list
->uuid
, st
->ss
->swapuuid
))
866 dn
= container2devname(array_list
->container
);
869 if (strncmp(dn
, ra
->text_version
+1,
871 ra
->text_version
[strlen(dn
)+1] != '/') {
876 /* we have a match */
879 fprintf(stderr
, Name
": match found for member %s\n",
884 if (match
&& match
->devname
&&
885 strcasecmp(match
->devname
, "<ignore>") == 0) {
887 fprintf(stderr
, Name
": array %s/%s is "
888 "explicitly ignored by mdadm.conf\n",
889 match
->container
, match
->member
);
895 mdfd
= create_mddev(match
? match
->devname
: NULL
,
903 fprintf(stderr
, Name
": failed to open %s: %s.\n",
904 chosen_name
, strerror(errno
));
908 assemble_container_content(st
, mdfd
, ra
, runstop
,
909 chosen_name
, verbose
);
916 * IncrementalRemove - Attempt to see if the passed in device belongs to any
917 * raid arrays, and if so first fail (if needed) and then remove the device.
919 * @devname - The device we want to remove
921 * Note: the device name must be a kernel name like "sda", so
922 * that we can find it in /proc/mdstat
924 int IncrementalRemove(char *devname
, int verbose
)
928 struct mdstat_ent
*ent
;
929 struct mddev_dev_s devlist
;
931 if (strchr(devname
, '/')) {
932 fprintf(stderr
, Name
": incremental removal requires a "
933 "kernel device name, not a file: %s\n", devname
);
936 ent
= mdstat_by_component(devname
);
938 fprintf(stderr
, Name
": %s does not appear to be a component "
939 "of any array\n", devname
);
942 mdfd
= open_dev(ent
->devnum
);
944 fprintf(stderr
, Name
": Cannot open array %s!!\n", ent
->dev
);
947 memset(&devlist
, 0, sizeof(devlist
));
948 devlist
.devname
= devname
;
949 devlist
.disposition
= 'f';
950 Manage_subdevs(ent
->dev
, mdfd
, &devlist
, verbose
, 0);
951 devlist
.disposition
= 'r';
952 rv
= Manage_subdevs(ent
->dev
, mdfd
, &devlist
, verbose
, 0);