diff options
author | Dan Williams <dan.j.williams@intel.com> | 2008-11-04 20:51:12 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2008-11-04 20:51:12 +1100 |
commit | 2de8884f0f3676cd170727b5161701a20e44f458 (patch) | |
tree | d45a62981c94eb7d463423cdb87fb8f58bc5256d /Assemble.c | |
parent | 6234c63ccc136a66be341c6bdc42eadc08c285d1 (diff) | |
download | mdadm-2de8884f0f3676cd170727b5161701a20e44f458.tar.gz mdadm-2de8884f0f3676cd170727b5161701a20e44f458.tar.xz mdadm-2de8884f0f3676cd170727b5161701a20e44f458.zip |
Assemble: block attempts to reassemble container members
Attempting to open(O_EXCL) each candidate device usually filters out all
busy raid components. However, containers do not behave like components
and will return container_content that may describe active member
arrays.
This patch just adds a function that will be used to check if a
container member is busy. It will be used shortly.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Assemble.c')
-rw-r--r-- | Assemble.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -50,6 +50,31 @@ static int name_matches(char *found, char *required, char *homehost) return 0; } +/*static */ int is_member_busy(char *metadata_version) +{ + /* check if the given member array is active */ + struct mdstat_ent *mdstat = mdstat_read(1, 0); + struct mdstat_ent *ent; + int busy = 0; + + for (ent = mdstat; ent; ent = ent->next) { + if (ent->metadata_version == NULL) + continue; + if (strncmp(ent->metadata_version, "external:", 9) != 0) + continue; + if (!is_subarray(&ent->metadata_version[9])) + continue; + /* Skip first char - it can be '/' or '-' */ + if (strcmp(&ent->metadata_version[10], metadata_version+1) == 0) { + busy = 1; + break; + } + } + free_mdstat(mdstat); + + return busy; +} + int Assemble(struct supertype *st, char *mddev, mddev_ident_t ident, mddev_dev_t devlist, char *backup_file, |