summaryrefslogtreecommitdiffstats
path: root/mapfile.c
diff options
context:
space:
mode:
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-07-05 10:49:27 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-07-30 16:00:37 +0200
commit4b3644ab4ce6df8c7f64c189c12b66627ff3e027 (patch)
treefe1a8996f70da8f1f8f3680c3fc5b7c4c6978402 /mapfile.c
parentreview.yml: fix typo in DEBIAN compiler flag (diff)
downloadmdadm-4b3644ab4ce6df8c7f64c189c12b66627ff3e027.tar.xz
mdadm-4b3644ab4ce6df8c7f64c189c12b66627ff3e027.zip
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 <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'mapfile.c')
-rw-r--r--mapfile.c12
1 files changed, 4 insertions, 8 deletions
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)