break;
}
printf("\n");
-#if 0
- /* This turns out to just be confusing */
- printf(" Array Slot : %d (", __le32_to_cpu(sb->dev_number));
- for (i = __le32_to_cpu(sb->max_dev); i > 0 ; i--)
- if (__le16_to_cpu(sb->dev_roles[i-1]) != MD_DISK_ROLE_SPARE)
- break;
- for (d = 0; d < i; d++) {
- int role = __le16_to_cpu(sb->dev_roles[d]);
- if (d)
- printf(", ");
- if (role == MD_DISK_ROLE_SPARE)
- printf("empty");
- else
- if(role == MD_DISK_ROLE_FAULTY)
- printf("failed");
- else
- printf("%d", role);
- }
- printf(")\n");
-#endif
printf(" Device Role : ");
role = role_from_sb(sb);
if (role >= MD_DISK_ROLE_FAULTY)
inconsistent = 1;
}
}
-#if 0
- /* This is confusing too */
- faulty = 0;
- for (i = 0; i < __le32_to_cpu(sb->max_dev); i++) {
- int role = __le16_to_cpu(sb->dev_roles[i]);
- if (role == MD_DISK_ROLE_FAULTY)
- faulty++;
- }
- if (faulty)
- printf(" %d failed", faulty);
-#endif
printf(" ('A' == active, '.' == missing, 'R' == replacing)");
printf("\n");
for (d = 0; d < __le32_to_cpu(sb->max_dev); d++) {
printf("ARRAY ");
if (nm) {
- printf("/dev/md/");
- print_escape(nm);
+ printf(DEV_MD_DIR "%s", nm);
putchar(' ');
}
if (verbose && c)
printf(":");
printf("%02x", sb->set_uuid[i]);
}
- if (sb->set_name[0]) {
- printf(" name=");
- print_quoted(sb->set_name);
- }
printf("\n");
}
struct mdp_superblock_1 *sb = st->sb;
int i;
- if (sb->set_name[0]) {
- printf(" name=");
- print_quoted(sb->set_name);
- }
printf(" UUID=");
for (i = 0; i < 16; i++) {
if ((i & 3) == 0 && i != 0)
__cpu_to_le16(info->disk.raid_disk);
break;
}
+ case UOPT_RESYNC:
+ /* make sure resync happens */
+ sb->resync_offset = 0;
+ break;
case UOPT_UUID:
copy_uuid(sb->set_uuid, info->uuid, super1.swapuuid);
di->devname = devname;
di->disk = *dk;
di->data_offset = data_offset;
- get_dev_size(fd, NULL, &di->dev_size);
+
+ if (is_fd_valid(fd))
+ get_dev_size(fd, NULL, &di->dev_size);
+
di->next = NULL;
*dip = di;
return 1;
}
+static bool has_raid0_layout(struct mdp_superblock_1 *sb)
+{
+ if (sb->level == 0 && sb->layout != 0)
+ return true;
+ else
+ return false;
+}
+
static int write_init_super1(struct supertype *st)
{
struct mdp_superblock_1 *sb = st->sb;
unsigned long long sb_offset;
unsigned long long data_offset;
long bm_offset;
- int raid0_need_layout = 0;
+ bool raid0_need_layout = false;
+
+ /* Since linux kernel v5.4, raid0 always has a layout */
+ if (has_raid0_layout(sb) && get_linux_version() >= 5004000)
+ raid0_need_layout = true;
for (di = st->info; di; di = di->next) {
if (di->disk.state & (1 << MD_DISK_JOURNAL))
sb->feature_map |= __cpu_to_le32(MD_FEATURE_JOURNAL);
- if (sb->level == 0 && sb->layout != 0) {
+ if (has_raid0_layout(sb) && !raid0_need_layout) {
+
struct devinfo *di2 = st->info;
unsigned long long s1, s2;
s1 = di->dev_size;
s2 -= di2->data_offset;
s2 /= __le32_to_cpu(sb->chunksize);
if (s1 != s2)
- raid0_need_layout = 1;
+ raid0_need_layout = true;
}
}
/* same array, so preserve events and
* dev_number */
sb->events = refsb->events;
- /* bugs in 2.6.17 and earlier mean the
- * dev_number chosen in Manage must be preserved
- */
- if (get_linux_version() >= 2006018)
- sb->dev_number = refsb->dev_number;
}
free_super1(refst);
}