Blame SOURCES/0073-libmultipath-prepare-proto_id-for-use-by-non-scsi-de.patch

86e138
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
86e138
From: Benjamin Marzinski <bmarzins@redhat.com>
86e138
Date: Fri, 7 Oct 2022 12:35:42 -0500
86e138
Subject: [PATCH] libmultipath: prepare proto_id for use by non-scsi devivces
86e138
86e138
Make sure that when we are checking for a scsi protocol, we are first
86e138
checking that we are working with a scsi path.
86e138
86e138
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
86e138
Reviewed-by: Martin Wilck <mwilck@suse.com>
86e138
---
86e138
 libmultipath/configure.c   |  9 +++++----
86e138
 libmultipath/discovery.c   | 13 ++++++++-----
86e138
 libmultipath/print.c       |  6 ++++--
86e138
 libmultipath/structs.c     |  2 +-
86e138
 libmultipath/structs.h     |  4 +++-
86e138
 multipathd/fpin_handlers.c |  2 +-
86e138
 6 files changed, 22 insertions(+), 14 deletions(-)
86e138
86e138
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
86e138
index cc778a22..c6803b40 100644
86e138
--- a/libmultipath/configure.c
86e138
+++ b/libmultipath/configure.c
86e138
@@ -223,10 +223,11 @@ int rr_optimize_path_order(struct pathgroup *pgp)
86e138
 
86e138
 	total_paths = VECTOR_SIZE(pgp->paths);
