From: Benjamin Marzinski <bmarzins@redhat.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>,
Martin Wilck <Martin.Wilck@suse.com>
Subject: [dm-devel] [PATCH v3 3/4] libmultipath: add uid failback for dasd devices
Date: Wed, 21 Oct 2020 16:39:25 -0500 [thread overview]
Message-ID: <1603316366-28735-4-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1603316366-28735-1-git-send-email-bmarzins@redhat.com>
Add failback code to get the uid for dasd devices from sysfs. Copied
from dasdinfo
Reviewed-by: Martin Wilck <mwilck@suse.com>
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
index 39a5e415..947ba467 100644
--- 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
index cbde3585..d7e8577f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1957,12 +1957,44 @@ get_vpd_uid(struct path * pp)
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) {
@@ -2010,6 +2042,9 @@ static bool has_uid_fallback(struct path *pp)
!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, ""))));
}
--
2.17.2
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2020-10-21 21:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 21:39 [dm-devel] [PATCH v3 0/4] add library to check if device is a valid path Benjamin Marzinski
2020-10-21 21:39 ` [dm-devel] [PATCH v3 1/4] multipath: add libmpathvalid library Benjamin Marzinski
2020-10-21 21:39 ` [dm-devel] [PATCH v3 2/4] multipath-tools tests: and unit tests for libmpathvalid Benjamin Marzinski
2020-10-21 21:39 ` Benjamin Marzinski [this message]
2020-10-21 21:39 ` [dm-devel] [PATCH v3 4/4] libmultipath: change log level for null uid_attribute Benjamin Marzinski
2020-11-01 20:48 ` Martin Wilck
2020-11-01 21:33 ` [dm-devel] [PATCH v3 0/4] add library to check if device is a valid path Martin Wilck
2020-11-02 20:22 ` Benjamin Marzinski
2020-12-16 20:52 ` Martin Wilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1603316366-28735-4-git-send-email-bmarzins@redhat.com \
--to=bmarzins@redhat.com \
--cc=Martin.Wilck@suse.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.