]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add spares to raid0 in mdadm
authorAdam Kwolek <adam.kwolek@intel.com>
Thu, 6 Jan 2011 07:42:53 +0000 (18:42 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 6 Jan 2011 07:42:53 +0000 (18:42 +1100)
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>
Manage.c

index 6b0853d70e9159b47c42c152d1bbcff344a5f492..4e6afb50390e6df10e162c39a6d69c7ac600e434 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -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));