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

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