]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Incremental.c
sysfs: Use the presence of /sys/block/<dev>/md as indicator of valid device
[thirdparty/mdadm.git] / Incremental.c
index 75d95ccc497a4a3c7fcb364b15a71cc9478b6238..802e5255d3389c74f00aef55a00c549ee31db926 100644 (file)
@@ -398,7 +398,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
                    && ! policy_action_allows(policy, st->ss->name,
                                              act_re_add)
                    && c->runstop < 1) {
-                       if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+                       if (md_get_array_info(mdfd, &ainf) == 0) {
                                pr_err("not adding %s to active array (without --run) %s\n",
                                       devname, chosen_name);
                                rv = 2;
@@ -528,6 +528,9 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
 
        journal_device_missing = (info.journal_device_required) && (info.journal_clean == 0);
 
+       if (info.consistency_policy == CONSISTENCY_POLICY_PPL)
+               info.array.state |= 1;
+
        if (enough(info.array.level, info.array.raid_disks,
                   info.array.layout, info.array.state & 1,
                   avail) == 0) {
@@ -546,7 +549,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
        /*   + add any bitmap file  */
        /*   + start the array (auto-readonly). */
 
-       if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+       if (md_get_array_info(mdfd, &ainf) == 0) {
                if (c->export) {
                        printf("MD_STARTED=already\n");
                } else if (c->verbose >= 0)
@@ -661,7 +664,7 @@ static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
        struct mdinfo *d;
        mdu_array_info_t ra;
 
-       if (ioctl(mdfd, GET_ARRAY_INFO, &ra) == 0)
+       if (md_get_array_info(mdfd, &ra) == 0)
                return; /* not safe to remove from active arrays
                         * without thinking more */
 
@@ -834,7 +837,7 @@ static int container_members_max_degradation(struct map_ent *map, struct map_ent
                if (afd < 0)
                        continue;
                /* most accurate information regarding array degradation */
-               if (ioctl(afd, GET_ARRAY_INFO, &array) >= 0) {
+               if (md_get_array_info(afd, &array) >= 0) {
                        int degraded = array.raid_disks - array.active_disks -
                                       array.spare_disks;
                        if (degraded > max_degraded)
@@ -1034,8 +1037,8 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
                        char chosen_devname[24]; // 2*11 for int (including signs) + colon + null
                        devlist.next = NULL;
                        devlist.used = 0;
-                       devlist.writemostly = 0;
-                       devlist.failfast = 0;
+                       devlist.writemostly = FlagDefault;
+                       devlist.failfast = FlagDefault;
                        devlist.devname = chosen_devname;
                        sprintf(chosen_devname, "%d:%d", major(stb.st_rdev),
                                minor(stb.st_rdev));
@@ -1342,7 +1345,6 @@ int IncrementalScan(struct context *c, char *devnm)
 restart:
        for (me = mapl ; me ; me = me->next) {
                mdu_array_info_t array;
-               mdu_bitmap_file_t bmf;
                struct mdinfo *sra;
                int mdfd;
 
@@ -1387,8 +1389,7 @@ restart:
                                rv = 1;
                        continue;
                }
-               if (ioctl(mdfd, GET_ARRAY_INFO, &array) == 0 ||
-                   errno != ENODEV) {
+               if (md_get_array_info(mdfd, &array) == 0 || errno != ENODEV) {
                        close(mdfd);
                        continue;
                }
@@ -1403,13 +1404,12 @@ restart:
                         * is a hint only
                         */
                        int added = -1;
-                       if (ioctl(mdfd, GET_ARRAY_INFO, &bmf) < 0) {
-                               int bmfd = open(mddev->bitmap_file, O_RDWR);
-                               if (bmfd >= 0) {
-                                       added = ioctl(mdfd, SET_BITMAP_FILE,
-                                                     bmfd);
-                                       close(bmfd);
-                               }
+                       int bmfd;
+
+                       bmfd = open(mddev->bitmap_file, O_RDWR);
+                       if (bmfd >= 0) {
+                               added = ioctl(mdfd, SET_BITMAP_FILE, bmfd);
+                               close(bmfd);
                        }
                        if (c->verbose >= 0) {
                                if (added == 0)