/*
* mdadm - manage Linux "md" devices aka RAID arrays.
*
- * Copyright (C) 2001-2004 Neil Brown <neilb@cse.unsw.edu.au>
+ * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
*
*
* This program is free software; you can redistribute it and/or modify
*/
/* These are only valid with feature bit '4' */
- __u64 reshape_position; /* next address in array-space for reshape */
__u32 new_level; /* new level we are reshaping to */
+ __u64 reshape_position; /* next address in array-space for reshape */
__u32 delta_disks; /* change in number of raid_disks */
__u32 new_layout; /* new layout */
__u32 new_chunk; /* new chunk size (bytes) */
printf(" New Layout : %s\n", c?c:"-unknown-");
}
if (__le32_to_cpu(sb->level) == 10) {
- printf(" New Layout : near=%d, far=%d\n",
+ printf(" New Layout : near=%d, %s=%d\n",
__le32_to_cpu(sb->new_layout)&255,
+ (__le32_to_cpu(sb->new_layout)&0x10000)?"offset":"far",
(__le32_to_cpu(sb->new_layout)>>8)&255);
}
}
}
if (__le32_to_cpu(sb->level) == 10) {
int lo = __le32_to_cpu(sb->layout);
- printf(" Layout : near=%d, far=%d\n",
- lo&255, (lo>>8)&255);
+ printf(" Layout : near=%d, %s=%d\n",
+ lo&255,
+ (lo&0x10000)?"offset":"far",
+ (lo>>8)&255);
}
switch(__le32_to_cpu(sb->level)) {
case 0:
cuuid[i] = super->set_uuid[i];
}
-static void getinfo_super1(struct mdinfo *info, mddev_ident_t ident, void *sbv)
+static void getinfo_super1(struct mdinfo *info, void *sbv)
{
struct mdp_superblock_1 *sb = sbv;
int working = 0;
info->array.layout = __le32_to_cpu(sb->layout);
info->array.md_minor = -1;
info->array.ctime = __le64_to_cpu(sb->ctime);
+ info->array.utime = __le64_to_cpu(sb->utime);
+ info->array.chunk_size = __le32_to_cpu(sb->chunksize)*512;
+
+ info->data_offset = __le64_to_cpu(sb->data_offset);
+ info->component_size = __le64_to_cpu(sb->size);
info->disk.major = 0;
info->disk.minor = 0;
memcpy(info->uuid, sb->set_uuid, 16);
- strncpy(ident->name, sb->set_name, 32);
- ident->name[32] = 0;
+ strncpy(info->name, sb->set_name, 32);
+ info->name[32] = 0;
+
+ if (sb->feature_map & __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE)) {
+ info->reshape_active = 1;
+ info->reshape_progress = __le64_to_cpu(sb->reshape_position);
+ info->new_level = __le32_to_cpu(sb->new_level);
+ info->delta_disks = __le32_to_cpu(sb->delta_disks);
+ info->new_layout = __le32_to_cpu(sb->new_layout);
+ info->new_chunk = __le32_to_cpu(sb->new_chunk)<<9;
+ } else
+ info->reshape_active = 0;
for (i=0; i< __le32_to_cpu(sb->max_dev); i++) {
role = __le16_to_cpu(sb->dev_roles[i]);
static int update_super1(struct mdinfo *info, void *sbv, char *update, char *devname, int verbose)
{
+ /* NOTE: for 'assemble' and 'force' we need to return non-zero if any change was made.
+ * For others, the return value is ignored.
+ */
int rv = 0;
struct mdp_superblock_1 *sb = sbv;
if (strcmp(update, "force")==0) {
+ if (sb->events != __cpu_to_le64(info->events))
+ rv = 1;
sb->events = __cpu_to_le64(info->events);
switch(__le32_to_cpu(sb->level)) {
case 5: case 4: case 6:
/* need to force clean */
+ if (sb->resync_offset != ~0ULL)
+ rv = 1;
sb->resync_offset = ~0ULL;
}
}
/* make sure resync happens */
sb->resync_offset = ~0ULL;
}
- if (strcmp(update, "uuid") == 0)
+ if (strcmp(update, "uuid") == 0) {
memcpy(sb->set_uuid, info->uuid, 16);
+ if (__le32_to_cpu(sb->feature_map)&MD_FEATURE_BITMAP_OFFSET) {
+ struct bitmap_super_s *bm;
+ bm = (struct bitmap_super_s*)(sbv+1024);
+ memcpy(bm->uuid, info->uuid, 16);
+ }
+ }
+ if (strcmp(update, "_reshape_progress")==0)
+ sb->reshape_position = __cpu_to_le64(info->reshape_progress);
sb->sb_csum = calc_sb_1_csum(sb);
return rv;
*rp = 0xfffe;
}
+static void locate_bitmap1(struct supertype *st, int fd, void *sbv);
+
static int store_super1(struct supertype *st, int fd, void *sbv)
{
struct mdp_superblock_1 *sb = sbv;
if (write(fd, sb, sbsize) != sbsize)
return 4;
+ if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET)) {
+ struct bitmap_super_s *bm = (struct bitmap_super_s*)
+ ((char*)sb)+1024;
+ if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC) {
+ locate_bitmap1(st, fd, sbv);
+ write(fd, bm, sizeof(*bm));
+ }
+ }
fsync(fd);
return 0;
}
return 1;
if (!first) {
- first = malloc(1024);
- memcpy(first, second, 1024);
+ first = malloc(1024+sizeof(bitmap_super_t));
+ memcpy(first, second, 1024+sizeof(bitmap_super_t));
*firstp = first;
return 0;
}
unsigned long long dsize;
unsigned long long sb_offset;
struct mdp_superblock_1 *super;
-
+ int uuid[4];
+ struct bitmap_super_s *bsb;
if (st->ss == NULL) {
/*
* Calculate the position of the superblock.
* It is always aligned to a 4K boundary and
- * depeding on minor_version, it can be:
+ * depending on minor_version, it can be:
* 0: At least 8K, but less than 12K, from end of device
* 1: At start of device
* 2: 4K from start of device.
return 2;
}
*sbp = super;
+
+ /* Now check on the bitmap superblock */
+ if ((__le32_to_cpu(super->feature_map)&MD_FEATURE_BITMAP_OFFSET) == 0)
+ return 0;
+ /* Read the bitmap superblock and make sure it looks
+ * valid. If it doesn't clear the bit. An --assemble --force
+ * should get that written out.
+ */
+ locate_bitmap1(st, fd, super);
+ if (read(fd, ((char*)super)+1024, sizeof(struct bitmap_super_s))
+ != sizeof(struct bitmap_super_s))
+ goto no_bitmap;
+
+ uuid_from_super1(uuid, super);
+ bsb = (struct bitmap_super_s *)(((char*)super)+1024);
+ if (__le32_to_cpu(bsb->magic) != BITMAP_MAGIC ||
+ memcmp(bsb->uuid, uuid, 16) != 0)
+ goto no_bitmap;
+ return 0;
+
+ no_bitmap:
+ super->feature_map = __cpu_to_le32(__le32_to_cpu(super->feature_map) & ~1);
return 0;
}
}
-void locate_bitmap1(struct supertype *st, int fd, void *sbv)
+static void locate_bitmap1(struct supertype *st, int fd, void *sbv)
{
unsigned long long offset;
struct mdp_superblock_1 *sb;
lseek64(fd, offset<<9, 0);
}
-int write_bitmap1(struct supertype *st, int fd, void *sbv)
+static int write_bitmap1(struct supertype *st, int fd, void *sbv)
{
struct mdp_superblock_1 *sb = sbv;
bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb)+1024);