From d6221e667f55c46505125ae182051de499000ed8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 18 Mar 2011 12:31:45 +1100 Subject: [PATCH] Manage: fix the mess I made in earlier patch. 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 Signed-off-by: NeilBrown --- Manage.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Manage.c b/Manage.c index 3361269d..a679c24c 100644 --- 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) { -- 2.47.2