]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super0.c
DDF: getinfo_super_ddf_bvd: fix offset calculation for SVDs
[thirdparty/mdadm.git] / super0.c
index 01c31c27b7ce731129397d5b4821d83067d4be17..e7d86d87f7e09a520741e0613db16342e4a7f5c4 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -36,7 +36,6 @@
  * .. other stuff
  */
 
-
 static unsigned long calc_sb0_csum(mdp_super_t *super)
 {
        unsigned long csum = super->sb_csum;
@@ -645,6 +644,38 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                        uuid_from_super0(st, info->uuid);
                        st->other = super1_make_v0(st, info, st->sb);
                }
+       } else if (strcmp(update, "revert-reshape") == 0) {
+               rv = -2;
+               if (sb->minor_version <= 90)
+                       pr_err("No active reshape to revert on %s\n",
+                              devname);
+               else if (sb->delta_disks == 0)
+                       pr_err("%s: Can only revert reshape which changes number of devices\n",
+                              devname);
+               else {
+                       int tmp;
+                       int parity = sb->level == 6 ? 2 : 1;
+                       rv = 0;
+
+                       if (sb->level >= 4 && sb->level <= 6 &&
+                           sb->reshape_position % (
+                                   sb->new_chunk/512 *
+                                   (sb->raid_disks - sb->delta_disks - parity))) {
+                               pr_err("Reshape position is not suitably aligned.\n");
+                               pr_err("Try normal assembly as stop again\n");
+                               return -2;
+                       }
+                       sb->raid_disks -= sb->delta_disks;
+                       sb->delta_disks = -sb->delta_disks;
+
+                       tmp = sb->new_layout;
+                       sb->new_layout = sb->layout;
+                       sb->layout = tmp;
+
+                       tmp = sb->new_chunk;
+                       sb->new_chunk = sb->chunk_size;
+                       sb->chunk_size = tmp;
+               }
        } else if (strcmp(update, "no-bitmap") == 0) {
                sb->state &= ~(1<<MD_SB_BITMAP_PRESENT);
        } else if (strcmp(update, "_reshape_progress")==0)
@@ -668,7 +699,6 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
  * host name
  */
 
-
 static int init_super0(struct supertype *st, mdu_array_info_t *info,
                       unsigned long long size, char *ignored_name, char *homehost,
                       int *uuid, unsigned long long data_offset)
@@ -810,7 +840,7 @@ static int store_super0(struct supertype *st, int fd)
 
        if (st->other) {
                /* Writing out v1.0 metadata for --update=metadata */
-               int ret;
+               int ret = 0;
 
                offset = dsize/512 - 8*2;
                offset &= ~(4*2-1);
@@ -839,7 +869,7 @@ static int store_super0(struct supertype *st, int fd)
        if (super->state & (1<<MD_SB_BITMAP_PRESENT)) {
                struct bitmap_super_s * bm = (struct bitmap_super_s*)(super+1);
                if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC)
-                       if (write(fd, bm, ROUND_UP(sizeof(*bm),4096)) != 
+                       if (write(fd, bm, ROUND_UP(sizeof(*bm),4096)) !=
                            ROUND_UP(sizeof(*bm),4096))
                            return 5;
        }
@@ -898,7 +928,7 @@ static int compare_super0(struct supertype *st, struct supertype *tst)
                return 1;
        if (!first) {
                if (posix_memalign((void**)&first, 4096,
-                            MD_SB_BYTES + 
+                            MD_SB_BYTES +
                             ROUND_UP(sizeof(struct bitmap_super_s), 4096)) != 0) {
                        pr_err("%s could not allocate superblock\n", __func__);
                        return 1;
@@ -925,7 +955,6 @@ static int compare_super0(struct supertype *st, struct supertype *tst)
        return 0;
 }
 
-
 static void free_super0(struct supertype *st);
 
 static int load_super0(struct supertype *st, int fd, char *devname)
@@ -1096,7 +1125,6 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
        bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + MD_SB_BYTES);
        int uuid[4];
 
-
        min_chunk = 4096; /* sub-page chunks don't work yet.. */
        bits = (size * 512) / min_chunk + 1;
        while (bits > max_bits) {
@@ -1128,7 +1156,6 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
        return 1;
 }
 
-
 static void locate_bitmap0(struct supertype *st, int fd)
 {
        unsigned long long dsize;