86e138
 	vector_foreach_slot(pgp->paths, pp, i) {
86e138
-		if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP &&
86e138
-			pp->sg_id.proto_id != SCSI_PROTOCOL_SAS &&
86e138
-			pp->sg_id.proto_id != SCSI_PROTOCOL_ISCSI &&
86e138
-			pp->sg_id.proto_id != SCSI_PROTOCOL_SRP) {
86e138
+		if (pp->bus != SYSFS_BUS_SCSI ||
86e138
+		    (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP &&
86e138
+		     pp->sg_id.proto_id != SCSI_PROTOCOL_SAS &&
86e138
+		     pp->sg_id.proto_id != SCSI_PROTOCOL_ISCSI &&
86e138
+		     pp->sg_id.proto_id != SCSI_PROTOCOL_SRP)) {
86e138
 			/* return success as default path order
86e138
 			 * is maintained in path group
86e138
 			 */
86e138
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
86e138
index bcda8b09..7f2eb409 100644
86e138
--- a/libmultipath/discovery.c
86e138
+++ b/libmultipath/discovery.c
86e138
@@ -481,10 +481,11 @@ int sysfs_get_host_adapter_name(const struct path *pp, char *adapter_name)
86e138
 
86e138
 	proto_id = pp->sg_id.proto_id;
86e138
 
86e138
-	if (proto_id != SCSI_PROTOCOL_FCP &&
86e138
-	    proto_id != SCSI_PROTOCOL_SAS &&
86e138
-	    proto_id != SCSI_PROTOCOL_ISCSI &&
86e138
-	    proto_id != SCSI_PROTOCOL_SRP) {
86e138
+	if (pp->bus != SYSFS_BUS_SCSI ||
86e138
+	    (proto_id != SCSI_PROTOCOL_FCP &&
86e138
+	     proto_id != SCSI_PROTOCOL_SAS &&
86e138
+	     proto_id != SCSI_PROTOCOL_ISCSI &&
86e138
+	     proto_id != SCSI_PROTOCOL_SRP)) {
86e138
 		return 1;
86e138
 	}
86e138
 	/* iscsi doesn't have adapter info in sysfs
86e138
@@ -1754,8 +1755,10 @@ sysfs_pathinfo(struct path *pp, const struct _vector *hwtable)
86e138
 		pp->bus = SYSFS_BUS_CCISS;
86e138
 	if (!strncmp(pp->dev,"dasd", 4))
86e138
 		pp->bus = SYSFS_BUS_CCW;
86e138
-	if (!strncmp(pp->dev,"sd", 2))
86e138
+	if (!strncmp(pp->dev,"sd", 2)) {
86e138
 		pp->bus = SYSFS_BUS_SCSI;
86e138
+		pp->sg_id.proto_id = SCSI_PROTOCOL_UNSPEC;
86e138
+	}
86e138
 	if (!strncmp(pp->dev,"nvme", 4))
86e138
 		pp->bus = SYSFS_BUS_NVME;
86e138
 
86e138
diff --git a/libmultipath/print.c b/libmultipath/print.c
86e138
index 46e3d32e..082e4e30 100644
86e138
--- a/libmultipath/print.c
86e138
+++ b/libmultipath/print.c
86e138
@@ -592,7 +592,8 @@ snprint_host_attr (struct strbuf *buff, const struct path * pp, char *attr)
86e138
 	const char *value = NULL;
86e138
 	int ret;
86e138
 
86e138
-	if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
86e138
+	if (pp->bus != SYSFS_BUS_SCSI ||
86e138
+	    pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
86e138
 		return append_strbuf_str(buff, "[undef]");
86e138
 	sprintf(host_id, "host%d", pp->sg_id.host_no);
86e138
 	host_dev = udev_device_new_from_subsystem_sysname(udev, "fc_host",
86e138
@@ -631,7 +632,8 @@ snprint_tgt_wwpn (struct strbuf *buff, const struct path * pp)
86e138
 	const char *value = NULL;
86e138
 	int ret;
86e138
 
86e138
-	if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
86e138
+	if (pp->bus != SYSFS_BUS_SCSI ||
86e138
+	    pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
86e138
 		return append_strbuf_str(buff, "[undef]");
86e138
 	sprintf(rport_id, "rport-%d:%d-%d",
86e138
 		pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id);
86e138
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
86e138
index 5dfa86a8..be81a83c 100644
86e138
--- a/libmultipath/structs.c
86e138
+++ b/libmultipath/structs.c
86e138
@@ -116,7 +116,7 @@ alloc_path (void)
86e138
 		pp->sg_id.channel = -1;
86e138
 		pp->sg_id.scsi_id = -1;
86e138
 		pp->sg_id.lun = SCSI_INVALID_LUN;
86e138
-		pp->sg_id.proto_id = SCSI_PROTOCOL_UNSPEC;
86e138
+		pp->sg_id.proto_id = PROTOCOL_UNSET;
86e138
 		pp->fd = -1;
86e138
 		pp->tpgs = TPGS_UNDEF;
86e138
 		pp->priority = PRIO_UNDEF;
86e138
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
86e138
index b4f75de0..2525af17 100644
86e138
--- a/libmultipath/structs.h
86e138
+++ b/libmultipath/structs.h
86e138
@@ -176,6 +176,8 @@ enum queue_mode_states {
86e138
 	QUEUE_MODE_RQ,
86e138
 };
86e138
 
86e138
+#define PROTOCOL_UNSET -1
86e138
+
86e138
 enum scsi_protocol {
86e138
 	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
86e138
 	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
86e138
@@ -284,7 +286,7 @@ struct sg_id {
86e138
 	uint64_t lun;
86e138
 	short h_cmd_per_lun;
86e138
 	short d_queue_depth;
86e138
-	enum scsi_protocol proto_id;
86e138
+	int proto_id;
86e138
 	int transport_id;
86e138
 };
86e138
 
86e138
diff --git a/multipathd/fpin_handlers.c b/multipathd/fpin_handlers.c
86e138
index aaf5655d..571796e7 100644
86e138
--- a/multipathd/fpin_handlers.c
86e138
+++ b/multipathd/fpin_handlers.c
86e138
@@ -219,7 +219,7 @@ static int  fpin_chk_wwn_setpath_marginal(uint16_t host_num,  struct vectors *ve
86e138
 
86e138
 	vector_foreach_slot(vecs->pathvec, pp, k) {
86e138
 		/* Checks the host number and also for the SCSI FCP */
86e138
-		if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP || host_num !=  pp->sg_id.host_no)
86e138
+		if (pp->bus != SYSFS_BUS_SCSI || pp->sg_id.proto_id != SCSI_PROTOCOL_FCP || host_num !=  pp->sg_id.host_no)
86e138
 			continue;
86e138
 		sprintf(rport_id, "rport-%d:%d-%d",
86e138
 				pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id);