mdadm/0107-imsm-limit-support-to-first-NVMe-namespace.patch
Neil Brown 5563a724f6 Accepting request 853269 from home:colyli:branches:Base:System
- There are some important fixes merged in mdadm upstream which
  should go with jsc#SLE-13700. This is the update from upstream
  mdadm including the important fixes we should have.
- Detail: show correct raid level when the array is inactive
  (jsc#SLE-13700)
  0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch
- Don't create bitmap for raid5 with journal disk
  (jsc#SLE-13700)
  0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch
- Monitor: refresh mdstat fd after select (jsc#SLE-13700)
  0097-Monitor-refresh-mdstat-fd-after-select.patch
- Monitor: stop notifing about containers.  (jsc#SLE-13700)
  0098-Monitor-stop-notifing-about-containers.patch
- mdmonitor: set small delay once (jsc#SLE-13700)
  0099-mdmonitor-set-small-delay-once.patch
- Check if other Monitor instance running before fork.
  (jsc#SLE-13700)
  0100-Check-if-other-Monitor-instance-running-before-fork.patch
- Super1: allow RAID0 layout setting to be removed.
  (jsc#SLE-13700)
  0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch
- Detail: fix segfault during IMSM raid creation
  (jsc#SLE-13700)
  0102-Detail-fix-segfault-during-IMSM-raid-creation.patch
- Create.c: close mdfd and generate uevent (jsc#SLE-13700)
  0103-Create.c-close-mdfd-and-generate-uevent.patch
- imsm: update num_data_stripes according to dev_size
  (jsc#SLE-13700)
  0104-imsm-update-num_data_stripes-according-to-dev_size.patch
- imsm: remove redundant calls to imsm_get_map (jsc#SLE-13700)

OBS-URL: https://build.opensuse.org/request/show/853269
OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=191
2020-12-09 21:09:06 +00:00

96 lines
2.8 KiB
Diff

From a8f3cfd54e45c8aabc4a99cdc92b6b9080b26607 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Date: Wed, 4 Nov 2020 10:01:28 +0100
Subject: [PATCH 13/17] imsm: limit support to first NVMe namespace
Due to metadata limitations NVMe multinamespace support has to be removed.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
---
platform-intel.c | 31 +++++++++++++++++++++++++++++++
platform-intel.h | 1 +
super-intel.c | 11 ++++++++++-
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/platform-intel.c b/platform-intel.c
index 04bffc5..f1f6d4c 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -766,3 +766,34 @@ char *vmd_domain_to_controller(struct sys_dev *hba, char *buf)
closedir(dir);
return NULL;
}
+/* Verify that NVMe drive is supported by IMSM
+ * Returns:
+ * 0 - not supported
+ * 1 - supported
+ */
+int imsm_is_nvme_supported(int disk_fd, int verbose)
+{
+ char nsid_path[PATH_MAX];
+ char buf[PATH_MAX];
+ struct stat stb;
+
+ if (disk_fd < 0)
+ return 0;
+
+ if (fstat(disk_fd, &stb))
+ return 0;
+
+ snprintf(nsid_path, PATH_MAX-1, "/sys/dev/block/%d:%d/nsid",
+ major(stb.st_rdev), minor(stb.st_rdev));
+
+ if (load_sys(nsid_path, buf, sizeof(buf))) {
+ pr_err("Cannot read %s, rejecting drive\n", nsid_path);
+ return 0;
+ }
+ if (strtoll(buf, NULL, 10) != 1) {
+ if (verbose)
+ pr_err("Only first namespace is supported by IMSM, aborting\n");
+ return 0;
+ }
+ return 1;
+}
diff --git a/platform-intel.h b/platform-intel.h
index 7cb370e..7371478 100644
--- a/platform-intel.h
+++ b/platform-intel.h
@@ -251,4 +251,5 @@ const struct orom_entry *get_orom_entry_by_device_id(__u16 dev_id);
const struct imsm_orom *get_orom_by_device_id(__u16 device_id);
struct sys_dev *device_by_id(__u16 device_id);
struct sys_dev *device_by_id_and_path(__u16 device_id, const char *path);
+int imsm_is_nvme_supported(int disk_fd, int verbose);
char *vmd_domain_to_controller(struct sys_dev *hba, char *buf);
diff --git a/super-intel.c b/super-intel.c
index 95f4eaf..715febf 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2364,7 +2364,9 @@ static int print_nvme_info(struct sys_dev *hba)
continue;
if (path_attached_to_hba(rp, hba->path)) {
fd = open_dev(ent->d_name);
- if (fd < 0) {
+ if (!imsm_is_nvme_supported(fd, 0)) {
+ if (fd >= 0)
+ close(fd);
free(rp);
continue;
}
@@ -5868,6 +5870,13 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
snprintf(controller_path, PATH_MAX-1, "%s/device", devpath);
free(devpath);
+ if (!imsm_is_nvme_supported(dd->fd, 1)) {
+ if (dd->devname)
+ free(dd->devname);
+ free(dd);
+ return 1;
+ }
+
if (devpath_to_vendor(controller_path) == 0x8086) {
/*
* If Intel's NVMe drive has serial ended with
--
2.26.2