]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Incremental.c
Add --offroot argument to mdadm
[thirdparty/mdadm.git] / Incremental.c
index b5d3e02566f983a6fcf4de79abef0432c5d24fcc..60175af048ef86c42413e6d138eab87d64d3ee5f 100644 (file)
@@ -259,8 +259,7 @@ int Incremental(char *devname, int verbose, int runstop,
 
        name_to_use = info.name;
        if (name_to_use[0] == 0 &&
-           info.array.level == LEVEL_CONTAINER &&
-           trustworthy == LOCAL) {
+           info.array.level == LEVEL_CONTAINER) {
                name_to_use = info.text_version;
                trustworthy = METADATA;
        }
@@ -386,6 +385,12 @@ int Incremental(char *devname, int verbose, int runstop,
                        sprintf(dn, "%d:%d", sra->devs->disk.major,
                                sra->devs->disk.minor);
                        dfd2 = dev_open(dn, O_RDONLY);
+                       if (dfd2 < 0) {
+                               fprintf(stderr, Name
+                                       ": unable to open %s\n", devname);
+                               rv = 2;
+                               goto out_unlock;
+                       }
                        st2 = dup_super(st);
                        if (st2->ss->load_super(st2, dfd2, NULL) ||
                            st->ss->compare_super(st, st2) != 0) {
@@ -441,10 +446,12 @@ int Incremental(char *devname, int verbose, int runstop,
        if (info.array.level == LEVEL_CONTAINER) {
                int devnum = devnum; /* defined and used iff ->external */
                /* Try to assemble within the container */
+               sysfs_uevent(sra, "change");
                if (verbose >= 0)
                        fprintf(stderr, Name
-                               ": container %s now has %d devices\n",
-                               chosen_name, info.array.working_disks);
+                               ": container %s now has %d device%s\n",
+                               chosen_name, info.array.working_disks,
+                               info.array.working_disks==1?"":"s");
                wait_for(chosen_name, mdfd);
                if (st->ss->external)
                        devnum = fd2devnum(mdfd);
@@ -878,8 +885,10 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
                         * to obtain minimum spare size */
                        struct supertype *st3 = dup_super(st2);
                        int mdfd = open_dev(mp->devnum);
-                       if (!mdfd)
+                       if (mdfd < 0) {
+                               free(st3);
                                goto next;
+                       }
                        if (st3->ss->load_container &&
                            !st3->ss->load_container(st3, mdfd, mp->path)) {
                                component_size = st3->ss->min_acceptable_spare_size(st3);
@@ -1119,6 +1128,8 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
                        close(fd);
        }
 
+       closedir(dir);
+
        if (!chosen)
                return 1;
 
@@ -1319,6 +1330,7 @@ int IncrementalScan(int verbose)
                                        strerror(errno));
                                rv = 1;
                        }
+                       sysfs_free(sra);
                }
        }
        return rv;
@@ -1400,9 +1412,6 @@ static int Incremental_container(struct supertype *st, char *devname,
        /* when nothing to activate - quit */
        if (list == NULL)
                return 0;
-       if (map_lock(&map))
-               fprintf(stderr, Name ": failed to get exclusive lock on "
-                       "mapfile\n");
        for (ra = list ; ra ; ra = ra->next) {
                int mdfd;
                char chosen_name[1024];
@@ -1497,10 +1506,8 @@ static int Incremental_container(struct supertype *st, char *devname,
 
        /* don't move spares to container with volume being activated
           when all volumes are blocked */
-       if (ra_all == ra_blocked) {
-               map_unlock(&map);
+       if (ra_all == ra_blocked)
                return 0;
-       }
 
        /* Now move all suitable spares from spare container */
        domains = domain_from_array(list, st->ss->name);