Manage, imsm: Write metadata before add
PATCH v2 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.
---
v2: removed unused variable.
Manage.c | 6 +---- super-intel.c | 66 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 28 deletions(-)
Manage.c +1 -5
@@ -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 +43 -23
101 lines not on this page · raw message
Signature · 1 line
2.25.0
Jes Sorensen
AppliedQuoted 17 lines · Tkaczyk Mariusz
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.
Quoted 7 lines
Signed-off-by Tkaczyk Mariusz <[email protected]>---
v2: removed unused variable.Manage.c | 6 +---- super-intel.c | 66 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 28 deletions(-)
Applied!
Thanks,
Jes