]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super1.c
Add key ENCRYPTION_NO_VERIFY to conf
[thirdparty/mdadm.git] / super1.c
index 1d20ef552d11beec36d4f5bdf2eab6f1c11bf4f3..81d29a652f3645d7596c7026716b2e596aafd701 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -544,26 +544,6 @@ static void examine_super1(struct supertype *st, char *homehost)
                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)
@@ -595,17 +575,6 @@ static void examine_super1(struct supertype *st, char *homehost)
                        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++) {
@@ -645,8 +614,7 @@ static void brief_examine_super1(struct supertype *st, int verbose)
 
        printf("ARRAY ");
        if (nm) {
-               printf("/dev/md/");
-               print_escape(nm);
+               printf(DEV_MD_DIR "%s", nm);
                putchar(' ');
        }
        if (verbose && c)
@@ -666,10 +634,6 @@ static void brief_examine_super1(struct supertype *st, int verbose)
                        printf(":");
                printf("%02x", sb->set_uuid[i]);
        }
-       if (sb->set_name[0]) {
-               printf(" name=");
-               print_quoted(sb->set_name);
-       }
        printf("\n");
 }
 
@@ -896,10 +860,6 @@ static void brief_detail_super1(struct supertype *st, char *subarray)
        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)
@@ -1377,6 +1337,10 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
                        __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);
 
@@ -1777,7 +1741,10 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
        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;
 
@@ -1968,6 +1935,14 @@ fail_to_write:
        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;
@@ -1979,12 +1954,17 @@ static int write_init_super1(struct supertype *st)
        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;
@@ -1996,7 +1976,7 @@ static int write_init_super1(struct supertype *st)
                                s2 -= di2->data_offset;
                        s2 /= __le32_to_cpu(sb->chunksize);
                        if (s1 != s2)
-                               raid0_need_layout = 1;
+                               raid0_need_layout = true;
                }
        }
 
@@ -2033,11 +2013,6 @@ static int write_init_super1(struct supertype *st)
                                /* 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);
                }