]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Monitor.c
Assemble: allow members of containers to be assembled and auto-assembled.
[thirdparty/mdadm.git] / Monitor.c
index 8d8939cef7ad190def2619e6d3f6acb4f51512f2..0e2e6bc7011ceeec31c929c480c74186616299e8 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -165,7 +165,10 @@ int Monitor(mddev_dev_t devlist,
        if (devlist == NULL) {
                mddev_ident_t mdlist = conf_get_ident(NULL);
                for (; mdlist; mdlist=mdlist->next) {
-                       struct state *st = malloc(sizeof *st);
+                       struct state *st;
+                       if (mdlist->devname == NULL)
+                               continue;
+                       st = malloc(sizeof *st);
                        if (st == NULL)
                                continue;
                        st->devname = strdup(mdlist->devname);
@@ -632,7 +635,7 @@ int Wait(char *dev)
 static char *clean_states[] = {
        "clear", "inactive", "readonly", "read-auto", "clean", NULL };
 
-int WaitClean(char *dev)
+int WaitClean(char *dev, int verbose)
 {
        int fd;
        struct mdinfo *mdi;
@@ -641,15 +644,17 @@ int WaitClean(char *dev)
 
        fd = open(dev, O_RDONLY); 
        if (fd < 0) {
-               fprintf(stderr, Name ": Couldn't open %s: %s\n", dev, strerror(errno));
+               if (verbose)
+                       fprintf(stderr, Name ": Couldn't open %s: %s\n", dev, strerror(errno));
                return 1;
        }
 
        devnum = fd2devnum(fd);
        mdi = sysfs_read(fd, devnum, GET_VERSION|GET_LEVEL|GET_SAFEMODE);
        if (!mdi) {
-               fprintf(stderr, Name ": Failed to read sysfs attributes for "
-                       "%s\n", dev);
+               if (verbose)
+                       fprintf(stderr, Name ": Failed to read sysfs attributes for "
+                               "%s\n", dev);
                close(fd);
                return 0;
        }
@@ -686,6 +691,9 @@ int WaitClean(char *dev)
                tm.tv_sec = 5;
                tm.tv_usec = 0;
 
+               /* give mdmon a chance to checkpoint resync */
+               sysfs_set_str(mdi, NULL, "sync_action", "idle");
+
                FD_ZERO(&fds);
 
                /* wait for array_state to be clean */
@@ -711,7 +719,7 @@ int WaitClean(char *dev)
                        rv = 0;
                } else
                        rv = 1;
-               if (rv)
+               if (rv && verbose)
                        fprintf(stderr, Name ": Error waiting for %s to be clean\n",
                                dev);