Blame SOURCES/0048-libmultipath-enable-linear-ordering-of-bus-proto-tup.patch

aebebb
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
aebebb
From: Martin Wilck <mwilck@suse.com>
aebebb
Date: Thu, 17 Feb 2022 17:22:32 +0100
aebebb
Subject: [PATCH] libmultipath: enable linear ordering of bus/proto tuple
aebebb
aebebb
We categorized protocols by bus/proto_id, while we only differentiate
aebebb
protocol IDs for SCSI. Allow transforming this into a linear sequence
aebebb
of bus/protocol IDs by having non-SCSI first, and follwing up with
aebebb
the different SCSI protocols.
aebebb
aebebb
Signed-off-by: Martin Wilck <mwilck@suse.com>
aebebb
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
aebebb
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
aebebb
---
aebebb
 libmultipath/structs.c | 10 ++++++++++
aebebb
 libmultipath/structs.h | 13 +++++++++++--
aebebb
 2 files changed, 21 insertions(+), 2 deletions(-)
aebebb
aebebb
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
aebebb
index 6e5a1038..2b7cde0c 100644
aebebb
--- a/libmultipath/structs.c
aebebb
+++ b/libmultipath/structs.c
aebebb
@@ -758,3 +758,13 @@ out:
aebebb
 
aebebb
 	return 0;
aebebb
 }
aebebb
+
aebebb
+unsigned int bus_protocol_id(const struct path *pp) {
aebebb
+	if (!pp || pp->bus < 0 || pp->bus > SYSFS_BUS_SCSI)
aebebb
+		return SYSFS_BUS_UNDEF;
aebebb
+	if (pp->bus != SYSFS_BUS_SCSI)
aebebb
+		return pp->bus;
aebebb
+	if ((int)pp->sg_id.proto_id < 0 || pp->sg_id.proto_id > SCSI_PROTOCOL_UNSPEC)
aebebb
+		return SYSFS_BUS_UNDEF;
aebebb
+	return SYSFS_BUS_SCSI + pp->sg_id.proto_id;
aebebb
+}
aebebb
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
aebebb
index 1188363e..45294f11 100644
aebebb
--- a/libmultipath/structs.h
aebebb
+++ b/libmultipath/structs.h
aebebb
@@ -56,12 +56,13 @@ enum failback_mode {
aebebb
 	FAILBACK_FOLLOWOVER
aebebb
 };
aebebb
 
aebebb
+/* SYSFS_BUS_SCSI should be last, see bus_protocol_id() */
aebebb
 enum sysfs_buses {
aebebb
 	SYSFS_BUS_UNDEF,
aebebb
-	SYSFS_BUS_SCSI,
aebebb
 	SYSFS_BUS_CCW,
aebebb
 	SYSFS_BUS_CCISS,
aebebb
 	SYSFS_BUS_NVME,
aebebb
+	SYSFS_BUS_SCSI,
aebebb
 };
aebebb
 
aebebb
 enum pathstates {
aebebb
@@ -180,9 +181,17 @@ enum scsi_protocol {
aebebb
 	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */
aebebb
 	SCSI_PROTOCOL_ATA = 8,
aebebb
 	SCSI_PROTOCOL_USB = 9,  /* USB Attached SCSI (UAS), and others */
aebebb
-	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
aebebb
+	SCSI_PROTOCOL_UNSPEC = 0xa, /* No specific protocol */
aebebb
 };
aebebb
 
aebebb
+/*
aebebb
+ * Linear ordering of bus/protocol
aebebb
+ * This assumes that SYSFS_BUS_SCSI is last in enum sysfs_buses
aebebb
+ * SCSI is the only bus type for which we distinguish protocols.
aebebb
+ */
aebebb
+#define LAST_BUS_PROTOCOL_ID (SYSFS_BUS_SCSI + SCSI_PROTOCOL_UNSPEC)
aebebb
+unsigned int bus_protocol_id(const struct path *pp);
aebebb
+
aebebb
 #define SCSI_INVALID_LUN ~0ULL
aebebb
 
aebebb
 enum no_undef_states {