Blame SOURCES/0124-libmultipath-enforce-queue_mode-bio-for-nmve-tcp-pat.patch

108c2a
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
108c2a
From: Benjamin Marzinski <bmarzins@redhat.com>
108c2a
Date: Fri, 7 Oct 2022 12:35:44 -0500
108c2a
Subject: [PATCH] libmultipath: enforce queue_mode bio for nmve:tcp paths
108c2a
108c2a
nvme:tcp devices set BLK_MQ_F_BLOCKING (they are the only block devices
108c2a
which multipath supports that do so), meaning that block_mq expects that
108c2a
they can block at certain points while servicing a request.  However,
108c2a
due to the way device-mapper sets up its queue, it is not able to set
108c2a
BLK_MQ_F_BLOCKING when it includes paths that set this flag.  Patches
108c2a
were written to address this issue but they were rejected upstream
108c2a
108c2a
https://lore.kernel.org/linux-block/YcH%2FE4JNag0QYYAa@infradead.org/T/#t
108c2a
108c2a
The proposed solution was to have multipath use the bio queue_mode for
108c2a
multipath devices that include nvme:tcp paths.
108c2a
108c2a
Multipath devices now automatically add the "queue_mode bio" feature if
108c2a
they include nvme:tcp paths.  If a multipath devices was created with
108c2a
"queue_mode rq", it will disallow the addition of nvme:tcp paths.
108c2a
108c2a
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
108c2a
Reviewed-by: Martin Wilck <mwilck@suse.com>
108c2a
---
108c2a
 libmultipath/configure.c   | 17 ++++++++++++++++-
108c2a
 libmultipath/structs_vec.c |  7 +++++++
108c2a
 multipath/multipath.conf.5 |  4 +++-
108c2a
 3 files changed, 26 insertions(+), 2 deletions(-)
108c2a
108c2a
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
108c2a
index 8e1bc488..c341793c 100644
108c2a
--- a/libmultipath/configure.c
108c2a
+++ b/libmultipath/configure.c
108c2a
@@ -297,6 +297,7 @@ int setup_map(struct multipath *mpp, char *params, int params_size,
108c2a
 	      struct vectors *vecs)
108c2a
 {
108c2a
 	struct pathgroup * pgp;
108c2a
+	struct path *pp;
108c2a
 	struct config *conf;
108c2a
 	int i, n_paths, marginal_pathgroups;
108c2a
 
108c2a
@@ -308,6 +309,14 @@ int setup_map(struct multipath *mpp, char *params, int params_size,
108c2a
 		return 1;
108c2a
 	}
108c2a
 
108c2a
+	/* Force QUEUE_MODE_BIO for maps with nvme:tcp paths */
108c2a
+	vector_foreach_slot(mpp->paths, pp, i) {
108c2a
+		if (pp->bus == SYSFS_BUS_NVME &&
108c2a
+		    pp->sg_id.proto_id == NVME_PROTOCOL_TCP) {
108c2a
+			mpp->queue_mode = QUEUE_MODE_BIO;
108c2a
+			break;
108c2a
+		}
108c2a
+	}
108c2a
 	/*
108c2a
 	 * free features, selector, and hwhandler properties if they are being reused
108c2a
 	 */
108c2a
@@ -1161,6 +1170,13 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
108c2a
 			continue;
108c2a
 		}
108c2a
 
108c2a
+		cmpp = find_mp_by_wwid(curmp, pp1->wwid);
108c2a
+		if (cmpp && cmpp->queue_mode == QUEUE_MODE_RQ &&
108c2a
+		    pp1->bus == SYSFS_BUS_NVME && pp1->sg_id.proto_id ==
108c2a
+		    NVME_PROTOCOL_TCP) {
108c2a
+			orphan_path(pp1, "nvme:tcp path not allowed with request queue_mode multipath device");
108c2a
+			continue;
108c2a
+		}
108c2a
 		/*
108c2a
 		 * at this point, we know we really got a new mp
108c2a
 		 */
108c2a
@@ -1199,7 +1215,6 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
108c2a
 		}
108c2a
 		verify_paths(mpp, vecs);
108c2a
 
108c2a
-		cmpp = find_mp_by_wwid(curmp, mpp->wwid);
108c2a
 		if (cmpp)
108c2a
 			mpp->queue_mode = cmpp->queue_mode;
108c2a
 		params[0] = '\0';
108c2a
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
108c2a
index 8137ea21..24ac022e 100644
108c2a
--- a/libmultipath/structs_vec.c
108c2a
+++ b/libmultipath/structs_vec.c
108c2a
@@ -68,6 +68,13 @@ int adopt_paths(vector pathvec, struct multipath *mpp)
108c2a
 					pp->dev, mpp->alias);
108c2a
 				continue;
108c2a
 			}
108c2a
+			if (mpp->queue_mode == QUEUE_MODE_RQ &&
108c2a
+			    pp->bus == SYSFS_BUS_NVME &&
108c2a
+			    pp->sg_id.proto_id == NVME_PROTOCOL_TCP) {
108c2a
+				condlog(2, "%s: mulitpath device %s created with request queue_mode. Unable to add nvme:tcp paths",
108c2a
+					pp->dev, mpp->alias);
108c2a
+				continue;
108c2a
+			}
108c2a
 			condlog(3, "%s: ownership set to %s",
108c2a
 				pp->dev, mpp->alias);
108c2a
 			pp->mpp = mpp;
108c2a
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
108c2a
index 1f5a40b6..cb07a62c 100644
108c2a
--- a/multipath/multipath.conf.5
108c2a
+++ b/multipath/multipath.conf.5
108c2a
@@ -462,7 +462,9 @@ Before kernel 4.20 The default depends on the kernel parameter
108c2a
 \fBdm_mod.use_blk_mq\fR. It is \fImq\fR if the latter is set, and \fIrq\fR
108c2a
 otherwise. Since kernel 4.20, \fIrq\fR and \fImq\fR both correspond to
108c2a
 block-multiqueue. Once a multipath device has been created, its queue_mode
108c2a
-cannot be changed.
108c2a
+cannot be changed. \fInvme:tcp\fR paths are only supported in multipath
108c2a
+devices with queue_mode set to \fIbio\fR. multipath will automatically
108c2a
+set this when creating a device with \fInvme:tcp\fR paths.
108c2a
 .TP
108c2a
 The default is: \fB<unset>\fR
108c2a
 .RE