]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super1.c
Consistently print program Name and __func__ in debug messages.
[thirdparty/mdadm.git] / super1.c
index 7fba9be0a252a868a579f732fc4bd8a39d503797..0fd84e25bfde2fbfd1f5fb814f0d1e42bd7c57f8 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -811,7 +811,7 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
 
        size = __le32_to_cpu(sb->bblog_size)* 512;
        if (posix_memalign((void**)&bbl, 4096, size) != 0) {
-               pr_err("%s could not allocate badblocks list\n", __func__);
+               pr_err("could not allocate badblocks list\n");
                return 0;
        }
        offset = __le64_to_cpu(sb->super_offset) +
@@ -1245,12 +1245,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
                /* set data_size to device size less data_offset */
                struct misc_dev_info *misc = (struct misc_dev_info*)
                        (st->sb + MAX_SB_SIZE + BM_SUPER_SIZE);
-               printf("Size was %llu\n", (unsigned long long)
-                      __le64_to_cpu(sb->data_size));
                sb->data_size = __cpu_to_le64(
                        misc->device_size - __le64_to_cpu(sb->data_offset));
-               printf("Size is %llu\n", (unsigned long long)
-                      __le64_to_cpu(sb->data_size));
        } else if (strcmp(update, "revert-reshape") == 0) {
                rv = -2;
                if (!(sb->feature_map & __cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE)))
@@ -1332,7 +1328,7 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
        int sbsize;
 
        if (posix_memalign((void**)&sb, 4096, SUPER1_SIZE) != 0) {
-               pr_err("%s could not allocate superblock\n", __func__);
+               pr_err("could not allocate superblock\n");
                return 0;
        }
        memset(sb, 0, SUPER1_SIZE);
@@ -1688,6 +1684,10 @@ static int write_init_super1(struct supertype *st)
                        rv = -EINVAL;
                        goto out;
                }
+               if (conf_get_create_info()->bblist == 0) {
+                       sb->bblog_size = 0;
+                       sb->bblog_offset = 0;
+               }
 
                sb->sb_csum = calc_sb_1_csum(sb);
                rv = store_super1(st, di->fd);
@@ -1726,7 +1726,7 @@ static int compare_super1(struct supertype *st, struct supertype *tst)
 
        if (!first) {
                if (posix_memalign((void**)&first, 4096, SUPER1_SIZE) != 0) {
-                       pr_err("%s could not allocate superblock\n", __func__);
+                       pr_err("could not allocate superblock\n");
                        return 1;
                }
                memcpy(first, second, SUPER1_SIZE);
@@ -1837,8 +1837,7 @@ static int load_super1(struct supertype *st, int fd, char *devname)
        }
 
        if (posix_memalign((void**)&super, 4096, SUPER1_SIZE) != 0) {
-               pr_err("%s could not allocate superblock\n",
-                       __func__);
+               pr_err("could not allocate superblock\n");
                return 1;
        }
 
@@ -2044,8 +2043,8 @@ add_internal_bitmap1(struct supertype *st,
                         * been left.
                         */
                        offset = 0;
-                       room = choose_bm_space(__le64_to_cpu(sb->size));
                        bbl_size = 8;
+                       room = choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size;
                } else {
                        room = __le64_to_cpu(sb->super_offset)
                                - __le64_to_cpu(sb->data_offset)
@@ -2071,8 +2070,8 @@ add_internal_bitmap1(struct supertype *st,
        case 2: /* between superblock and data */
                if (creating) {
                        offset = 4*2;
-                       room = choose_bm_space(__le64_to_cpu(sb->size));
                        bbl_size = 8;
+                       room = choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size;
                } else {
                        room = __le64_to_cpu(sb->data_offset)
                                - __le64_to_cpu(sb->super_offset);
@@ -2101,6 +2100,10 @@ add_internal_bitmap1(struct supertype *st,
                /* Limit to 128K of bitmap when chunk size not requested */
                room = 128*2;
 
+       if (room <= 1)
+               /* No room for a bitmap */
+               return 0;
+
        max_bits = (room * 512 - sizeof(bitmap_super_t)) * 8;
 
        min_chunk = 4096; /* sub-page chunks don't work yet.. */