]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super0.c
FIX: Remove disks in mdmon for external metadata
[thirdparty/mdadm.git] / super0.c
index 1fcdd24c37526e4adf1da065435458d39bc66b14..0b95dac214c73c34bf64d6bcf704a51395cd50f7 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -418,8 +418,9 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                         char *devname, int verbose,
                         int uuid_set, char *homehost)
 {
-       /* NOTE: for 'assemble' and 'force' we need to return non-zero if any change was made.
-        * For others, the return value is ignored.
+       /* NOTE: for 'assemble' and 'force' we need to return non-zero
+        * if any change was made.  For others, the return value is
+        * ignored.
         */
        int rv = 0;
        mdp_super_t *sb = st->sb;
@@ -548,6 +549,8 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                        bm = (struct bitmap_super_s*)(sb+1);
                        uuid_from_super0(st, (int*)bm->uuid);
                }
+       } else if (strcmp(update, "no-bitmap") == 0) {
+               sb->state &= ~(1<<MD_SB_BITMAP_PRESENT);
        } else if (strcmp(update, "_reshape_progress")==0)
                sb->reshape_position = info->reshape_progress;
        else
@@ -749,8 +752,6 @@ static int write_init_super0(struct supertype *st)
                        fprintf(stderr,
                                Name ": failed to write superblock to %s\n",
                                di->devname);
-               close(di->fd);
-               di->fd = -1;
        }
        return rv;
 }
@@ -1076,6 +1077,13 @@ static void free_super0(struct supertype *st)
 {
        if (st->sb)
                free(st->sb);
+       while (st->info) {
+               struct devinfo *di = st->info;
+               st->info = di->next;
+               if (di->fd >= 0)
+                       close(di->fd);
+               free(di);
+       }
        st->sb = NULL;
 }