Blame SOURCES/0092-multipath-tools-update-mpp-force_readonly-in-ev_add_.patch

7805a0
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
7805a0
From: Uday Shankar <ushankar@purestorage.com>
7805a0
Date: Wed, 9 Mar 2022 13:03:26 -0700
7805a0
Subject: [PATCH] multipath-tools: update mpp->force_readonly in ev_add_path
7805a0
7805a0
When NVMe disks are added to the system, no uevent containing the
7805a0
DISK_RO property is generated. As a result, dm-* nodes backed by
7805a0
readonly NVMe disks will not have their RO state set properly. The
7805a0
result looks like this:
7805a0
7805a0
$ multipath -l
7805a0
eui.00c92c091fd6564424a9376600011bd1 dm-3 NVME,Pure Storage FlashArray
7805a0
size=1.0T features='0' hwhandler='0' wp=rw
7805a0
|-+- policy='service-time 0' prio=0 status=active
7805a0
| `- 0:2:2:72657 nvme0n2 259:4 active undef running
7805a0
`-+- policy='service-time 0' prio=0 status=enabled
7805a0
  `- 1:0:2:72657 nvme1n2 259:1 active undef running
7805a0
$ cat /sys/block/dm-3/ro
7805a0
0
7805a0
$ cat /sys/block/nvme*n2/ro
7805a0
1
7805a0
1
7805a0
7805a0
This is not a problem for SCSI disks, since the kernel will emit change
7805a0
uevents containing the DISK_RO property when the disk is added to the
7805a0
system. See the following thread for my initial attempt to fix this
7805a0
issue at the kernel level:
7805a0
https://lore.kernel.org/linux-block/Yib8GqCA5e3SQYty@infradead.org/T/#t
7805a0
7805a0
Fix the issue by picking up the path ro state from sysfs in ev_add_path,
7805a0
setting the mpp->force_readonly accordingly, and changing
7805a0
dm_addmap_create to be aware of mpp->force_readonly.
7805a0
7805a0
Signed-off-by: Uday Shankar <ushankar@purestorage.com>
7805a0
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
7805a0
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7805a0
---
7805a0
 libmultipath/devmapper.c | 2 +-
7805a0
 multipathd/main.c        | 6 ++++++
7805a0
 2 files changed, 7 insertions(+), 1 deletion(-)
7805a0
7805a0
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
7805a0
index 3f70e576..e3c3c119 100644
7805a0
--- a/libmultipath/devmapper.c
7805a0
+++ b/libmultipath/devmapper.c
7805a0
@@ -420,7 +420,7 @@ int dm_addmap_create (struct multipath *mpp, char * params)
7805a0
 	int ro;
7805a0
 	uint16_t udev_flags = build_udev_flags(mpp, 0);
7805a0
 
7805a0
-	for (ro = 0; ro <= 1; ro++) {
7805a0
+	for (ro = mpp->force_readonly ? 1 : 0; ro <= 1; ro++) {
7805a0
 		int err;
7805a0
 
7805a0
 		if (dm_addmap(DM_DEVICE_CREATE, TGT_MPATH, mpp, params, ro,
7805a0
diff --git a/multipathd/main.c b/multipathd/main.c
7805a0
index f4b79882..eeded52b 100644
7805a0
--- a/multipathd/main.c
7805a0
+++ b/multipathd/main.c
7805a0
@@ -988,6 +988,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map)
7805a0
 	int retries = 3;
7805a0
 	int start_waiter = 0;
7805a0
 	int ret;
7805a0
+	int ro;
7805a0
 
7805a0
 	/*
7805a0
 	 * need path UID to go any further
7805a0
@@ -1051,6 +1052,11 @@ rescan:
7805a0
 	/* persistent reservation check*/
7805a0
 	mpath_pr_event_handle(pp);
7805a0
 
7805a0
+	/* ro check - if new path is ro, force map to be ro as well */
7805a0
+	ro = sysfs_get_ro(pp);
7805a0
+	if (ro == 1)
7805a0
+		mpp->force_readonly = 1;
7805a0
+
7805a0
 	if (!need_do_map)
7805a0
 		return 0;
7805a0