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) +
/* 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)))
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);
unsigned long long data_offset;
for (di = st->info; di; di = di->next) {
- if (di->disk.state == 1)
+ if (di->disk.state & (1 << MD_DISK_FAULTY))
continue;
if (di->fd < 0)
continue;
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);
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);
}
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;
}
* 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)
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);
/* 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.. */