]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super0.c
mdadm.man: added encouragement to shrink filesystem before array.
[thirdparty/mdadm.git] / super0.c
index b8dfdb44eb3723aaf4549c840a2a8c6f85f397ca..e855541369e797db7a420c2000bdf27c65a71229 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -113,7 +113,7 @@ static void examine_super0(struct supertype *st, char *homehost)
        printf("  Creation Time : %.24s\n", ctime(&atime));
        c=map_num(pers, sb->level);
        printf("     Raid Level : %s\n", c?c:"-unknown-");
-       if ((int)sb->level >= 0) {
+       if ((int)sb->level > 0) {
                int ddsks=0;
                printf("  Used Dev Size : %d%s\n", sb->size,
                       human_size((long long)sb->size<<10));
@@ -389,7 +389,7 @@ static void getinfo_super0(struct supertype *st, struct mdinfo *info)
        /* work_disks is calculated rather than read directly */
        for (i=0; i < MD_SB_DISKS; i++)
                if ((sb->disks[i].state & (1<<MD_DISK_SYNC)) &&
-                   (sb->disks[i].raid_disk < info->array.raid_disks) &&
+                   (sb->disks[i].raid_disk < (unsigned)info->array.raid_disks) &&
                    (sb->disks[i].state & (1<<MD_DISK_ACTIVE)) &&
                    !(sb->disks[i].state & (1<<MD_DISK_FAULTY)))
                        working ++;
@@ -402,8 +402,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;
@@ -427,7 +428,7 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                                devname, info->array.md_minor);
        }
        if (strcmp(update, "summaries") == 0) {
-               int i;
+               unsigned int i;
                /* set nr_disks, active_disks, working_disks,
                 * failed_disks, spare_disks based on disks[]
                 * array in superblock.
@@ -487,10 +488,24 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                         */
                        add = (1<<MD_DISK_SYNC);
                if (((sb->disks[d].state & ~mask) | add)
-                   != info->disk.state) {
+                   != (unsigned)info->disk.state) {
                        sb->disks[d].state = info->disk.state | wonly;
                        rv = 1;
                }
+               if (info->reshape_active &&
+                   sb->minor_version > 90 && (sb->reshape_position+1) != 0 &&
+                   info->delta_disks >= 0 &&
+                   info->reshape_progress < sb->reshape_position) {
+                       sb->reshape_position = info->reshape_progress;
+                       rv = 1;
+               }
+               if (info->reshape_active &&
+                   sb->minor_version > 90 && (sb->reshape_position+1) != 0 &&
+                   info->delta_disks < 0 &&
+                   info->reshape_progress > sb->reshape_position) {
+                       sb->reshape_position = info->reshape_progress;
+                       rv = 1;
+               }
        }
        if (strcmp(update, "linear-grow-new") == 0) {
                memset(&sb->disks[info->disk.number], 0, sizeof(sb->disks[0]));
@@ -542,6 +557,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);
        }
        if (strcmp(update, "_reshape_progress")==0)
                sb->reshape_position = info->reshape_progress;
@@ -593,7 +610,7 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info,
        sb->gvalid_words = 0; /* ignored */
        sb->ctime = time(0);
        sb->level = info->level;
-       if (size != info->size)
+       if (size != (unsigned long long)info->size)
                return 0;
        sb->size = info->size;
        sb->nr_disks = info->nr_disks;
@@ -982,7 +999,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
                chunk = min_chunk;
                if (chunk < 64*1024*1024)
                        chunk = 64*1024*1024;
-       } else if (chunk < min_chunk)
+       } else if ((unsigned long long)chunk < min_chunk)
                return 0; /* chunk size too small */
 
        sb->state |= (1<<MD_SB_BITMAP_PRESENT);