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

e71b65
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
e71b65
From: Benjamin Marzinski <bmarzins@redhat.com>
e71b65
Date: Fri, 7 Oct 2022 12:35:44 -0500
e71b65
Subject: [PATCH] libmultipath: enforce queue_mode bio for nmve:tcp paths
e71b65
e71b65
nvme:tcp devices set BLK_MQ_F_BLOCKING (they are the only block devices
e71b65
which multipath supports that do so), meaning that block_mq expects that
e71b65
they can block at certain points while servicing a request.  However,
e71b65
due to the way device-mapper sets up its queue, it is not able to set
e71b65
BLK_MQ_F_BLOCKING when it includes paths that set this flag.  Patches
e71b65
were written to address this issue but they were rejected upstream
e71b65
e71b65
https://lore.kernel.org/linux-block/YcH%2FE4JNag0QYYAa@infradead.org/T/#t
e71b65
e71b65
The proposed solution was to have multipath use the bio queue_mode for
e71b65
multipath devices that include nvme:tcp paths.
e71b65
e71b65
Multipath devices now automatically add the "queue_mode bio" feature if
e71b65
they include nvme:tcp paths.  If a multipath devices was created with
e71b65
"queue_mode rq", it will disallow the addition of nvme:tcp paths.
e71b65
e71b65
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
e71b65
Reviewed-by: Martin Wilck <mwilck@suse.com>
e71b65
---
e71b65
 libmultipath/configure.c   | 17 ++++++++++++++++-
e71b65
 libmultipath/structs_vec.c |  7 +++++++
e71b65
 multipath/multipath.conf.5 |  4 +++-
e71b65
 3 files changed, 26 insertions(+), 2 deletions(-)
e71b65
e71b65
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
e71b65
index c6803b40..193bf27d 100644
e71b65
--- a/libmultipath/configure.c
e71b65
+++ b/libmultipath/configure.c
e71b65
@@ -296,6 +296,7 @@ static int wait_for_pending_paths(struct multipath *mpp,
e71b65
 int setup_map(struct multipath *mpp, char **params, struct vectors *vecs)
e71b65
 {
e71b65
 	struct pathgroup * pgp;
e71b65
+	struct path *pp;
e71b65
 	struct config *conf;
e71b65
 	int i, n_paths, marginal_pathgroups;
e71b65
 	char *save_attr;
e71b65
@@ -311,6 +312,14 @@ int setup_map(struct multipath *mpp, char **params, struct vectors *vecs)
e71b65
 	if (mpp->disable_queueing && VECTOR_SIZE(mpp->paths) != 0)
e71b65
 		mpp->disable_queueing = 0;
e71b65
 
e71b65
+	/* Force QUEUE_MODE_BIO for maps with nvme:tcp paths */
e71b65
+	vector_foreach_slot(mpp->paths, pp, i) {
e71b65
+		if (pp->bus == SYSFS_BUS_NVME &&
e71b65
+		    pp->sg_id.proto_id == NVME_PROTOCOL_TCP) {
e71b65
+			mpp->queue_mode = QUEUE_MODE_BIO;
e71b65
+			break;
e71b65
+		}
e71b65
+	}
e71b65
 	/*
e71b65
 	 * If this map was created with add_map_without_path(),
e71b65
 	 * mpp->hwe might not be set yet.
e71b65
@@ -1191,6 +1200,13 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
e71b65
 			continue;
e71b65
 		}
e71b65
 
e71b65
+		cmpp = find_mp_by_wwid(curmp, pp1->wwid);
e71b65
+		if (cmpp && cmpp->queue_mode == QUEUE_MODE_RQ &&
e71b65
+		    pp1->bus == SYSFS_BUS_NVME && pp1->sg_id.proto_id ==
e71b65
+		    NVME_PROTOCOL_TCP) {
e71b65
+			orphan_path(pp1, "nvme:tcp path not allowed with request queue_mode multipath device");
e71b65
+			continue;
e71b65
+		}
e71b65
 		/*
e71b65
 		 * at this point, we know we really got a new mp
e71b65
 		 */
e71b65
@@ -1229,7 +1245,6 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
e71b65
 		}
e71b65
 		verify_paths(mpp);
e71b65
 
e71b65
-		cmpp = find_mp_by_wwid(curmp, mpp->wwid);
e71b65
 		if (cmpp)
e71b65
 			mpp->queue_mode = cmpp->queue_mode;
e71b65
 		if (setup_map(mpp, &params, vecs)) {
e71b65
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
e71b65
index 85d97ac1..4a32b405 100644
e71b65
--- a/libmultipath/structs_vec.c
e71b65
+++ b/libmultipath/structs_vec.c
e71b65
@@ -262,6 +262,13 @@ int adopt_paths(vector pathvec, struct multipath *mpp)
e71b65
 			}
e71b65
 			if (pp->initialized == INIT_REMOVED)
e71b65
 				continue;
e71b65
+			if (mpp->queue_mode == QUEUE_MODE_RQ &&
e71b65
+			    pp->bus == SYSFS_BUS_NVME &&
e71b65
+			    pp->sg_id.proto_id == NVME_PROTOCOL_TCP) {
e71b65
+				condlog(2, "%s: mulitpath device %s created with request queue_mode. Unable to add nvme:tcp paths",
e71b65
+					pp->dev, mpp->alias);
e71b65
+				continue;
e71b65
+			}
e71b65
 			if (!mpp->paths && !(mpp->paths = vector_alloc()))
e71b65
 				goto err;
e71b65
 
e71b65
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
e71b65
index 7af53588..01904feb 100644
e71b65
--- a/multipath/multipath.conf.5
e71b65
+++ b/multipath/multipath.conf.5
e71b65
@@ -472,7 +472,9 @@ Before kernel 4.20 The default depends on the kernel parameter
e71b65
 \fBdm_mod.use_blk_mq\fR. It is \fImq\fR if the latter is set, and \fIrq\fR
e71b65
 otherwise. Since kernel 4.20, \fIrq\fR and \fImq\fR both correspond to
e71b65
 block-multiqueue. Once a multipath device has been created, its queue_mode
e71b65
-cannot be changed.
e71b65
+cannot be changed. \fInvme:tcp\fR paths are only supported in multipath
e71b65
+devices with queue_mode set to \fIbio\fR. multipath will automatically
e71b65
+set this when creating a device with \fInvme:tcp\fR paths.
e71b65
 .TP
e71b65
 The default is: \fB<unset>\fR
e71b65
 .RE