]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Assemble: block attempts to reassemble container members
authorDan Williams <dan.j.williams@intel.com>
Tue, 4 Nov 2008 09:51:12 +0000 (20:51 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 4 Nov 2008 09:51:12 +0000 (20:51 +1100)
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>
Assemble.c

index 2fa574c8ab2302a1d3aeb66053332a053c2212ee..dc8adc1e432daecf0551f883bc8d51abec223683 100644 (file)
@@ -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,