]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Manage: fix the mess I made in earlier patch.
authorNeilBrown <neilb@suse.de>
Fri, 18 Mar 2011 01:31:45 +0000 (12:31 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 18 Mar 2011 01:31:45 +0000 (12:31 +1100)
When I separated the 'native metadata' case more cleanly from the
"external metadata" case for adding a drive, I left some 'external'
code in the 'native' case, and didn't copy it to the 'external' case.

When - in the external case - we add to super, we much check for
mdmon first, so we know whether to do the metadata update ourselves
or not, then afterwards call either flush_metadata_updates (to send
to mdmon) or sync_metadata (to do it directly).

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Manage.c

index 3361269dedc8d32ed5bcaff06e8965fc6651d7ad..a679c24ce571d6550a28fc09099056a4793e37f8 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -835,9 +835,6 @@ 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);
@@ -898,13 +895,18 @@ int Manage_subdevs(char *devname, int fd,
                                }
 
                                dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
+                               if (mdmon_running(tst->container_dev))
+                                       tst->update_tail = &tst->updates;
                                if (tst->ss->add_to_super(tst, &disc, dfd,
                                                          dv->devname)) {
                                        close(dfd);
                                        close(container_fd);
                                        return 1;
                                }
-                               close(dfd);
+                               if (st->update_tail)
+                                       flush_metadata_updates(st);
+                               else
+                                       tst->ss->sync_metadata(st);
 
                                sra = sysfs_read(container_fd, -1, 0);
                                if (!sra) {