summaryrefslogtreecommitdiff
path: root/mdstat.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-12-16 11:45:21 +1100
committerNeilBrown <neilb@suse.de>2010-12-16 11:45:21 +1100
commit78b10e663c35a301406facbda3f5be02973e2ba4 (patch)
tree545b594c2e7f1e6f8ea3f5192d49435925b25995 /mdstat.c
parent94827db3b336c59c23bb1c29692d5045af7f4bec (diff)
imsm: Prepare reshape_update in mdadm
During Online Capacity Expansion metadata has to be updated to show array changes and allow for future assembly of array. To do this mdadm prepares and sends reshape_update metadata update to mdmon. The update contains the old and new number of raid disks, and the indices of the spare disks that will be used to fill the spaces. This works as follows: 1. reshape_super() prepares metadata update. 2. mdadm discovers the spares and adds them to the array 3. mdadm sends the update to mdmon 4. managemon in prepare_update() allocates required memory for bigger device object 5. monitor in process_update() updates the metadata to record the new sizes and the newly assigned devices. 6. mdadm initiates the reshape Based on code From: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdstat.c')
-rw-r--r--mdstat.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/mdstat.c b/mdstat.c
index c5a07b5b..bac37421 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -383,3 +383,36 @@ struct mdstat_ent *mdstat_by_component(char *name)
}
return NULL;
}
+
+struct mdstat_ent *mdstat_by_subdev(char *subdev, int container)
+{
+ struct mdstat_ent *mdstat = mdstat_read(0, 0);
+
+ while (mdstat) {
+ struct mdstat_ent *ent;
+ char *pos;
+ /* metadata version must match:
+ * external:[/-]md%d/%s
+ * where %d is 'container' and %s is 'subdev'
+ */
+ if (mdstat->metadata_version &&
+ strncmp(mdstat->metadata_version, "external:", 9) == 0 &&
+ strchr("/-", mdstat->metadata_version[9]) != NULL &&
+ strncmp(mdstat->metadata_version+10, "md", 2) == 0 &&
+ strtoul(mdstat->metadata_version+11, &pos, 10)
+ == (unsigned)container &&
+ pos > mdstat->metadata_version+11 &&
+ *pos == '/' &&
+ strcmp(pos+1, subdev) == 0
+ ) {
+ free_mdstat(mdstat->next);
+ mdstat->next = NULL;
+ return mdstat;
+ }
+ ent = mdstat;
+ mdstat = mdstat->next;
+ ent->next = NULL;
+ free_mdstat(ent);
+ }
+ return NULL;
+}