]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Grow.c
imsm: Remove --dump/--restore implementation
[thirdparty/mdadm.git] / Grow.c
diff --git a/Grow.c b/Grow.c
index 3ee015b7d20e136c162b765b0f19f96bb1baf552..764374fc2da4f38a3672389b6ed9dffad5614612 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -242,6 +242,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
                if (st->ss->load_super(st, fd2, NULL)) {
                        pr_err("cannot find super block on %s\n", dv);
                        close(fd);
+                       close(fd2);
                        return 1;
                }
                info.array.raid_disks = nd+1;
@@ -445,7 +446,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
                if (offset_setable) {
                        st->ss->getinfo_super(st, mdi, NULL);
                        if (sysfs_init(mdi, fd, NULL)) {
-                               pr_err("failed to intialize sysfs.\n");
+                               pr_err("failed to initialize sysfs.\n");
                                free(mdi);
                        }
                        rv = sysfs_set_num_signed(mdi, NULL, "bitmap/location",
@@ -753,7 +754,8 @@ static int check_idle(struct supertype *st)
        for (e = ent ; e; e = e->next) {
                if (!is_container_member(e, container))
                        continue;
-               if (e->percent >= 0) {
+               /* frozen array is not idle*/
+               if (e->percent >= 0 || e->metadata_version[9] == '-') {
                        is_idle = 0;
                        break;
                }
@@ -1194,7 +1196,8 @@ unsigned long compute_backup_blocks(int nchunk, int ochunk,
        /* Find GCD */
        a = GCD(a, b);
        /* LCM == product / GCD */
-       blocks = (ochunk/512) * (nchunk/512) * odata * ndata / a;
+       blocks = (unsigned long)(ochunk/512) * (unsigned long)(nchunk/512) *
+               odata * ndata / a;
 
        return blocks;
 }
@@ -1794,6 +1797,11 @@ int Grow_reshape(char *devname, int fd,
                        devname);
                return 1;
        }
+       if (s->level != UnSet && s->chunk) {
+               pr_err("Cannot change array level in the same operation as changing chunk size.\n");
+               return 1;
+       }
+
        if (data_offset != INVALID_SECTORS && array.level != 10 &&
            (array.level < 4 || array.level > 6)) {
                pr_err("--grow --data-offset not yet supported\n");
@@ -1816,7 +1824,7 @@ int Grow_reshape(char *devname, int fd,
        }
 
        if (array.level > 1 && s->size > 1 &&
-           (array.chunk_size / 1024) > (int)s->size) {
+           (unsigned long long) (array.chunk_size / 1024) > s->size) {
                pr_err("component size must be larger than chunk size.\n");
                return 1;
        }
@@ -2170,7 +2178,7 @@ size_change_error:
        memset(&info, 0, sizeof(info));
        info.array = array;
        if (sysfs_init(&info, fd, NULL)) {
-               pr_err("failed to intialize sysfs.\n");
+               pr_err("failed to initialize sysfs.\n");
                rv = 1;
                goto release;
        }
@@ -2605,8 +2613,8 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
                                        goto release;
                                }
                                if (data_offset != INVALID_SECTORS &&
-                                   data_offset < sd->data_offset - min) {
-                                       pr_err("--data-offset too small on %s\n",
+                                   data_offset > sd->data_offset - min) {
+                                       pr_err("--data-offset too large on %s\n",
                                                dn);
                                        goto release;
                                }
@@ -2895,7 +2903,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
        struct mdinfo info;
 
        if (sysfs_init(&info, fd, NULL)) {
-               pr_err("failed to intialize sysfs.\n");
+               pr_err("failed to initialize sysfs.\n");
                return  1;
        }
 
@@ -3278,7 +3286,7 @@ static int reshape_array(char *container, int fd, char *devname,
                                goto release;
                        } else if (verbose >= 0)
                                printf("chunk size for %s set to %d\n",
-                                      devname, array.chunk_size);
+                                      devname, info->new_chunk);
                }
                unfreeze(st);
                return 0;