Add spares to raid0 in mdadm

When user wants to add spares to container with raid0 arrays only
it is not possible to update metadata due to lack of running mdmon.
To allow for this direct metadata update by mdadm is used in such case.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Adam Kwolek 2011-01-06 18:42:53 +11:00 committed by NeilBrown
parent 0e2d1a4e68
commit 73cb8d43f4
1 changed files with 7 additions and 14 deletions

View File

@ -800,16 +800,16 @@ int Manage_subdevs(char *devname, int fd,
if (dv->writemostly == 1)
disc.state |= 1 << MD_DISK_WRITEMOSTLY;
dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
if (tst->ss->external &&
mdmon_running(tst->container_dev))
tst->update_tail = &tst->updates;
if (tst->ss->add_to_super(tst, &disc, dfd,
dv->devname)) {
close(dfd);
return 1;
}
/* write_init_super will close 'dfd' */
if (tst->ss->external)
/* mdmon will write the metadata */
close(dfd);
else if (tst->ss->write_init_super(tst))
if (tst->ss->write_init_super(tst))
return 1;
} else if (dv->re_add) {
/* this had better be raid1.
@ -844,9 +844,8 @@ int Manage_subdevs(char *devname, int fd,
if (dv->writemostly == 1)
disc.state |= (1 << MD_DISK_WRITEMOSTLY);
if (tst->ss->external) {
/* add a disk to an external metadata container
* only if mdmon is around to see it
*/
/* add a disk
* to an external metadata container */
struct mdinfo new_mdi;
struct mdinfo *sra;
int container_fd;
@ -860,13 +859,6 @@ int Manage_subdevs(char *devname, int fd,
return 1;
}
if (!mdmon_running(devnum)) {
fprintf(stderr, Name ": add failed for %s: mdmon not running\n",
dv->devname);
close(container_fd);
return 1;
}
sra = sysfs_read(container_fd, -1, 0);
if (!sra) {
fprintf(stderr, Name ": add failed for %s: sysfs_read failed\n",
@ -884,6 +876,7 @@ int Manage_subdevs(char *devname, int fd,
fprintf(stderr, Name ": add new device to external metadata"
" failed for %s\n", dv->devname);
close(container_fd);
sysfs_free(sra);
return 1;
}
ping_monitor(devnum2devname(devnum));