]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: retry load_and_parse_mpb if we suspect mdmon has made modifications
authorArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Mon, 2 Jun 2014 13:02:59 +0000 (15:02 +0200)
committerNeilBrown <neilb@suse.de>
Mon, 2 Jun 2014 23:09:41 +0000 (09:09 +1000)
If the checksum verification fails in mdadm and mdmon is running, retry
the load to get a consistent snapshot of the mpb.

Based on db575f3b

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
super-intel.c

index f0a7ab5ccc7abe44e103de4b8b64edd5679f7d5a..9dd807ac3201bcff23b7ed50db5f543607408e64 100644 (file)
@@ -4422,6 +4422,7 @@ static int load_super_imsm(struct supertype *st, int fd, char *devname)
 {
        struct intel_super *super;
        int rv;
+       int retry;
 
        if (test_partition(fd))
                /* IMSM not allowed on partitions */
@@ -4444,6 +4445,22 @@ static int load_super_imsm(struct supertype *st, int fd, char *devname)
        }
        rv = load_and_parse_mpb(fd, super, devname, 0);
 
+       /* retry the load if we might have raced against mdmon */
+       if (rv == 3) {
+               struct mdstat_ent *mdstat = mdstat_by_component(fd2devnm(fd));
+
+               if (mdstat && mdmon_running(mdstat->devnm) && getpid() != mdmon_pid(mdstat->devnm)) {
+                       for (retry = 0; retry < 3; retry++) {
+                               usleep(3000);
+                               rv = load_and_parse_mpb(fd, super, devname, 0);
+                               if (rv != 3)
+                                       break;
+                       }
+               }
+
+               free_mdstat(mdstat);
+       }
+
        if (rv) {
                if (devname)
                        pr_err("Failed to load all information "