return st;
}
+#ifndef MDASSEMBLE
static __u8 *get_imsm_version(struct imsm_super *mpb)
{
return &mpb->sig[MPB_SIG_LEN];
}
+#endif
/* retrieve a disk directly from the anchor when the anchor is known to be
* up-to-date, currently only at load time
return &mpb->disk[index];
}
+#ifndef MDASSEMBLE
/* retrieve a disk from the parsed metadata */
static struct imsm_disk *get_imsm_disk(struct intel_super *super, __u8 index)
{
return NULL;
}
+#endif
/* generate a checksum directly from the anchor when the anchor is known to be
* up-to-date, currently only at load or write_super after coalescing
return map->raid_level;
}
+#ifndef MDASSEMBLE
static int cmp_extent(const void *av, const void *bv)
{
const struct extent *a = av;
return rv;
}
-#ifndef MDASSEMBLE
static void print_imsm_dev(struct imsm_dev *dev, int index)
{
__u64 sz;
memcpy(dest, src, sizeof_imsm_dev(src, 0));
}
+#ifndef MDASSEMBLE
/* When migrating map0 contains the 'destination' state while map1
* contains the current state. When not migrating map0 contains the
* current state. This routine assumes that map[0].map_state is set to
memcpy(dest, src, sizeof_imsm_map(src));
src->map_state = to_state;
}
+#endif
static int parse_raid_devices(struct intel_super *super)
{
return 1;
}
+#ifndef MDASSEMBLE
static void add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
int fd, char *devname)
{
return 0;
}
+
static int create_array(struct supertype *st)
{
size_t len;
return 0;
}
-static int add_disk(struct supertype *st)
+static int _add_disk(struct supertype *st)
{
struct intel_super *super = st->sb;
size_t len;
/* in the add disk case we are running in mdmon
* context, so don't close fd's
*/
- return add_disk(st);
+ return _add_disk(st);
} else
rv = create_array(st);
} else
return write_super_imsm(st->sb, 1);
}
+#endif
static int store_zero_imsm(struct supertype *st, int fd)
{
return 0;
}
+static int imsm_bbm_log_size(struct imsm_super *mpb)
+{
+ return __le32_to_cpu(mpb->bbm_log_size);
+}
+
+#ifndef MDASSEMBLE
static int validate_geometry_imsm_container(struct supertype *st, int level,
int layout, int raiddisks, int chunk,
unsigned long long size, char *dev,
return 1;
}
-int imsm_bbm_log_size(struct imsm_super *mpb)
-{
- return __le32_to_cpu(mpb->bbm_log_size);
-}
-
static int validate_geometry_imsm(struct supertype *st, int level, int layout,
int raiddisks, int chunk, unsigned long long size,
char *dev, unsigned long long *freesize,
return 1;
}
+#endif /* MDASSEMBLE */
static struct mdinfo *container_content_imsm(struct supertype *st)
{
}
+#ifndef MDASSEMBLE
static int imsm_open_new(struct supertype *c, struct active_array *a,
char *inst)
{
if ((state & DS_FAULTY) && !(status & FAILED_DISK)) {
status |= FAILED_DISK;
disk->status = __cpu_to_le32(status);
- disk->scsi_id = __cpu_to_le32(~0UL);
+ disk->scsi_id = __cpu_to_le32(~(__u32)0);
memmove(&disk->serial[0], &disk->serial[1], MAX_RAID_SERIAL_LEN - 1);
super->updates_pending++;
}
return dl;
}
-static struct dl *imsm_add_spare(struct intel_super *super, int idx, struct active_array *a)
+static struct dl *imsm_add_spare(struct intel_super *super, int slot, struct active_array *a)
{
struct imsm_dev *dev = get_imsm_dev(super, a->info.container_member);
+ int idx = get_imsm_disk_idx(dev, slot);
struct imsm_map *map = get_imsm_map(dev, 0);
unsigned long long esize;
unsigned long long pos;
for (dl = super->disks; dl; dl = dl->next) {
/* If in this array, skip */
for (d = a->info.devs ; d ; d = d->next)
- if (d->disk.major == dl->major &&
+ if (d->state_fd >= 0 &&
+ d->disk.major == dl->major &&
d->disk.minor == dl->minor) {
dprintf("%x:%x already in array\n", dl->major, dl->minor);
break;
if (d)
continue;
- /* skip marked in use or failed drives */
+ /* skip in use or failed drives */
status = __le32_to_cpu(dl->disk.status);
- if (status & FAILED_DISK || status & CONFIGURED_DISK) {
+ if (status & FAILED_DISK || idx == dl->index) {
dprintf("%x:%x status ( %s%s)\n",
dl->major, dl->minor,
status & FAILED_DISK ? "failed " : "",
- status & CONFIGURED_DISK ? "configured " : "");
+ idx == dl->index ? "in use " : "");
continue;
}
for (a = st->arrays; a; a = a->next)
a->check_degraded = 1;
}
- /* check if we can add / replace some disks in the
- * metadata */
+ /* add some spares to the metadata */
while (super->add) {
- struct dl **dlp, *dl, *al;
+ struct dl *al;
+
al = super->add;
super->add = al->next;
- for (dlp = &super->disks; *dlp ; ) {
- if (serialcmp(al->serial, (*dlp)->serial) == 0) {
- dl = *dlp;
- *dlp = (*dlp)->next;
- __free_imsm_disk(dl);
- break;
- } else
- dlp = &(*dlp)->next;
- }
al->next = super->disks;
super->disks = al;
+ dprintf("%s: added %x:%x\n",
+ __func__, al->major, al->minor);
}
break;
__free_imsm_disk(dl);
}
}
+#endif /* MDASSEMBLE */
struct superswitch super_imsm = {
#ifndef MDASSEMBLE
.detail_super = detail_super_imsm,
.brief_detail_super = brief_detail_super_imsm,
.write_init_super = write_init_super_imsm,
+ .validate_geometry = validate_geometry_imsm,
+ .add_to_super = add_to_super_imsm,
#endif
.match_home = match_home_imsm,
.uuid_from_super= uuid_from_super_imsm,
.load_super = load_super_imsm,
.init_super = init_super_imsm,
- .add_to_super = add_to_super_imsm,
.store_super = store_zero_imsm,
.free_super = free_super_imsm,
.match_metadata_desc = match_metadata_desc_imsm,
.container_content = container_content_imsm,
- .validate_geometry = validate_geometry_imsm,
.external = 1,
+#ifndef MDASSEMBLE
/* for mdmon */
.open_new = imsm_open_new,
.load_super = load_super_imsm,
.activate_spare = imsm_activate_spare,
.process_update = imsm_process_update,
.prepare_update = imsm_prepare_update,
+#endif /* MDASSEMBLE */
};