device-mapper-multipath/0125-libmultipath-cleanup-uid_attribute-checking-code.patch
Benjamin Marzinski b05147c356 device-mapper-multipath-0.8.5-6
Change patch format to remove Git version
  * Patches 0001-0122 only have the patch format modified
Update to the head of the upstream staging branch plus redhat patches
  * Patches 0123-0134 & 1036-0142 are from the upstream staging branch
  * Patches 0143-1046 have been submitted upstream
  * Patch 0156 is a Red Hat only patch. Red Hat udev rules set ID_SERIAL
    from 60-persistent-storage.rules instead of 55-scsi-sg3_id.rules.
    Multipath's parse_vpd_pg83() function needs to match the ID_SERIAL
    value from udev.
Rename files
  * Previous patches 0123-0132 are now patches 1035 & 0147-0155
2021-03-26 13:33:56 -05:00

54 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Wed, 24 Feb 2021 00:33:21 -0600
Subject: [PATCH] libmultipath: cleanup uid_attribute checking code
In get_uid(), if pp->getuid is NULL, multipath will check the
pp->uid_attribute to get the wwid. If pp->uid_attribute is NULL,
nothing will happen in that block of code, because both udev_available
and has_uid_fallback() are false if pp->uid_attribute is NULL. So
instead of multiple checks if pp->uid_attribute is NULL, just check once
for the code block.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/discovery.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 3a06f319..40727fa3 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -2183,22 +2183,21 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev,
} else
len = strlen(pp->wwid);
origin = "callout";
- } else {
- bool valid_uid_attr = pp->uid_attribute
- && *pp->uid_attribute;
- bool empty_uid_attr = pp->uid_attribute
- && !*pp->uid_attribute;
- bool udev_available = udev && valid_uid_attr;
+ } else if (pp->uid_attribute) {
+ /* if the uid_attribute is an empty string skip udev checking */
+ bool check_uid_attr = udev && *pp->uid_attribute;
- if (udev_available) {
+ if (check_uid_attr) {
len = get_udev_uid(pp, pp->uid_attribute, udev);
origin = "udev";
if (len == 0)
condlog(1, "%s: empty udev uid", pp->dev);
}
- if ((!udev_available || (len <= 0 && allow_fallback))
+ if ((!check_uid_attr || (len <= 0 && allow_fallback))
&& has_uid_fallback(pp)) {
- if (!udev || !empty_uid_attr)
+ /* if udev wasn't set or we failed in get_udev_uid()
+ * log at a higher priority */
+ if (!udev || check_uid_attr)
used_fallback = 1;
len = uid_fallback(pp, path_state, &origin);
}