libmultipath/foreign/nvme: fix ouput for "%n" wildcard
authorMartin Wilck <mwilck@suse.com>
Sun, 23 Dec 2018 22:21:26 +0000 (23:21 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Mon, 7 Jan 2019 10:46:48 +0000 (11:46 +0100)
The output for "%n" ("name") is broken: it omits the NSID,
and thus it isn't unique per namespace; and it duplicates the
NQN. Change the format to "$NQN:nsid.$NSID".

Real-world example:
nqn.1992-08.com.netapp:sn.7c6b997ca1f611e8abb200a09890f5bf:subsystem.netapp-nvme-svm-subsystem:nsid.1

Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/foreign/nvme.c

index 838e450..f0e8293 100644 (file)
@@ -148,10 +148,11 @@ static int snprint_nvme_map(const struct gen_multipath *gmp,
                return snprintf(buff, len, "%s",
                                udev_device_get_sysname(nvm->udev));
        case 'n':
-               return snprintf(buff, len, "%s:NQN:%s",
-                               udev_device_get_sysname(nvm->subsys),
+               return snprintf(buff, len, "%s:nsid.%s",
                                udev_device_get_sysattr_value(nvm->subsys,
-                                                             "subsysnqn"));
+                                                             "subsysnqn"),
+                               udev_device_get_sysattr_value(nvm->udev,
+                                                             "nsid"));
        case 'w':
                return snprintf(buff, len, "%s",
                                udev_device_get_sysattr_value(nvm->udev,