]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - monitor.c
imsm: fix up compare_super_imsm() to match family_num for populated mpb's
[thirdparty/mdadm.git] / monitor.c
index ffb4c9c48dc7e439cc1da352949f6c2aa6032f5b..45b5d5b5551bfa91e0ef80359ea088b471567aaf 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -238,22 +238,20 @@ static int read_and_act(struct active_array *a)
        }
 
        if (a->curr_state == readonly) {
-               /* Well, I'm ready to handle things, so
-                * read-auto is OK. FIXME what if we really want
-                * readonly ???
+               /* Well, I'm ready to handle things.  If readonly
+                * wasn't requested, transition to read-auto.
                 */
-               get_resync_start(a);
-               if (a->resync_start == ~0ULL) {
-                       a->next_state = read_auto; /* array is clean */
-                       /* give the metadata a chance to force active if
-                        * we have some recovery to do.  metadata sets
-                        * resync_start to !MaxSector in this case
-                        */
-                       a->container->ss->set_array_state(a, 1);
-               }
-               if (a->resync_start != ~0ULL) {
-                       a->container->ss->set_array_state(a, 0);
-                       a->next_state = active;
+               char buf[64];
+               read_attr(buf, sizeof(buf), a->metadata_fd);
+               if (strncmp(buf, "external:-", 10) == 0) {
+                       /* explicit request for readonly array.  Leave it alone */
+                       ;
+               } else {
+                       get_resync_start(a);
+                       if (a->container->ss->set_array_state(a, 2))
+                               a->next_state = read_auto; /* array is clean */
+                       else
+                               a->next_state = active; /* Now active for recovery etc */
                }
        }