/*
* mdadm - Intel(R) Matrix Storage Manager Support
*
- * Copyright (C) 2002-2007 Intel Corporation
+ * Copyright (C) 2002-2008 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
enum imsm_update_type type;
};
-static int imsm_env_devname_as_serial(void)
-{
- char *val = getenv("IMSM_DEVNAME_AS_SERIAL");
-
- if (val && atoi(val) == 1)
- return 1;
-
- return 0;
-}
-
-
static struct supertype *match_metadata_desc_imsm(char *arg)
{
struct supertype *st;
}
#ifndef MDASSEMBLE
-static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info);
-
-static void print_imsm_dev(struct imsm_dev *dev, int index)
+static void print_imsm_dev(struct imsm_dev *dev, char *uuid, int disk_idx)
{
__u64 sz;
int slot;
__u32 ord;
printf("\n");
- printf("[%s]:\n", dev->volume);
+ printf("[%.16s]:\n", dev->volume);
+ printf(" UUID : %s\n", uuid);
printf(" RAID Level : %d\n", get_imsm_raid_level(map));
printf(" Members : %d\n", map->num_members);
for (slot = 0; slot < map->num_members; slot++)
- if (index == get_imsm_disk_idx(dev, slot))
+ if (disk_idx== get_imsm_disk_idx(dev, slot))
break;
if (slot < map->num_members) {
ord = get_imsm_ord_tbl_ent(dev, slot);
human_size(sz * 512));
}
+static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info);
+
static void examine_super_imsm(struct supertype *st, char *homehost)
{
struct intel_super *super = st->sb;
printf(" Spare Blocks : %d\n", __le32_to_cpu(log->reserved_spare_block_count));
printf(" First Spare : %llx\n", __le64_to_cpu(log->first_spare_lba));
}
- for (i = 0; i < mpb->num_raid_devs; i++)
- print_imsm_dev(__get_imsm_dev(mpb, i), super->disks->index);
+ for (i = 0; i < mpb->num_raid_devs; i++) {
+ struct mdinfo info;
+ struct imsm_dev *dev = __get_imsm_dev(mpb, i);
+
+ super->current_vol = i;
+ getinfo_super_imsm(st, &info);
+ fname_from_uuid(st, &info, nbuf, '-');
+ print_imsm_dev(dev, nbuf + 5, super->disks->index);
+ }
for (i = 0; i < mpb->num_disks; i++) {
if (i == super->disks->index)
continue;
}
}
-static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info);
-
static void brief_examine_super_imsm(struct supertype *st)
{
/* We just write a generic IMSM ARRAY entry */
struct mdinfo info;
char nbuf[64];
+ char nbuf1[64];
+ struct intel_super *super = st->sb;
+ int i;
+
+ if (!super->anchor->num_raid_devs)
+ return;
getinfo_super_imsm(st, &info);
fname_from_uuid(st, &info, nbuf,'-');
- printf("ARRAY /dev/imsm metadata=imsm auto=md UUID=%s\n", nbuf + 5);
+ printf("ARRAY metadata=imsm auto=md UUID=%s\n", nbuf + 5);
+ for (i = 0; i < super->anchor->num_raid_devs; i++) {
+ struct imsm_dev *dev = get_imsm_dev(super, i);
+
+ super->current_vol = i;
+ getinfo_super_imsm(st, &info);
+ fname_from_uuid(st, &info, nbuf1,'-');
+ printf("ARRAY /dev/md/%.16s container=%s\n"
+ " member=%d auto=mdp UUID=%s\n",
+ dev->volume, nbuf + 5, i, nbuf1 + 5);
+ }
}
static void detail_super_imsm(struct supertype *st, char *homehost)
{
- printf("%s\n", __FUNCTION__);
+ struct mdinfo info;
+ char nbuf[64];
+
+ getinfo_super_imsm(st, &info);
+ fname_from_uuid(st, &info, nbuf,'-');
+ printf("\n UUID : %s\n", nbuf + 5);
}
static void brief_detail_super_imsm(struct supertype *st)
struct intel_super *super = st->sb;
struct imsm_disk *disk;
__u32 s;
- int is_spare = 0;
if (super->current_vol >= 0) {
getinfo_super_imsm_volume(st, info);
s = __le32_to_cpu(disk->status);
info->disk.state = s & CONFIGURED_DISK ? (1 << MD_DISK_ACTIVE) : 0;
info->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
- info->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
- if (s & SPARE_DISK)
- is_spare = 1;
+ info->disk.state |= s & SPARE_DISK ? 0 : (1 << MD_DISK_SYNC);
}
- if (is_spare)
- memcpy(info->uuid, uuid_match_any, sizeof(int[4]));
- else
+
+ /* only call uuid_from_super_imsm when this disk is part of a populated container,
+ * ->compare_super may have updated the 'num_raid_devs' field for spares
+ */
+ if (info->disk.state & (1 << MD_DISK_SYNC) || super->anchor->num_raid_devs)
uuid_from_super_imsm(st, info->uuid);
+ else
+ memcpy(info->uuid, uuid_match_any, sizeof(int[4]));
}
static int update_super_imsm(struct supertype *st, struct mdinfo *info,
*/
if (first->anchor->num_raid_devs == 0 &&
sec->anchor->num_raid_devs > 0) {
+ int i;
+
+ /* we need to copy raid device info from sec if an allocation
+ * fails here we don't associate the spare
+ */
+ for (i = 0; i < sec->anchor->num_raid_devs; i++) {
+ first->dev_tbl[i] = malloc(sizeof(struct imsm_dev));
+ if (!first->dev_tbl) {
+ while (--i >= 0) {
+ free(first->dev_tbl[i]);
+ first->dev_tbl[i] = NULL;
+ }
+ fprintf(stderr, "imsm: failed to associate spare\n");
+ return 3;
+ }
+ *first->dev_tbl[i] = *sec->dev_tbl[i];
+ }
+
first->anchor->num_raid_devs = sec->anchor->num_raid_devs;
first->anchor->family_num = sec->anchor->family_num;
}
rv = scsi_get_serial(fd, scsi_serial, sizeof(scsi_serial));
- if (rv && imsm_env_devname_as_serial()) {
+ if (rv && check_env("IMSM_DEVNAME_AS_SERIAL")) {
memset(serial, 0, MAX_RAID_SERIAL_LEN);
fd2devname(fd, (char *) serial);
return 0;
* slot+1
*/
int i;
- int insync;
+ /* gcc -Os complains that this is unused */
+ int insync = insync;
for (i = 0; i < map->num_members; i++) {
__u32 ord = get_imsm_ord_tbl_ent(dev, i);
* being added */
if (super->add) {
struct active_array *a;
+
+ super->updates_pending++;
for (a = st->arrays; a; a = a->next)
a->check_degraded = 1;
}