*/
#include "mdadm.h"
-#include <asm/byteorder.h>
/*
* All handling for the 0.90.0 version superblock is in
sb->cp_events_hi = sb->cp_events_lo;
sb->cp_events_lo = t32;
-}
+}
#ifndef MDASSEMBLE
printf(" Creation Time : %.24s\n", ctime(&atime));
c=map_num(pers, sb->level);
printf(" Raid Level : %s\n", c?c:"-unknown-");
- if ((int)sb->level >= 0)
+ if ((int)sb->level >= 0) {
+ int ddsks=0;
printf(" Device Size : %d%s\n", sb->size, human_size((long long)sb->size<<10));
+ switch(sb->level) {
+ case 1: ddsks=1;break;
+ case 4:
+ case 5: ddsks = sb->raid_disks-1; break;
+ case 6: ddsks = sb->raid_disks-2; break;
+ case 10: ddsks = sb->raid_disks / (sb->layout&255) / ((sb->layout>>8)&255);
+ }
+ if (ddsks)
+ printf(" Array Size : %llu%s\n", (unsigned long long)ddsks * sb->size,
+ human_size(ddsks*(long long)sb->size<<10));
+ }
printf(" Raid Devices : %d\n", sb->raid_disks);
printf(" Total Devices : %d\n", sb->nr_disks);
printf("Preferred Minor : %d\n", sb->md_minor);
printf("\n");
+ if (sb->minor_version > 90 && (sb->reshape_position+1) != 0) {
+ printf(" Reshape pos'n : %llu%s\n", (unsigned long long)sb->reshape_position/2, human_size((long long)sb->reshape_position<<9));
+ if (sb->delta_disks) {
+ printf(" Delta Devices : %d", sb->delta_disks);
+ if (sb->delta_disks)
+ printf(" (%d->%d)\n", sb->raid_disks-sb->delta_disks, sb->raid_disks);
+ else
+ printf(" (%d->%d)\n", sb->raid_disks, sb->raid_disks+sb->delta_disks);
+ }
+ if (sb->new_level != sb->level) {
+ c = map_num(pers, sb->new_level);
+ printf(" New Level : %s\n", c?c:"-unknown-");
+ }
+ if (sb->new_layout != sb->layout) {
+ if (sb->level == 5) {
+ c = map_num(r5layout, sb->new_layout);
+ printf(" New Layout : %s\n", c?c:"-unknown-");
+ }
+ if (sb->level == 10) {
+ printf(" New Layout : near=%d, far=%d\n",
+ sb->new_layout&255, (sb->new_layout>>8)&255);
+ }
+ }
+ if (sb->new_chunk != sb->chunk_size)
+ printf(" New Chunksize : %d\n", sb->new_chunk);
+ printf("\n");
+ }
atime = sb->utime;
printf(" Update Time : %.24s\n", ctime(&atime));
printf(" State : %s\n",
c = map_num(r5layout, sb->layout);
printf(" Layout : %s\n", c?c:"-unknown-");
}
+ if (sb->level == 10) {
+ printf(" Layout : near=%d, far=%d\n",
+ sb->layout&255, (sb->layout>>8)&255);
+ }
switch(sb->level) {
case 0:
case 4:
case -1:
printf(" Rounding : %dK\n", sb->chunk_size/1024);
break;
- default: break;
+ default: break;
}
printf("\n");
printf(" Number Major Minor RaidDevice State\n");
if (dp->state & (1<<MD_DISK_REMOVED)) printf(" removed");
if (wonly) printf(" write-mostly");
if (dp->state == 0) printf(" spare");
- if ((dv=map_dev(dp->major, dp->minor)))
+ if ((dv=map_dev(dp->major, dp->minor, 0)))
printf(" %s", dv);
printf("\n");
if (d == -1) printf("\n");
}
}
-static void getinfo_super0(struct mdinfo *info, mddev_ident_t ident, void *sbv)
+static void getinfo_super0(struct mdinfo *info, void *sbv)
{
mdp_super_t *sb = sbv;
int working = 0;
info->array.patch_version = sb->patch_version;
info->array.raid_disks = sb->raid_disks;
info->array.level = sb->level;
+ info->array.layout = sb->layout;
info->array.md_minor = sb->md_minor;
info->array.ctime = sb->ctime;
+ info->array.utime = sb->utime;
+ info->array.chunk_size = sb->chunk_size;
+ info->component_size = sb->size*2;
info->disk.state = sb->this_disk.state;
info->disk.major = sb->this_disk.major;
info->disk.number = sb->this_disk.number;
info->events = md_event(sb);
+ info->data_offset = 0;
uuid_from_super0(info->uuid, sbv);
- ident->name[0] = 0;
+ if (sb->minor_version > 90 && (sb->reshape_position+1) != 0) {
+ info->reshape_active = 1;
+ info->reshape_progress = sb->reshape_position;
+ info->new_level = sb->new_level;
+ info->delta_disks = sb->delta_disks;
+ info->new_layout = sb->new_layout;
+ info->new_chunk = sb->new_chunk;
+ } else
+ info->reshape_active = 0;
+
+ info->name[0] = 0;
/* work_disks is calculated rather than read directly */
for (i=0; i < MD_SB_DISKS; i++)
if ((sb->disks[i].state & (1<<MD_DISK_SYNC)) &&
sb->state &= ~(1<<MD_SB_CLEAN);
sb->recovery_cp = 0;
}
+ if (strcmp(update, "uuid") == 0) {
+ sb->set_uuid0 = info->uuid[0];
+ sb->set_uuid1 = info->uuid[1];
+ sb->set_uuid2 = info->uuid[2];
+ sb->set_uuid3 = info->uuid[3];
+ }
+ if (strcmp(update, "_reshape_progress")==0)
+ sb->reshape_position = info->reshape_progress;
sb->sb_csum = calc_sb0_csum(sb);
return rv;
-static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info, char *ignored_name)
+static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info, unsigned long long size, char *ignored_name)
{
mdp_super_t *sb = malloc(MD_SB_BYTES + sizeof(bitmap_super_t));
int spares;
sb->set_uuid0 = random();
sb->ctime = time(0);
sb->level = info->level;
+ if (size != info->size)
+ return 0;
sb->size = info->size;
sb->nr_disks = info->nr_disks;
sb->raid_disks = info->raid_disks;
{
mdp_super_t *sb = sbv;
mdp_disk_t *dk = &sb->disks[dinfo->number];
-
+
dk->number = dinfo->number;
dk->major = dinfo->major;
dk->minor = dinfo->minor;
dsize = ((unsigned long long)size)<<9;
}
- if (dsize < MD_RESERVED_SECTORS*2)
+ if (dsize < MD_RESERVED_SECTORS*2*512)
return 2;
-
+
offset = MD_NEW_SIZE_SECTORS(dsize>>9);
offset *= 512;
sb->sb_csum = calc_sb0_csum(sb);
rv = store_super0(st, fd, sb);
- if (sb->state & (1<<MD_SB_BITMAP_PRESENT)) {
- int towrite, n;
- char buf[4096];
-
- write(fd, ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t));
- towrite = 64*1024 - MD_SB_BYTES - sizeof(bitmap_super_t);
- memset(buf, 0xff, sizeof(buf));
- while (towrite > 0) {
- n = towrite;
- if (n > sizeof(buf))
- n = sizeof(buf);
- n = write(fd, buf, n);
- if (n > 0)
- towrite -= n;
- else
- break;
- }
- fsync(fd);
- if (towrite)
- rv = -2;
- }
+ if (rv == 0 && (sb->state & (1<<MD_SB_BITMAP_PRESENT)))
+ rv = st->ss->write_bitmap(st, fd, sbv);
close(fd);
if (rv)
devname, size);
return 1;
}
-
+
offset = MD_NEW_SIZE_SECTORS(dsize>>9);
offset *= 512;
return NULL;
}
-static __u64 avail_size0(__u64 devsize)
+static __u64 avail_size0(struct supertype *st, __u64 devsize)
{
if (devsize < MD_RESERVED_SECTORS*2)
return 0ULL;
return MD_NEW_SIZE_SECTORS(devsize);
}
-static int add_internal_bitmap0(void *sbv, int chunk, int delay, int write_behind, unsigned long long size)
+static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int delay, int write_behind, unsigned long long size, int may_change, int major)
{
/*
* The bitmap comes immediately after the superblock and must be 60K in size
*
* size is in K, chunk is in bytes !!!
*/
-
- unsigned long long bits = size;
+ unsigned long long bits;
unsigned long long max_bits = 60*1024*8;
unsigned long long min_chunk;
mdp_super_t *sb = sbv;
bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + MD_SB_BYTES);
-
+
min_chunk = 4096; /* sub-page chunks don't work yet.. */
+ bits = (size * 512)/ min_chunk +1;
while (bits > max_bits) {
min_chunk *= 2;
bits = (bits+1)/2;
sb->state |= (1<<MD_SB_BITMAP_PRESENT);
- memset(bms, sizeof(*bms), 0);
+ memset(bms, 0, sizeof(*bms));
bms->magic = __cpu_to_le32(BITMAP_MAGIC);
- bms->version = __cpu_to_le32(BITMAP_MAJOR);
+ bms->version = __cpu_to_le32(major);
uuid_from_super0((int*)bms->uuid, sb);
bms->chunksize = __cpu_to_le32(chunk);
bms->daemon_sleep = __cpu_to_le32(delay);
return 1;
}
-
-void locate_bitmap0(struct supertype *st, int fd)
+
+void locate_bitmap0(struct supertype *st, int fd, void *sbv)
{
unsigned long long dsize;
unsigned long size;
if (dsize < MD_RESERVED_SECTORS*2)
return;
-
+
offset = MD_NEW_SIZE_SECTORS(dsize>>9);
offset *= 512;
}
if (dsize < MD_RESERVED_SECTORS*2)
- return -1;
-
+ return -1;
+
offset = MD_NEW_SIZE_SECTORS(dsize>>9);
offset *= 512;
return 3;
- write(fd, ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t));
+ if (write(fd, ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t)) !=
+ sizeof(bitmap_super_t))
+ return -2;
towrite = 64*1024 - MD_SB_BYTES - sizeof(bitmap_super_t);
memset(buf, 0xff, sizeof(buf));
while (towrite > 0) {