[PATCH 1/4] libmultipath: enable linear ordering of bus/proto tuple

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

We categorized protocols by bus/proto_id, while we only differentiate
protocol IDs for SCSI. Allow transforming this into a linear sequence
of bus/protocol IDs by having non-SCSI first, and follwing up with
the different SCSI protocols.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/structs.c | 10 ++++++++++
 libmultipath/structs.h | 13 +++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 17f4baf..5849bf1 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -753,3 +753,13 @@ out:
 
 	return 0;
 }
+
+unsigned int bus_protocol_id(const struct path *pp) {
+	if (!pp || pp->bus < 0 || pp->bus > SYSFS_BUS_SCSI)
+		return SYSFS_BUS_UNDEF;
+	if (pp->bus != SYSFS_BUS_SCSI)
+		return pp->bus;
+	if (pp->sg_id.proto_id < 0 || pp->sg_id.proto_id > SCSI_PROTOCOL_UNSPEC)
+		return SYSFS_BUS_UNDEF;
+	return SYSFS_BUS_SCSI + pp->sg_id.proto_id;
+}
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index 205cf64..d94f93a 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -57,12 +57,13 @@ enum failback_mode {
 	FAILBACK_FOLLOWOVER
 };
 
+/* SYSFS_BUS_SCSI should be last, see bus_protocol_id() */
 enum sysfs_buses {
 	SYSFS_BUS_UNDEF,
-	SYSFS_BUS_SCSI,
 	SYSFS_BUS_CCW,
 	SYSFS_BUS_CCISS,
 	SYSFS_BUS_NVME,
+	SYSFS_BUS_SCSI,
 };
 
 enum pathstates {
@@ -181,9 +182,17 @@ enum scsi_protocol {
 	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */
 	SCSI_PROTOCOL_ATA = 8,
 	SCSI_PROTOCOL_USB = 9,  /* USB Attached SCSI (UAS), and others */
-	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
+	SCSI_PROTOCOL_UNSPEC = 0xa, /* No specific protocol */
 };
 
+/*
+ * Linear ordering of bus/protocol
+ * This assumes that SYSFS_BUS_SCSI is last in enum sysfs_buses
+ * SCSI is the only bus type for which we distinguish protocols.
+ */
+#define LAST_BUS_PROTOCOL_ID (SYSFS_BUS_SCSI + SCSI_PROTOCOL_UNSPEC)
+unsigned int bus_protocol_id(const struct path *pp);
+
 #define SCSI_INVALID_LUN ~0ULL
 
 enum no_undef_states {
-- 
2.35.1


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux