2020-07-21 22:39:38 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Benjamin Marzinski <bmarzins@redhat.com>
|
2021-01-20 00:06:09 +00:00
|
|
|
Date: Wed, 21 Oct 2020 16:39:25 -0500
|
2020-07-21 22:39:38 +00:00
|
|
|
Subject: [PATCH] libmultipath: add uid failback for dasd devices
|
|
|
|
|
|
|
|
Add failback code to get the uid for dasd devices from sysfs. Copied
|
|
|
|
from dasdinfo
|
|
|
|
|
2021-01-20 00:06:09 +00:00
|
|
|
Reviewed-by: Martin Wilck <mwilck@suse.com>
|
2020-07-21 22:39:38 +00:00
|
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
|
---
|
|
|
|
libmultipath/defaults.h | 1 +
|
|
|
|
libmultipath/discovery.c | 37 ++++++++++++++++++++++++++++++++++++-
|
|
|
|
2 files changed, 37 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
|
2021-01-20 00:06:09 +00:00
|
|
|
index 39a5e415..947ba467 100644
|
2020-07-21 22:39:38 +00:00
|
|
|
--- a/libmultipath/defaults.h
|
|
|
|
+++ b/libmultipath/defaults.h
|
|
|
|
@@ -8,6 +8,7 @@
|
|
|
|
*/
|
|
|
|
#define DEFAULT_UID_ATTRIBUTE "ID_SERIAL"
|
|
|
|
#define DEFAULT_NVME_UID_ATTRIBUTE "ID_WWN"
|
|
|
|
+#define DEFAULT_DASD_UID_ATTRIBUTE "ID_UID"
|
|
|
|
#define DEFAULT_UDEVDIR "/dev"
|
|
|
|
#define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath"
|
|
|
|
#define DEFAULT_SELECTOR "service-time 0"
|
|
|
|
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
|
2021-01-20 00:06:09 +00:00
|
|
|
index e7084664..877e8f2b 100644
|
2020-07-21 22:39:38 +00:00
|
|
|
--- a/libmultipath/discovery.c
|
|
|
|
+++ b/libmultipath/discovery.c
|
2021-01-20 00:06:09 +00:00
|
|
|
@@ -1959,12 +1959,44 @@ get_vpd_uid(struct path * pp)
|
2020-07-21 22:39:38 +00:00
|
|
|
return get_vpd_sysfs(parent, 0x83, pp->wwid, WWID_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
+/* based on code from s390-tools/dasdinfo/dasdinfo.c */
|
|
|
|
+static ssize_t dasd_get_uid(struct path *pp)
|
|
|
|
+{
|
|
|
|
+ struct udev_device *parent;
|
|
|
|
+ char value[80];
|
|
|
|
+ char *p;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ parent = udev_device_get_parent_with_subsystem_devtype(pp->udev, "ccw",
|
|
|
|
+ NULL);
|
|
|
|
+ if (!parent)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ if (sysfs_attr_get_value(parent, "uid", value, 80) < 0)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ p = value - 1;
|
|
|
|
+ /* look for the 4th '.' and cut there */
|
|
|
|
+ for (i = 0; i < 4; i++) {
|
|
|
|
+ p = index(p + 1, '.');
|
|
|
|
+ if (!p)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (p)
|
|
|
|
+ *p = '\0';
|
|
|
|
+
|
|
|
|
+ return strlcpy(pp->wwid, value, WWID_SIZE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static ssize_t uid_fallback(struct path *pp, int path_state,
|
|
|
|
const char **origin)
|
|
|
|
{
|
|
|
|
ssize_t len = -1;
|
|
|
|
|
|
|
|
- if (pp->bus == SYSFS_BUS_SCSI) {
|
|
|
|
+ if (pp->bus == SYSFS_BUS_CCW) {
|
|
|
|
+ len = dasd_get_uid(pp);
|
|
|
|
+ *origin = "sysfs";
|
|
|
|
+ } else if (pp->bus == SYSFS_BUS_SCSI) {
|
|
|
|
len = get_vpd_uid(pp);
|
|
|
|
*origin = "sysfs";
|
|
|
|
if (len < 0 && path_state == PATH_UP) {
|
2021-01-20 00:06:09 +00:00
|
|
|
@@ -2012,6 +2044,9 @@ static bool has_uid_fallback(struct path *pp)
|
2020-07-21 22:39:38 +00:00
|
|
|
!strcmp(pp->uid_attribute, ""))) ||
|
|
|
|
(pp->bus == SYSFS_BUS_NVME &&
|
|
|
|
(!strcmp(pp->uid_attribute, DEFAULT_NVME_UID_ATTRIBUTE) ||
|
|
|
|
+ !strcmp(pp->uid_attribute, ""))) ||
|
|
|
|
+ (pp->bus == SYSFS_BUS_CCW &&
|
|
|
|
+ (!strcmp(pp->uid_attribute, DEFAULT_DASD_UID_ATTRIBUTE) ||
|
|
|
|
!strcmp(pp->uid_attribute, ""))));
|
|
|
|
}
|
|
|
|
|