]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-intel.c
IMSM: Enable spanning between VMD domains
[thirdparty/mdadm.git] / super-intel.c
index e501b6fd30ed682c22c17467ab9cd7f2fcade3f8..21e853224ee07f7a9c08cd5480b7ac344aee6daf 100644 (file)
@@ -567,10 +567,6 @@ static int attach_hba_to_super(struct intel_super *super, struct sys_dev *device
        if (device->type != hba->type)
                return 2;
 
-       /* Always forbid spanning between VMD domains (seen as different controllers by mdadm) */
-       if (device->type == SYS_DEV_VMD && !path_attached_to_hba(device->path, hba->path))
-               return 2;
-
        /* Multiple same type HBAs can be used if they share the same OROM */
        const struct imsm_orom *device_orom = get_orom_by_device_id(device->dev_id);
 
@@ -2023,10 +2019,10 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
 
        for (entry = orom_entries; entry; entry = entry->next) {
                if (entry->type == SYS_DEV_VMD) {
+                       print_imsm_capability(&entry->orom);
                        for (hba = list; hba; hba = hba->next) {
                                if (hba->type == SYS_DEV_VMD) {
                                        char buf[PATH_MAX];
-                                       print_imsm_capability(&entry->orom);
                                        printf(" I/O Controller : %s (%s)\n",
                                                vmd_domain_to_controller(hba, buf), get_sys_dev_type(hba->type));
                                        if (print_vmd_attached_devs(hba)) {
@@ -2034,9 +2030,9 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
                                                        pr_err("failed to get devices attached to VMD domain.\n");
                                                result |= 2;
                                        }
-                                       printf("\n");
                                }
                        }
+                       printf("\n");
                        continue;
                }
 
@@ -5137,9 +5133,53 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
        rv = imsm_read_serial(fd, devname, dd->serial);
        if (rv) {
                pr_err("failed to retrieve scsi serial, aborting\n");
+               if (dd->devname)
+                       free(dd->devname);
                free(dd);
                abort();
        }
+       if (super->hba && ((super->hba->type == SYS_DEV_NVME) ||
+          (super->hba->type == SYS_DEV_VMD))) {
+               int i;
+               char *devpath = diskfd_to_devpath(fd);
+               char controller_path[PATH_MAX];
+
+               if (!devpath) {
+                       pr_err("failed to get devpath, aborting\n");
+                       if (dd->devname)
+                               free(dd->devname);
+                       free(dd);
+                       return 1;
+               }
+
+               snprintf(controller_path, PATH_MAX-1, "%s/device", devpath);
+               free(devpath);
+
+               if (devpath_to_vendor(controller_path) == 0x8086) {
+                       /*
+                        * If Intel's NVMe drive has serial ended with
+                        * "-A","-B","-1" or "-2" it means that this is "x8"
+                        * device (double drive on single PCIe card).
+                        * User should be warned about potential data loss.
+                        */
+                       for (i = MAX_RAID_SERIAL_LEN-1; i > 0; i--) {
+                               /* Skip empty character at the end */
+                               if (dd->serial[i] == 0)
+                                       continue;
+
+                               if (((dd->serial[i] == 'A') ||
+                                  (dd->serial[i] == 'B') ||
+                                  (dd->serial[i] == '1') ||
+                                  (dd->serial[i] == '2')) &&
+                                  (dd->serial[i-1] == '-'))
+                                       pr_err("\tThe action you are about to take may put your data at risk.\n"
+                                               "\tPlease note that x8 devices may consist of two separate x4 devices "
+                                               "located on a single PCIe port.\n"
+                                               "\tRAID 0 is the only supported configuration for this type of x8 device.\n");
+                               break;
+                       }
+               }
+       }
 
        get_dev_size(fd, NULL, &size);
        /* clear migr_rec when adding disk to container */
@@ -5993,14 +6033,6 @@ count_volumes(struct intel_hba *hba, int dpa, int verbose)
                else
                        return 0;
 
-               /* VMD has one orom entry for all domain, but spanning is not allowed.
-                * VMD arrays should be counted per domain (controller), so skip
-                * domains that are not the given one.
-                */
-               if (hba->type == SYS_DEV_VMD &&
-                  (strncmp(device->path, hba->path, strlen(device->path)) != 0))
-                       continue;
-
                devlist = get_devices(hba_path);
                /* if no intel devices return zero volumes */
                if (devlist == NULL)
@@ -9262,8 +9294,7 @@ int validate_container_imsm(struct mdinfo *info)
                        return 1;
                }
 
-               if (orom != orom2 ||
-                   (hba->type == SYS_DEV_VMD && hba != hba2)) {
+               if (orom != orom2) {
                        pr_err("WARNING - IMSM container assembled with disks under different HBAs!\n"
                                "       This operation is not supported and can lead to data loss.\n");
                        return 1;