return __le32_to_cpu(*ord_tbl & ~(0xff << 24));
}
-#ifndef MDASSEMBLE
static int get_imsm_raid_level(struct imsm_map *map)
{
if (map->raid_level == 1) {
return map->raid_level;
}
+#ifndef MDASSEMBLE
static void print_imsm_dev(struct imsm_dev *dev, int index)
{
__u64 sz;
printf("%s\n", __FUNCTION__);
}
-static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info)
+static void
+get_imsm_numerical_version(struct imsm_super *mpb, int *m, int *p)
{
- struct intel_super *super = st->sb;
- struct imsm_super *mpb = super->mpb;
- struct imsm_disk *disk;
- __u32 s;
__u8 *v = get_imsm_version(mpb);
__u8 *end = mpb->sig + MAX_SIGNATURE_LENGTH;
char major[] = { 0, 0, 0 };
v++;
}
+ *m = strtol(minor, NULL, 0);
+ *p = strtol(patch, NULL, 0);
+}
+
+static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info)
+{
+ struct intel_super *super = st->sb;
+ struct imsm_super *mpb = super->mpb;
+ struct imsm_disk *disk;
+ __u32 s;
+ int i, j;
+
info->array.major_version = 2000;
- info->array.minor_version = strtol(minor, NULL, 0);
- info->array.patch_version = strtol(patch, NULL, 0);
+ get_imsm_numerical_version(mpb, &info->array.minor_version,
+ &info->array.patch_version);
info->array.raid_disks = mpb->num_disks;
info->array.level = LEVEL_CONTAINER;
info->array.layout = 0;
char *update, char *devname, int verbose,
int uuid_set, char *homehost)
{
- return 0;
+ /* FIXME */
+
+ /* For 'assemble' and 'force' we need to return non-zero if any
+ * change was made. For others, the return value is ignored.
+ * Update options are:
+ * force-one : This device looks a bit old but needs to be included,
+ * update age info appropriately.
+ * assemble: clear any 'faulty' flag to allow this device to
+ * be assembled.
+ * force-array: Array is degraded but being forced, mark it clean
+ * if that will be needed to assemble it.
+ *
+ * newdev: not used ????
+ * grow: Array has gained a new device - this is currently for
+ * linear only
+ * resync: mark as dirty so a resync will happen.
+ * name: update the name - preserving the homehost
+ *
+ * Following are not relevant for this imsm:
+ * sparc2.2 : update from old dodgey metadata
+ * super-minor: change the preferred_minor number
+ * summaries: update redundant counters.
+ * uuid: Change the uuid of the array to match watch is given
+ * homehost: update the recorded homehost
+ * _reshape_progress: record new reshape_progress position.
+ */
+ int rv = 0;
+ //struct intel_super *super = st->sb;
+ //struct imsm_super *mpb = super->mpb;
+
+ if (strcmp(update, "grow") == 0) {
+ }
+ if (strcmp(update, "resync") == 0) {
+ /* dev->vol.dirty = 1; */
+ }
+
+ /* IMSM has no concept of UUID or homehost */
+
+ return rv;
}
static __u64 avail_size_imsm(struct supertype *st, __u64 size)
int rv;
#ifndef MDASSEMBLE
- if (load_super_imsm_all(st, fd, &st->sb, devname, 0) == 0)
+ if (load_super_imsm_all(st, fd, &st->sb, devname, 1) == 0)
return 0;
#endif
return 0;
}
-static void getinfo_super_n_container(struct supertype *st, struct mdinfo *info)
+static void getinfo_super_n_imsm_container(struct supertype *st, struct mdinfo *info)
{
- printf("%s\n", __FUNCTION__);
+ /* just need offset and size...
+ * of the metadata??
+ */
+ struct intel_super *super = st->sb;
+ struct imsm_super *mpb = super->mpb;
+ struct imsm_disk *disk = get_imsm_disk(mpb, info->disk.number);
+ int sect = mpb_sectors(mpb);
+
+ info->data_offset = __le32_to_cpu(disk->total_blocks) - (2 + sect - 1);
+ info->component_size = sect;
}
static void getinfo_super_n_raid(struct supertype *st, struct mdinfo *info)
return 0;
}
+static struct mdinfo *container_content_imsm(struct supertype *st)
+{
+ /* Given a container loaded by load_super_imsm_all,
+ * extract information about all the arrays into
+ * an mdinfo tree.
+ *
+ * For each imsm_dev create an mdinfo, fill it in,
+ * then look for matching devices in super->disks
+ * and create appropriate device mdinfo.
+ */
+ struct intel_super *super = st->sb;
+ struct imsm_super *mpb = super->mpb;
+ struct mdinfo *rest = NULL;
+ int i;
+ for (i = 0; i < mpb->num_raid_devs; i++) {
+ struct imsm_dev *dev = get_imsm_dev(mpb, i);
+ struct imsm_vol *vol = &dev->vol;
+ struct imsm_map *map = vol->map;
+ struct mdinfo *this;
+ __u64 sz;
+ int slot;
+
+ this = malloc(sizeof(*this));
+ memset(this, 0, sizeof(*this));
+ this->next = rest;
+ rest = this;
+
+ this->array.major_version = 2000;
+ get_imsm_numerical_version(mpb, &this->array.minor_version,
+ &this->array.patch_version);
+ this->array.level = get_imsm_raid_level(map);
+ this->array.raid_disks = map->num_members;
+ switch(this->array.level) {
+ case 0:
+ case 1:
+ this->array.layout = 0;
+ break;
+ case 5:
+ case 6:
+ this->array.layout = ALGORITHM_LEFT_SYMMETRIC;
+ break;
+ case 10:
+ this->array.layout = 0x102; //FIXME is this correct?
+ break;
+ default:
+ this->array.layout = -1; // FIXME
+ }
+ this->array.md_minor = -1;
+ this->array.ctime = 0;
+ this->array.utime = 0;
+ this->array.chunk_size = __le16_to_cpu(map->blocks_per_strip) << 9;
+ this->array.state = !vol->dirty;
+ this->container_member = i;
+ if (map->map_state == IMSM_T_STATE_UNINITIALIZED || dev->vol.dirty)
+ this->resync_start = 0;
+ else
+ this->resync_start = ~0ULL;
+
+ strncpy(this->name, (char *) dev->volume, MAX_RAID_SERIAL_LEN);
+ this->name[MAX_RAID_SERIAL_LEN] = 0;
+
+ memset(this->uuid, 0, sizeof(this->uuid));
+
+ sz = __le32_to_cpu(dev->size_high);
+ sz <<= 32;
+ sz += __le32_to_cpu(dev->size_low);
+ this->component_size = sz;
+ this->array.size = this->component_size / 2;
+
+ for (slot = 0 ; slot < map->num_members; slot++) {
+ struct imsm_disk *disk;
+ struct mdinfo *info_d;
+ struct dl *d;
+ int idx;
+ __u32 s;
+
+ idx = __le32_to_cpu(map->disk_ord_tbl[slot] & ~(0xff << 24));
+ for (d = super->disks; d ; d = d->next)
+ if (d->index == idx)
+ break;
+
+ if (d == NULL)
+ break; /* shouldn't this be continue ?? */
+
+ info_d = malloc(sizeof(*info_d));
+ if (!info_d)
+ break; /* ditto ?? */
+ memset(info_d, 0, sizeof(*info_d));
+ info_d->next = this->devs;
+ this->devs = info_d;
+
+ disk = get_imsm_disk(mpb, idx);
+ s = __le32_to_cpu(disk->status);
+
+ info_d->disk.number = d->index;
+ info_d->disk.major = d->major;
+ info_d->disk.minor = d->minor;
+ info_d->disk.raid_disk = slot;
+ info_d->disk.state = s & CONFIGURED_DISK ? (1 << MD_DISK_ACTIVE) : 0;
+ info_d->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
+ info_d->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
+
+ this->array.working_disks++;
+
+ info_d->events = __le32_to_cpu(mpb->generation_num);
+ info_d->data_offset = __le32_to_cpu(map->pba_of_lba0);
+ info_d->component_size = __le32_to_cpu(map->blocks_per_member);
+ if (d->devname)
+ strcpy(info_d->name, d->devname);
+ }
+ }
-static struct mdinfo *container_content_imsm(struct supertype *st)
+ return rest;
+}
+
+
+static int imsm_open_new(struct supertype *c, struct active_array *a, int inst)
{
- printf("%s\n", __FUNCTION__);
+ fprintf(stderr, "imsm: open_new %d\n", inst);
+ return 0;
+}
- return NULL;
+static void imsm_mark_clean(struct active_array *a, unsigned long long sync_pos)
+{
+ fprintf(stderr, "imsm: mark clean %llu\n", sync_pos);
+}
+
+static void imsm_mark_dirty(struct active_array *a)
+{
+ fprintf(stderr, "imsm: mark dirty\n");
+}
+
+static void imsm_mark_sync(struct active_array *a, unsigned long long resync)
+{
+ fprintf(stderr, "imsm: mark sync\n");
+}
+
+static void imsm_set_disk(struct active_array *a, int n)
+{
+ fprintf(stderr, "imsm: set_disk %d\n", n);
+}
+
+static void imsm_sync_metadata(struct active_array *a)
+{
+ fprintf(stderr, "imsm: sync_metadata\n");
}
struct superswitch super_imsm = {
.store_super = store_zero_imsm,
.free_super = free_super_imsm,
.match_metadata_desc = match_metadata_desc_imsm,
- .getinfo_super_n = getinfo_super_n_container,
+ .getinfo_super_n = getinfo_super_n_imsm_container,
.validate_geometry = validate_geometry_imsm,
.major = 2000,
.swapuuid = 0,
.external = 1,
.text_version = "imsm",
+
+/* for mdmon */
+ .open_new = imsm_open_new,
+ .load_super = load_super_imsm,
+ .mark_clean = imsm_mark_clean,
+ .mark_dirty = imsm_mark_dirty,
+ .mark_sync = imsm_mark_sync,
+ .set_disk = imsm_set_disk,
+ .sync_metadata = imsm_sync_metadata,
};
/* super_imsm_container is set by validate_geometry_imsm when given a
.add_to_super = add_to_super_imsm,
.write_init_super = write_init_super_imsm,
.getinfo_super = getinfo_super_imsm,
- .getinfo_super_n = getinfo_super_n_container,
+ .getinfo_super_n = getinfo_super_n_imsm_container,
.load_super = load_super_imsm,
#ifndef MDASSEMBLE