diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> | 2020-11-04 10:01:28 +0100 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2020-11-26 00:09:47 +0100 |
commit | a8f3cfd54e45c8aabc4a99cdc92b6b9080b26607 (patch) | |
tree | 95ab151d80a92e9fb32c394494348aeca0d5606e /platform-intel.c | |
parent | Monitor: don't use default modes when creating a file (diff) | |
download | mdadm-a8f3cfd54e45c8aabc4a99cdc92b6b9080b26607.tar.xz mdadm-a8f3cfd54e45c8aabc4a99cdc92b6b9080b26607.zip |
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>
Diffstat (limited to 'platform-intel.c')
-rw-r--r-- | platform-intel.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/platform-intel.c b/platform-intel.c index 04bffc57..f1f6d4cd 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; +} |