]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super0.c
Merge branch 'master' in devel-3.0
[thirdparty/mdadm.git] / super0.c
index 924d75d3e7692def4996b4de811191331d1bae06..18e1d45eed5e5c4b651b44bc9a5b5f60a3f66af8 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -93,7 +93,7 @@ static void examine_super0(struct supertype *st, char *homehost)
        char *c;
 
        printf("          Magic : %08x\n", sb->md_magic);
-       printf("        Version : %02d.%02d.%02d\n", sb->major_version, sb->minor_version,
+       printf("        Version : %d.%02d.%02d\n", sb->major_version, sb->minor_version,
               sb->patch_version);
        if (sb->minor_version >= 90) {
                printf("           UUID : %08x:%08x:%08x:%08x", sb->set_uuid0, sb->set_uuid1,
@@ -545,7 +545,8 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info,
        mdp_super_t *sb;
        int spares;
 
-       if (posix_memalign((void**)&sb, 512, MD_SB_BYTES + sizeof(bitmap_super_t)) != 0) {
+       if (posix_memalign((void**)&sb, 4096,
+                          MD_SB_BYTES + ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
                fprintf(stderr, Name ": %s could not allocate superblock\n", __func__);
                return 0;
        }
@@ -627,7 +628,7 @@ struct devinfo {
 
 #ifndef MDASSEMBLE
 /* Add a device to the superblock being created */
-static void add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
+static int add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
                          int fd, char *devname)
 {
        mdp_super_t *sb = st->sb;
@@ -652,6 +653,8 @@ static void add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
        di->disk = *dinfo;
        di->next = NULL;
        *dip = di;
+
+       return 0;
 }
 #endif
 
@@ -680,8 +683,8 @@ 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),512)) != 
-                           ROUND_UP(sizeof(*bm),512))
+                       if (write(fd, bm, ROUND_UP(sizeof(*bm),4096)) != 
+                           ROUND_UP(sizeof(*bm),4096))
                            return 5;
        }
 
@@ -741,8 +744,9 @@ static int compare_super0(struct supertype *st, struct supertype *tst)
        if (second->md_magic != MD_SB_MAGIC)
                return 1;
        if (!first) {
-               if (posix_memalign((void**)&first, 512, 
-                              MD_SB_BYTES + sizeof(struct bitmap_super_s)) != 0) {
+               if (posix_memalign((void**)&first, 4096,
+                            MD_SB_BYTES + 
+                            ROUND_UP(sizeof(struct bitmap_super_s), 4096)) != 0) {
                        fprintf(stderr, Name
                                ": %s could not allocate superblock\n", __func__);
                        return 1;
@@ -815,8 +819,9 @@ static int load_super0(struct supertype *st, int fd, char *devname)
                return 1;
        }
 
-       if (posix_memalign((void**)&super, 512,
-                          MD_SB_BYTES + sizeof(bitmap_super_t)+512) != 0) {
+       if (posix_memalign((void**)&super, 4096,
+                          MD_SB_BYTES +
+                          ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
                fprintf(stderr, Name
                        ": %s could not allocate superblock\n", __func__);
                return 1;
@@ -864,8 +869,8 @@ static int load_super0(struct supertype *st, int fd, char *devname)
         * valid.  If it doesn't clear the bit.  An --assemble --force
         * should get that written out.
         */
-       if (read(fd, super+1, ROUND_UP(sizeof(struct bitmap_super_s),512))
-           != ROUND_UP(sizeof(struct bitmap_super_s),512))
+       if (read(fd, super+1, ROUND_UP(sizeof(struct bitmap_super_s),4096))
+           != ROUND_UP(sizeof(struct bitmap_super_s),4096))
                goto no_bitmap;
 
        uuid_from_super0(st, uuid);
@@ -996,8 +1001,8 @@ static int write_bitmap0(struct supertype *st, int fd)
        int rv = 0;
 
        int towrite, n;
-       char abuf[4096+512];
-       char *buf = (char*)(((long)(abuf+512))&~511UL);
+       char abuf[4096+4096];
+       char *buf = (char*)(((long)(abuf+4096))&~4095L);
 
        if (!get_dev_size(fd, NULL, &dsize))
                return 1;
@@ -1055,7 +1060,7 @@ static int validate_geometry0(struct supertype *st, int level,
                return 0;
        if (raiddisks > MD_SB_DISKS)
                return 0;
-       if (size > (0x7fffffffULL<<10))
+       if (size > (0x7fffffffULL<<9))
                return 0;
        if (!subdev)
                return 1;
@@ -1076,7 +1081,7 @@ static int validate_geometry0(struct supertype *st, int level,
 
        if (ldsize < MD_RESERVED_SECTORS * 512)
                return 0;
-       if (size > (0x7fffffffULL<<10))
+       if (size > (0x7fffffffULL<<9))
                return 0;
        *freesize = MD_NEW_SIZE_SECTORS(ldsize >> 9);
        return 1;
@@ -1108,4 +1113,5 @@ struct superswitch super0 = {
        .locate_bitmap = locate_bitmap0,
        .write_bitmap = write_bitmap0,
        .free_super = free_super0,
+       .name = "0.90",
 };