2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2016 Neil Brown <neilb@suse.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Email: <neilb@suse.de>
28 * The version-1 superblock :
29 * All numeric fields are little-endian.
31 * total size: 256 bytes plus 2 per device.
32 * 1K allows 384 devices.
34 struct mdp_superblock_1
{
35 /* constant array information - 128 bytes */
36 __u32 magic
; /* MD_SB_MAGIC: 0xa92b4efc - little endian */
37 __u32 major_version
; /* 1 */
38 __u32 feature_map
; /* 0 for now */
39 __u32 pad0
; /* always set to 0 when writing */
41 __u8 set_uuid
[16]; /* user-space generated. */
42 char set_name
[32]; /* set and interpreted by user-space */
44 __u64 ctime
; /* lo 40 bits are seconds, top 24 are microseconds or 0*/
45 __u32 level
; /* -4 (multipath), -1 (linear), 0,1,4,5 */
46 __u32 layout
; /* only for raid5 currently */
47 __u64 size
; /* used size of component devices, in 512byte sectors */
49 __u32 chunksize
; /* in 512byte sectors */
52 __u32 bitmap_offset
; /* sectors after start of superblock that bitmap starts
53 * NOTE: signed, so bitmap can be before superblock
54 * only meaningful of feature_map[0] is set.
57 /* only meaningful when feature_map[MD_FEATURE_PPL] is set */
59 __s16 offset
; /* sectors from start of superblock that ppl starts */
60 __u16 size
; /* ppl size in sectors */
64 /* These are only valid with feature bit '4' */
65 __u32 new_level
; /* new level we are reshaping to */
66 __u64 reshape_position
; /* next address in array-space for reshape */
67 __u32 delta_disks
; /* change in number of raid_disks */
68 __u32 new_layout
; /* new layout */
69 __u32 new_chunk
; /* new chunk size (sectors) */
70 __u32 new_offset
; /* signed number to add to data_offset in new
71 * layout. 0 == no-change. This can be
72 * different on each device in the array.
75 /* constant this-device information - 64 bytes */
76 __u64 data_offset
; /* sector start of data, often 0 */
77 __u64 data_size
; /* sectors in this device that can be used for data */
78 __u64 super_offset
; /* sector start of this superblock */
80 __u64 recovery_offset
;/* sectors before this offset (from data_offset) have been recovered */
81 __u64 journal_tail
;/* journal tail of journal device (from data_offset) */
83 __u32 dev_number
; /* permanent identifier of this device - not role in raid */
84 __u32 cnt_corrected_read
; /* number of read errors that were corrected by re-writing */
85 __u8 device_uuid
[16]; /* user-space setable, ignored by kernel */
86 __u8 devflags
; /* per-device flags. Only one defined...*/
87 #define WriteMostly1 1 /* mask for writemostly flag in above */
88 #define FailFast1 2 /* Device should get FailFast requests */
89 /* bad block log. If there are any bad blocks the feature flag is set.
90 * if offset and size are non-zero, that space is reserved and available.
92 __u8 bblog_shift
; /* shift from sectors to block size for badblocklist */
93 __u16 bblog_size
; /* number of sectors reserved for badblocklist */
94 __u32 bblog_offset
; /* sector offset from superblock to bblog, signed */
96 /* array state information - 64 bytes */
97 __u64 utime
; /* 40 bits second, 24 btes microseconds */
98 __u64 events
; /* incremented when superblock updated */
99 __u64 resync_offset
; /* data before this offset (from data_offset) known to be in sync */
100 __u32 sb_csum
; /* checksum upto dev_roles[max_dev] */
101 __u32 max_dev
; /* size of dev_roles[] array to consider */
102 __u8 pad3
[64-32]; /* set to 0 when writing */
104 /* device state information. Indexed by dev_number.
106 * Note there are no per-device state flags. State information is rolled
107 * into the 'roles' value. If a device is spare or faulty, then it doesn't
108 * have a meaningful role.
110 __u16 dev_roles
[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */
113 #define MAX_SB_SIZE 4096
114 /* bitmap super size is 256, but we round up to a sector for alignment */
115 #define BM_SUPER_SIZE 512
116 #define MAX_DEVS ((int)(MAX_SB_SIZE - sizeof(struct mdp_superblock_1)) / 2)
117 #define SUPER1_SIZE (MAX_SB_SIZE + BM_SUPER_SIZE \
118 + sizeof(struct misc_dev_info))
120 struct misc_dev_info
{
124 /* feature_map bits */
125 #define MD_FEATURE_BITMAP_OFFSET 1
126 #define MD_FEATURE_RECOVERY_OFFSET 2 /* recovery_offset is present and
129 #define MD_FEATURE_RESHAPE_ACTIVE 4
130 #define MD_FEATURE_BAD_BLOCKS 8 /* badblock list is not empty */
131 #define MD_FEATURE_REPLACEMENT 16 /* This device is replacing an
132 * active device with same 'role'.
133 * 'recovery_offset' is also set.
135 #define MD_FEATURE_RESHAPE_BACKWARDS 32 /* Reshape doesn't change number
136 * of devices, but is going
139 #define MD_FEATURE_NEW_OFFSET 64 /* new_offset must be honoured */
140 #define MD_FEATURE_BITMAP_VERSIONED 256 /* bitmap version number checked properly */
141 #define MD_FEATURE_JOURNAL 512 /* support write journal */
142 #define MD_FEATURE_PPL 1024 /* support PPL */
143 #define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \
144 |MD_FEATURE_RECOVERY_OFFSET \
145 |MD_FEATURE_RESHAPE_ACTIVE \
146 |MD_FEATURE_BAD_BLOCKS \
147 |MD_FEATURE_REPLACEMENT \
148 |MD_FEATURE_RESHAPE_BACKWARDS \
149 |MD_FEATURE_NEW_OFFSET \
150 |MD_FEATURE_BITMAP_VERSIONED \
151 |MD_FEATURE_JOURNAL \
156 static int role_from_sb(struct mdp_superblock_1
*sb
)
161 d
= __le32_to_cpu(sb
->dev_number
);
162 if (d
< __le32_to_cpu(sb
->max_dev
))
163 role
= __le16_to_cpu(sb
->dev_roles
[d
]);
165 role
= MD_DISK_ROLE_SPARE
;
170 /* return how many bytes are needed for bitmap, for cluster-md each node
171 * should have it's own bitmap */
172 static unsigned int calc_bitmap_size(bitmap_super_t
*bms
, unsigned int boundary
)
174 unsigned long long bits
, bytes
;
176 bits
= bitmap_bits(__le64_to_cpu(bms
->sync_size
),
177 __le32_to_cpu(bms
->chunksize
));
178 bytes
= (bits
+7) >> 3;
179 bytes
+= sizeof(bitmap_super_t
);
180 bytes
= ROUND_UP(bytes
, boundary
);
185 static unsigned int calc_sb_1_csum(struct mdp_superblock_1
* sb
)
187 unsigned int disk_csum
, csum
;
188 unsigned long long newcsum
;
189 int size
= sizeof(*sb
) + __le32_to_cpu(sb
->max_dev
)*2;
190 unsigned int *isuper
= (unsigned int*)sb
;
192 /* make sure I can count... */
193 if (offsetof(struct mdp_superblock_1
,data_offset
) != 128 ||
194 offsetof(struct mdp_superblock_1
, utime
) != 192 ||
195 sizeof(struct mdp_superblock_1
) != 256) {
196 fprintf(stderr
, "WARNING - superblock isn't sized correctly\n");
199 disk_csum
= sb
->sb_csum
;
202 for (; size
>=4; size
-= 4 ) {
203 newcsum
+= __le32_to_cpu(*isuper
);
208 newcsum
+= __le16_to_cpu(*(unsigned short*) isuper
);
210 csum
= (newcsum
& 0xffffffff) + (newcsum
>> 32);
211 sb
->sb_csum
= disk_csum
;
212 return __cpu_to_le32(csum
);
216 * Information related to file descriptor used for aligned reads/writes.
217 * Cache the block size.
224 static void init_afd(struct align_fd
*afd
, int fd
)
227 if (!get_dev_sector_size(afd
->fd
, NULL
, (unsigned int *)&afd
->blk_sz
))
231 static char abuf
[4096+4096];
232 static int aread(struct align_fd
*afd
, void *buf
, int len
)
235 * On devices with a 4K sector size, we need to read
236 * the full sector and copy relevant bits into
245 if (!bsize
|| bsize
> 4096 || len
> 4096) {
247 fprintf(stderr
, "WARNING - aread() called with invalid block size\n");
250 b
= ROUND_UP_PTR((char *)abuf
, 4096);
252 for (iosize
= 0; iosize
< len
; iosize
+= bsize
)
254 n
= read(afd
->fd
, b
, iosize
);
257 lseek(afd
->fd
, len
- n
, 1);
264 static int awrite(struct align_fd
*afd
, void *buf
, int len
)
267 * On devices with a 4K sector size, we need to write
268 * the full sector. We pre-read if the sector is larger
270 * The address must be sector-aligned.
277 if (!bsize
|| bsize
> 4096 || len
> 4096) {
279 fprintf(stderr
, "WARNING - awrite() called with invalid block size\n");
282 b
= ROUND_UP_PTR((char *)abuf
, 4096);
284 for (iosize
= 0; iosize
< len
; iosize
+= bsize
)
288 n
= read(afd
->fd
, b
, iosize
);
291 lseek(afd
->fd
, -n
, 1);
295 n
= write(afd
->fd
, b
, iosize
);
298 lseek(afd
->fd
, len
- n
, 1);
302 static inline unsigned int choose_ppl_space(int chunk
)
304 return (PPL_HEADER_SIZE
>> 9) + (chunk
> 128*2 ? chunk
: 128*2);
308 static void examine_super1(struct supertype
*st
, char *homehost
)
310 struct mdp_superblock_1
*sb
= st
->sb
;
311 bitmap_super_t
*bms
= (bitmap_super_t
*)(((char*)sb
)+MAX_SB_SIZE
);
318 int l
= homehost
? strlen(homehost
) : 0;
320 unsigned long long sb_offset
;
323 printf(" Magic : %08x\n", __le32_to_cpu(sb
->magic
));
324 printf(" Version : 1");
325 sb_offset
= __le64_to_cpu(sb
->super_offset
);
328 else if (sb_offset
<= 8)
332 printf(" Feature Map : 0x%x\n", __le32_to_cpu(sb
->feature_map
));
333 printf(" Array UUID : ");
334 for (i
=0; i
<16; i
++) {
335 if ((i
&3)==0 && i
!= 0) printf(":");
336 printf("%02x", sb
->set_uuid
[i
]);
339 printf(" Name : %.32s", sb
->set_name
);
340 if (l
> 0 && l
< 32 &&
341 sb
->set_name
[l
] == ':' &&
342 strncmp(sb
->set_name
, homehost
, l
) == 0)
343 printf(" (local to host %s)", homehost
);
345 if (bms
->nodes
> 0 && (__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_BITMAP_OFFSET
))
346 printf(" Cluster Name : %-64s\n", bms
->cluster_name
);
347 atime
= __le64_to_cpu(sb
->ctime
) & 0xFFFFFFFFFFULL
;
348 printf(" Creation Time : %.24s\n", ctime(&atime
));
349 c
=map_num(pers
, __le32_to_cpu(sb
->level
));
350 printf(" Raid Level : %s\n", c
?c
:"-unknown-");
351 printf(" Raid Devices : %d\n", __le32_to_cpu(sb
->raid_disks
));
353 printf(" Avail Dev Size : %llu%s\n",
354 (unsigned long long)__le64_to_cpu(sb
->data_size
),
355 human_size(__le64_to_cpu(sb
->data_size
)<<9));
356 if (__le32_to_cpu(sb
->level
) > 0) {
357 int ddsks
= 0, ddsks_denom
= 1;
358 switch(__le32_to_cpu(sb
->level
)) {
359 case 1: ddsks
=1;break;
361 case 5: ddsks
= __le32_to_cpu(sb
->raid_disks
)-1; break;
362 case 6: ddsks
= __le32_to_cpu(sb
->raid_disks
)-2; break;
364 layout
= __le32_to_cpu(sb
->layout
);
365 ddsks
= __le32_to_cpu(sb
->raid_disks
);
366 ddsks_denom
= (layout
&255) * ((layout
>>8)&255);
369 long long asize
= __le64_to_cpu(sb
->size
);
370 asize
= (asize
<< 9) * ddsks
/ ddsks_denom
;
371 printf(" Array Size : %llu%s\n",
372 asize
>> 10, human_size(asize
));
374 if (sb
->size
!= sb
->data_size
)
375 printf(" Used Dev Size : %llu%s\n",
376 (unsigned long long)__le64_to_cpu(sb
->size
),
377 human_size(__le64_to_cpu(sb
->size
)<<9));
380 printf(" Data Offset : %llu sectors\n",
381 (unsigned long long)__le64_to_cpu(sb
->data_offset
));
382 if (sb
->new_offset
&&
383 (__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_NEW_OFFSET
)) {
384 unsigned long long offset
= __le64_to_cpu(sb
->data_offset
);
385 offset
+= (signed)(int32_t)__le32_to_cpu(sb
->new_offset
);
386 printf(" New Offset : %llu sectors\n", offset
);
388 printf(" Super Offset : %llu sectors\n",
389 (unsigned long long)__le64_to_cpu(sb
->super_offset
));
390 if (__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_RECOVERY_OFFSET
)
391 printf("Recovery Offset : %llu sectors\n", (unsigned long long)__le64_to_cpu(sb
->recovery_offset
));
393 st
->ss
->getinfo_super(st
, &info
, NULL
);
394 if (info
.space_after
!= 1 &&
395 !(__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_NEW_OFFSET
))
396 printf(" Unused Space : before=%llu sectors, after=%llu sectors\n",
397 info
.space_before
, info
.space_after
);
399 printf(" State : %s\n", (__le64_to_cpu(sb
->resync_offset
)+1)? "active":"clean");
400 printf(" Device UUID : ");
401 for (i
=0; i
<16; i
++) {
402 if ((i
&3)==0 && i
!= 0) printf(":");
403 printf("%02x", sb
->device_uuid
[i
]);
407 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET
)) {
408 printf("Internal Bitmap : %ld sectors from superblock\n",
409 (long)(int32_t)__le32_to_cpu(sb
->bitmap_offset
));
410 } else if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_PPL
)) {
411 printf(" PPL : %u sectors at offset %d sectors from superblock\n",
412 __le16_to_cpu(sb
->ppl
.size
),
413 __le16_to_cpu(sb
->ppl
.offset
));
415 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE
)) {
416 printf(" Reshape pos'n : %llu%s\n", (unsigned long long)__le64_to_cpu(sb
->reshape_position
)/2,
417 human_size(__le64_to_cpu(sb
->reshape_position
)<<9));
418 if (__le32_to_cpu(sb
->delta_disks
)) {
419 printf(" Delta Devices : %d", __le32_to_cpu(sb
->delta_disks
));
420 printf(" (%d->%d)\n",
421 __le32_to_cpu(sb
->raid_disks
)-__le32_to_cpu(sb
->delta_disks
),
422 __le32_to_cpu(sb
->raid_disks
));
423 if ((int)__le32_to_cpu(sb
->delta_disks
) < 0)
424 delta_extra
= -__le32_to_cpu(sb
->delta_disks
);
426 if (__le32_to_cpu(sb
->new_level
) != __le32_to_cpu(sb
->level
)) {
427 c
= map_num(pers
, __le32_to_cpu(sb
->new_level
));
428 printf(" New Level : %s\n", c
?c
:"-unknown-");
430 if (__le32_to_cpu(sb
->new_layout
) != __le32_to_cpu(sb
->layout
)) {
431 if (__le32_to_cpu(sb
->level
) == 5) {
432 c
= map_num(r5layout
, __le32_to_cpu(sb
->new_layout
));
433 printf(" New Layout : %s\n", c
?c
:"-unknown-");
435 if (__le32_to_cpu(sb
->level
) == 6) {
436 c
= map_num(r6layout
, __le32_to_cpu(sb
->new_layout
));
437 printf(" New Layout : %s\n", c
?c
:"-unknown-");
439 if (__le32_to_cpu(sb
->level
) == 10) {
440 printf(" New Layout :");
441 print_r10_layout(__le32_to_cpu(sb
->new_layout
));
445 if (__le32_to_cpu(sb
->new_chunk
) != __le32_to_cpu(sb
->chunksize
))
446 printf(" New Chunksize : %dK\n", __le32_to_cpu(sb
->new_chunk
)/2);
451 if (sb
->devflags
& WriteMostly1
)
452 printf(" write-mostly");
453 if (sb
->devflags
& FailFast1
)
458 atime
= __le64_to_cpu(sb
->utime
) & 0xFFFFFFFFFFULL
;
459 printf(" Update Time : %.24s\n", ctime(&atime
));
461 if (sb
->bblog_size
&& sb
->bblog_offset
) {
462 printf(" Bad Block Log : %d entries available at offset %ld sectors",
463 __le16_to_cpu(sb
->bblog_size
)*512/8,
464 (long)(int32_t)__le32_to_cpu(sb
->bblog_offset
));
465 if (sb
->feature_map
&
466 __cpu_to_le32(MD_FEATURE_BAD_BLOCKS
))
467 printf(" - bad blocks present.");
471 if (calc_sb_1_csum(sb
) == sb
->sb_csum
)
472 printf(" Checksum : %x - correct\n", __le32_to_cpu(sb
->sb_csum
));
474 printf(" Checksum : %x - expected %x\n", __le32_to_cpu(sb
->sb_csum
),
475 __le32_to_cpu(calc_sb_1_csum(sb
)));
476 printf(" Events : %llu\n", (unsigned long long)__le64_to_cpu(sb
->events
));
478 if (__le32_to_cpu(sb
->level
) == 5) {
479 c
= map_num(r5layout
, __le32_to_cpu(sb
->layout
));
480 printf(" Layout : %s\n", c
?c
:"-unknown-");
482 if (__le32_to_cpu(sb
->level
) == 6) {
483 c
= map_num(r6layout
, __le32_to_cpu(sb
->layout
));
484 printf(" Layout : %s\n", c
?c
:"-unknown-");
486 if (__le32_to_cpu(sb
->level
) == 10) {
487 int lo
= __le32_to_cpu(sb
->layout
);
489 print_r10_layout(lo
);
492 switch(__le32_to_cpu(sb
->level
)) {
498 printf(" Chunk Size : %dK\n", __le32_to_cpu(sb
->chunksize
)/2);
501 printf(" Rounding : %dK\n", __le32_to_cpu(sb
->chunksize
)/2);
507 /* This turns out to just be confusing */
508 printf(" Array Slot : %d (", __le32_to_cpu(sb
->dev_number
));
509 for (i
= __le32_to_cpu(sb
->max_dev
); i
> 0 ; i
--)
510 if (__le16_to_cpu(sb
->dev_roles
[i
-1]) != MD_DISK_ROLE_SPARE
)
512 for (d
=0; d
< i
; d
++) {
513 int role
= __le16_to_cpu(sb
->dev_roles
[d
]);
515 if (role
== MD_DISK_ROLE_SPARE
) printf("empty");
516 else if(role
== MD_DISK_ROLE_FAULTY
) printf("failed");
517 else printf("%d", role
);
521 printf(" Device Role : ");
522 role
= role_from_sb(sb
);
523 if (role
>= MD_DISK_ROLE_FAULTY
)
525 else if (role
== MD_DISK_ROLE_JOURNAL
)
527 else if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_REPLACEMENT
))
528 printf("Replacement device %d\n", role
);
530 printf("Active device %d\n", role
);
532 printf(" Array State : ");
533 for (d
=0; d
<__le32_to_cpu(sb
->raid_disks
) + delta_extra
; d
++) {
536 for (i
=0; i
< __le32_to_cpu(sb
->max_dev
); i
++) {
537 unsigned int role
= __le16_to_cpu(sb
->dev_roles
[i
]);
551 /* This is confusing too */
553 for (i
=0; i
< __le32_to_cpu(sb
->max_dev
); i
++) {
554 int role
= __le16_to_cpu(sb
->dev_roles
[i
]);
555 if (role
== MD_DISK_ROLE_FAULTY
)
558 if (faulty
) printf(" %d failed", faulty
);
560 printf(" ('A' == active, '.' == missing, 'R' == replacing)");
564 static void brief_examine_super1(struct supertype
*st
, int verbose
)
566 struct mdp_superblock_1
*sb
= st
->sb
;
568 unsigned long long sb_offset
;
570 char *c
=map_num(pers
, __le32_to_cpu(sb
->level
));
572 nm
= strchr(sb
->set_name
, ':');
575 else if (sb
->set_name
[0])
587 printf(" level=%s", c
);
588 sb_offset
= __le64_to_cpu(sb
->super_offset
);
590 printf(" metadata=1.1 ");
591 else if (sb_offset
<= 8)
592 printf(" metadata=1.2 ");
594 printf(" metadata=1.0 ");
596 printf("num-devices=%d ", __le32_to_cpu(sb
->raid_disks
));
598 for (i
=0; i
<16; i
++) {
599 if ((i
&3)==0 && i
!= 0) printf(":");
600 printf("%02x", sb
->set_uuid
[i
]);
602 if (sb
->set_name
[0]) {
604 print_quoted(sb
->set_name
);
609 static void export_examine_super1(struct supertype
*st
)
611 struct mdp_superblock_1
*sb
= st
->sb
;
616 printf("MD_LEVEL=%s\n", map_num(pers
, __le32_to_cpu(sb
->level
)));
617 printf("MD_DEVICES=%d\n", __le32_to_cpu(sb
->raid_disks
));
619 if (sb
->set_name
[i
] == '\n' ||
620 sb
->set_name
[i
] == '\0') {
625 printf("MD_NAME=%.*s\n", len
, sb
->set_name
);
626 if (__le32_to_cpu(sb
->level
) > 0) {
627 int ddsks
= 0, ddsks_denom
= 1;
628 switch(__le32_to_cpu(sb
->level
)) {
629 case 1: ddsks
=1;break;
631 case 5: ddsks
= __le32_to_cpu(sb
->raid_disks
)-1; break;
632 case 6: ddsks
= __le32_to_cpu(sb
->raid_disks
)-2; break;
634 layout
= __le32_to_cpu(sb
->layout
);
635 ddsks
= __le32_to_cpu(sb
->raid_disks
);
636 ddsks_denom
= (layout
&255) * ((layout
>>8)&255);
639 long long asize
= __le64_to_cpu(sb
->size
);
640 asize
= (asize
<< 9) * ddsks
/ ddsks_denom
;
641 printf("MD_ARRAY_SIZE=%s\n",human_size_brief(asize
,JEDEC
));
645 for (i
=0; i
<16; i
++) {
646 if ((i
&3)==0 && i
!= 0) printf(":");
647 printf("%02x", sb
->set_uuid
[i
]);
650 printf("MD_UPDATE_TIME=%llu\n",
651 __le64_to_cpu(sb
->utime
) & 0xFFFFFFFFFFULL
);
652 printf("MD_DEV_UUID=");
653 for (i
=0; i
<16; i
++) {
654 if ((i
&3)==0 && i
!= 0) printf(":");
655 printf("%02x", sb
->device_uuid
[i
]);
658 printf("MD_EVENTS=%llu\n",
659 (unsigned long long)__le64_to_cpu(sb
->events
));
662 static int copy_metadata1(struct supertype
*st
, int from
, int to
)
664 /* Read superblock. If it looks good, write it out.
665 * Then if a bitmap is present, copy that.
666 * And if a bad-block-list is present, copy that too.
669 unsigned long long dsize
, sb_offset
;
670 const int bufsize
= 4*1024;
671 struct mdp_superblock_1 super
, *sb
;
673 if (posix_memalign(&buf
, 4096, bufsize
) != 0)
676 if (!get_dev_size(from
, NULL
, &dsize
))
682 switch(st
->minor_version
) {
686 sb_offset
&= ~(4*2-1);
698 if (lseek64(from
, sb_offset
<< 9, 0) < 0LL)
700 if (read(from
, buf
, bufsize
) != bufsize
)
704 super
= *sb
; // save most of sb for when we reuse buf
706 if (__le32_to_cpu(super
.magic
) != MD_SB_MAGIC
||
707 __le32_to_cpu(super
.major_version
) != 1 ||
708 __le64_to_cpu(super
.super_offset
) != sb_offset
||
709 calc_sb_1_csum(sb
) != super
.sb_csum
)
712 if (lseek64(to
, sb_offset
<< 9, 0) < 0LL)
714 if (write(to
, buf
, bufsize
) != bufsize
)
717 if (super
.feature_map
& __le32_to_cpu(MD_FEATURE_BITMAP_OFFSET
)) {
718 unsigned long long bitmap_offset
= sb_offset
;
719 int bytes
= 4096; // just an estimate.
721 struct align_fd afrom
, ato
;
723 init_afd(&afrom
, from
);
726 bitmap_offset
+= (int32_t)__le32_to_cpu(super
.bitmap_offset
);
728 if (lseek64(from
, bitmap_offset
<<9, 0) < 0)
730 if (lseek64(to
, bitmap_offset
<<9, 0) < 0)
733 for (written
= 0; written
< bytes
; ) {
734 int n
= bytes
- written
;
737 if (aread(&afrom
, buf
, n
) != n
)
740 /* have the header, can calculate
741 * correct bitmap bytes */
744 bytes
= calc_bitmap_size(bms
, 512);
748 if (awrite(&ato
, buf
, n
) != n
)
754 if (super
.bblog_size
!= 0 &&
755 __le16_to_cpu(super
.bblog_size
) <= 100 &&
756 super
.bblog_offset
!= 0 &&
757 (super
.feature_map
& __le32_to_cpu(MD_FEATURE_BAD_BLOCKS
))) {
758 /* There is a bad block log */
759 unsigned long long bb_offset
= sb_offset
;
760 int bytes
= __le16_to_cpu(super
.bblog_size
) * 512;
762 struct align_fd afrom
, ato
;
764 init_afd(&afrom
, from
);
767 bb_offset
+= (int32_t)__le32_to_cpu(super
.bblog_offset
);
769 if (lseek64(from
, bb_offset
<<9, 0) < 0)
771 if (lseek64(to
, bb_offset
<<9, 0) < 0)
774 for (written
= 0; written
< bytes
; ) {
775 int n
= bytes
- written
;
778 if (aread(&afrom
, buf
, n
) != n
)
781 if (awrite(&ato
, buf
, n
) != n
)
795 static void detail_super1(struct supertype
*st
, char *homehost
)
797 struct mdp_superblock_1
*sb
= st
->sb
;
798 bitmap_super_t
*bms
= (bitmap_super_t
*)(((char*)sb
) + MAX_SB_SIZE
);
800 int l
= homehost
? strlen(homehost
) : 0;
802 printf(" Name : %.32s", sb
->set_name
);
803 if (l
> 0 && l
< 32 &&
804 sb
->set_name
[l
] == ':' &&
805 strncmp(sb
->set_name
, homehost
, l
) == 0)
806 printf(" (local to host %s)", homehost
);
807 if (bms
->nodes
> 0 && (__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_BITMAP_OFFSET
))
808 printf("\n Cluster Name : %-64s", bms
->cluster_name
);
809 printf("\n UUID : ");
810 for (i
=0; i
<16; i
++) {
811 if ((i
&3)==0 && i
!= 0) printf(":");
812 printf("%02x", sb
->set_uuid
[i
]);
814 printf("\n Events : %llu\n\n",
815 (unsigned long long)__le64_to_cpu(sb
->events
));
818 static void brief_detail_super1(struct supertype
*st
)
820 struct mdp_superblock_1
*sb
= st
->sb
;
823 if (sb
->set_name
[0]) {
825 print_quoted(sb
->set_name
);
828 for (i
=0; i
<16; i
++) {
829 if ((i
&3)==0 && i
!= 0) printf(":");
830 printf("%02x", sb
->set_uuid
[i
]);
834 static void export_detail_super1(struct supertype
*st
)
836 struct mdp_superblock_1
*sb
= st
->sb
;
841 if (sb
->set_name
[i
] == '\n' ||
842 sb
->set_name
[i
] == '\0') {
847 printf("MD_NAME=%.*s\n", len
, sb
->set_name
);
850 static int examine_badblocks_super1(struct supertype
*st
, int fd
, char *devname
)
852 struct mdp_superblock_1
*sb
= st
->sb
;
853 unsigned long long offset
;
858 if (!sb
->bblog_size
|| __le16_to_cpu(sb
->bblog_size
) > 100
859 || !sb
->bblog_offset
){
860 printf("No bad-blocks list configured on %s\n", devname
);
863 if ((sb
->feature_map
& __cpu_to_le32(MD_FEATURE_BAD_BLOCKS
))
865 printf("Bad-blocks list is empty in %s\n", devname
);
869 size
= __le16_to_cpu(sb
->bblog_size
)* 512;
870 if (posix_memalign((void**)&bbl
, 4096, size
) != 0) {
871 pr_err("could not allocate badblocks list\n");
874 offset
= __le64_to_cpu(sb
->super_offset
) +
875 (int)__le32_to_cpu(sb
->bblog_offset
);
877 if (lseek64(fd
, offset
, 0) < 0) {
878 pr_err("Cannot seek to bad-blocks list\n");
881 if (read(fd
, bbl
, size
) != size
) {
882 pr_err("Cannot read bad-blocks list\n");
885 /* 64bits per entry. 10 bits is block-count, 54 bits is block
886 * offset. Blocks are sectors unless bblog->shift makes them bigger
889 printf("Bad-blocks on %s:\n", devname
);
890 for (i
= 0; i
< size
/8; i
++, bbp
++) {
891 __u64 bb
= __le64_to_cpu(*bbp
);
892 int count
= bb
& 0x3ff;
893 unsigned long long sector
= bb
>> 10;
898 sector
<<= sb
->bblog_shift
;
899 count
<<= sb
->bblog_shift
;
901 printf("%20llu for %d sectors\n", sector
, count
);
908 static int match_home1(struct supertype
*st
, char *homehost
)
910 struct mdp_superblock_1
*sb
= st
->sb
;
911 int l
= homehost
? strlen(homehost
) : 0;
913 return (l
> 0 && l
< 32 &&
914 sb
->set_name
[l
] == ':' &&
915 strncmp(sb
->set_name
, homehost
, l
) == 0);
918 static void uuid_from_super1(struct supertype
*st
, int uuid
[4])
920 struct mdp_superblock_1
*super
= st
->sb
;
921 char *cuuid
= (char*)uuid
;
924 cuuid
[i
] = super
->set_uuid
[i
];
927 static void getinfo_super1(struct supertype
*st
, struct mdinfo
*info
, char *map
)
929 struct mdp_superblock_1
*sb
= st
->sb
;
930 struct bitmap_super_s
*bsb
= (void*)(((char*)sb
)+MAX_SB_SIZE
);
931 struct misc_dev_info
*misc
= (void*)(((char*)sb
)+MAX_SB_SIZE
+BM_SUPER_SIZE
);
935 unsigned int map_disks
= info
->array
.raid_disks
;
936 unsigned long long super_offset
;
937 unsigned long long data_size
;
939 memset(info
, 0, sizeof(*info
));
940 info
->array
.major_version
= 1;
941 info
->array
.minor_version
= st
->minor_version
;
942 info
->array
.patch_version
= 0;
943 info
->array
.raid_disks
= __le32_to_cpu(sb
->raid_disks
);
944 info
->array
.level
= __le32_to_cpu(sb
->level
);
945 info
->array
.layout
= __le32_to_cpu(sb
->layout
);
946 info
->array
.md_minor
= -1;
947 info
->array
.ctime
= __le64_to_cpu(sb
->ctime
);
948 info
->array
.utime
= __le64_to_cpu(sb
->utime
);
949 info
->array
.chunk_size
= __le32_to_cpu(sb
->chunksize
)*512;
951 (__le64_to_cpu(sb
->resync_offset
) == MaxSector
)
953 if (__le32_to_cpu(bsb
->nodes
) > 1)
954 info
->array
.state
|= (1 << MD_SB_CLUSTERED
);
956 super_offset
= __le64_to_cpu(sb
->super_offset
);
957 info
->data_offset
= __le64_to_cpu(sb
->data_offset
);
958 info
->component_size
= __le64_to_cpu(sb
->size
);
959 if (sb
->feature_map
& __le32_to_cpu(MD_FEATURE_BITMAP_OFFSET
)) {
960 info
->bitmap_offset
= (int32_t)__le32_to_cpu(sb
->bitmap_offset
);
961 } else if (sb
->feature_map
& __le32_to_cpu(MD_FEATURE_PPL
)) {
962 info
->ppl_offset
= __le16_to_cpu(sb
->ppl
.offset
);
963 info
->ppl_size
= __le16_to_cpu(sb
->ppl
.size
);
964 info
->ppl_sector
= super_offset
+ info
->ppl_offset
;
967 info
->disk
.major
= 0;
968 info
->disk
.minor
= 0;
969 info
->disk
.number
= __le32_to_cpu(sb
->dev_number
);
970 if (__le32_to_cpu(sb
->dev_number
) >= __le32_to_cpu(sb
->max_dev
) ||
971 __le32_to_cpu(sb
->dev_number
) >= MAX_DEVS
)
972 role
= MD_DISK_ROLE_FAULTY
;
974 role
= __le16_to_cpu(sb
->dev_roles
[__le32_to_cpu(sb
->dev_number
)]);
976 if (info
->array
.level
<= 0)
977 data_size
= __le64_to_cpu(sb
->data_size
);
979 data_size
= __le64_to_cpu(sb
->size
);
980 if (info
->data_offset
< super_offset
) {
981 unsigned long long end
;
982 info
->space_before
= info
->data_offset
;
985 if (sb
->bblog_offset
&& sb
->bblog_size
) {
986 unsigned long long bboffset
= super_offset
;
987 bboffset
+= (int32_t)__le32_to_cpu(sb
->bblog_offset
);
992 if (super_offset
+ info
->bitmap_offset
+ info
->ppl_offset
< end
)
993 end
= super_offset
+ info
->bitmap_offset
+ info
->ppl_offset
;
995 if (info
->data_offset
+ data_size
< end
)
996 info
->space_after
= end
- data_size
- info
->data_offset
;
998 info
->space_after
= 0;
1000 unsigned long long earliest
;
1001 earliest
= super_offset
+ (32+4)*2; /* match kernel */
1002 if (info
->bitmap_offset
> 0) {
1003 unsigned long long bmend
= info
->bitmap_offset
;
1004 unsigned long long size
= calc_bitmap_size(bsb
, 4096);
1007 if (bmend
> earliest
)
1009 } else if (info
->ppl_offset
> 0) {
1010 unsigned long long pplend
= info
->ppl_offset
+
1012 if (pplend
> earliest
)
1015 if (sb
->bblog_offset
&& sb
->bblog_size
) {
1016 unsigned long long bbend
= super_offset
;
1017 bbend
+= (int32_t)__le32_to_cpu(sb
->bblog_offset
);
1018 bbend
+= __le16_to_cpu(sb
->bblog_size
);
1019 if (bbend
> earliest
)
1022 if (earliest
< info
->data_offset
)
1023 info
->space_before
= info
->data_offset
- earliest
;
1025 info
->space_before
= 0;
1026 info
->space_after
= misc
->device_size
- data_size
- info
->data_offset
;
1028 if (info
->space_before
== 0 && info
->space_after
== 0) {
1029 /* It will look like we don't support data_offset changes,
1030 * be we do - it's just that there is no room.
1031 * A change that reduced the number of devices should
1032 * still be allowed, so set the otherwise useless value of '1'
1034 info
->space_after
= 1;
1037 info
->disk
.raid_disk
= -1;
1039 case MD_DISK_ROLE_SPARE
:
1040 info
->disk
.state
= 0; /* spare: not active, not sync, not faulty */
1042 case MD_DISK_ROLE_FAULTY
:
1043 info
->disk
.state
= 1; /* faulty */
1045 case MD_DISK_ROLE_JOURNAL
:
1046 info
->disk
.state
= (1 << MD_DISK_JOURNAL
);
1047 info
->disk
.raid_disk
= role
;
1048 info
->space_after
= (misc
->device_size
- info
->data_offset
) % 8; /* journal uses all 4kB blocks*/
1051 info
->disk
.state
= 6; /* active and in sync */
1052 info
->disk
.raid_disk
= role
;
1054 if (sb
->devflags
& WriteMostly1
)
1055 info
->disk
.state
|= (1 << MD_DISK_WRITEMOSTLY
);
1056 if (sb
->devflags
& FailFast1
)
1057 info
->disk
.state
|= (1 << MD_DISK_FAILFAST
);
1058 info
->events
= __le64_to_cpu(sb
->events
);
1059 sprintf(info
->text_version
, "1.%d", st
->minor_version
);
1060 info
->safe_mode_delay
= 200;
1062 memcpy(info
->uuid
, sb
->set_uuid
, 16);
1064 strncpy(info
->name
, sb
->set_name
, 32);
1067 if ((__le32_to_cpu(sb
->feature_map
)&MD_FEATURE_REPLACEMENT
)) {
1068 info
->disk
.state
&= ~(1 << MD_DISK_SYNC
);
1069 info
->disk
.state
|= 1 << MD_DISK_REPLACEMENT
;
1072 if (sb
->feature_map
& __le32_to_cpu(MD_FEATURE_RECOVERY_OFFSET
))
1073 info
->recovery_start
= __le32_to_cpu(sb
->recovery_offset
);
1075 info
->recovery_start
= MaxSector
;
1077 if (sb
->feature_map
& __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE
)) {
1078 info
->reshape_active
= 1;
1079 if ((sb
->feature_map
& __le32_to_cpu(MD_FEATURE_NEW_OFFSET
)) &&
1080 sb
->new_offset
!= 0)
1081 info
->reshape_active
|= RESHAPE_NO_BACKUP
;
1082 info
->reshape_progress
= __le64_to_cpu(sb
->reshape_position
);
1083 info
->new_level
= __le32_to_cpu(sb
->new_level
);
1084 info
->delta_disks
= __le32_to_cpu(sb
->delta_disks
);
1085 info
->new_layout
= __le32_to_cpu(sb
->new_layout
);
1086 info
->new_chunk
= __le32_to_cpu(sb
->new_chunk
)<<9;
1087 if (info
->delta_disks
< 0)
1088 info
->array
.raid_disks
-= info
->delta_disks
;
1090 info
->reshape_active
= 0;
1092 info
->recovery_blocked
= info
->reshape_active
;
1095 for (i
=0; i
<map_disks
; i
++)
1097 for (i
= 0; i
< __le32_to_cpu(sb
->max_dev
); i
++) {
1098 role
= __le16_to_cpu(sb
->dev_roles
[i
]);
1099 if (/*role == MD_DISK_ROLE_SPARE || */role
< (unsigned) info
->array
.raid_disks
) {
1101 if (map
&& role
< map_disks
)
1106 info
->array
.working_disks
= working
;
1108 if (sb
->feature_map
& __le32_to_cpu(MD_FEATURE_JOURNAL
)) {
1109 info
->journal_device_required
= 1;
1110 info
->consistency_policy
= CONSISTENCY_POLICY_JOURNAL
;
1111 } else if (sb
->feature_map
& __le32_to_cpu(MD_FEATURE_PPL
)) {
1112 info
->consistency_policy
= CONSISTENCY_POLICY_PPL
;
1113 } else if (sb
->feature_map
& __le32_to_cpu(MD_FEATURE_BITMAP_OFFSET
)) {
1114 info
->consistency_policy
= CONSISTENCY_POLICY_BITMAP
;
1115 } else if (info
->array
.level
<= 0) {
1116 info
->consistency_policy
= CONSISTENCY_POLICY_NONE
;
1118 info
->consistency_policy
= CONSISTENCY_POLICY_RESYNC
;
1121 info
->journal_clean
= 0;
1124 static struct mdinfo
*container_content1(struct supertype
*st
, char *subarray
)
1126 struct mdinfo
*info
;
1131 info
= xmalloc(sizeof(*info
));
1132 getinfo_super1(st
, info
, NULL
);
1136 static int update_super1(struct supertype
*st
, struct mdinfo
*info
,
1138 char *devname
, int verbose
,
1139 int uuid_set
, char *homehost
)
1141 /* NOTE: for 'assemble' and 'force' we need to return non-zero
1142 * if any change was made. For others, the return value is
1147 struct mdp_superblock_1
*sb
= st
->sb
;
1148 bitmap_super_t
*bms
= (bitmap_super_t
*)(((char*)sb
) + MAX_SB_SIZE
);
1150 if (bms
->version
== BITMAP_MAJOR_CLUSTERED
&& dlm_funs_ready()) {
1151 rv
= cluster_get_dlmlock(&lockid
);
1153 pr_err("Cannot get dlmlock in %s return %d\n", __func__
, rv
);
1154 cluster_release_dlmlock(lockid
);
1159 if (strcmp(update
, "homehost") == 0 &&
1161 /* Note that 'homehost' is special as it is really
1166 c
= strchr(sb
->set_name
, ':');
1168 strncpy(info
->name
, c
+1, 31 - (c
-sb
->set_name
));
1170 strncpy(info
->name
, sb
->set_name
, 32);
1174 if (strcmp(update
, "force-one")==0) {
1175 /* Not enough devices for a working array,
1176 * so bring this one up-to-date
1178 if (sb
->events
!= __cpu_to_le64(info
->events
))
1180 sb
->events
= __cpu_to_le64(info
->events
);
1181 } else if (strcmp(update
, "force-array")==0) {
1182 /* Degraded array and 'force' requests to
1183 * maybe need to mark it 'clean'.
1185 switch(__le32_to_cpu(sb
->level
)) {
1186 case 5: case 4: case 6:
1187 /* need to force clean */
1188 if (sb
->resync_offset
!= MaxSector
)
1190 sb
->resync_offset
= MaxSector
;
1192 } else if (strcmp(update
, "assemble")==0) {
1193 int d
= info
->disk
.number
;
1195 if (info
->disk
.state
& (1<<MD_DISK_ACTIVE
))
1196 want
= info
->disk
.raid_disk
;
1197 else if (info
->disk
.state
& (1<<MD_DISK_JOURNAL
))
1198 want
= MD_DISK_ROLE_JOURNAL
;
1200 want
= MD_DISK_ROLE_SPARE
;
1201 if (sb
->dev_roles
[d
] != __cpu_to_le16(want
)) {
1202 sb
->dev_roles
[d
] = __cpu_to_le16(want
);
1205 if (info
->reshape_active
&&
1206 sb
->feature_map
& __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE
) &&
1207 info
->delta_disks
>= 0 &&
1208 info
->reshape_progress
< __le64_to_cpu(sb
->reshape_position
)) {
1209 sb
->reshape_position
= __cpu_to_le64(info
->reshape_progress
);
1212 if (info
->reshape_active
&&
1213 sb
->feature_map
& __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE
) &&
1214 info
->delta_disks
< 0 &&
1215 info
->reshape_progress
> __le64_to_cpu(sb
->reshape_position
)) {
1216 sb
->reshape_position
= __cpu_to_le64(info
->reshape_progress
);
1219 } else if (strcmp(update
, "linear-grow-new") == 0) {
1222 unsigned int max
= __le32_to_cpu(sb
->max_dev
);
1224 for (i
=0 ; i
< max
; i
++)
1225 if (__le16_to_cpu(sb
->dev_roles
[i
]) >= MD_DISK_ROLE_FAULTY
)
1227 sb
->dev_number
= __cpu_to_le32(i
);
1228 info
->disk
.number
= i
;
1229 if (max
>= __le32_to_cpu(sb
->max_dev
))
1230 sb
->max_dev
= __cpu_to_le32(max
+1);
1232 random_uuid(sb
->device_uuid
);
1235 __cpu_to_le16(info
->disk
.raid_disk
);
1237 fd
= open(devname
, O_RDONLY
);
1239 unsigned long long ds
;
1240 get_dev_size(fd
, devname
, &ds
);
1243 if (__le64_to_cpu(sb
->super_offset
) <
1244 __le64_to_cpu(sb
->data_offset
)) {
1245 sb
->data_size
= __cpu_to_le64(
1246 ds
- __le64_to_cpu(sb
->data_offset
));
1249 ds
&= ~(unsigned long long)(4*2-1);
1250 sb
->super_offset
= __cpu_to_le64(ds
);
1251 sb
->data_size
= __cpu_to_le64(
1252 ds
- __le64_to_cpu(sb
->data_offset
));
1255 } else if (strcmp(update
, "linear-grow-update") == 0) {
1256 sb
->raid_disks
= __cpu_to_le32(info
->array
.raid_disks
);
1257 sb
->dev_roles
[info
->disk
.number
] =
1258 __cpu_to_le16(info
->disk
.raid_disk
);
1259 } else if (strcmp(update
, "resync") == 0) {
1260 /* make sure resync happens */
1261 sb
->resync_offset
= 0ULL;
1262 } else if (strcmp(update
, "uuid") == 0) {
1263 copy_uuid(sb
->set_uuid
, info
->uuid
, super1
.swapuuid
);
1265 if (__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_BITMAP_OFFSET
)
1266 memcpy(bms
->uuid
, sb
->set_uuid
, 16);
1267 } else if (strcmp(update
, "no-bitmap") == 0) {
1268 sb
->feature_map
&= ~__cpu_to_le32(MD_FEATURE_BITMAP_OFFSET
);
1269 } else if (strcmp(update
, "bbl") == 0) {
1270 /* only possible if there is room after the bitmap, or if
1271 * there is no bitmap
1273 unsigned long long sb_offset
= __le64_to_cpu(sb
->super_offset
);
1274 unsigned long long data_offset
= __le64_to_cpu(sb
->data_offset
);
1275 long bitmap_offset
= 0;
1276 long bm_sectors
= 0;
1280 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET
)) {
1281 bitmap_offset
= (long)__le32_to_cpu(sb
->bitmap_offset
);
1282 bm_sectors
= calc_bitmap_size(bms
, 4096) >> 9;
1283 } else if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_PPL
)) {
1284 bitmap_offset
= (long)__le16_to_cpu(sb
->ppl
.offset
);
1285 bm_sectors
= (long)__le16_to_cpu(sb
->ppl
.size
);
1288 if (sb_offset
< data_offset
) {
1289 /* 1.1 or 1.2. Put bbl after bitmap leaving at least 32K
1292 bb_offset
= sb_offset
+ 8;
1293 if (bm_sectors
&& bitmap_offset
> 0)
1294 bb_offset
= bitmap_offset
+ bm_sectors
;
1295 while (bb_offset
< (long)sb_offset
+ 8 + 32*2
1296 && bb_offset
+ 8+8 <= (long)data_offset
)
1297 /* too close to bitmap, and room to grow */
1299 if (bb_offset
+ 8 <= (long)data_offset
) {
1300 sb
->bblog_size
= __cpu_to_le16(8);
1301 sb
->bblog_offset
= __cpu_to_le32(bb_offset
);
1304 /* 1.0 - Put bbl just before super block */
1305 if (bm_sectors
&& bitmap_offset
< 0)
1306 space
= -bitmap_offset
- bm_sectors
;
1308 space
= sb_offset
- data_offset
-
1309 __le64_to_cpu(sb
->data_size
);
1311 sb
->bblog_size
= __cpu_to_le16(8);
1312 sb
->bblog_offset
= __cpu_to_le32((unsigned)-8);
1315 } else if (strcmp(update
, "no-bbl") == 0) {
1316 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_BAD_BLOCKS
))
1317 pr_err("Cannot remove active bbl from %s\n",devname
);
1320 sb
->bblog_shift
= 0;
1321 sb
->bblog_offset
= 0;
1323 } else if (strcmp(update
, "force-no-bbl") == 0) {
1324 sb
->feature_map
&= ~ __cpu_to_le32(MD_FEATURE_BAD_BLOCKS
);
1326 sb
->bblog_shift
= 0;
1327 sb
->bblog_offset
= 0;
1328 } else if (strcmp(update
, "ppl") == 0) {
1329 unsigned long long sb_offset
= __le64_to_cpu(sb
->super_offset
);
1330 unsigned long long data_offset
= __le64_to_cpu(sb
->data_offset
);
1331 unsigned long long data_size
= __le64_to_cpu(sb
->data_size
);
1332 long bb_offset
= __le32_to_cpu(sb
->bblog_offset
);
1337 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET
)) {
1338 pr_err("Cannot add PPL to array with bitmap\n");
1342 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_JOURNAL
)) {
1343 pr_err("Cannot add PPL to array with journal\n");
1347 if (sb_offset
< data_offset
) {
1349 space
= bb_offset
- 8;
1351 space
= data_offset
- sb_offset
- 8;
1354 offset
= -(sb_offset
- data_offset
- data_size
);
1355 if (offset
< INT16_MIN
)
1357 space
= -(offset
- bb_offset
);
1360 if (space
< (PPL_HEADER_SIZE
>> 9) + 8) {
1361 pr_err("Not enough space to add ppl\n");
1365 optimal_space
= choose_ppl_space(__le32_to_cpu(sb
->chunksize
));
1367 if (space
> optimal_space
)
1368 space
= optimal_space
;
1369 if (space
> UINT16_MAX
)
1372 sb
->ppl
.offset
= __cpu_to_le16(offset
);
1373 sb
->ppl
.size
= __cpu_to_le16(space
);
1374 sb
->feature_map
|= __cpu_to_le32(MD_FEATURE_PPL
);
1375 } else if (strcmp(update
, "no-ppl") == 0) {
1376 sb
->feature_map
&= ~ __cpu_to_le32(MD_FEATURE_PPL
);
1377 } else if (strcmp(update
, "name") == 0) {
1378 if (info
->name
[0] == 0)
1379 sprintf(info
->name
, "%d", info
->array
.md_minor
);
1380 memset(sb
->set_name
, 0, sizeof(sb
->set_name
));
1382 strchr(info
->name
, ':') == NULL
&&
1383 strlen(homehost
)+1+strlen(info
->name
) < 32) {
1384 strcpy(sb
->set_name
, homehost
);
1385 strcat(sb
->set_name
, ":");
1386 strcat(sb
->set_name
, info
->name
);
1388 strncpy(sb
->set_name
, info
->name
, sizeof(sb
->set_name
));
1389 } else if (strcmp(update
, "devicesize") == 0 &&
1390 __le64_to_cpu(sb
->super_offset
) <
1391 __le64_to_cpu(sb
->data_offset
)) {
1392 /* set data_size to device size less data_offset */
1393 struct misc_dev_info
*misc
= (struct misc_dev_info
*)
1394 (st
->sb
+ MAX_SB_SIZE
+ BM_SUPER_SIZE
);
1395 sb
->data_size
= __cpu_to_le64(
1396 misc
->device_size
- __le64_to_cpu(sb
->data_offset
));
1397 } else if (strncmp(update
, "revert-reshape", 14) == 0) {
1399 if (!(sb
->feature_map
& __cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE
)))
1400 pr_err("No active reshape to revert on %s\n",
1404 unsigned long long reshape_sectors
;
1407 /* If the reshape hasn't started, just stop it.
1408 * It is conceivable that a stripe was modified but
1409 * the metadata not updated. In that case the backup
1410 * should have been used to get passed the critical stage.
1411 * If that couldn't happen, the "-nobackup" version
1414 if (strcmp(update
, "revert-reshape-nobackup") == 0 &&
1415 sb
->reshape_position
== 0 &&
1416 (__le32_to_cpu(sb
->delta_disks
) > 0 ||
1417 (__le32_to_cpu(sb
->delta_disks
) == 0 &&
1418 !(sb
->feature_map
& __cpu_to_le32(MD_FEATURE_RESHAPE_BACKWARDS
))))) {
1419 sb
->feature_map
&= ~__cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE
);
1420 sb
->raid_disks
= __cpu_to_le32(__le32_to_cpu(sb
->raid_disks
) -
1421 __le32_to_cpu(sb
->delta_disks
));
1422 sb
->delta_disks
= 0;
1425 /* reshape_position is a little messy.
1426 * Its value must be a multiple of the larger
1427 * chunk size, and of the "after" data disks.
1428 * So when reverting we need to change it to
1429 * be a multiple of the new "after" data disks,
1430 * which is the old "before".
1431 * If it isn't already a multiple of 'before',
1432 * the only thing we could do would be
1433 * copy some block around on the disks, which
1434 * is easy to get wrong.
1435 * So we reject a revert-reshape unless the
1436 * alignment is good.
1438 if (__le32_to_cpu(sb
->level
) >= 4 &&
1439 __le32_to_cpu(sb
->level
) <= 6) {
1440 reshape_sectors
= __le64_to_cpu(sb
->reshape_position
);
1441 reshape_chunk
= __le32_to_cpu(sb
->new_chunk
);
1442 reshape_chunk
*= __le32_to_cpu(sb
->raid_disks
) - __le32_to_cpu(sb
->delta_disks
) -
1443 (__le32_to_cpu(sb
->level
)==6 ? 2 : 1);
1444 if (reshape_sectors
% reshape_chunk
) {
1445 pr_err("Reshape position is not suitably aligned.\n");
1446 pr_err("Try normal assembly and stop again\n");
1450 sb
->raid_disks
= __cpu_to_le32(__le32_to_cpu(sb
->raid_disks
) -
1451 __le32_to_cpu(sb
->delta_disks
));
1452 if (sb
->delta_disks
== 0)
1453 sb
->feature_map
^= __cpu_to_le32(MD_FEATURE_RESHAPE_BACKWARDS
);
1455 sb
->delta_disks
= __cpu_to_le32(-__le32_to_cpu(sb
->delta_disks
));
1457 temp
= sb
->new_layout
;
1458 sb
->new_layout
= sb
->layout
;
1461 temp
= sb
->new_chunk
;
1462 sb
->new_chunk
= sb
->chunksize
;
1463 sb
->chunksize
= temp
;
1465 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_NEW_OFFSET
)) {
1466 long offset_delta
= (int32_t)__le32_to_cpu(sb
->new_offset
);
1467 sb
->data_offset
= __cpu_to_le64(__le64_to_cpu(sb
->data_offset
) + offset_delta
);
1468 sb
->new_offset
= __cpu_to_le32(-offset_delta
);
1469 sb
->data_size
= __cpu_to_le64(__le64_to_cpu(sb
->data_size
) - offset_delta
);
1473 } else if (strcmp(update
, "_reshape_progress")==0)
1474 sb
->reshape_position
= __cpu_to_le64(info
->reshape_progress
);
1475 else if (strcmp(update
, "writemostly")==0)
1476 sb
->devflags
|= WriteMostly1
;
1477 else if (strcmp(update
, "readwrite")==0)
1478 sb
->devflags
&= ~WriteMostly1
;
1479 else if (strcmp(update
, "failfast") == 0)
1480 sb
->devflags
|= FailFast1
;
1481 else if (strcmp(update
, "nofailfast") == 0)
1482 sb
->devflags
&= ~FailFast1
;
1486 sb
->sb_csum
= calc_sb_1_csum(sb
);
1487 if (bms
->version
== BITMAP_MAJOR_CLUSTERED
&& dlm_funs_ready())
1488 cluster_release_dlmlock(lockid
);
1493 static int init_super1(struct supertype
*st
, mdu_array_info_t
*info
,
1494 struct shape
*s
, char *name
, char *homehost
,
1495 int *uuid
, unsigned long long data_offset
)
1497 struct mdp_superblock_1
*sb
;
1502 if (posix_memalign((void**)&sb
, 4096, SUPER1_SIZE
) != 0) {
1503 pr_err("could not allocate superblock\n");
1506 memset(sb
, 0, SUPER1_SIZE
);
1510 /* zeroing superblock */
1514 spares
= info
->working_disks
- info
->active_disks
;
1515 if (info
->raid_disks
+ spares
> MAX_DEVS
) {
1516 pr_err("too many devices requested: %d+%d > %d\n",
1517 info
->raid_disks
, spares
, MAX_DEVS
);
1521 sb
->magic
= __cpu_to_le32(MD_SB_MAGIC
);
1522 sb
->major_version
= __cpu_to_le32(1);
1523 sb
->feature_map
= 0;
1527 copy_uuid(sb
->set_uuid
, uuid
, super1
.swapuuid
);
1529 random_uuid(sb
->set_uuid
);;
1531 if (name
== NULL
|| *name
== 0) {
1532 sprintf(defname
, "%d", info
->md_minor
);
1536 strchr(name
, ':')== NULL
&&
1537 strlen(homehost
)+1+strlen(name
) < 32) {
1538 strcpy(sb
->set_name
, homehost
);
1539 strcat(sb
->set_name
, ":");
1540 strcat(sb
->set_name
, name
);
1542 strncpy(sb
->set_name
, name
, sizeof(sb
->set_name
));
1544 sb
->ctime
= __cpu_to_le64((unsigned long long)time(0));
1545 sb
->level
= __cpu_to_le32(info
->level
);
1546 sb
->layout
= __cpu_to_le32(info
->layout
);
1547 sb
->size
= __cpu_to_le64(s
->size
*2ULL);
1548 sb
->chunksize
= __cpu_to_le32(info
->chunk_size
>>9);
1549 sb
->raid_disks
= __cpu_to_le32(info
->raid_disks
);
1551 sb
->data_offset
= __cpu_to_le64(data_offset
);
1552 sb
->data_size
= __cpu_to_le64(0);
1553 sb
->super_offset
= __cpu_to_le64(0);
1554 sb
->recovery_offset
= __cpu_to_le64(0);
1556 sb
->utime
= sb
->ctime
;
1557 sb
->events
= __cpu_to_le64(1);
1558 if (info
->state
& (1<<MD_SB_CLEAN
))
1559 sb
->resync_offset
= MaxSector
;
1561 sb
->resync_offset
= 0;
1562 sbsize
= sizeof(struct mdp_superblock_1
) + 2 * (info
->raid_disks
+ spares
);
1563 sbsize
= ROUND_UP(sbsize
, 512);
1564 sb
->max_dev
= __cpu_to_le32((sbsize
- sizeof(struct mdp_superblock_1
)) / 2);
1566 memset(sb
->dev_roles
, 0xff, MAX_SB_SIZE
- sizeof(struct mdp_superblock_1
));
1568 if (s
->consistency_policy
== CONSISTENCY_POLICY_PPL
)
1569 sb
->feature_map
|= __cpu_to_le32(MD_FEATURE_PPL
);
1577 long long data_offset
;
1578 mdu_disk_info_t disk
;
1579 struct devinfo
*next
;
1582 /* Add a device to the superblock being created */
1583 static int add_to_super1(struct supertype
*st
, mdu_disk_info_t
*dk
,
1584 int fd
, char *devname
, unsigned long long data_offset
)
1586 struct mdp_superblock_1
*sb
= st
->sb
;
1587 __u16
*rp
= sb
->dev_roles
+ dk
->number
;
1588 struct devinfo
*di
, **dip
;
1589 bitmap_super_t
*bms
= (bitmap_super_t
*)(((char*)sb
) + MAX_SB_SIZE
);
1593 if (bms
->version
== BITMAP_MAJOR_CLUSTERED
&& dlm_funs_ready()) {
1594 rv
= cluster_get_dlmlock(&lockid
);
1596 pr_err("Cannot get dlmlock in %s return %d\n", __func__
, rv
);
1597 cluster_release_dlmlock(lockid
);
1602 dk_state
= dk
->state
& ~(1<<MD_DISK_FAILFAST
);
1603 if ((dk_state
& 6) == 6) /* active, sync */
1604 *rp
= __cpu_to_le16(dk
->raid_disk
);
1605 else if (dk_state
& (1<<MD_DISK_JOURNAL
))
1606 *rp
= MD_DISK_ROLE_JOURNAL
;
1607 else if ((dk_state
& ~2) == 0) /* active or idle -> spare */
1608 *rp
= MD_DISK_ROLE_SPARE
;
1610 *rp
= MD_DISK_ROLE_FAULTY
;
1612 if (dk
->number
>= (int)__le32_to_cpu(sb
->max_dev
) &&
1613 __le32_to_cpu(sb
->max_dev
) < MAX_DEVS
)
1614 sb
->max_dev
= __cpu_to_le32(dk
->number
+1);
1616 sb
->dev_number
= __cpu_to_le32(dk
->number
);
1617 sb
->devflags
= 0; /* don't copy another disks flags */
1618 sb
->sb_csum
= calc_sb_1_csum(sb
);
1620 dip
= (struct devinfo
**)&st
->info
;
1622 dip
= &(*dip
)->next
;
1623 di
= xmalloc(sizeof(struct devinfo
));
1625 di
->devname
= devname
;
1627 di
->data_offset
= data_offset
;
1631 if (bms
->version
== BITMAP_MAJOR_CLUSTERED
&& dlm_funs_ready())
1632 cluster_release_dlmlock(lockid
);
1638 static int locate_bitmap1(struct supertype
*st
, int fd
, int node_num
);
1640 static int store_super1(struct supertype
*st
, int fd
)
1642 struct mdp_superblock_1
*sb
= st
->sb
;
1643 unsigned long long sb_offset
;
1644 struct align_fd afd
;
1646 unsigned long long dsize
;
1647 bitmap_super_t
*bms
= (bitmap_super_t
*)(((char*)sb
) + MAX_SB_SIZE
);
1650 if (bms
->version
== BITMAP_MAJOR_CLUSTERED
&& dlm_funs_ready()) {
1651 rv
= cluster_get_dlmlock(&lockid
);
1653 pr_err("Cannot get dlmlock in %s return %d\n", __func__
, rv
);
1654 cluster_release_dlmlock(lockid
);
1659 if (!get_dev_size(fd
, NULL
, &dsize
))
1670 * Calculate the position of the superblock.
1671 * It is always aligned to a 4K boundary and
1672 * depending on minor_version, it can be:
1673 * 0: At least 8K, but less than 12K, from end of device
1674 * 1: At start of device
1675 * 2: 4K from start of device.
1677 switch(st
->minor_version
) {
1681 sb_offset
&= ~(4*2-1);
1693 if (sb_offset
!= __le64_to_cpu(sb
->super_offset
) &&
1694 0 != __le64_to_cpu(sb
->super_offset
)
1696 pr_err("internal error - sb_offset is wrong\n");
1700 if (lseek64(fd
, sb_offset
<< 9, 0)< 0LL)
1703 sbsize
= ROUND_UP(sizeof(*sb
) + 2 * __le32_to_cpu(sb
->max_dev
), 512);
1705 if (awrite(&afd
, sb
, sbsize
) != sbsize
)
1708 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET
)) {
1709 struct bitmap_super_s
*bm
= (struct bitmap_super_s
*)
1710 (((char*)sb
)+MAX_SB_SIZE
);
1711 if (__le32_to_cpu(bm
->magic
) == BITMAP_MAGIC
) {
1712 locate_bitmap1(st
, fd
, 0);
1713 if (awrite(&afd
, bm
, sizeof(*bm
)) != sizeof(*bm
))
1718 if (bms
->version
== BITMAP_MAJOR_CLUSTERED
&& dlm_funs_ready())
1719 cluster_release_dlmlock(lockid
);
1724 static int load_super1(struct supertype
*st
, int fd
, char *devname
);
1726 static unsigned long choose_bm_space(unsigned long devsize
)
1728 /* if the device is bigger than 8Gig, save 64k for bitmap usage,
1729 * if bigger than 200Gig, save 128k
1730 * NOTE: result must be multiple of 4K else bad things happen
1731 * on 4K-sector devices.
1735 if (devsize
- 64*2 >= 200*1024*1024*2)
1737 if (devsize
- 4*2 > 8*1024*1024*2)
1742 static void free_super1(struct supertype
*st
);
1746 __u32
crc32c_le(__u32 crc
, unsigned char const *p
, size_t len
);
1748 static int write_init_ppl1(struct supertype
*st
, struct mdinfo
*info
, int fd
)
1750 struct mdp_superblock_1
*sb
= st
->sb
;
1752 struct ppl_header
*ppl_hdr
;
1755 ret
= posix_memalign(&buf
, 4096, PPL_HEADER_SIZE
);
1757 pr_err("Failed to allocate PPL header buffer\n");
1761 memset(buf
, 0, PPL_HEADER_SIZE
);
1763 memset(ppl_hdr
->reserved
, 0xff, PPL_HDR_RESERVED
);
1764 ppl_hdr
->signature
= __cpu_to_le32(~crc32c_le(~0, sb
->set_uuid
,
1765 sizeof(sb
->set_uuid
)));
1766 ppl_hdr
->checksum
= __cpu_to_le32(~crc32c_le(~0, buf
, PPL_HEADER_SIZE
));
1768 if (lseek64(fd
, info
->ppl_sector
* 512, SEEK_SET
) < 0) {
1770 perror("Failed to seek to PPL header location");
1773 if (!ret
&& write(fd
, buf
, PPL_HEADER_SIZE
) != PPL_HEADER_SIZE
) {
1775 perror("Write PPL header failed");
1785 #define META_BLOCK_SIZE 4096
1787 static int write_empty_r5l_meta_block(struct supertype
*st
, int fd
)
1789 struct r5l_meta_block
*mb
;
1790 struct mdp_superblock_1
*sb
= st
->sb
;
1791 struct align_fd afd
;
1796 if (posix_memalign((void**)&mb
, 4096, META_BLOCK_SIZE
) != 0) {
1797 pr_err("Could not allocate memory for the meta block.\n");
1801 memset(mb
, 0, META_BLOCK_SIZE
);
1803 mb
->magic
= __cpu_to_le32(R5LOG_MAGIC
);
1804 mb
->version
= R5LOG_VERSION
;
1805 mb
->meta_size
= __cpu_to_le32(sizeof(struct r5l_meta_block
));
1806 mb
->seq
= __cpu_to_le64(random32());
1807 mb
->position
= __cpu_to_le64(0);
1809 crc
= crc32c_le(0xffffffff, sb
->set_uuid
, sizeof(sb
->set_uuid
));
1810 crc
= crc32c_le(crc
, (void *)mb
, META_BLOCK_SIZE
);
1813 if (lseek64(fd
, __le64_to_cpu(sb
->data_offset
) * 512, 0) < 0LL) {
1814 pr_err("cannot seek to offset of the meta block\n");
1818 if (awrite(&afd
, mb
, META_BLOCK_SIZE
) != META_BLOCK_SIZE
) {
1819 pr_err("failed to store write the meta block \n");
1832 static int write_init_super1(struct supertype
*st
)
1834 struct mdp_superblock_1
*sb
= st
->sb
;
1835 struct supertype
*refst
;
1837 unsigned long long bm_space
;
1839 unsigned long long dsize
, array_size
;
1840 unsigned long long sb_offset
;
1841 unsigned long long data_offset
;
1844 for (di
= st
->info
; di
; di
= di
->next
) {
1845 if (di
->disk
.state
& (1 << MD_DISK_JOURNAL
))
1846 sb
->feature_map
|= __cpu_to_le32(MD_FEATURE_JOURNAL
);
1849 for (di
= st
->info
; di
; di
= di
->next
) {
1850 if (di
->disk
.state
& (1 << MD_DISK_FAULTY
))
1855 while (Kill(di
->devname
, NULL
, 0, -1, 1) == 0)
1858 sb
->dev_number
= __cpu_to_le32(di
->disk
.number
);
1859 if (di
->disk
.state
& (1<<MD_DISK_WRITEMOSTLY
))
1860 sb
->devflags
|= WriteMostly1
;
1862 sb
->devflags
&= ~WriteMostly1
;
1863 if (di
->disk
.state
& (1<<MD_DISK_FAILFAST
))
1864 sb
->devflags
|= FailFast1
;
1866 sb
->devflags
&= ~FailFast1
;
1868 random_uuid(sb
->device_uuid
);
1870 if (!(di
->disk
.state
& (1<<MD_DISK_JOURNAL
)))
1873 refst
= dup_super(st
);
1874 if (load_super1(refst
, di
->fd
, NULL
)==0) {
1875 struct mdp_superblock_1
*refsb
= refst
->sb
;
1877 memcpy(sb
->device_uuid
, refsb
->device_uuid
, 16);
1878 if (memcmp(sb
->set_uuid
, refsb
->set_uuid
, 16)==0) {
1879 /* same array, so preserve events and
1881 sb
->events
= refsb
->events
;
1882 /* bugs in 2.6.17 and earlier mean the
1883 * dev_number chosen in Manage must be preserved
1885 if (get_linux_version() >= 2006018)
1886 sb
->dev_number
= refsb
->dev_number
;
1892 if (!get_dev_size(di
->fd
, NULL
, &dsize
)) {
1905 * Calculate the position of the superblock.
1906 * It is always aligned to a 4K boundary and
1907 * depending on minor_version, it can be:
1908 * 0: At least 8K, but less than 12K, from end of device
1909 * 1: At start of device
1910 * 2: 4K from start of device.
1911 * data_offset has already been set.
1913 array_size
= __le64_to_cpu(sb
->size
);
1915 /* work out how much space we left for a bitmap */
1916 if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET
)) {
1917 bitmap_super_t
*bms
= (bitmap_super_t
*)
1918 (((char *)sb
) + MAX_SB_SIZE
);
1919 bm_space
= calc_bitmap_size(bms
, 4096) >> 9;
1920 bm_offset
= (long)__le32_to_cpu(sb
->bitmap_offset
);
1921 } else if (sb
->feature_map
& __cpu_to_le32(MD_FEATURE_PPL
)) {
1922 bm_space
= choose_ppl_space(__le32_to_cpu(sb
->chunksize
));
1923 if (bm_space
> UINT16_MAX
)
1924 bm_space
= UINT16_MAX
;
1925 if (st
->minor_version
== 0) {
1926 bm_offset
= -bm_space
- 8;
1927 if (bm_offset
< INT16_MIN
) {
1928 bm_offset
= INT16_MIN
;
1929 bm_space
= -bm_offset
- 8;
1934 sb
->ppl
.offset
= __cpu_to_le16(bm_offset
);
1935 sb
->ppl
.size
= __cpu_to_le16(bm_space
);
1937 bm_space
= choose_bm_space(array_size
);
1941 data_offset
= di
->data_offset
;
1942 if (data_offset
== INVALID_SECTORS
)
1943 data_offset
= st
->data_offset
;
1944 switch(st
->minor_version
) {
1946 /* Add 8 sectors for bad block log */
1948 if (data_offset
== INVALID_SECTORS
)
1952 sb_offset
&= ~(4*2-1);
1953 sb
->data_offset
= __cpu_to_le64(data_offset
);
1954 sb
->super_offset
= __cpu_to_le64(sb_offset
);
1955 if (sb_offset
< array_size
+ bm_space
)
1956 bm_space
= sb_offset
- array_size
;
1957 sb
->data_size
= __cpu_to_le64(sb_offset
- bm_space
);
1958 if (bm_space
>= 8) {
1959 sb
->bblog_size
= __cpu_to_le16(8);
1960 sb
->bblog_offset
= __cpu_to_le32((unsigned)-8);
1965 sb_offset
= st
->minor_version
== 2 ? 8 : 0;
1966 sb
->super_offset
= __cpu_to_le64(sb_offset
);
1967 if (data_offset
== INVALID_SECTORS
)
1968 data_offset
= sb_offset
+ 16;
1970 sb
->data_offset
= __cpu_to_le64(data_offset
);
1971 sb
->data_size
= __cpu_to_le64(dsize
- data_offset
);
1972 if (data_offset
>= sb_offset
+bm_offset
+bm_space
+8) {
1973 sb
->bblog_size
= __cpu_to_le16(8);
1974 sb
->bblog_offset
= __cpu_to_le32(bm_offset
+
1976 } else if (data_offset
>= sb_offset
+ 16) {
1977 sb
->bblog_size
= __cpu_to_le16(8);
1978 /* '8' sectors for the bblog, and 'sb_offset'
1979 * because we want offset from superblock, not
1982 sb
->bblog_offset
= __cpu_to_le32(data_offset
-
1987 pr_err("Failed to write invalid metadata format 1.%i to %s\n",
1988 st
->minor_version
, di
->devname
);
1992 /* Disable badblock log on clusters, or when explicitly requested */
1993 if (st
->nodes
> 0 || conf_get_create_info()->bblist
== 0) {
1995 sb
->bblog_offset
= 0;
1998 sb
->sb_csum
= calc_sb_1_csum(sb
);
1999 rv
= store_super1(st
, di
->fd
);
2001 if (rv
== 0 && (di
->disk
.state
& (1 << MD_DISK_JOURNAL
))) {
2002 rv
= write_empty_r5l_meta_block(st
, di
->fd
);
2008 (__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_BITMAP_OFFSET
)) {
2009 rv
= st
->ss
->write_bitmap(st
, di
->fd
, NodeNumUpdate
);
2010 } else if (rv
== 0 &&
2011 (__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_PPL
)) {
2014 st
->ss
->getinfo_super(st
, &info
, NULL
);
2015 rv
= st
->ss
->write_init_ppl(st
, &info
, di
->fd
);
2025 pr_err("Failed to write metadata to %s\n",
2032 static int compare_super1(struct supertype
*st
, struct supertype
*tst
)
2036 * 0 same, or first was empty, and second was copied
2037 * 1 second had wrong number
2039 * 3 wrong other info
2041 struct mdp_superblock_1
*first
= st
->sb
;
2042 struct mdp_superblock_1
*second
= tst
->sb
;
2044 if (second
->magic
!= __cpu_to_le32(MD_SB_MAGIC
))
2046 if (second
->major_version
!= __cpu_to_le32(1))
2050 if (posix_memalign((void**)&first
, 4096, SUPER1_SIZE
) != 0) {
2051 pr_err("could not allocate superblock\n");
2054 memcpy(first
, second
, SUPER1_SIZE
);
2058 if (memcmp(first
->set_uuid
, second
->set_uuid
, 16)!= 0)
2061 if (first
->ctime
!= second
->ctime
||
2062 first
->level
!= second
->level
||
2063 first
->layout
!= second
->layout
||
2064 first
->size
!= second
->size
||
2065 first
->chunksize
!= second
->chunksize
||
2066 first
->raid_disks
!= second
->raid_disks
)
2071 static int load_super1(struct supertype
*st
, int fd
, char *devname
)
2073 unsigned long long dsize
;
2074 unsigned long long sb_offset
;
2075 struct mdp_superblock_1
*super
;
2077 struct bitmap_super_s
*bsb
;
2078 struct misc_dev_info
*misc
;
2079 struct align_fd afd
;
2085 if (st
->ss
== NULL
|| st
->minor_version
== -1) {
2087 struct supertype tst
;
2088 __u64 bestctime
= 0;
2089 /* guess... choose latest ctime */
2090 memset(&tst
, 0, sizeof(tst
));
2092 for (tst
.minor_version
= 0; tst
.minor_version
<= 2 ; tst
.minor_version
++) {
2093 switch(load_super1(&tst
, fd
, devname
)) {
2094 case 0: super
= tst
.sb
;
2095 if (bestvers
== -1 ||
2096 bestctime
< __le64_to_cpu(super
->ctime
)) {
2097 bestvers
= tst
.minor_version
;
2098 bestctime
= __le64_to_cpu(super
->ctime
);
2103 case 1: return 1; /*bad device */
2104 case 2: break; /* bad, try next */
2107 if (bestvers
!= -1) {
2109 tst
.minor_version
= bestvers
;
2111 tst
.max_devs
= MAX_DEVS
;
2112 rv
= load_super1(&tst
, fd
, devname
);
2119 if (!get_dev_size(fd
, devname
, &dsize
))
2125 pr_err("%s is too small for md: size is %llu sectors.\n",
2131 * Calculate the position of the superblock.
2132 * It is always aligned to a 4K boundary and
2133 * depending on minor_version, it can be:
2134 * 0: At least 8K, but less than 12K, from end of device
2135 * 1: At start of device
2136 * 2: 4K from start of device.
2138 switch(st
->minor_version
) {
2142 sb_offset
&= ~(4*2-1);
2154 if (lseek64(fd
, sb_offset
<< 9, 0)< 0LL) {
2156 pr_err("Cannot seek to superblock on %s: %s\n",
2157 devname
, strerror(errno
));
2161 if (posix_memalign((void**)&super
, 4096, SUPER1_SIZE
) != 0) {
2162 pr_err("could not allocate superblock\n");
2166 memset(super
, 0, SUPER1_SIZE
);
2168 if (aread(&afd
, super
, MAX_SB_SIZE
) != MAX_SB_SIZE
) {
2170 pr_err("Cannot read superblock on %s\n",
2176 if (__le32_to_cpu(super
->magic
) != MD_SB_MAGIC
) {
2178 pr_err("No super block found on %s (Expected magic %08x, got %08x)\n",
2179 devname
, MD_SB_MAGIC
, __le32_to_cpu(super
->magic
));
2184 if (__le32_to_cpu(super
->major_version
) != 1) {
2186 pr_err("Cannot interpret superblock on %s - version is %d\n",
2187 devname
, __le32_to_cpu(super
->major_version
));
2191 if (__le64_to_cpu(super
->super_offset
) != sb_offset
) {
2193 pr_err("No superblock found on %s (super_offset is wrong)\n",
2200 bsb
= (struct bitmap_super_s
*)(((char*)super
)+MAX_SB_SIZE
);
2202 misc
= (struct misc_dev_info
*) (((char*)super
)+MAX_SB_SIZE
+BM_SUPER_SIZE
);
2203 misc
->device_size
= dsize
;
2204 if (st
->data_offset
== INVALID_SECTORS
)
2205 st
->data_offset
= __le64_to_cpu(super
->data_offset
);
2207 /* Now check on the bitmap superblock */
2208 if ((__le32_to_cpu(super
->feature_map
)&MD_FEATURE_BITMAP_OFFSET
) == 0)
2210 /* Read the bitmap superblock and make sure it looks
2211 * valid. If it doesn't clear the bit. An --assemble --force
2212 * should get that written out.
2214 locate_bitmap1(st
, fd
, 0);
2215 if (aread(&afd
, bsb
, 512) != 512)
2218 uuid_from_super1(st
, uuid
);
2219 if (__le32_to_cpu(bsb
->magic
) != BITMAP_MAGIC
||
2220 memcmp(bsb
->uuid
, uuid
, 16) != 0)
2225 super
->feature_map
= __cpu_to_le32(__le32_to_cpu(super
->feature_map
)
2226 & ~MD_FEATURE_BITMAP_OFFSET
);
2230 static struct supertype
*match_metadata_desc1(char *arg
)
2232 struct supertype
*st
= xcalloc(1, sizeof(*st
));
2234 st
->container_devnm
[0] = 0;
2236 st
->max_devs
= MAX_DEVS
;
2238 st
->data_offset
= INVALID_SECTORS
;
2239 /* leading zeros can be safely ignored. --detail generates them. */
2242 if (strcmp(arg
, "1.0") == 0 ||
2243 strcmp(arg
, "1.00") == 0) {
2244 st
->minor_version
= 0;
2247 if (strcmp(arg
, "1.1") == 0 ||
2248 strcmp(arg
, "1.01") == 0
2250 st
->minor_version
= 1;
2253 if (strcmp(arg
, "1.2") == 0 ||
2254 #ifndef DEFAULT_OLD_METADATA /* ifdef in super0.c */
2255 strcmp(arg
, "default") == 0 ||
2256 #endif /* DEFAULT_OLD_METADATA */
2257 strcmp(arg
, "1.02") == 0) {
2258 st
->minor_version
= 2;
2261 if (strcmp(arg
, "1") == 0 ||
2262 strcmp(arg
, "default") == 0) {
2263 st
->minor_version
= -1;
2271 /* find available size on device with this devsize, using
2272 * superblock type st, and reserving 'reserve' sectors for
2275 static __u64
avail_size1(struct supertype
*st
, __u64 devsize
,
2276 unsigned long long data_offset
)
2278 struct mdp_superblock_1
*super
= st
->sb
;
2285 if (__le32_to_cpu(super
->feature_map
) & MD_FEATURE_BITMAP_OFFSET
) {
2286 /* hot-add. allow for actual size of bitmap */
2287 struct bitmap_super_s
*bsb
;
2288 bsb
= (struct bitmap_super_s
*)(((char*)super
)+MAX_SB_SIZE
);
2289 bmspace
= calc_bitmap_size(bsb
, 4096) >> 9;
2290 } else if (__le32_to_cpu(super
->feature_map
) & MD_FEATURE_PPL
) {
2291 bmspace
= __le16_to_cpu(super
->ppl
.size
);
2294 /* Allow space for bad block log */
2295 if (super
->bblog_size
)
2296 bbspace
= __le16_to_cpu(super
->bblog_size
);
2298 if (st
->minor_version
< 0)
2299 /* not specified, so time to set default */
2300 st
->minor_version
= 2;
2302 if (data_offset
== INVALID_SECTORS
)
2303 data_offset
= st
->data_offset
;
2305 if (data_offset
!= INVALID_SECTORS
)
2306 switch(st
->minor_version
) {
2308 return devsize
- data_offset
- 8*2 - bbspace
;
2311 return devsize
- data_offset
;
2318 switch(st
->minor_version
) {
2321 return ((devsize
- 8*2 - bbspace
) & ~(4*2-1));
2323 /* at start, 4K for superblock and possible bitmap */
2324 return devsize
- 4*2 - bbspace
;
2326 /* 4k from start, 4K for superblock and possible bitmap */
2327 return devsize
- (4+4)*2 - bbspace
;
2333 add_internal_bitmap1(struct supertype
*st
,
2334 int *chunkp
, int delay
, int write_behind
,
2335 unsigned long long size
,
2336 int may_change
, int major
)
2339 * If not may_change, then this is a 'Grow' without sysfs support for
2340 * bitmaps, and the bitmap must fit after the superblock at 1K offset.
2341 * If may_change, then this is create or a Grow with sysfs syupport,
2342 * and we can put the bitmap wherever we like.
2344 * size is in sectors, chunk is in bytes !!!
2347 unsigned long long bits
;
2348 unsigned long long max_bits
;
2349 unsigned long long min_chunk
;
2351 long bbl_offset
, bbl_size
;
2352 unsigned long long chunk
= *chunkp
;
2356 struct mdp_superblock_1
*sb
= st
->sb
;
2357 bitmap_super_t
*bms
= (bitmap_super_t
*)(((char*)sb
) + MAX_SB_SIZE
);
2360 if (__le64_to_cpu(sb
->data_size
) == 0)
2361 /* Must be creating the array, else data_size would be non-zero */
2363 switch(st
->minor_version
) {
2365 /* either 3K after the superblock (when hot-add),
2366 * or some amount of space before.
2369 /* We are creating array, so we *know* how much room has
2374 room
= choose_bm_space(__le64_to_cpu(sb
->size
)) + bbl_size
;
2376 room
= __le64_to_cpu(sb
->super_offset
)
2377 - __le64_to_cpu(sb
->data_offset
)
2378 - __le64_to_cpu(sb
->data_size
);
2379 bbl_size
= __le16_to_cpu(sb
->bblog_size
);
2382 bbl_offset
= (__s32
)__le32_to_cpu(sb
->bblog_offset
);
2383 if (bbl_size
< -bbl_offset
)
2384 bbl_size
= -bbl_offset
;
2386 if (!may_change
|| (room
< 3*2 &&
2387 __le32_to_cpu(sb
->max_dev
) <= 384)) {
2392 offset
= 0; /* means movable offset */
2397 case 2: /* between superblock and data */
2401 room
= choose_bm_space(__le64_to_cpu(sb
->size
)) + bbl_size
;
2403 room
= __le64_to_cpu(sb
->data_offset
)
2404 - __le64_to_cpu(sb
->super_offset
);
2405 bbl_size
= __le16_to_cpu(sb
->bblog_size
);
2407 room
= __le32_to_cpu(sb
->bblog_offset
) + bbl_size
;
2412 room
-= 2; /* Leave 1K for superblock */
2416 room
-= 4*2; /* leave 4K for superblock */
2426 if (chunk
== UnSet
&& room
> 128*2)
2427 /* Limit to 128K of bitmap when chunk size not requested */
2431 /* No room for a bitmap */
2434 max_bits
= (room
* 512 - sizeof(bitmap_super_t
)) * 8;
2436 min_chunk
= 4096; /* sub-page chunks don't work yet.. */
2437 bits
= (size
*512)/min_chunk
+1;
2438 while (bits
> max_bits
) {
2442 if (chunk
== UnSet
) {
2443 /* For practical purpose, 64Meg is a good
2444 * default chunk size for internal bitmaps.
2447 if (chunk
< 64*1024*1024)
2448 chunk
= 64*1024*1024;
2449 } else if (chunk
< min_chunk
)
2450 return -EINVAL
; /* chunk size too small */
2451 if (chunk
== 0) /* rounding problem */
2455 /* start bitmap on a 4K boundary with enough space for
2458 bits
= (size
*512) / chunk
+ 1;
2459 room
= ((bits
+7)/8 + sizeof(bitmap_super_t
) +4095)/4096;
2460 room
*= 8; /* convert 4K blocks to sectors */
2461 offset
= -room
- bbl_size
;
2464 sb
->bitmap_offset
= (int32_t)__cpu_to_le32(offset
);
2466 sb
->feature_map
= __cpu_to_le32(__le32_to_cpu(sb
->feature_map
)
2467 | MD_FEATURE_BITMAP_OFFSET
);
2468 memset(bms
, 0, sizeof(*bms
));
2469 bms
->magic
= __cpu_to_le32(BITMAP_MAGIC
);
2470 bms
->version
= __cpu_to_le32(major
);
2471 uuid_from_super1(st
, uuid
);
2472 memcpy(bms
->uuid
, uuid
, 16);
2473 bms
->chunksize
= __cpu_to_le32(chunk
);
2474 bms
->daemon_sleep
= __cpu_to_le32(delay
);
2475 bms
->sync_size
= __cpu_to_le64(size
);
2476 bms
->write_behind
= __cpu_to_le32(write_behind
);
2477 bms
->nodes
= __cpu_to_le32(st
->nodes
);
2479 sb
->feature_map
= __cpu_to_le32(__le32_to_cpu(sb
->feature_map
)
2480 | MD_FEATURE_BITMAP_VERSIONED
);
2481 if (st
->cluster_name
) {
2482 len
= sizeof(bms
->cluster_name
);
2483 strncpy((char *)bms
->cluster_name
, st
->cluster_name
, len
);
2484 bms
->cluster_name
[len
- 1] = '\0';
2491 static int locate_bitmap1(struct supertype
*st
, int fd
, int node_num
)
2493 unsigned long long offset
;
2494 struct mdp_superblock_1
*sb
;
2499 if (st
->ss
->load_super(st
, fd
, NULL
))
2500 return -1; /* no error I hope... */
2505 if ((__le32_to_cpu(sb
->feature_map
) & MD_FEATURE_BITMAP_OFFSET
))
2509 offset
= __le64_to_cpu(sb
->super_offset
);
2510 offset
+= (int32_t) __le32_to_cpu(sb
->bitmap_offset
) * (node_num
+ 1);
2513 lseek64(fd
, offset
<<9, 0);
2517 static int write_bitmap1(struct supertype
*st
, int fd
, enum bitmap_update update
)
2519 struct mdp_superblock_1
*sb
= st
->sb
;
2520 bitmap_super_t
*bms
= (bitmap_super_t
*)(((char*)sb
)+MAX_SB_SIZE
);
2523 int towrite
, n
, len
;
2524 struct align_fd afd
;
2526 unsigned long long total_bm_space
, bm_space_per_node
;
2530 /* update cluster name */
2531 if (st
->cluster_name
) {
2532 len
= sizeof(bms
->cluster_name
);
2533 memset((char *)bms
->cluster_name
, 0, len
);
2534 strncpy((char *)bms
->cluster_name
,
2535 st
->cluster_name
, len
);
2536 bms
->cluster_name
[len
- 1] = '\0';
2540 /* cluster md only supports superblock 1.2 now */
2541 if (st
->minor_version
!= 2 && bms
->version
== BITMAP_MAJOR_CLUSTERED
) {
2542 pr_err("Warning: cluster md only works with superblock 1.2\n");
2546 if (bms
->version
== BITMAP_MAJOR_CLUSTERED
) {
2547 if (__cpu_to_le32(st
->nodes
) < bms
->nodes
) {
2548 /* Since the nodes num is not increased, no need to check the space
2549 * is enough or not, just update bms->nodes */
2550 bms
->nodes
= __cpu_to_le32(st
->nodes
);
2554 /* no need to change bms->nodes for other bitmap types */
2556 pr_err("Warning: --nodes option is only suitable for clustered bitmap\n");
2560 /* Each node has an independent bitmap, it is necessary to calculate the
2561 * space is enough or not, first get how many bytes for the total bitmap */
2562 bm_space_per_node
= calc_bitmap_size(bms
, 4096);
2564 total_bm_space
= 512 * (__le64_to_cpu(sb
->data_offset
) - __le64_to_cpu(sb
->super_offset
));
2565 total_bm_space
= total_bm_space
- 4096; /* leave another 4k for superblock */
2567 if (bm_space_per_node
* st
->nodes
> total_bm_space
) {
2568 pr_err("Warning: The max num of nodes can't exceed %llu\n",
2569 total_bm_space
/ bm_space_per_node
);
2573 bms
->nodes
= __cpu_to_le32(st
->nodes
);
2582 locate_bitmap1(st
, fd
, 0);
2584 if (posix_memalign(&buf
, 4096, 4096))
2588 /* Only the bitmap[0] should resync
2589 * whole device on initial assembly
2592 memset(buf
, 0x00, 4096);
2594 memset(buf
, 0xff, 4096);
2595 memcpy(buf
, (char *)bms
, sizeof(bitmap_super_t
));
2598 * use 4096 boundary if bitmap_offset is aligned
2599 * with 8 sectors, then it should compatible with
2602 if (__le32_to_cpu(sb
->bitmap_offset
) & 7)
2603 towrite
= calc_bitmap_size(bms
, 512);
2605 towrite
= calc_bitmap_size(bms
, 4096);
2606 while (towrite
> 0) {
2610 n
= awrite(&afd
, buf
, n
);
2616 memset(buf
, 0x00, 4096);
2618 memset(buf
, 0xff, 4096);
2625 } while (++i
< __le32_to_cpu(bms
->nodes
));
2631 static void free_super1(struct supertype
*st
)
2637 struct devinfo
*di
= st
->info
;
2638 st
->info
= di
->next
;
2647 static int validate_geometry1(struct supertype
*st
, int level
,
2648 int layout
, int raiddisks
,
2649 int *chunk
, unsigned long long size
,
2650 unsigned long long data_offset
,
2651 char *subdev
, unsigned long long *freesize
,
2652 int consistency_policy
, int verbose
)
2654 unsigned long long ldsize
, devsize
;
2656 unsigned long long headroom
;
2659 if (level
== LEVEL_CONTAINER
) {
2661 pr_err("1.x metadata does not support containers\n");
2664 if (*chunk
== UnSet
)
2665 *chunk
= DEFAULT_CHUNK
;
2670 if (st
->minor_version
< 0)
2671 /* not specified, so time to set default */
2672 st
->minor_version
= 2;
2674 fd
= open(subdev
, O_RDONLY
|O_EXCL
, 0);
2677 pr_err("super1.x cannot open %s: %s\n",
2678 subdev
, strerror(errno
));
2682 if (!get_dev_size(fd
, subdev
, &ldsize
)) {
2688 devsize
= ldsize
>> 9;
2694 /* creating: allow suitable space for bitmap or PPL */
2695 bmspace
= consistency_policy
== CONSISTENCY_POLICY_PPL
?
2696 choose_ppl_space((*chunk
)*2) : choose_bm_space(devsize
);
2698 if (data_offset
== INVALID_SECTORS
)
2699 data_offset
= st
->data_offset
;
2700 if (data_offset
== INVALID_SECTORS
)
2701 switch (st
->minor_version
) {
2707 /* Choose data offset appropriate for this device
2708 * and use as default for whole array.
2709 * The data_offset must allow for bitmap space
2710 * and base metadata, should allow for some headroom
2711 * for reshape, and should be rounded to multiple
2713 * Headroom is limited to 128M, but aim for about 0.1%
2715 headroom
= 128*1024*2;
2716 while ((headroom
<< 10) > devsize
&&
2718 headroom
/ 2 >= ((unsigned)(*chunk
)*2)*2))
2720 data_offset
= 12*2 + bmspace
+ headroom
;
2721 #define ONE_MEG (2*1024)
2722 if (data_offset
> ONE_MEG
)
2723 data_offset
= (data_offset
/ ONE_MEG
) * ONE_MEG
;
2726 if (st
->data_offset
== INVALID_SECTORS
)
2727 st
->data_offset
= data_offset
;
2728 switch(st
->minor_version
) {
2729 case 0: /* metadata at end. Round down and subtract space to reserve */
2730 devsize
= (devsize
& ~(4ULL*2-1));
2731 /* space for metadata, bblog, bitmap/ppl */
2732 devsize
-= 8*2 + 8 + bmspace
;
2736 devsize
-= data_offset
;
2739 *freesize
= devsize
;
2742 #endif /* MDASSEMBLE */
2744 void *super1_make_v0(struct supertype
*st
, struct mdinfo
*info
, mdp_super_t
*sb0
)
2746 /* Create a v1.0 superblock based on 'info'*/
2748 struct mdp_superblock_1
*sb
;
2750 unsigned long long offset
;
2752 if (posix_memalign(&ret
, 4096, 1024) != 0)
2755 memset(ret
, 0, 1024);
2756 sb
->magic
= __cpu_to_le32(MD_SB_MAGIC
);
2757 sb
->major_version
= __cpu_to_le32(1);
2759 copy_uuid(sb
->set_uuid
, info
->uuid
, super1
.swapuuid
);
2760 sprintf(sb
->set_name
, "%d", sb0
->md_minor
);
2761 sb
->ctime
= __cpu_to_le32(info
->array
.ctime
+1);
2762 sb
->level
= __cpu_to_le32(info
->array
.level
);
2763 sb
->layout
= __cpu_to_le32(info
->array
.layout
);
2764 sb
->size
= __cpu_to_le64(info
->component_size
);
2765 sb
->chunksize
= __cpu_to_le32(info
->array
.chunk_size
/512);
2766 sb
->raid_disks
= __cpu_to_le32(info
->array
.raid_disks
);
2767 if (info
->array
.level
> 0)
2768 sb
->data_size
= sb
->size
;
2770 sb
->data_size
= st
->ss
->avail_size(st
, st
->devsize
/512, 0);
2771 sb
->resync_offset
= MaxSector
;
2772 sb
->max_dev
= __cpu_to_le32(MD_SB_DISKS
);
2773 sb
->dev_number
= __cpu_to_le32(info
->disk
.number
);
2774 sb
->utime
= __cpu_to_le64(info
->array
.utime
);
2776 offset
= st
->devsize
/512 - 8*2;
2778 sb
->super_offset
= __cpu_to_le64(offset
);
2779 //*(__u64*)(st->other + 128 + 8 + 8) = __cpu_to_le64(offset);
2781 random_uuid(sb
->device_uuid
);
2783 for (i
= 0; i
< MD_SB_DISKS
; i
++) {
2784 int state
= sb0
->disks
[i
].state
;
2785 sb
->dev_roles
[i
] = MD_DISK_ROLE_SPARE
;
2786 if ((state
& (1<<MD_DISK_SYNC
)) &&
2787 !(state
& (1<<MD_DISK_FAULTY
)))
2788 sb
->dev_roles
[i
] = __cpu_to_le16(sb0
->disks
[i
].raid_disk
);
2790 sb
->sb_csum
= calc_sb_1_csum(sb
);
2794 struct superswitch super1
= {
2796 .examine_super
= examine_super1
,
2797 .brief_examine_super
= brief_examine_super1
,
2798 .export_examine_super
= export_examine_super1
,
2799 .detail_super
= detail_super1
,
2800 .brief_detail_super
= brief_detail_super1
,
2801 .export_detail_super
= export_detail_super1
,
2802 .write_init_super
= write_init_super1
,
2803 .validate_geometry
= validate_geometry1
,
2804 .add_to_super
= add_to_super1
,
2805 .examine_badblocks
= examine_badblocks_super1
,
2806 .copy_metadata
= copy_metadata1
,
2807 .write_init_ppl
= write_init_ppl1
,
2809 .match_home
= match_home1
,
2810 .uuid_from_super
= uuid_from_super1
,
2811 .getinfo_super
= getinfo_super1
,
2812 .container_content
= container_content1
,
2813 .update_super
= update_super1
,
2814 .init_super
= init_super1
,
2815 .store_super
= store_super1
,
2816 .compare_super
= compare_super1
,
2817 .load_super
= load_super1
,
2818 .match_metadata_desc
= match_metadata_desc1
,
2819 .avail_size
= avail_size1
,
2820 .add_internal_bitmap
= add_internal_bitmap1
,
2821 .locate_bitmap
= locate_bitmap1
,
2822 .write_bitmap
= write_bitmap1
,
2823 .free_super
= free_super1
,
2824 #if __BYTE_ORDER == BIG_ENDIAN