imsm: 'volume' is the proper name for imsm container members
[thirdparty/mdadm.git] / super-intel.c
CommitLineData
cdddbdbc
DW
1/*
2 * mdadm - Intel(R) Matrix Storage Manager Support
3 *
4 * Copyright (C) 2002-2007 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#include "mdadm.h"
c2a1e7da 21#include "mdmon.h"
cdddbdbc
DW
22#include <values.h>
23#include <scsi/sg.h>
24#include <ctype.h>
25
26/* MPB == Metadata Parameter Block */
27#define MPB_SIGNATURE "Intel Raid ISM Cfg Sig. "
28#define MPB_SIG_LEN (strlen(MPB_SIGNATURE))
29#define MPB_VERSION_RAID0 "1.0.00"
30#define MPB_VERSION_RAID1 "1.1.00"
31#define MPB_VERSION_RAID5 "1.2.02"
32#define MAX_SIGNATURE_LENGTH 32
33#define MAX_RAID_SERIAL_LEN 16
34
35/* Disk configuration info. */
36#define IMSM_MAX_DEVICES 255
37struct imsm_disk {
38 __u8 serial[MAX_RAID_SERIAL_LEN];/* 0xD8 - 0xE7 ascii serial number */
39 __u32 total_blocks; /* 0xE8 - 0xEB total blocks */
40 __u32 scsi_id; /* 0xEC - 0xEF scsi ID */
41 __u32 status; /* 0xF0 - 0xF3 */
42#define SPARE_DISK 0x01 /* Spare */
43#define CONFIGURED_DISK 0x02 /* Member of some RaidDev */
44#define FAILED_DISK 0x04 /* Permanent failure */
45#define USABLE_DISK 0x08 /* Fully usable unless FAILED_DISK is set */
46
47#define IMSM_DISK_FILLERS 5
48 __u32 filler[IMSM_DISK_FILLERS]; /* 0xF4 - 0x107 MPB_DISK_FILLERS for future expansion */
49};
50
51/* RAID map configuration infos. */
52struct imsm_map {
53 __u32 pba_of_lba0; /* start address of partition */
54 __u32 blocks_per_member;/* blocks per member */
55 __u32 num_data_stripes; /* number of data stripes */
56 __u16 blocks_per_strip;
57 __u8 map_state; /* Normal, Uninitialized, Degraded, Failed */
58#define IMSM_T_STATE_NORMAL 0
59#define IMSM_T_STATE_UNINITIALIZED 1
60#define IMSM_T_STATE_DEGRADED 2 /* FIXME: is this correct? */
61#define IMSM_T_STATE_FAILED 3 /* FIXME: is this correct? */
62 __u8 raid_level;
63#define IMSM_T_RAID0 0
64#define IMSM_T_RAID1 1
65#define IMSM_T_RAID5 5 /* since metadata version 1.2.02 ? */
66 __u8 num_members; /* number of member disks */
67 __u8 reserved[3];
68 __u32 filler[7]; /* expansion area */
69 __u32 disk_ord_tbl[1]; /* disk_ord_tbl[num_members],
70 top byte special */
71} __attribute__ ((packed));
72
73struct imsm_vol {
74 __u32 reserved[2];
75 __u8 migr_state; /* Normal or Migrating */
76 __u8 migr_type; /* Initializing, Rebuilding, ... */
77 __u8 dirty;
78 __u8 fill[1];
79 __u32 filler[5];
80 struct imsm_map map[1];
81 /* here comes another one if migr_state */
82} __attribute__ ((packed));
83
84struct imsm_dev {
85 __u8 volume[MAX_RAID_SERIAL_LEN];
86 __u32 size_low;
87 __u32 size_high;
88 __u32 status; /* Persistent RaidDev status */
89 __u32 reserved_blocks; /* Reserved blocks at beginning of volume */
90#define IMSM_DEV_FILLERS 12
91 __u32 filler[IMSM_DEV_FILLERS];
92 struct imsm_vol vol;
93} __attribute__ ((packed));
94
95struct imsm_super {
96 __u8 sig[MAX_SIGNATURE_LENGTH]; /* 0x00 - 0x1F */
97 __u32 check_sum; /* 0x20 - 0x23 MPB Checksum */
98 __u32 mpb_size; /* 0x24 - 0x27 Size of MPB */
99 __u32 family_num; /* 0x28 - 0x2B Checksum from first time this config was written */
100 __u32 generation_num; /* 0x2C - 0x2F Incremented each time this array's MPB is written */
101 __u32 reserved[2]; /* 0x30 - 0x37 */
102 __u8 num_disks; /* 0x38 Number of configured disks */
103 __u8 num_raid_devs; /* 0x39 Number of configured volumes */
104 __u8 fill[2]; /* 0x3A - 0x3B */
105#define IMSM_FILLERS 39
106 __u32 filler[IMSM_FILLERS]; /* 0x3C - 0xD7 RAID_MPB_FILLERS */
107 struct imsm_disk disk[1]; /* 0xD8 diskTbl[numDisks] */
108 /* here comes imsm_dev[num_raid_devs] */
109} __attribute__ ((packed));
110
111#ifndef MDASSEMBLE
112static char *map_state_str[] = { "normal", "uninitialized", "degraded", "failed" };
113#endif
114
87eb16df 115static unsigned int sector_count(__u32 bytes)
cdddbdbc 116{
87eb16df
DW
117 return ((bytes + (512-1)) & (~(512-1))) / 512;
118}
cdddbdbc 119
87eb16df
DW
120static unsigned int mpb_sectors(struct imsm_super *mpb)
121{
122 return sector_count(__le32_to_cpu(mpb->mpb_size));
cdddbdbc
DW
123}
124
125/* internal representation of IMSM metadata */
126struct intel_super {
127 union {
128 struct imsm_super *mpb;
129 void *buf;
130 };
c2a1e7da 131 int updates_pending;
cdddbdbc
DW
132 struct dl {
133 struct dl *next;
134 int index;
135 __u8 serial[MAX_RAID_SERIAL_LEN];
136 int major, minor;
137 char *devname;
138 int fd;
139 } *disks;
140};
141
142static struct supertype *match_metadata_desc_imsm(char *arg)
143{
144 struct supertype *st;
145
146 if (strcmp(arg, "imsm") != 0 &&
147 strcmp(arg, "default") != 0
148 )
149 return NULL;
150
151 st = malloc(sizeof(*st));
152 st->ss = &super_imsm;
153 st->max_devs = IMSM_MAX_DEVICES;
154 st->minor_version = 0;
155 st->sb = NULL;
156 return st;
157}
158
8b353278 159static struct supertype *match_metadata_desc_imsm_volume(char *arg)
cdddbdbc
DW
160{
161 struct supertype *st;
162
8b353278 163 if (strcmp(arg, "imsm/volume") != 0 &&
cdddbdbc
DW
164 strcmp(arg, "raid") != 0 &&
165 strcmp(arg, "default") != 0
166 )
167 return NULL;
168
169 st = malloc(sizeof(*st));
8b353278 170 st->ss = &super_imsm_volume;
cdddbdbc
DW
171 st->max_devs = IMSM_MAX_DEVICES;
172 st->minor_version = 0;
173 st->sb = NULL;
174 return st;
175}
176
177static __u8 *get_imsm_version(struct imsm_super *mpb)
178{
179 return &mpb->sig[MPB_SIG_LEN];
180}
181
182static struct imsm_disk *get_imsm_disk(struct imsm_super *mpb, __u8 index)
183{
184 if (index > mpb->num_disks - 1)
185 return NULL;
186 return &mpb->disk[index];
187}
188
189static __u32 gen_imsm_checksum(struct imsm_super *mpb)
190{
191 __u32 end = mpb->mpb_size / sizeof(end);
192 __u32 *p = (__u32 *) mpb;
193 __u32 sum = 0;
194
195 while (end--)
196 sum += __le32_to_cpu(*p++);
197
198 return sum - __le32_to_cpu(mpb->check_sum);
199}
200
201static size_t sizeof_imsm_dev(struct imsm_dev *dev)
202{
203 size_t size = sizeof(*dev);
204
205 /* each map has disk_ord_tbl[num_members - 1] additional space */
206 size += sizeof(__u32) * (dev->vol.map[0].num_members - 1);
207
208 /* migrating means an additional map */
209 if (dev->vol.migr_state) {
210 size += sizeof(struct imsm_map);
211 size += sizeof(__u32) * (dev->vol.map[1].num_members - 1);
212 }
213
214 return size;
215}
216
217static struct imsm_dev *get_imsm_dev(struct imsm_super *mpb, __u8 index)
218{
219 int offset;
220 int i;
221 void *_mpb = mpb;
222
223 if (index > mpb->num_raid_devs - 1)
224 return NULL;
225
226 /* devices start after all disks */
227 offset = ((void *) &mpb->disk[mpb->num_disks]) - _mpb;
228
229 for (i = 0; i <= index; i++)
230 if (i == index)
231 return _mpb + offset;
232 else
233 offset += sizeof_imsm_dev(_mpb + offset);
234
235 return NULL;
236}
237
238static __u32 get_imsm_disk_idx(struct imsm_map *map, int slot)
239{
240 __u32 *ord_tbl = &map->disk_ord_tbl[slot];
241
242 /* top byte is 'special' */
243 return __le32_to_cpu(*ord_tbl & ~(0xff << 24));
244}
245
cdddbdbc
DW
246static int get_imsm_raid_level(struct imsm_map *map)
247{
248 if (map->raid_level == 1) {
249 if (map->num_members == 2)
250 return 1;
251 else
252 return 10;
253 }
254
255 return map->raid_level;
256}
257
4f5bc454 258#ifndef MDASSEMBLE
cdddbdbc
DW
259static void print_imsm_dev(struct imsm_dev *dev, int index)
260{
261 __u64 sz;
262 int slot;
263 struct imsm_map *map = dev->vol.map;
264
265 printf("\n");
266 printf("[%s]:\n", dev->volume);
267 printf(" RAID Level : %d\n", get_imsm_raid_level(map));
268 printf(" Members : %d\n", map->num_members);
269 for (slot = 0; slot < map->num_members; slot++)
270 if (index == get_imsm_disk_idx(map, slot))
271 break;
272 if (slot < map->num_members)
273 printf(" This Slot : %d\n", slot);
274 else
275 printf(" This Slot : ?\n");
276 sz = __le32_to_cpu(dev->size_high);
277 sz <<= 32;
278 sz += __le32_to_cpu(dev->size_low);
279 printf(" Array Size : %llu%s\n", (unsigned long long)sz,
280 human_size(sz * 512));
281 sz = __le32_to_cpu(map->blocks_per_member);
282 printf(" Per Dev Size : %llu%s\n", (unsigned long long)sz,
283 human_size(sz * 512));
284 printf(" Sector Offset : %u\n",
285 __le32_to_cpu(map->pba_of_lba0));
286 printf(" Num Stripes : %u\n",
287 __le32_to_cpu(map->num_data_stripes));
288 printf(" Chunk Size : %u KiB\n",
289 __le16_to_cpu(map->blocks_per_strip) / 2);
290 printf(" Reserved : %d\n", __le32_to_cpu(dev->reserved_blocks));
291 printf(" Migrate State : %s\n", dev->vol.migr_state ? "migrating" : "idle");
292 printf(" Dirty State : %s\n", dev->vol.dirty ? "dirty" : "clean");
293 printf(" Map State : %s\n", map_state_str[map->map_state]);
294}
295
296static void print_imsm_disk(struct imsm_super *mpb, int index)
297{
298 struct imsm_disk *disk = get_imsm_disk(mpb, index);
299 char str[MAX_RAID_SERIAL_LEN];
300 __u32 s;
301 __u64 sz;
302
303 printf("\n");
304 snprintf(str, MAX_RAID_SERIAL_LEN, "%s", disk->serial);
305 printf(" Disk%02d Serial : %s\n", index, str);
306 s = __le32_to_cpu(disk->status);
307 printf(" State :%s%s%s%s\n", s&SPARE_DISK ? " spare" : "",
308 s&CONFIGURED_DISK ? " active" : "",
309 s&FAILED_DISK ? " failed" : "",
310 s&USABLE_DISK ? " usable" : "");
311 printf(" Id : %08x\n", __le32_to_cpu(disk->scsi_id));
312 sz = __le32_to_cpu(disk->total_blocks) - mpb_sectors(mpb);
313 printf(" Usable Size : %llu%s\n", (unsigned long long)sz,
314 human_size(sz * 512));
315}
316
317static void examine_super_imsm(struct supertype *st, char *homehost)
318{
319 struct intel_super *super = st->sb;
320 struct imsm_super *mpb = super->mpb;
321 char str[MAX_SIGNATURE_LENGTH];
322 int i;
323 __u32 sum;
324
325 snprintf(str, MPB_SIG_LEN, "%s", mpb->sig);
326 printf(" Magic : %s\n", str);
327 snprintf(str, strlen(MPB_VERSION_RAID0), "%s", get_imsm_version(mpb));
328 printf(" Version : %s\n", get_imsm_version(mpb));
329 printf(" Family : %08x\n", __le32_to_cpu(mpb->family_num));
330 printf(" Generation : %08x\n", __le32_to_cpu(mpb->generation_num));
331 sum = __le32_to_cpu(mpb->check_sum);
332 printf(" Checksum : %08x %s\n", sum,
333 gen_imsm_checksum(mpb) == sum ? "correct" : "incorrect");
87eb16df 334 printf(" MPB Sectors : %d\n", mpb_sectors(mpb));
cdddbdbc
DW
335 printf(" Disks : %d\n", mpb->num_disks);
336 printf(" RAID Devices : %d\n", mpb->num_raid_devs);
337 print_imsm_disk(mpb, super->disks->index);
338 for (i = 0; i < mpb->num_raid_devs; i++)
339 print_imsm_dev(get_imsm_dev(mpb, i), super->disks->index);
340 for (i = 0; i < mpb->num_disks; i++) {
341 if (i == super->disks->index)
342 continue;
343 print_imsm_disk(mpb, i);
344 }
345}
346
347static void brief_examine_super_imsm(struct supertype *st)
348{
349 struct intel_super *super = st->sb;
350 struct imsm_super *mpb = super->mpb;
351
352 printf("ARRAY /dev/imsm family=%08x metadata=external:imsm\n",
353 __le32_to_cpu(mpb->family_num));
354}
355
356static void detail_super_imsm(struct supertype *st, char *homehost)
357{
358 printf("%s\n", __FUNCTION__);
359}
360
361static void brief_detail_super_imsm(struct supertype *st)
362{
363 printf("%s\n", __FUNCTION__);
364}
365#endif
366
367static int match_home_imsm(struct supertype *st, char *homehost)
368{
369 printf("%s\n", __FUNCTION__);
370
371 return 0;
372}
373
374static void uuid_from_super_imsm(struct supertype *st, int uuid[4])
375{
376 printf("%s\n", __FUNCTION__);
377}
378
4f5bc454
DW
379static void
380get_imsm_numerical_version(struct imsm_super *mpb, int *m, int *p)
cdddbdbc 381{
cdddbdbc
DW
382 __u8 *v = get_imsm_version(mpb);
383 __u8 *end = mpb->sig + MAX_SIGNATURE_LENGTH;
384 char major[] = { 0, 0, 0 };
385 char minor[] = { 0 ,0, 0 };
386 char patch[] = { 0, 0, 0 };
387 char *ver_parse[] = { major, minor, patch };
388 int i, j;
389
390 i = j = 0;
391 while (*v != '\0' && v < end) {
392 if (*v != '.' && j < 2)
393 ver_parse[i][j++] = *v;
394 else {
395 i++;
396 j = 0;
397 }
398 v++;
399 }
400
4f5bc454
DW
401 *m = strtol(minor, NULL, 0);
402 *p = strtol(patch, NULL, 0);
403}
404
405static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info)
406{
407 struct intel_super *super = st->sb;
408 struct imsm_super *mpb = super->mpb;
409 struct imsm_disk *disk;
410 __u32 s;
411 int i, j;
412
cdddbdbc 413 info->array.major_version = 2000;
4f5bc454
DW
414 get_imsm_numerical_version(mpb, &info->array.minor_version,
415 &info->array.patch_version);
cdddbdbc
DW
416 info->array.raid_disks = mpb->num_disks;
417 info->array.level = LEVEL_CONTAINER;
418 info->array.layout = 0;
419 info->array.md_minor = -1;
420 info->array.ctime = __le32_to_cpu(mpb->generation_num); //??
421 info->array.utime = 0;
422 info->array.chunk_size = 0;
423
424 info->disk.major = 0;
425 info->disk.minor = 0;
426 info->disk.number = super->disks->index;
427 info->disk.raid_disk = -1;
428 /* is this disk a member of a raid device? */
429 for (i = 0; i < mpb->num_raid_devs; i++) {
430 struct imsm_dev *dev = get_imsm_dev(mpb, i);
431 struct imsm_map *map = dev->vol.map;
432
433 for (j = 0; j < map->num_members; j++) {
434 __u32 index = get_imsm_disk_idx(map, j);
435
436 if (index == super->disks->index) {
437 info->disk.raid_disk = super->disks->index;
438 break;
439 }
440 }
441 if (info->disk.raid_disk != -1)
442 break;
443 }
444 disk = get_imsm_disk(mpb, super->disks->index);
445 s = __le32_to_cpu(disk->status);
446 info->disk.state = s & CONFIGURED_DISK ? (1 << MD_DISK_ACTIVE) : 0;
447 info->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
448 info->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
449 info->reshape_active = 0;
159c3a1a
NB
450
451 strcpy(info->text_version, "imsm");
cdddbdbc
DW
452}
453
8b353278 454static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info)
cdddbdbc
DW
455{
456 printf("%s\n", __FUNCTION__);
159c3a1a
NB
457
458 sprintf(info->text_version, "/%s/%d",
459 devnum2devname(st->container_dev),
460 info->container_member); // FIXME is this even set here?
cdddbdbc
DW
461}
462
463static int update_super_imsm(struct supertype *st, struct mdinfo *info,
464 char *update, char *devname, int verbose,
465 int uuid_set, char *homehost)
466{
f352c545
DW
467 /* FIXME */
468
469 /* For 'assemble' and 'force' we need to return non-zero if any
470 * change was made. For others, the return value is ignored.
471 * Update options are:
472 * force-one : This device looks a bit old but needs to be included,
473 * update age info appropriately.
474 * assemble: clear any 'faulty' flag to allow this device to
475 * be assembled.
476 * force-array: Array is degraded but being forced, mark it clean
477 * if that will be needed to assemble it.
478 *
479 * newdev: not used ????
480 * grow: Array has gained a new device - this is currently for
481 * linear only
482 * resync: mark as dirty so a resync will happen.
483 * name: update the name - preserving the homehost
484 *
485 * Following are not relevant for this imsm:
486 * sparc2.2 : update from old dodgey metadata
487 * super-minor: change the preferred_minor number
488 * summaries: update redundant counters.
489 * uuid: Change the uuid of the array to match watch is given
490 * homehost: update the recorded homehost
491 * _reshape_progress: record new reshape_progress position.
492 */
493 int rv = 0;
494 //struct intel_super *super = st->sb;
495 //struct imsm_super *mpb = super->mpb;
496
497 if (strcmp(update, "grow") == 0) {
498 }
499 if (strcmp(update, "resync") == 0) {
500 /* dev->vol.dirty = 1; */
501 }
502
503 /* IMSM has no concept of UUID or homehost */
504
505 return rv;
cdddbdbc
DW
506}
507
508static __u64 avail_size_imsm(struct supertype *st, __u64 size)
509{
510 printf("%s\n", __FUNCTION__);
511
512 return 0;
513}
514
515static int compare_super_imsm(struct supertype *st, struct supertype *tst)
516{
517 /*
518 * return:
519 * 0 same, or first was empty, and second was copied
520 * 1 second had wrong number
521 * 2 wrong uuid
522 * 3 wrong other info
523 */
524 struct intel_super *first = st->sb;
525 struct intel_super *sec = tst->sb;
526
527 if (!first) {
528 st->sb = tst->sb;
529 tst->sb = NULL;
530 return 0;
531 }
532
533 if (memcmp(first->mpb->sig, sec->mpb->sig, MAX_SIGNATURE_LENGTH) != 0)
534 return 3;
535 if (first->mpb->family_num != sec->mpb->family_num)
536 return 3;
537 if (first->mpb->mpb_size != sec->mpb->mpb_size)
538 return 3;
539 if (first->mpb->check_sum != sec->mpb->check_sum)
540 return 3;
541
542 return 0;
543}
544
545extern int scsi_get_serial(int fd, void *buf, size_t buf_len);
546
547static int imsm_read_serial(int fd, char *devname,
548 __u8 serial[MAX_RAID_SERIAL_LEN])
549{
550 unsigned char scsi_serial[255];
cdddbdbc 551 int sg_fd;
cdddbdbc
DW
552 int rv;
553 int rsp_len;
554 int i, cnt;
555
556 memset(scsi_serial, 0, sizeof(scsi_serial));
cdddbdbc 557
90c8b707 558 sg_fd = sysfs_disk_to_sg(fd);
cdddbdbc
DW
559 if (sg_fd < 0) {
560 if (devname)
561 fprintf(stderr,
90c8b707
DW
562 Name ": Failed to open sg interface for %s: %s\n",
563 devname, strerror(errno));
cdddbdbc
DW
564 return 1;
565 }
566
567 rv = scsi_get_serial(sg_fd, scsi_serial, sizeof(scsi_serial));
568 close(sg_fd);
569
570 if (rv != 0) {
571 if (devname)
572 fprintf(stderr,
573 Name ": Failed to retrieve serial for %s\n",
574 devname);
575 return rv;
576 }
577
578 rsp_len = scsi_serial[3];
579 for (i = 0, cnt = 0; i < rsp_len; i++) {
580 if (!isspace(scsi_serial[4 + i]))
581 serial[cnt++] = scsi_serial[4 + i];
582 if (cnt == MAX_RAID_SERIAL_LEN)
583 break;
584 }
585
586 serial[MAX_RAID_SERIAL_LEN - 1] = '\0';
587
588 return 0;
589}
590
591static int
592load_imsm_disk(int fd, struct intel_super *super, char *devname, int keep_fd)
593{
594 struct imsm_super *mpb = super->mpb;
595 struct dl *dl;
596 struct stat stb;
597 struct imsm_disk *disk;
598 int rv;
599 int i;
600
601 dl = malloc(sizeof(*dl));
602 if (!dl) {
603 if (devname)
604 fprintf(stderr,
605 Name ": failed to allocate disk buffer for %s\n",
606 devname);
607 return 2;
608 }
609 memset(dl, 0, sizeof(*dl));
610
611 fstat(fd, &stb);
612 dl->major = major(stb.st_rdev);
613 dl->minor = minor(stb.st_rdev);
614 dl->next = super->disks;
615 dl->fd = keep_fd ? fd : -1;
616 dl->devname = devname ? strdup(devname) : NULL;
617 dl->index = -1;
618 super->disks = dl;
619 rv = imsm_read_serial(fd, devname, dl->serial);
620
621 if (rv != 0)
622 return 2;
623
624 /* look up this disk's index */
625 for (i = 0; i < mpb->num_disks; i++) {
626 disk = get_imsm_disk(mpb, i);
627
628 if (memcmp(disk->serial, dl->serial, MAX_RAID_SERIAL_LEN) == 0)
629 break;
630 }
631
632 if (i > mpb->num_disks)
633 return 2;
634
635 dl->index = i;
636
637 return 0;
638}
639
640/* load_imsm_mpb - read matrix metadata
641 * allocates super->mpb to be freed by free_super
642 */
643static int load_imsm_mpb(int fd, struct intel_super *super, char *devname)
644{
645 unsigned long long dsize;
646 size_t len, mpb_size;
647 unsigned long long sectors;
648 struct stat;
649 struct imsm_super anchor;
650 __u32 check_sum;
651
652 memset(super, 0, sizeof(*super));
653 get_dev_size(fd, NULL, &dsize);
654
655 if (lseek64(fd, dsize - (512 * 2), SEEK_SET) < 0) {
656 if (devname)
657 fprintf(stderr,
658 Name ": Cannot seek to anchor block on %s: %s\n",
659 devname, strerror(errno));
660 return 1;
661 }
662
663 len = sizeof(anchor);
664 if (read(fd, &anchor, len) != len) {
665 if (devname)
666 fprintf(stderr,
667 Name ": Cannot read anchor block on %s: %s\n",
668 devname, strerror(errno));
669 return 1;
670 }
671
672 if (strncmp((char *) anchor.sig, MPB_SIGNATURE, MPB_SIG_LEN) != 0) {
673 if (devname)
674 fprintf(stderr,
675 Name ": no IMSM anchor on %s\n", devname);
676 return 2;
677 }
678
679 mpb_size = __le32_to_cpu(anchor.mpb_size);
680 super->mpb = malloc(mpb_size < 512 ? 512 : mpb_size);
681 if (!super->mpb) {
682 if (devname)
683 fprintf(stderr,
684 Name ": unable to allocate %zu byte mpb buffer\n",
685 mpb_size);
686 return 2;
687 }
688 memcpy(super->buf, &anchor, sizeof(anchor));
689
690 /* read the rest of the first block */
691 len = 512 - sizeof(anchor);
692 if (read(fd, super->buf + sizeof(anchor), len) != len) {
693 if (devname)
694 fprintf(stderr,
695 Name ": Cannot read anchor remainder on %s: %s\n",
696 devname, strerror(errno));
697 return 2;
698 }
699
700 sectors = mpb_sectors(&anchor) - 1;
701 if (!sectors)
702 return load_imsm_disk(fd, super, devname, 0);
703
704 /* read the extended mpb */
705 if (lseek64(fd, dsize - (512 * (2 + sectors)), SEEK_SET) < 0) {
706 if (devname)
707 fprintf(stderr,
708 Name ": Cannot seek to extended mpb on %s: %s\n",
709 devname, strerror(errno));
710 return 1;
711 }
712
713 len = mpb_size - 512;
714 if (read(fd, super->buf + 512, len) != len) {
715 if (devname)
716 fprintf(stderr,
717 Name ": Cannot read extended mpb on %s: %s\n",
718 devname, strerror(errno));
719 return 2;
720 }
721
722 check_sum = gen_imsm_checksum(super->mpb);
723 if (check_sum != __le32_to_cpu(super->mpb->check_sum)) {
724 if (devname)
725 fprintf(stderr,
726 Name ": IMSM checksum %x != %x on %s\n",
727 check_sum, __le32_to_cpu(super->mpb->check_sum),
728 devname);
729 return 2;
730 }
731
732 return load_imsm_disk(fd, super, devname, 0);
733}
734
735struct superswitch super_imsm_container;
736
737static void free_imsm_disks(struct intel_super *super)
738{
739 while (super->disks) {
740 struct dl *d = super->disks;
741
742 super->disks = d->next;
743 if (d->fd >= 0)
744 close(d->fd);
745 if (d->devname)
746 free(d->devname);
747 free(d);
748 }
749}
750
751static void free_imsm(struct intel_super *super)
752{
753 if (super->mpb)
754 free(super->mpb);
755 free_imsm_disks(super);
756 free(super);
757}
758
759
760static void free_super_imsm(struct supertype *st)
761{
762 struct intel_super *super = st->sb;
763
764 if (!super)
765 return;
766
767 free_imsm(super);
768 st->sb = NULL;
769}
770
771#ifndef MDASSEMBLE
772static int load_super_imsm_all(struct supertype *st, int fd, void **sbp,
773 char *devname, int keep_fd)
774{
775 struct mdinfo *sra;
776 struct intel_super *super;
777 struct mdinfo *sd, *best = NULL;
778 __u32 bestgen = 0;
779 __u32 gen;
780 char nm[20];
781 int dfd;
782 int rv;
783
784 /* check if this disk is a member of an active array */
785 sra = sysfs_read(fd, 0, GET_LEVEL|GET_VERSION|GET_DEVS|GET_STATE);
786 if (!sra)
787 return 1;
788
789 if (sra->array.major_version != -1 ||
790 sra->array.minor_version != -2 ||
791 strcmp(sra->text_version, "imsm") != 0)
792 return 1;
793
794 super = malloc(sizeof(*super));
795 if (!super)
796 return 1;
797
798 /* find the most up to date disk in this array */
799 for (sd = sra->devs; sd; sd = sd->next) {
800 sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor);
801 dfd = dev_open(nm, keep_fd ? O_RDWR : O_RDONLY);
802 if (!dfd) {
803 free_imsm(super);
804 return 2;
805 }
806 rv = load_imsm_mpb(dfd, super, NULL);
807 if (!keep_fd)
808 close(dfd);
809 if (rv == 0) {
810 gen = __le32_to_cpu(super->mpb->generation_num);
811 if (!best || gen > bestgen) {
812 bestgen = gen;
813 best = sd;
814 }
815 } else {
816 free_imsm(super);
817 return 2;
818 }
819 }
820
821 if (!best) {
822 free_imsm(super);
823 return 1;
824 }
825
826 /* load the most up to date anchor */
827 sprintf(nm, "%d:%d", best->disk.major, best->disk.minor);
828 dfd = dev_open(nm, O_RDONLY);
829 if (!dfd) {
830 free_imsm(super);
831 return 1;
832 }
833 rv = load_imsm_mpb(dfd, super, NULL);
834 close(dfd);
835 if (rv != 0) {
836 free_imsm(super);
837 return 2;
838 }
839
840 /* reset the disk list */
841 free_imsm_disks(super);
842
843 /* populate disk list */
844 for (sd = sra->devs ; sd ; sd = sd->next) {
845 sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor);
846 dfd = dev_open(nm, keep_fd? O_RDWR : O_RDONLY);
847 if (!dfd) {
848 free_imsm(super);
849 return 2;
850 }
851 load_imsm_disk(dfd, super, NULL, keep_fd);
852 if (!keep_fd)
853 close(dfd);
854 }
855
856 *sbp = super;
857 if (st->ss == NULL) {
858 st->ss = &super_imsm_container;
859 st->minor_version = 0;
860 st->max_devs = IMSM_MAX_DEVICES;
f4d11639 861 st->container_dev = fd2devnum(fd);
cdddbdbc
DW
862 }
863
864 return 0;
865}
866#endif
867
868static int load_super_imsm(struct supertype *st, int fd, char *devname)
869{
870 struct intel_super *super;
871 int rv;
872
873#ifndef MDASSEMBLE
3dbccbcf 874 if (load_super_imsm_all(st, fd, &st->sb, devname, 1) == 0)
cdddbdbc
DW
875 return 0;
876#endif
877
878 super = malloc(sizeof(*super));
879 if (!super) {
880 fprintf(stderr,
881 Name ": malloc of %zu failed.\n",
882 sizeof(*super));
883 return 1;
884 }
885
886 rv = load_imsm_mpb(fd, super, devname);
887
888 if (rv) {
889 if (devname)
890 fprintf(stderr,
891 Name ": Failed to load all information "
892 "sections on %s\n", devname);
893 free_imsm(super);
894 return rv;
895 }
896
897 st->sb = super;
898 if (st->ss == NULL) {
899 st->ss = &super_imsm;
900 st->minor_version = 0;
901 st->max_devs = IMSM_MAX_DEVICES;
902 }
903
904 return 0;
905}
906
907static int init_zero_imsm(struct supertype *st, mdu_array_info_t *info,
908 unsigned long long size, char *name,
909 char *homehost, int *uuid)
910{
911 printf("%s\n", __FUNCTION__);
912
913 return 0;
914}
915
916static int init_super_imsm(struct supertype *st, mdu_array_info_t *info,
917 unsigned long long size, char *name,
918 char *homehost, int *uuid)
919{
920 printf("%s\n", __FUNCTION__);
921
922 return 0;
923}
924
8b353278
DW
925static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
926 unsigned long long size, char *name,
927 char *homehost, int *uuid)
cdddbdbc
DW
928{
929 printf("%s\n", __FUNCTION__);
930
931 return 0;
932}
933
934static void add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dinfo,
935 int fd, char *devname)
936{
937 printf("%s\n", __FUNCTION__);
938}
939
8b353278
DW
940static void add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dinfo,
941 int fd, char *devname)
cdddbdbc
DW
942{
943 printf("%s\n", __FUNCTION__);
944}
945
946static int write_init_super_imsm(struct supertype *st)
947{
948 printf("%s\n", __FUNCTION__);
949
950 return 0;
951}
952
953static int store_zero_imsm(struct supertype *st, int fd)
954{
955 printf("%s\n", __FUNCTION__);
956
957 return 0;
958}
959
f352c545 960static void getinfo_super_n_imsm_container(struct supertype *st, struct mdinfo *info)
cdddbdbc 961{
f352c545
DW
962 /* just need offset and size...
963 * of the metadata??
964 */
965 struct intel_super *super = st->sb;
966 struct imsm_super *mpb = super->mpb;
967 struct imsm_disk *disk = get_imsm_disk(mpb, info->disk.number);
968 int sect = mpb_sectors(mpb);
969
970 info->data_offset = __le32_to_cpu(disk->total_blocks) - (2 + sect - 1);
971 info->component_size = sect;
cdddbdbc
DW
972}
973
8b353278 974static void getinfo_super_n_imsm_volume(struct supertype *st, struct mdinfo *info)
cdddbdbc
DW
975{
976 printf("%s\n", __FUNCTION__);
977}
978
979static int validate_geometry_imsm(struct supertype *st, int level, int layout,
980 int raiddisks, int chunk, unsigned long long size,
981 char *subdev, unsigned long long *freesize)
982{
983 printf("%s\n", __FUNCTION__);
984
985 return 0;
986}
987
988static int validate_geometry_imsm_container(struct supertype *st, int level,
989 int layout, int raiddisks, int chunk,
990 unsigned long long size, char *subdev,
991 unsigned long long *freesize)
992{
993 printf("%s\n", __FUNCTION__);
994
995 return 0;
996}
997
8b353278
DW
998static int validate_geometry_imsm_volume(struct supertype *st, int level,
999 int layout, int raiddisks, int chunk,
1000 unsigned long long size, char *subdev,
1001 unsigned long long *freesize)
cdddbdbc
DW
1002{
1003 printf("%s\n", __FUNCTION__);
1004
1005 return 0;
1006}
1007
cdddbdbc
DW
1008static struct mdinfo *container_content_imsm(struct supertype *st)
1009{
4f5bc454
DW
1010 /* Given a container loaded by load_super_imsm_all,
1011 * extract information about all the arrays into
1012 * an mdinfo tree.
1013 *
1014 * For each imsm_dev create an mdinfo, fill it in,
1015 * then look for matching devices in super->disks
1016 * and create appropriate device mdinfo.
1017 */
1018 struct intel_super *super = st->sb;
1019 struct imsm_super *mpb = super->mpb;
1020 struct mdinfo *rest = NULL;
1021 int i;
cdddbdbc 1022
4f5bc454
DW
1023 for (i = 0; i < mpb->num_raid_devs; i++) {
1024 struct imsm_dev *dev = get_imsm_dev(mpb, i);
1025 struct imsm_vol *vol = &dev->vol;
1026 struct imsm_map *map = vol->map;
1027 struct mdinfo *this;
1028 __u64 sz;
1029 int slot;
1030
1031 this = malloc(sizeof(*this));
1032 memset(this, 0, sizeof(*this));
1033 this->next = rest;
1034 rest = this;
1035
1036 this->array.major_version = 2000;
1037 get_imsm_numerical_version(mpb, &this->array.minor_version,
1038 &this->array.patch_version);
1039 this->array.level = get_imsm_raid_level(map);
1040 this->array.raid_disks = map->num_members;
1041 switch(this->array.level) {
1042 case 0:
1043 case 1:
1044 this->array.layout = 0;
1045 break;
1046 case 5:
1047 case 6:
1048 this->array.layout = ALGORITHM_LEFT_SYMMETRIC;
1049 break;
1050 case 10:
1051 this->array.layout = 0x102; //FIXME is this correct?
1052 break;
1053 default:
1054 this->array.layout = -1; // FIXME
1055 }
1056 this->array.md_minor = -1;
1057 this->array.ctime = 0;
1058 this->array.utime = 0;
1059 this->array.chunk_size = __le16_to_cpu(map->blocks_per_strip) << 9;
1060 this->array.state = !vol->dirty;
1061 this->container_member = i;
0fd5c350
DW
1062 if (map->map_state == IMSM_T_STATE_UNINITIALIZED || dev->vol.dirty)
1063 this->resync_start = 0;
1064 else
1065 this->resync_start = ~0ULL;
1066
4f5bc454
DW
1067 strncpy(this->name, (char *) dev->volume, MAX_RAID_SERIAL_LEN);
1068 this->name[MAX_RAID_SERIAL_LEN] = 0;
1069
159c3a1a
NB
1070 sprintf(this->text_version, "/%s/%d",
1071 devnum2devname(st->container_dev),
1072 this->container_member);
1073
4f5bc454
DW
1074 memset(this->uuid, 0, sizeof(this->uuid));
1075
1076 sz = __le32_to_cpu(dev->size_high);
1077 sz <<= 32;
1078 sz += __le32_to_cpu(dev->size_low);
1079 this->component_size = sz;
1080 this->array.size = this->component_size / 2;
1081
1082 for (slot = 0 ; slot < map->num_members; slot++) {
1083 struct imsm_disk *disk;
1084 struct mdinfo *info_d;
1085 struct dl *d;
1086 int idx;
1087 __u32 s;
1088
1089 idx = __le32_to_cpu(map->disk_ord_tbl[slot] & ~(0xff << 24));
1090 for (d = super->disks; d ; d = d->next)
1091 if (d->index == idx)
1092 break;
1093
1094 if (d == NULL)
1095 break; /* shouldn't this be continue ?? */
1096
1097 info_d = malloc(sizeof(*info_d));
1098 if (!info_d)
1099 break; /* ditto ?? */
1100 memset(info_d, 0, sizeof(*info_d));
1101 info_d->next = this->devs;
1102 this->devs = info_d;
1103
1104 disk = get_imsm_disk(mpb, idx);
1105 s = __le32_to_cpu(disk->status);
1106
1107 info_d->disk.number = d->index;
1108 info_d->disk.major = d->major;
1109 info_d->disk.minor = d->minor;
1110 info_d->disk.raid_disk = slot;
1111 info_d->disk.state = s & CONFIGURED_DISK ? (1 << MD_DISK_ACTIVE) : 0;
1112 info_d->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
1113 info_d->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
1114
1115 this->array.working_disks++;
1116
1117 info_d->events = __le32_to_cpu(mpb->generation_num);
1118 info_d->data_offset = __le32_to_cpu(map->pba_of_lba0);
1119 info_d->component_size = __le32_to_cpu(map->blocks_per_member);
1120 if (d->devname)
1121 strcpy(info_d->name, d->devname);
1122 }
1123 }
1124
1125 return rest;
cdddbdbc
DW
1126}
1127
845dea95 1128
cba0191b
NB
1129static int imsm_open_new(struct supertype *c, struct active_array *a,
1130 char *inst)
845dea95 1131{
cba0191b
NB
1132 fprintf(stderr, "imsm: open_new %s\n", inst);
1133 a->info.container_member = atoi(inst);
845dea95
NB
1134 return 0;
1135}
1136
ed9d66aa 1137static void imsm_set_array_state(struct active_array *a, int consistent)
845dea95 1138{
c2a1e7da
DW
1139 int inst = a->info.container_member;
1140 struct intel_super *super = a->container->sb;
1141 struct imsm_dev *dev = get_imsm_dev(super->mpb, inst);
ed9d66aa 1142 int dirty = !consistent || (a->resync_start != ~0ULL);
c2a1e7da 1143
4e5528c6 1144 if (dev->vol.dirty != dirty) {
ed9d66aa
NB
1145 fprintf(stderr, "imsm: mark '%s' (%llu)\n",
1146 dirty?"dirty":"clean", a->resync_start);
845dea95 1147
4e5528c6 1148 dev->vol.dirty = dirty;
c2a1e7da
DW
1149 super->updates_pending++;
1150 }
1151}
1152
1153static __u8 imsm_check_degraded(struct imsm_super *mpb, int n, int failed)
1154{
1155 struct imsm_dev *dev = get_imsm_dev(mpb, n);
1156 struct imsm_map *map = dev->vol.map;
1157
1158 if (!failed)
1159 return map->map_state;
1160
1161 switch (get_imsm_raid_level(map)) {
1162 case 0:
1163 return IMSM_T_STATE_FAILED;
1164 break;
1165 case 1:
1166 if (failed < map->num_members)
1167 return IMSM_T_STATE_DEGRADED;
1168 else
1169 return IMSM_T_STATE_FAILED;
1170 break;
1171 case 10:
1172 {
1173 /**
1174 * check to see if any mirrors have failed,
1175 * otherwise we are degraded
1176 */
1177 int device_per_mirror = 2; /* FIXME is this always the case?
1178 * and are they always adjacent?
1179 */
1180 int failed = 0;
1181 int i;
1182
1183 for (i = 0; i < map->num_members; i++) {
1184 int idx = get_imsm_disk_idx(map, i);
1185 struct imsm_disk *disk = get_imsm_disk(mpb, idx);
1186
1187 if (__le32_to_cpu(disk->status) & FAILED_DISK)
1188 failed++;
1189
1190 if (failed >= device_per_mirror)
1191 return IMSM_T_STATE_FAILED;
1192
1193 /* reset 'failed' for next mirror set */
1194 if (!((i + 1) % device_per_mirror))
1195 failed = 0;
1196 }
1197
1198 return IMSM_T_STATE_DEGRADED;
1199 }
1200 case 5:
1201 if (failed < 2)
1202 return IMSM_T_STATE_DEGRADED;
1203 else
1204 return IMSM_T_STATE_FAILED;
1205 break;
1206 default:
1207 break;
1208 }
1209
1210 return map->map_state;
1211}
1212
1213static int imsm_count_failed(struct imsm_super *mpb, struct imsm_map *map)
1214{
1215 int i;
1216 int failed = 0;
1217 struct imsm_disk *disk;
1218
1219 for (i = 0; i < map->num_members; i++) {
1220 int idx = get_imsm_disk_idx(map, i);
1221
1222 disk = get_imsm_disk(mpb, idx);
1223 if (__le32_to_cpu(disk->status) & FAILED_DISK)
1224 failed++;
1225 }
1226
1227 return failed;
845dea95
NB
1228}
1229
8d45d196 1230static void imsm_set_disk(struct active_array *a, int n, int state)
845dea95 1231{
8d45d196
DW
1232 int inst = a->info.container_member;
1233 struct intel_super *super = a->container->sb;
1234 struct imsm_dev *dev = get_imsm_dev(super->mpb, inst);
1235 struct imsm_map *map = dev->vol.map;
1236 struct imsm_disk *disk;
1237 __u32 status;
1238 int failed = 0;
1239 int new_failure = 0;
1240
1241 if (n > map->num_members)
1242 fprintf(stderr, "imsm: set_disk %d out of range 0..%d\n",
1243 n, map->num_members - 1);
1244
1245 if (n < 0)
1246 return;
1247
1248 fprintf(stderr, "imsm: set_disk %d:%x\n", n, state);
1249
1250 disk = get_imsm_disk(super->mpb, get_imsm_disk_idx(map, n));
1251
1252 /* check if we have seen this failure before */
1253 status = __le32_to_cpu(disk->status);
1254 if ((state & DS_FAULTY) && !(status & FAILED_DISK)) {
1255 status |= FAILED_DISK;
1256 disk->status = __cpu_to_le32(status);
1257 new_failure = 1;
1258 }
1259
1260 /**
1261 * the number of failures have changed, count up 'failed' to determine
1262 * degraded / failed status
1263 */
1264 if (new_failure && map->map_state != IMSM_T_STATE_FAILED)
1265 failed = imsm_count_failed(super->mpb, map);
1266
1267 if (failed)
1268 map->map_state = imsm_check_degraded(super->mpb, inst, failed);
1269
1270 if (new_failure)
1271 super->updates_pending++;
845dea95
NB
1272}
1273
c2a1e7da
DW
1274static int store_imsm_mpb(int fd, struct intel_super *super)
1275{
1276 struct imsm_super *mpb = super->mpb;
1277 __u32 mpb_size = __le32_to_cpu(mpb->mpb_size);
1278 unsigned long long dsize;
1279 unsigned long long sectors;
1280
1281 get_dev_size(fd, NULL, &dsize);
1282
1283 /* first block is stored on second to last sector of the disk */
1284 if (lseek64(fd, dsize - (512 * 2), SEEK_SET) < 0)
1285 return 1;
1286
1287 if (write(fd, super->buf, 512) != 512)
1288 return 1;
1289
1290 if (mpb_size <= 512)
1291 return 0;
1292
1293 /* -1 because we already wrote a sector */
1294 sectors = mpb_sectors(mpb) - 1;
1295
1296 /* write the extended mpb to the sectors preceeding the anchor */
1297 if (lseek64(fd, dsize - (512 * (2 + sectors)), SEEK_SET) < 0)
1298 return 1;
1299
1300 if (write(fd, super->buf + 512, mpb_size - 512) != mpb_size - 512)
1301 return 1;
1302
1303 fsync(fd);
1304
1305 return 0;
1306}
1307
2e735d19 1308static void imsm_sync_metadata(struct supertype *container)
845dea95 1309{
2e735d19 1310 struct intel_super *super = container->sb;
c2a1e7da
DW
1311 struct imsm_super *mpb = super->mpb;
1312 struct dl *d;
1313 __u32 generation;
1314 __u32 sum;
1315
1316 if (!super->updates_pending)
1317 return;
1318
845dea95 1319 fprintf(stderr, "imsm: sync_metadata\n");
c2a1e7da
DW
1320
1321 /* 'generation' is incremented everytime the metadata is written */
1322 generation = __le32_to_cpu(mpb->generation_num);
1323 generation++;
1324 mpb->generation_num = __cpu_to_le32(generation);
1325
1326 /* recalculate checksum */
1327 sum = gen_imsm_checksum(mpb);
1328 mpb->check_sum = __cpu_to_le32(sum);
1329
1330 for (d = super->disks; d ; d = d->next)
1331 if (store_imsm_mpb(d->fd, super))
1332 fprintf(stderr, "%s: failed for device %d:%d %s\n",
1333 __func__, d->major, d->minor, strerror(errno));
1334
1335 super->updates_pending = 0;
845dea95
NB
1336}
1337
cdddbdbc
DW
1338struct superswitch super_imsm = {
1339#ifndef MDASSEMBLE
1340 .examine_super = examine_super_imsm,
1341 .brief_examine_super = brief_examine_super_imsm,
1342 .detail_super = detail_super_imsm,
1343 .brief_detail_super = brief_detail_super_imsm,
1344#endif
1345 .match_home = match_home_imsm,
1346 .uuid_from_super= uuid_from_super_imsm,
1347 .getinfo_super = getinfo_super_imsm,
1348 .update_super = update_super_imsm,
1349
1350 .avail_size = avail_size_imsm,
1351
1352 .compare_super = compare_super_imsm,
1353
1354 .load_super = load_super_imsm,
1355 .init_super = init_zero_imsm,
1356 .store_super = store_zero_imsm,
1357 .free_super = free_super_imsm,
1358 .match_metadata_desc = match_metadata_desc_imsm,
f352c545 1359 .getinfo_super_n = getinfo_super_n_imsm_container,
cdddbdbc
DW
1360
1361 .validate_geometry = validate_geometry_imsm,
1362 .major = 2000,
1363 .swapuuid = 0,
1364 .external = 1,
845dea95
NB
1365
1366/* for mdmon */
1367 .open_new = imsm_open_new,
1368 .load_super = load_super_imsm,
ed9d66aa 1369 .set_array_state= imsm_set_array_state,
845dea95
NB
1370 .set_disk = imsm_set_disk,
1371 .sync_metadata = imsm_sync_metadata,
cdddbdbc
DW
1372};
1373
1374/* super_imsm_container is set by validate_geometry_imsm when given a
1375 * device that is not part of any array
1376 */
1377struct superswitch super_imsm_container = {
1378
1379 .validate_geometry = validate_geometry_imsm_container,
1380 .init_super = init_super_imsm,
1381 .add_to_super = add_to_super_imsm,
1382 .write_init_super = write_init_super_imsm,
1383 .getinfo_super = getinfo_super_imsm,
f352c545 1384 .getinfo_super_n = getinfo_super_n_imsm_container,
cdddbdbc
DW
1385 .load_super = load_super_imsm,
1386
1387#ifndef MDASSEMBLE
1388 .examine_super = examine_super_imsm,
1389 .brief_examine_super = brief_examine_super_imsm,
1390 .detail_super = detail_super_imsm,
1391 .brief_detail_super = brief_detail_super_imsm,
1392#endif
1393
1394 .free_super = free_super_imsm,
1395
1396 .container_content = container_content_imsm,
1397
1398 .major = 2000,
1399 .swapuuid = 0,
1400 .external = 1,
cdddbdbc
DW
1401};
1402
8b353278 1403struct superswitch super_imsm_volume = {
cdddbdbc 1404 .update_super = update_super_imsm,
8b353278
DW
1405 .init_super = init_super_imsm_volume,
1406 .add_to_super = add_to_super_imsm_volume,
1407 .getinfo_super = getinfo_super_imsm_volume,
1408 .getinfo_super_n = getinfo_super_n_imsm_volume,
cdddbdbc
DW
1409 .write_init_super = write_init_super_imsm,
1410
1411 .load_super = load_super_imsm,
1412 .free_super = free_super_imsm,
8b353278 1413 .match_metadata_desc = match_metadata_desc_imsm_volume,
cdddbdbc
DW
1414
1415
8b353278 1416 .validate_geometry = validate_geometry_imsm_volume,
cdddbdbc
DW
1417 .major = 2001,
1418 .swapuuid = 0,
1419 .external = 2,
cdddbdbc 1420};