Skip to contentSkip to conversation

Manage, imsm: Write metadata before add

PATCH Superseded Mariusz Tkaczyk 1 participant 1 message Apr 8, 2020 MD RAID

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Manage, imsm: Write metadata before add

New drive in container always appears as spare. Manager is able to handle that, and queues appropriative update to monitor.
No update from mdadm side has to be processed, just insert the drive and ping the mdmon. Metadata has to be written if no mdmon is running (case for Raid0 or container without arrays).

If bare drive is added very early on startup (by custom bare rule), there is possiblity that mdmon was not restarted after switch root. Old one is not able to handle new drive. New one fails because there is drive without metadata in container and metadata cannot be loaded.

To prevent this, write spare metadata before adding device to container. Mdmon will overwrite it (same case as spare migration, if drive appears it writes the most recent metadata). Metadata has to be written only on new drive before sysfs_add_disk(), don't race with mdmon if running.

---
 Manage.c      |  6 +----
 super-intel.c | 67 +++++++++++++++++++++++++++++++++------------------
 2 files changed, 45 insertions(+), 28 deletions(-)
Manage.c +1 -5
index b22c3969..0a5f09b3 100644
@@ -994,17 +994,13 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
 
 		Kill(dv->devname, NULL, 0, -1, 0);
 		dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
-		if (mdmon_running(tst->container_devnm))
-			tst->update_tail = &tst->updates;
 		if (tst->ss->add_to_super(tst, &disc, dfd,
 					  dv->devname, INVALID_SECTORS)) {
 			close(dfd);
 			close(container_fd);
 			return -1;
 		}
-		if (tst->update_tail)
-			flush_metadata_updates(tst);
-		else
+		if (!mdmon_running(tst->container_devnm))
 			tst->ss->sync_metadata(tst);
 
 		sra = sysfs_read(container_fd, NULL, 0);
super-intel.c +44 -23

102 lines not on this page · raw message

Signature · 1 line
2.25.0