]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super0.c
IMSM: retry reading sync_completed during reshape
[thirdparty/mdadm.git] / super0.c
index 85acf368d0a1ba9b33d3b71f052f1df625fdc7be..467a37373d83dda63fd46297a9b7e066c3e26b94 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -405,7 +405,8 @@ static void getinfo_super0(struct supertype *st, struct mdinfo *info, char *map)
        info->array.utime = sb->utime;
        info->array.chunk_size = sb->chunk_size;
        info->array.state = sb->state;
-       info->component_size = sb->size*2;
+       info->component_size = sb->size;
+       info->component_size *= 2;
 
        if (sb->state & (1<<MD_SB_BITMAP_PRESENT))
                info->bitmap_offset = 8;
@@ -713,7 +714,7 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info,
 
        if (posix_memalign((void**)&sb, 4096,
                           MD_SB_BYTES + ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
-               pr_err("%s could not allocate superblock\n", __func__);
+               pr_err("could not allocate superblock\n");
                return 0;
        }
        memset(sb, 0, MD_SB_BYTES + sizeof(bitmap_super_t));
@@ -805,9 +806,8 @@ static int add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
        dk->major = dinfo->major;
        dk->minor = dinfo->minor;
        dk->raid_disk = dinfo->raid_disk;
-       dk->state = dinfo->state;
-       /* In case our source disk was writemostly, don't copy that bit */
-       dk->state &= ~(1<<MD_DISK_WRITEMOSTLY);
+       dk->state = dinfo->state & ((1<<MD_DISK_ACTIVE) |
+                                   (1<<MD_DISK_SYNC));
 
        sb->this_disk = sb->disks[dinfo->number];
        sb->sb_csum = calc_sb0_csum(sb);
@@ -887,7 +887,7 @@ static int write_init_super0(struct supertype *st)
 
        for (di = st->info ; di && ! rv ; di = di->next) {
 
-               if (di->disk.state == 1)
+               if (di->disk.state & (1 << MD_DISK_FAULTY))
                        continue;
                if (di->fd == -1)
                        continue;
@@ -901,7 +901,7 @@ static int write_init_super0(struct supertype *st)
                rv = store_super0(st, di->fd);
 
                if (rv == 0 && (sb->state & (1<<MD_SB_BITMAP_PRESENT)))
-                       rv = st->ss->write_bitmap(st, di->fd);
+                       rv = st->ss->write_bitmap(st, di->fd, NoUpdate);
 
                if (rv)
                        pr_err("failed to write superblock to %s\n",
@@ -930,7 +930,7 @@ static int compare_super0(struct supertype *st, struct supertype *tst)
                if (posix_memalign((void**)&first, 4096,
                             MD_SB_BYTES +
                             ROUND_UP(sizeof(struct bitmap_super_s), 4096)) != 0) {
-                       pr_err("%s could not allocate superblock\n", __func__);
+                       pr_err("could not allocate superblock\n");
                        return 1;
                }
                memcpy(first, second, MD_SB_BYTES + sizeof(struct bitmap_super_s));
@@ -998,7 +998,7 @@ static int load_super0(struct supertype *st, int fd, char *devname)
        if (posix_memalign((void**)&super, 4096,
                           MD_SB_BYTES +
                           ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
-               pr_err("%s could not allocate superblock\n", __func__);
+               pr_err("could not allocate superblock\n");
                return 1;
        }
 
@@ -1139,7 +1139,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
                if (chunk < 64*1024*1024)
                        chunk = 64*1024*1024;
        } else if ((unsigned long long)chunk < min_chunk)
-               return 0; /* chunk size too small */
+               return -EINVAL; /* chunk size too small */
 
        sb->state |= (1<<MD_SB_BITMAP_PRESENT);
 
@@ -1153,19 +1153,19 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
        bms->sync_size = __cpu_to_le64(size);
        bms->write_behind = __cpu_to_le32(write_behind);
        *chunkp = chunk;
-       return 1;
+       return 0;
 }
 
-static void locate_bitmap0(struct supertype *st, int fd)
+static int locate_bitmap0(struct supertype *st, int fd, int node_num)
 {
        unsigned long long dsize;
        unsigned long long offset;
 
        if (!get_dev_size(fd, NULL, &dsize))
-               return;
+               return -1;
 
        if (dsize < MD_RESERVED_SECTORS*512)
-               return;
+               return -1;
 
        offset = MD_NEW_SIZE_SECTORS(dsize>>9);
 
@@ -1174,9 +1174,10 @@ static void locate_bitmap0(struct supertype *st, int fd)
        offset += MD_SB_BYTES;
 
        lseek64(fd, offset, 0);
+       return 0;
 }
 
-static int write_bitmap0(struct supertype *st, int fd)
+static int write_bitmap0(struct supertype *st, int fd, enum bitmap_update update)
 {
        unsigned long long dsize;
        unsigned long long offset;
@@ -1270,11 +1271,10 @@ static int validate_geometry0(struct supertype *st, int level,
        }
        if (size >= tbmax * 2ULL*1024*1024*1024) {
                if (verbose)
-                       pr_err("0.90 metadata supports at most "
-                              "%d terabytes per device\n", tbmax);
+                       pr_err("0.90 metadata supports at most %d terabytes per device\n", tbmax);
                return 0;
        }
-       if (chunk && *chunk == UnSet)
+       if (*chunk == UnSet)
                *chunk = DEFAULT_CHUNK;
 
        if (!subdev)