|
|
b7337d |
From 7159242be31dbb3f25aa67920462107bc2bc5fe0 Mon Sep 17 00:00:00 2001
|
|
|
b7337d |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
b7337d |
Date: Thu, 9 Jul 2020 18:20:18 -0500
|
|
|
b7337d |
Subject: [PATCH] libmultipath: count pending paths as active on loads
|
|
|
b7337d |
|
|
|
b7337d |
When multipath loads a table, it signals to udev if there are no active
|
|
|
b7337d |
paths. Multipath wasn't counting pending paths as active. This meant
|
|
|
b7337d |
that if all the paths were pending, udev would treat the device as not
|
|
|
b7337d |
ready, and not run kpartx on it. Even if the pending paths later
|
|
|
b7337d |
because active and were reinstated, the kernel would not send a new
|
|
|
b7337d |
uevent, because from its point of view, they were always up.
|
|
|
b7337d |
|
|
|
b7337d |
The alternative would be to continue to treat them as failed in the udev
|
|
|
b7337d |
rules, but then also tell the kernel that they were down, so that it
|
|
|
b7337d |
would trigger a uevent when they were reinstated. However, this could
|
|
|
b7337d |
lead to newly created multipath devices failing IO, simply because the
|
|
|
b7337d |
path checkers hadn't returned yet. Having udev assume that the the
|
|
|
b7337d |
device is up, like the kernel does, seems like the safer option.
|
|
|
b7337d |
|
|
|
b7337d |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
b7337d |
---
|
|
|
b7337d |
libmultipath/devmapper.c | 3 ++-
|
|
|
b7337d |
libmultipath/structs.c | 20 ++++++++++++++++++++
|
|
|
b7337d |
libmultipath/structs.h | 1 +
|
|
|
b7337d |
3 files changed, 23 insertions(+), 1 deletion(-)
|
|
|
b7337d |
|
|
|
b7337d |
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
|
|
|
b7337d |
index 7f98bf9d..91ff0b3d 100644
|
|
|
b7337d |
--- a/libmultipath/devmapper.c
|
|
|
b7337d |
+++ b/libmultipath/devmapper.c
|
|
|
b7337d |
@@ -408,7 +408,8 @@ static uint16_t build_udev_flags(const struct multipath *mpp, int reload)
|
|
|
b7337d |
/* DM_UDEV_DISABLE_LIBRARY_FALLBACK is added in dm_addmap */
|
|
|
b7337d |
return (mpp->skip_kpartx == SKIP_KPARTX_ON ?
|
|
|
b7337d |
MPATH_UDEV_NO_KPARTX_FLAG : 0) |
|
|
|
b7337d |
- ((count_active_paths(mpp) == 0 || mpp->ghost_delay_tick > 0) ?
|
|
|
b7337d |
+ ((count_active_pending_paths(mpp) == 0 ||
|
|
|
b7337d |
+ mpp->ghost_delay_tick > 0) ?
|
|
|
b7337d |
MPATH_UDEV_NO_PATHS_FLAG : 0) |
|
|
|
b7337d |
(reload && !mpp->force_udev_reload ?
|
|
|
b7337d |
MPATH_UDEV_RELOAD_FLAG : 0);
|
|
|
b7337d |
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
|
|
|
b7337d |
index 2dd378c4..dda9884c 100644
|
|
|
b7337d |
--- a/libmultipath/structs.c
|
|
|
b7337d |
+++ b/libmultipath/structs.c
|
|
|
b7337d |
@@ -500,6 +500,26 @@ int count_active_paths(const struct multipath *mpp)
|
|
|
b7337d |
return count;
|
|
|
b7337d |
}
|
|
|
b7337d |
|
|
|
b7337d |
+int count_active_pending_paths(const struct multipath *mpp)
|
|
|
b7337d |
+{
|
|
|
b7337d |
+ struct pathgroup *pgp;
|
|
|
b7337d |
+ struct path *pp;
|
|
|
b7337d |
+ int count = 0;
|
|
|
b7337d |
+ int i, j;
|
|
|
b7337d |
+
|
|
|
b7337d |
+ if (!mpp->pg)
|
|
|
b7337d |
+ return 0;
|
|
|
b7337d |
+
|
|
|
b7337d |
+ vector_foreach_slot (mpp->pg, pgp, i) {
|
|
|
b7337d |
+ vector_foreach_slot (pgp->paths, pp, j) {
|
|
|
b7337d |
+ if (pp->state == PATH_UP || pp->state == PATH_GHOST ||
|
|
|
b7337d |
+ pp->state == PATH_PENDING)
|
|
|
b7337d |
+ count++;
|
|
|
b7337d |
+ }
|
|
|
b7337d |
+ }
|
|
|
b7337d |
+ return count;
|
|
|
b7337d |
+}
|
|
|
b7337d |
+
|
|
|
b7337d |
int pathcmp(const struct pathgroup *pgp, const struct pathgroup *cpgp)
|
|
|
b7337d |
{
|
|
|
b7337d |
int i, j;
|
|
|
b7337d |
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
|
|
|
b7337d |
index 9bd39eb1..8e78b8c0 100644
|
|
|
b7337d |
--- a/libmultipath/structs.h
|
|
|
b7337d |
+++ b/libmultipath/structs.h
|
|
|
b7337d |
@@ -465,6 +465,7 @@ struct path * first_path (const struct multipath *mpp);
|
|
|
b7337d |
int pathcountgr (const struct pathgroup *, int);
|
|
|
b7337d |
int pathcount (const struct multipath *, int);
|
|
|
b7337d |
int count_active_paths(const struct multipath *);
|
|
|
b7337d |
+int count_active_pending_paths(const struct multipath *);
|
|
|
b7337d |
int pathcmp (const struct pathgroup *, const struct pathgroup *);
|
|
|
b7337d |
int add_feature (char **, const char *);
|
|
|
b7337d |
int remove_feature (char **, const char *);
|
|
|
b7337d |
--
|
|
|
b7337d |
2.17.2
|
|
|
b7337d |
|