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

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