From 4b3644ab4ce6df8c7f64c189c12b66627ff3e027 Mon Sep 17 00:00:00 2001 From: Mariusz Tkaczyk Date: Fri, 5 Jul 2024 10:49:27 +0200 Subject: mdstat: Rework mdstat external arrays handling To avoid repeating mdstat_read() in IncrementalRemove(), new function mdstat_find_by_member_name() has been proposed. With that, IncrementalRemove() handles own copy of mdstat content and there is no need to repeat reading for external stop. Additionally, It proposed few helper to avoid repeating mdstat_ent->metadata_version checks across code. Signed-off-by: Mariusz Tkaczyk --- mapfile.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'mapfile.c') diff --git a/mapfile.c b/mapfile.c index ea9837ac..632cf5e8 100644 --- a/mapfile.c +++ b/mapfile.c @@ -339,18 +339,14 @@ struct map_ent *map_by_name(struct map_ent **map, char *name) */ static char *get_member_info(struct mdstat_ent *ent) { + char *subarray; - if (ent->metadata_version == NULL || - strncmp(ent->metadata_version, "external:", 9) != 0) + if (!is_mdstat_ent_subarray(ent)) return NULL; - if (is_subarray(&ent->metadata_version[9])) { - char *subarray; + subarray = strrchr(ent->metadata_version, '/'); - subarray = strrchr(ent->metadata_version, '/'); - return subarray + 1; - } - return NULL; + return subarray + 1; } void RebuildMap(void) -- cgit v1.2.3