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