mdu_disk_info_t *dinfo, char *devname)
{
struct mdp_superblock_1 *sb = sbv;
- struct mdp_superblock_1 *refsb = NULL;
+ void *refsbv = NULL;
int fd = open(devname, O_RDWR | O_EXCL);
int rfd;
int rv;
if (rfd >= 0) close(rfd);
sb->events = 0;
- if (load_super1(st, fd, (void**)&refsb, NULL)==0) {
+ if (load_super1(st, fd, &refsbv, NULL)==0) {
+ struct mdp_superblock_1 *refsb = refsbv;
+
memcpy(sb->device_uuid, refsb->device_uuid, 16);
if (memcmp(sb->set_uuid, refsb->set_uuid, 16)==0) {
/* same array, so preserve events and dev_number */
static int
add_internal_bitmap1(struct supertype *st, void *sbv,
- int chunk, int delay, int write_behind, int *sizep, int may_change)
+ int chunk, int delay, int write_behind, unsigned long long size, int may_change, int major)
{
/*
* If not may_change, then this is a 'Grow', and the bitmap
* before the superblock if we like, or may move the start.
* For now, just squeeze the bitmap into 3k and don't change anything.
*
- * size is in K, chunk is in bytes !!!
+ * size is in sectors, chunk is in bytes !!!
*/
- unsigned long long size = *sizep;
unsigned long long bits;
unsigned long long max_bits = (3*512 - sizeof(bitmap_super_t)) * 8;
unsigned long long min_chunk;
min_chunk = 4096; /* sub-page chunks don't work yet.. */
- bits = (size*1024)/min_chunk +1;
+ bits = (size*512)/min_chunk +1;
while (bits > max_bits) {
min_chunk *= 2;
bits = (bits+1)/2;
sb->feature_map = __cpu_to_le32(__le32_to_cpu(sb->feature_map) | 1);
memset(bms, sizeof(*bms), 0);
bms->magic = __cpu_to_le32(BITMAP_MAGIC);
- bms->version = __cpu_to_le32(BITMAP_MAJOR);
+ bms->version = __cpu_to_le32(major);
uuid_from_super1((int*)bms->uuid, sb);
bms->chunksize = __cpu_to_le32(chunk);
bms->daemon_sleep = __cpu_to_le32(delay);
- bms->sync_size = __cpu_to_le64(size<<1);
+ bms->sync_size = __cpu_to_le64(size);
bms->write_behind = __cpu_to_le32(write_behind);
return 1;
unsigned long long offset;
struct mdp_superblock_1 *sb;
- if (sbv)
- sb = sbv;
- else {
- if (st->ss->load_super(st, fd, (void**)&sb, NULL))
+ if (!sbv)
+ if (st->ss->load_super(st, fd, sbv, NULL))
return; /* no error I hope... */
- }
+
+ sb = sbv;
+
offset = __le64_to_cpu(sb->super_offset);
offset += (long) __le32_to_cpu(sb->bitmap_offset);
if (!sbv)