Remove st->text_version in favour of info->text_version
[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
115static unsigned long long mpb_sectors(struct imsm_super *mpb)
116{
117 __u32 size = __le32_to_cpu(mpb->mpb_size);
118
119 return ((size + (512-1)) & (~(512-1))) / 512;
120}
121
122/* internal representation of IMSM metadata */
123struct intel_super {
124 union {
125 struct imsm_super *mpb;
126 void *buf;
127 };
c2a1e7da 128 int updates_pending;
cdddbdbc
DW
129 struct dl {
130 struct dl *next;
131 int index;
132 __u8 serial[MAX_RAID_SERIAL_LEN];
133 int major, minor;
134 char *devname;
135 int fd;
136 } *disks;
137};
138
139static struct supertype *match_metadata_desc_imsm(char *arg)
140{
141 struct supertype *st;
142
143 if (strcmp(arg, "imsm") != 0 &&
144 strcmp(arg, "default") != 0
145 )
146 return NULL;
147
148 st = malloc(sizeof(*st));
149 st->ss = &super_imsm;
150 st->max_devs = IMSM_MAX_DEVICES;
151 st->minor_version = 0;
152 st->sb = NULL;
153 return st;
154}
155
156static struct supertype *match_metadata_desc_imsm_raid(char *arg)
157{
158 struct supertype *st;
159
160 if (strcmp(arg, "imsm/raid") != 0 &&
161 strcmp(arg, "raid") != 0 &&
162 strcmp(arg, "default") != 0
163 )
164 return NULL;
165
166 st = malloc(sizeof(*st));
167 st->ss = &super_imsm_raid;
168 st->max_devs = IMSM_MAX_DEVICES;
169 st->minor_version = 0;
170 st->sb = NULL;
171 return st;
172}
173
174static __u8 *get_imsm_version(struct imsm_super *mpb)
175{
176 return &mpb->sig[MPB_SIG_LEN];
177}
178
179static struct imsm_disk *get_imsm_disk(struct imsm_super *mpb, __u8 index)
180{
181 if (index > mpb->num_disks - 1)
182 return NULL;
183 return &mpb->disk[index];
184}
185
186static __u32 gen_imsm_checksum(struct imsm_super *mpb)
187{
188 __u32 end = mpb->mpb_size / sizeof(end);
189 __u32 *p = (__u32 *) mpb;
190 __u32 sum = 0;
191
192 while (end--)
193 sum += __le32_to_cpu(*p++);
194
195 return sum - __le32_to_cpu(mpb->check_sum);
196}
197
198static size_t sizeof_imsm_dev(struct imsm_dev *dev)
199{
200 size_t size = sizeof(*dev);
201
202 /* each map has disk_ord_tbl[num_members - 1] additional space */
203 size += sizeof(__u32) * (dev->vol.map[0].num_members - 1);
204
205 /* migrating means an additional map */
206 if (dev->vol.migr_state) {
207 size += sizeof(struct imsm_map);
208 size += sizeof(__u32) * (dev->vol.map[1].num_members - 1);
209 }
210
211 return size;
212}
213
214static struct imsm_dev *get_imsm_dev(struct imsm_super *mpb, __u8 index)
215{
216 int offset;
217 int i;
218 void *_mpb = mpb;
219
220 if (index > mpb->num_raid_devs - 1)
221 return NULL;
222
223 /* devices start after all disks */
224 offset = ((void *) &mpb->disk[mpb->num_disks]) - _mpb;
225
226 for (i = 0; i <= index; i++)
227 if (i == index)
228 return _mpb + offset;
229 else
230 offset += sizeof_imsm_dev(_mpb + offset);
231
232 return NULL;
233}
234
235static __u32 get_imsm_disk_idx(struct imsm_map *map, int slot)
236{
237 __u32 *ord_tbl = &map->disk_ord_tbl[slot];
238
239 /* top byte is 'special' */
240 return __le32_to_cpu(*ord_tbl & ~(0xff << 24));
241}
242
cdddbdbc
DW
243static int get_imsm_raid_level(struct imsm_map *map)
244{
245 if (map->raid_level == 1) {
246 if (map->num_members == 2)
247 return 1;
248 else
249 return 10;
250 }
251
252 return map->raid_level;
253}
254
4f5bc454 255#ifndef MDASSEMBLE
cdddbdbc
DW
256static void print_imsm_dev(struct imsm_dev *dev, int index)
257{
258 __u64 sz;
259 int slot;
260 struct imsm_map *map = dev->vol.map;
261
262 printf("\n");
263 printf("[%s]:\n", dev->volume);
264 printf(" RAID Level : %d\n", get_imsm_raid_level(map));
265 printf(" Members : %d\n", map->num_members);
266 for (slot = 0; slot < map->num_members; slot++)
267 if (index == get_imsm_disk_idx(map, slot))
268 break;
269 if (slot < map->num_members)
270 printf(" This Slot : %d\n", slot);
271 else
272 printf(" This Slot : ?\n");
273 sz = __le32_to_cpu(dev->size_high);
274 sz <<= 32;
275 sz += __le32_to_cpu(dev->size_low);
276 printf(" Array Size : %llu%s\n", (unsigned long long)sz,
277 human_size(sz * 512));
278 sz = __le32_to_cpu(map->blocks_per_member);
279 printf(" Per Dev Size : %llu%s\n", (unsigned long long)sz,
280 human_size(sz * 512));
281 printf(" Sector Offset : %u\n",
282 __le32_to_cpu(map->pba_of_lba0));
283 printf(" Num Stripes : %u\n",
284 __le32_to_cpu(map->num_data_stripes));
285 printf(" Chunk Size : %u KiB\n",
286 __le16_to_cpu(map->blocks_per_strip) / 2);
287 printf(" Reserved : %d\n", __le32_to_cpu(dev->reserved_blocks));
288 printf(" Migrate State : %s\n", dev->vol.migr_state ? "migrating" : "idle");
289 printf(" Dirty State : %s\n", dev->vol.dirty ? "dirty" : "clean");
290 printf(" Map State : %s\n", map_state_str[map->map_state]);
291}
292
293static void print_imsm_disk(struct imsm_super *mpb, int index)
294{
295 struct imsm_disk *disk = get_imsm_disk(mpb, index);
296 char str[MAX_RAID_SERIAL_LEN];
297 __u32 s;
298 __u64 sz;
299
300 printf("\n");
301 snprintf(str, MAX_RAID_SERIAL_LEN, "%s", disk->serial);
302 printf(" Disk%02d Serial : %s\n", index, str);
303 s = __le32_to_cpu(disk->status);
304 printf(" State :%s%s%s%s\n", s&SPARE_DISK ? " spare" : "",
305 s&CONFIGURED_DISK ? " active" : "",
306 s&FAILED_DISK ? " failed" : "",
307 s&USABLE_DISK ? " usable" : "");
308 printf(" Id : %08x\n", __le32_to_cpu(disk->scsi_id));
309 sz = __le32_to_cpu(disk->total_blocks) - mpb_sectors(mpb);
310 printf(" Usable Size : %llu%s\n", (unsigned long long)sz,
311 human_size(sz * 512));
312}
313
314static void examine_super_imsm(struct supertype *st, char *homehost)
315{
316 struct intel_super *super = st->sb;
317 struct imsm_super *mpb = super->mpb;
318 char str[MAX_SIGNATURE_LENGTH];
319 int i;
320 __u32 sum;
321
322 snprintf(str, MPB_SIG_LEN, "%s", mpb->sig);
323 printf(" Magic : %s\n", str);
324 snprintf(str, strlen(MPB_VERSION_RAID0), "%s", get_imsm_version(mpb));
325 printf(" Version : %s\n", get_imsm_version(mpb));
326 printf(" Family : %08x\n", __le32_to_cpu(mpb->family_num));
327 printf(" Generation : %08x\n", __le32_to_cpu(mpb->generation_num));
328 sum = __le32_to_cpu(mpb->check_sum);
329 printf(" Checksum : %08x %s\n", sum,
330 gen_imsm_checksum(mpb) == sum ? "correct" : "incorrect");
331 printf(" Disks : %d\n", mpb->num_disks);
332 printf(" RAID Devices : %d\n", mpb->num_raid_devs);
333 print_imsm_disk(mpb, super->disks->index);
334 for (i = 0; i < mpb->num_raid_devs; i++)
335 print_imsm_dev(get_imsm_dev(mpb, i), super->disks->index);
336 for (i = 0; i < mpb->num_disks; i++) {
337 if (i == super->disks->index)
338 continue;
339 print_imsm_disk(mpb, i);
340 }
341}
342
343static void brief_examine_super_imsm(struct supertype *st)
344{
345 struct intel_super *super = st->sb;
346 struct imsm_super *mpb = super->mpb;
347
348 printf("ARRAY /dev/imsm family=%08x metadata=external:imsm\n",
349 __le32_to_cpu(mpb->family_num));
350}
351
352static void detail_super_imsm(struct supertype *st, char *homehost)
353{
354 printf("%s\n", __FUNCTION__);
355}
356
357static void brief_detail_super_imsm(struct supertype *st)
358{
359 printf("%s\n", __FUNCTION__);
360}
361#endif
362
363static int match_home_imsm(struct supertype *st, char *homehost)
364{
365 printf("%s\n", __FUNCTION__);
366
367 return 0;
368}
369
370static void uuid_from_super_imsm(struct supertype *st, int uuid[4])
371{
372 printf("%s\n", __FUNCTION__);
373}
374
4f5bc454
DW
375static void
376get_imsm_numerical_version(struct imsm_super *mpb, int *m, int *p)
cdddbdbc 377{
cdddbdbc
DW
378 __u8 *v = get_imsm_version(mpb);
379 __u8 *end = mpb->sig + MAX_SIGNATURE_LENGTH;
380 char major[] = { 0, 0, 0 };
381 char minor[] = { 0 ,0, 0 };
382 char patch[] = { 0, 0, 0 };
383 char *ver_parse[] = { major, minor, patch };
384 int i, j;
385
386 i = j = 0;
387 while (*v != '\0' && v < end) {
388 if (*v != '.' && j < 2)
389 ver_parse[i][j++] = *v;
390 else {
391 i++;
392 j = 0;
393 }
394 v++;
395 }
396
4f5bc454
DW
397 *m = strtol(minor, NULL, 0);
398 *p = strtol(patch, NULL, 0);
399}
400
401static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info)
402{
403 struct intel_super *super = st->sb;
404 struct imsm_super *mpb = super->mpb;
405 struct imsm_disk *disk;
406 __u32 s;
407 int i, j;
408
cdddbdbc 409 info->array.major_version = 2000;
4f5bc454
DW
410 get_imsm_numerical_version(mpb, &info->array.minor_version,
411 &info->array.patch_version);
cdddbdbc
DW
412 info->array.raid_disks = mpb->num_disks;
413 info->array.level = LEVEL_CONTAINER;
414 info->array.layout = 0;
415 info->array.md_minor = -1;
416 info->array.ctime = __le32_to_cpu(mpb->generation_num); //??
417 info->array.utime = 0;
418 info->array.chunk_size = 0;
419
420 info->disk.major = 0;
421 info->disk.minor = 0;
422 info->disk.number = super->disks->index;
423 info->disk.raid_disk = -1;
424 /* is this disk a member of a raid device? */
425 for (i = 0; i < mpb->num_raid_devs; i++) {
426 struct imsm_dev *dev = get_imsm_dev(mpb, i);
427 struct imsm_map *map = dev->vol.map;
428
429 for (j = 0; j < map->num_members; j++) {
430 __u32 index = get_imsm_disk_idx(map, j);
431
432 if (index == super->disks->index) {
433 info->disk.raid_disk = super->disks->index;
434 break;
435 }
436 }
437 if (info->disk.raid_disk != -1)
438 break;
439 }
440 disk = get_imsm_disk(mpb, super->disks->index);
441 s = __le32_to_cpu(disk->status);
442 info->disk.state = s & CONFIGURED_DISK ? (1 << MD_DISK_ACTIVE) : 0;
443 info->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
444 info->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
445 info->reshape_active = 0;
159c3a1a
NB
446
447 strcpy(info->text_version, "imsm");
cdddbdbc
DW
448}
449
450static void getinfo_super_imsm_raid(struct supertype *st, struct mdinfo *info)
451{
452 printf("%s\n", __FUNCTION__);
159c3a1a
NB
453
454 sprintf(info->text_version, "/%s/%d",
455 devnum2devname(st->container_dev),
456 info->container_member); // FIXME is this even set here?
cdddbdbc
DW
457}
458
459static int update_super_imsm(struct supertype *st, struct mdinfo *info,
460 char *update, char *devname, int verbose,
461 int uuid_set, char *homehost)
462{
f352c545
DW
463 /* FIXME */
464
465 /* For 'assemble' and 'force' we need to return non-zero if any
466 * change was made. For others, the return value is ignored.
467 * Update options are:
468 * force-one : This device looks a bit old but needs to be included,
469 * update age info appropriately.
470 * assemble: clear any 'faulty' flag to allow this device to
471 * be assembled.
472 * force-array: Array is degraded but being forced, mark it clean
473 * if that will be needed to assemble it.
474 *
475 * newdev: not used ????
476 * grow: Array has gained a new device - this is currently for
477 * linear only
478 * resync: mark as dirty so a resync will happen.
479 * name: update the name - preserving the homehost
480 *
481 * Following are not relevant for this imsm:
482 * sparc2.2 : update from old dodgey metadata
483 * super-minor: change the preferred_minor number
484 * summaries: update redundant counters.
485 * uuid: Change the uuid of the array to match watch is given
486 * homehost: update the recorded homehost
487 * _reshape_progress: record new reshape_progress position.
488 */
489 int rv = 0;
490 //struct intel_super *super = st->sb;
491 //struct imsm_super *mpb = super->mpb;
492
493 if (strcmp(update, "grow") == 0) {
494 }
495 if (strcmp(update, "resync") == 0) {
496 /* dev->vol.dirty = 1; */
497 }
498
499 /* IMSM has no concept of UUID or homehost */
500
501 return rv;
cdddbdbc
DW
502}
503
504static __u64 avail_size_imsm(struct supertype *st, __u64 size)
505{
506 printf("%s\n", __FUNCTION__);
507
508 return 0;
509}
510
511static int compare_super_imsm(struct supertype *st, struct supertype *tst)
512{
513 /*
514 * return:
515 * 0 same, or first was empty, and second was copied
516 * 1 second had wrong number
517 * 2 wrong uuid
518 * 3 wrong other info
519 */
520 struct intel_super *first = st->sb;
521 struct intel_super *sec = tst->sb;
522
523 if (!first) {
524 st->sb = tst->sb;
525 tst->sb = NULL;
526 return 0;
527 }
528
529 if (memcmp(first->mpb->sig, sec->mpb->sig, MAX_SIGNATURE_LENGTH) != 0)
530 return 3;
531 if (first->mpb->family_num != sec->mpb->family_num)
532 return 3;
533 if (first->mpb->mpb_size != sec->mpb->mpb_size)
534 return 3;
535 if (first->mpb->check_sum != sec->mpb->check_sum)
536 return 3;
537
538 return 0;
539}
540
541extern int scsi_get_serial(int fd, void *buf, size_t buf_len);
542
543static int imsm_read_serial(int fd, char *devname,
544 __u8 serial[MAX_RAID_SERIAL_LEN])
545{
546 unsigned char scsi_serial[255];
547 struct stat stb;
548 int sg_fd;
549 int minor;
550 char sg_path[20];
551 int rv;
552 int rsp_len;
553 int i, cnt;
554
555 memset(scsi_serial, 0, sizeof(scsi_serial));
556 fstat(fd, &stb);
557 minor = minor(stb.st_rdev);
558 minor /= 16;
559
560 sprintf(sg_path, "/dev/sg%d", minor);
561 sg_fd = open(sg_path, O_RDONLY);
562 if (sg_fd < 0) {
563 if (devname)
564 fprintf(stderr,
565 Name ": Failed to open %s for %s: %s\n",
566 sg_path, devname, strerror(errno));
567 return 1;
568 }
569
570 rv = scsi_get_serial(sg_fd, scsi_serial, sizeof(scsi_serial));
571 close(sg_fd);
572
573 if (rv != 0) {
574 if (devname)
575 fprintf(stderr,
576 Name ": Failed to retrieve serial for %s\n",
577 devname);
578 return rv;
579 }
580
581 rsp_len = scsi_serial[3];
582 for (i = 0, cnt = 0; i < rsp_len; i++) {
583 if (!isspace(scsi_serial[4 + i]))
584 serial[cnt++] = scsi_serial[4 + i];
585 if (cnt == MAX_RAID_SERIAL_LEN)
586 break;
587 }
588
589 serial[MAX_RAID_SERIAL_LEN - 1] = '\0';
590
591 return 0;
592}
593
594static int
595load_imsm_disk(int fd, struct intel_super *super, char *devname, int keep_fd)
596{
597 struct imsm_super *mpb = super->mpb;
598 struct dl *dl;
599 struct stat stb;
600 struct imsm_disk *disk;
601 int rv;
602 int i;
603
604 dl = malloc(sizeof(*dl));
605 if (!dl) {
606 if (devname)
607 fprintf(stderr,
608 Name ": failed to allocate disk buffer for %s\n",
609 devname);
610 return 2;
611 }
612 memset(dl, 0, sizeof(*dl));
613
614 fstat(fd, &stb);
615 dl->major = major(stb.st_rdev);
616 dl->minor = minor(stb.st_rdev);
617 dl->next = super->disks;
618 dl->fd = keep_fd ? fd : -1;
619 dl->devname = devname ? strdup(devname) : NULL;
620 dl->index = -1;
621 super->disks = dl;
622 rv = imsm_read_serial(fd, devname, dl->serial);
623
624 if (rv != 0)
625 return 2;
626
627 /* look up this disk's index */
628 for (i = 0; i < mpb->num_disks; i++) {
629 disk = get_imsm_disk(mpb, i);
630
631 if (memcmp(disk->serial, dl->serial, MAX_RAID_SERIAL_LEN) == 0)
632 break;
633 }
634
635 if (i > mpb->num_disks)
636 return 2;
637
638 dl->index = i;
639
640 return 0;
641}
642
643/* load_imsm_mpb - read matrix metadata
644 * allocates super->mpb to be freed by free_super
645 */
646static int load_imsm_mpb(int fd, struct intel_super *super, char *devname)
647{
648 unsigned long long dsize;
649 size_t len, mpb_size;
650 unsigned long long sectors;
651 struct stat;
652 struct imsm_super anchor;
653 __u32 check_sum;
654
655 memset(super, 0, sizeof(*super));
656 get_dev_size(fd, NULL, &dsize);
657
658 if (lseek64(fd, dsize - (512 * 2), SEEK_SET) < 0) {
659 if (devname)
660 fprintf(stderr,
661 Name ": Cannot seek to anchor block on %s: %s\n",
662 devname, strerror(errno));
663 return 1;
664 }
665
666 len = sizeof(anchor);
667 if (read(fd, &anchor, len) != len) {
668 if (devname)
669 fprintf(stderr,
670 Name ": Cannot read anchor block on %s: %s\n",
671 devname, strerror(errno));
672 return 1;
673 }
674
675 if (strncmp((char *) anchor.sig, MPB_SIGNATURE, MPB_SIG_LEN) != 0) {
676 if (devname)
677 fprintf(stderr,
678 Name ": no IMSM anchor on %s\n", devname);
679 return 2;
680 }
681
682 mpb_size = __le32_to_cpu(anchor.mpb_size);
683 super->mpb = malloc(mpb_size < 512 ? 512 : mpb_size);
684 if (!super->mpb) {
685 if (devname)
686 fprintf(stderr,
687 Name ": unable to allocate %zu byte mpb buffer\n",
688 mpb_size);
689 return 2;
690 }
691 memcpy(super->buf, &anchor, sizeof(anchor));
692
693 /* read the rest of the first block */
694 len = 512 - sizeof(anchor);
695 if (read(fd, super->buf + sizeof(anchor), len) != len) {
696 if (devname)
697 fprintf(stderr,
698 Name ": Cannot read anchor remainder on %s: %s\n",
699 devname, strerror(errno));
700 return 2;
701 }
702
703 sectors = mpb_sectors(&anchor) - 1;
704 if (!sectors)
705 return load_imsm_disk(fd, super, devname, 0);
706
707 /* read the extended mpb */
708 if (lseek64(fd, dsize - (512 * (2 + sectors)), SEEK_SET) < 0) {
709 if (devname)
710 fprintf(stderr,
711 Name ": Cannot seek to extended mpb on %s: %s\n",
712 devname, strerror(errno));
713 return 1;
714 }
715
716 len = mpb_size - 512;
717 if (read(fd, super->buf + 512, len) != len) {
718 if (devname)
719 fprintf(stderr,
720 Name ": Cannot read extended mpb on %s: %s\n",
721 devname, strerror(errno));
722 return 2;
723 }
724
725 check_sum = gen_imsm_checksum(super->mpb);
726 if (check_sum != __le32_to_cpu(super->mpb->check_sum)) {
727 if (devname)
728 fprintf(stderr,
729 Name ": IMSM checksum %x != %x on %s\n",
730 check_sum, __le32_to_cpu(super->mpb->check_sum),
731 devname);
732 return 2;
733 }
734
735 return load_imsm_disk(fd, super, devname, 0);
736}
737
738struct superswitch super_imsm_container;
739
740static void free_imsm_disks(struct intel_super *super)
741{
742 while (super->disks) {
743 struct dl *d = super->disks;
744
745 super->disks = d->next;
746 if (d->fd >= 0)
747 close(d->fd);
748 if (d->devname)
749 free(d->devname);
750 free(d);
751 }
752}
753
754static void free_imsm(struct intel_super *super)
755{
756 if (super->mpb)
757 free(super->mpb);
758 free_imsm_disks(super);
759 free(super);
760}
761
762
763static void free_super_imsm(struct supertype *st)
764{
765 struct intel_super *super = st->sb;
766
767 if (!super)
768 return;
769
770 free_imsm(super);
771 st->sb = NULL;
772}
773
774#ifndef MDASSEMBLE
775static int load_super_imsm_all(struct supertype *st, int fd, void **sbp,
776 char *devname, int keep_fd)
777{
778 struct mdinfo *sra;
779 struct intel_super *super;
780 struct mdinfo *sd, *best = NULL;
781 __u32 bestgen = 0;
782 __u32 gen;
783 char nm[20];
784 int dfd;
785 int rv;
786
787 /* check if this disk is a member of an active array */
788 sra = sysfs_read(fd, 0, GET_LEVEL|GET_VERSION|GET_DEVS|GET_STATE);
789 if (!sra)
790 return 1;
791
792 if (sra->array.major_version != -1 ||
793 sra->array.minor_version != -2 ||
794 strcmp(sra->text_version, "imsm") != 0)
795 return 1;
796
797 super = malloc(sizeof(*super));
798 if (!super)
799 return 1;
800
801 /* find the most up to date disk in this array */
802 for (sd = sra->devs; sd; sd = sd->next) {
803 sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor);
804 dfd = dev_open(nm, keep_fd ? O_RDWR : O_RDONLY);
805 if (!dfd) {
806 free_imsm(super);
807 return 2;
808 }
809 rv = load_imsm_mpb(dfd, super, NULL);
810 if (!keep_fd)
811 close(dfd);
812 if (rv == 0) {
813 gen = __le32_to_cpu(super->mpb->generation_num);
814 if (!best || gen > bestgen) {
815 bestgen = gen;
816 best = sd;
817 }
818 } else {
819 free_imsm(super);
820 return 2;
821 }
822 }
823
824 if (!best) {
825 free_imsm(super);
826 return 1;
827 }
828
829 /* load the most up to date anchor */
830 sprintf(nm, "%d:%d", best->disk.major, best->disk.minor);
831 dfd = dev_open(nm, O_RDONLY);
832 if (!dfd) {
833 free_imsm(super);
834 return 1;
835 }
836 rv = load_imsm_mpb(dfd, super, NULL);
837 close(dfd);
838 if (rv != 0) {
839 free_imsm(super);
840 return 2;
841 }
842
843 /* reset the disk list */
844 free_imsm_disks(super);
845
846 /* populate disk list */
847 for (sd = sra->devs ; sd ; sd = sd->next) {
848 sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor);
849 dfd = dev_open(nm, keep_fd? O_RDWR : O_RDONLY);
850 if (!dfd) {
851 free_imsm(super);
852 return 2;
853 }
854 load_imsm_disk(dfd, super, NULL, keep_fd);
855 if (!keep_fd)
856 close(dfd);
857 }
858
859 *sbp = super;
860 if (st->ss == NULL) {
861 st->ss = &super_imsm_container;
862 st->minor_version = 0;
863 st->max_devs = IMSM_MAX_DEVICES;
864 }
865
866 return 0;
867}
868#endif
869
870static int load_super_imsm(struct supertype *st, int fd, char *devname)
871{
872 struct intel_super *super;
873 int rv;
874
875#ifndef MDASSEMBLE
3dbccbcf 876 if (load_super_imsm_all(st, fd, &st->sb, devname, 1) == 0)
cdddbdbc
DW
877 return 0;
878#endif
879
880 super = malloc(sizeof(*super));
881 if (!super) {
882 fprintf(stderr,
883 Name ": malloc of %zu failed.\n",
884 sizeof(*super));
885 return 1;
886 }
887
888 rv = load_imsm_mpb(fd, super, devname);
889
890 if (rv) {
891 if (devname)
892 fprintf(stderr,
893 Name ": Failed to load all information "
894 "sections on %s\n", devname);
895 free_imsm(super);
896 return rv;
897 }
898
899 st->sb = super;
900 if (st->ss == NULL) {
901 st->ss = &super_imsm;
902 st->minor_version = 0;
903 st->max_devs = IMSM_MAX_DEVICES;
904 }
905
906 return 0;
907}
908
909static int init_zero_imsm(struct supertype *st, mdu_array_info_t *info,
910 unsigned long long size, char *name,
911 char *homehost, int *uuid)
912{
913 printf("%s\n", __FUNCTION__);
914
915 return 0;
916}
917
918static int init_super_imsm(struct supertype *st, mdu_array_info_t *info,
919 unsigned long long size, char *name,
920 char *homehost, int *uuid)
921{
922 printf("%s\n", __FUNCTION__);
923
924 return 0;
925}
926
927static int init_super_imsm_raid(struct supertype *st, mdu_array_info_t *info,
928 unsigned long long size, char *name,
929 char *homehost, int *uuid)
930{
931 printf("%s\n", __FUNCTION__);
932
933 return 0;
934}
935
936static void add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dinfo,
937 int fd, char *devname)
938{
939 printf("%s\n", __FUNCTION__);
940}
941
942static void add_to_super_imsm_raid(struct supertype *st, mdu_disk_info_t *dinfo,
943 int fd, char *devname)
944{
945 printf("%s\n", __FUNCTION__);
946}
947
948static int write_init_super_imsm(struct supertype *st)
949{
950 printf("%s\n", __FUNCTION__);
951
952 return 0;
953}
954
955static int store_zero_imsm(struct supertype *st, int fd)
956{
957 printf("%s\n", __FUNCTION__);
958
959 return 0;
960}
961
f352c545 962static void getinfo_super_n_imsm_container(struct supertype *st, struct mdinfo *info)
cdddbdbc 963{
f352c545
DW
964 /* just need offset and size...
965 * of the metadata??
966 */
967 struct intel_super *super = st->sb;
968 struct imsm_super *mpb = super->mpb;
969 struct imsm_disk *disk = get_imsm_disk(mpb, info->disk.number);
970 int sect = mpb_sectors(mpb);
971
972 info->data_offset = __le32_to_cpu(disk->total_blocks) - (2 + sect - 1);
973 info->component_size = sect;
cdddbdbc
DW
974}
975
976static void getinfo_super_n_raid(struct supertype *st, struct mdinfo *info)
977{
978 printf("%s\n", __FUNCTION__);
979}
980
981static int validate_geometry_imsm(struct supertype *st, int level, int layout,
982 int raiddisks, int chunk, unsigned long long size,
983 char *subdev, unsigned long long *freesize)
984{
985 printf("%s\n", __FUNCTION__);
986
987 return 0;
988}
989
990static int validate_geometry_imsm_container(struct supertype *st, int level,
991 int layout, int raiddisks, int chunk,
992 unsigned long long size, char *subdev,
993 unsigned long long *freesize)
994{
995 printf("%s\n", __FUNCTION__);
996
997 return 0;
998}
999
1000static int validate_geometry_imsm_raid(struct supertype *st, int level,
1001 int layout, int raiddisks, int chunk,
1002 unsigned long long size, char *subdev,
1003 unsigned long long *freesize)
1004{
1005 printf("%s\n", __FUNCTION__);
1006
1007 return 0;
1008}
1009
cdddbdbc
DW
1010static struct mdinfo *container_content_imsm(struct supertype *st)
1011{
4f5bc454
DW
1012 /* Given a container loaded by load_super_imsm_all,
1013 * extract information about all the arrays into
1014 * an mdinfo tree.
1015 *
1016 * For each imsm_dev create an mdinfo, fill it in,
1017 * then look for matching devices in super->disks
1018 * and create appropriate device mdinfo.
1019 */
1020 struct intel_super *super = st->sb;
1021 struct imsm_super *mpb = super->mpb;
1022 struct mdinfo *rest = NULL;
1023 int i;
cdddbdbc 1024
4f5bc454
DW
1025 for (i = 0; i < mpb->num_raid_devs; i++) {
1026 struct imsm_dev *dev = get_imsm_dev(mpb, i);
1027 struct imsm_vol *vol = &dev->vol;
1028 struct imsm_map *map = vol->map;
1029 struct mdinfo *this;
1030 __u64 sz;
1031 int slot;
1032
1033 this = malloc(sizeof(*this));
1034 memset(this, 0, sizeof(*this));
1035 this->next = rest;
1036 rest = this;
1037
1038 this->array.major_version = 2000;
1039 get_imsm_numerical_version(mpb, &this->array.minor_version,
1040 &this->array.patch_version);
1041 this->array.level = get_imsm_raid_level(map);
1042 this->array.raid_disks = map->num_members;
1043 switch(this->array.level) {
1044 case 0:
1045 case 1:
1046 this->array.layout = 0;
1047 break;
1048 case 5:
1049 case 6:
1050 this->array.layout = ALGORITHM_LEFT_SYMMETRIC;
1051 break;
1052 case 10:
1053 this->array.layout = 0x102; //FIXME is this correct?
1054 break;
1055 default:
1056 this->array.layout = -1; // FIXME
1057 }
1058 this->array.md_minor = -1;
1059 this->array.ctime = 0;
1060 this->array.utime = 0;
1061 this->array.chunk_size = __le16_to_cpu(map->blocks_per_strip) << 9;
1062 this->array.state = !vol->dirty;
1063 this->container_member = i;
0fd5c350
DW
1064 if (map->map_state == IMSM_T_STATE_UNINITIALIZED || dev->vol.dirty)
1065 this->resync_start = 0;
1066 else
1067 this->resync_start = ~0ULL;
1068
4f5bc454
DW
1069 strncpy(this->name, (char *) dev->volume, MAX_RAID_SERIAL_LEN);
1070 this->name[MAX_RAID_SERIAL_LEN] = 0;
1071
159c3a1a
NB
1072 sprintf(this->text_version, "/%s/%d",
1073 devnum2devname(st->container_dev),
1074 this->container_member);
1075
4f5bc454
DW
1076 memset(this->uuid, 0, sizeof(this->uuid));
1077
1078 sz = __le32_to_cpu(dev->size_high);
1079 sz <<= 32;
1080 sz += __le32_to_cpu(dev->size_low);
1081 this->component_size = sz;
1082 this->array.size = this->component_size / 2;
1083
1084 for (slot = 0 ; slot < map->num_members; slot++) {
1085 struct imsm_disk *disk;
1086 struct mdinfo *info_d;
1087 struct dl *d;
1088 int idx;
1089 __u32 s;
1090
1091 idx = __le32_to_cpu(map->disk_ord_tbl[slot] & ~(0xff << 24));
1092 for (d = super->disks; d ; d = d->next)
1093 if (d->index == idx)
1094 break;
1095
1096 if (d == NULL)
1097 break; /* shouldn't this be continue ?? */
1098
1099 info_d = malloc(sizeof(*info_d));
1100 if (!info_d)
1101 break; /* ditto ?? */
1102 memset(info_d, 0, sizeof(*info_d));
1103 info_d->next = this->devs;
1104 this->devs = info_d;
1105
1106 disk = get_imsm_disk(mpb, idx);
1107 s = __le32_to_cpu(disk->status);
1108
1109 info_d->disk.number = d->index;
1110 info_d->disk.major = d->major;
1111 info_d->disk.minor = d->minor;
1112 info_d->disk.raid_disk = slot;
1113 info_d->disk.state = s & CONFIGURED_DISK ? (1 << MD_DISK_ACTIVE) : 0;
1114 info_d->disk.state |= s & FAILED_DISK ? (1 << MD_DISK_FAULTY) : 0;
1115 info_d->disk.state |= s & USABLE_DISK ? (1 << MD_DISK_SYNC) : 0;
1116
1117 this->array.working_disks++;
1118
1119 info_d->events = __le32_to_cpu(mpb->generation_num);
1120 info_d->data_offset = __le32_to_cpu(map->pba_of_lba0);
1121 info_d->component_size = __le32_to_cpu(map->blocks_per_member);
1122 if (d->devname)
1123 strcpy(info_d->name, d->devname);
1124 }
1125 }
1126
1127 return rest;
cdddbdbc
DW
1128}
1129
845dea95
NB
1130
1131static int imsm_open_new(struct supertype *c, struct active_array *a, int inst)
1132{
1133 fprintf(stderr, "imsm: open_new %d\n", inst);
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
845dea95
NB
1308static void imsm_sync_metadata(struct active_array *a)
1309{
c2a1e7da
DW
1310 struct intel_super *super = a->container->sb;
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
1403struct superswitch super_imsm_raid = {
1404 .update_super = update_super_imsm,
1405 .init_super = init_super_imsm_raid,
1406 .add_to_super = add_to_super_imsm_raid,
1407 .getinfo_super = getinfo_super_imsm_raid,
1408 .getinfo_super_n = getinfo_super_n_raid,
1409 .write_init_super = write_init_super_imsm,
1410
1411 .load_super = load_super_imsm,
1412 .free_super = free_super_imsm,
1413 .match_metadata_desc = match_metadata_desc_imsm_raid,
1414
1415
1416 .validate_geometry = validate_geometry_imsm_raid,
1417 .major = 2001,
1418 .swapuuid = 0,
1419 .external = 2,
cdddbdbc 1420};