From 6df0bcd804a50314b396b75dd7b70ccd29edf43a Mon Sep 17 00:00:00 2001 From: liubo Date: Thu, 16 Nov 2023 10:13:32 +0800 Subject: [PATCH] backport patches from community backport two patches from community. 1. libmultipath: use directio checker for LIO target 2. multipathd: make pr registration consistent Signed-off-by: liubo (cherry picked from commit ee0fed9d9c62936bc10577d2ade7aa93ef601491) --- ...use-directio-checker-for-LIO-targets.patch | 36 +++++ ...athd-make-pr-registration-consistent.patch | 142 ++++++++++++++++++ multipath-tools.spec | 7 +- 3 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 0024-libmultipath-use-directio-checker-for-LIO-targets.patch create mode 100644 0025-multipathd-make-pr-registration-consistent.patch diff --git a/0024-libmultipath-use-directio-checker-for-LIO-targets.patch b/0024-libmultipath-use-directio-checker-for-LIO-targets.patch new file mode 100644 index 0000000..6a40a53 --- /dev/null +++ b/0024-libmultipath-use-directio-checker-for-LIO-targets.patch @@ -0,0 +1,36 @@ +From 71448bb3742446679955037c4416dc5e5fd73836 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Thu, 23 Mar 2023 21:43:32 +0100 +Subject: [PATCH] libmultipath: use directio checker for LIO targets + +LIO always responds with GOOD status to TUR. Thus TUR is +not useful as path checker for LIO targets. + +Fixes https://github.com/opensvc/multipath-tools/issues/54 + +mwilck: v2: fixed up with .detect_checker setting. + +Reported-by: Li Xiaokeng +Signed-off-by: Martin Wilck +Reviewed-by: Benjamin Marzinski +Tested-by: Li Xiaokeng +--- + libmultipath/hwtable.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 3c4f866a..65bca744 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -1067,6 +1067,8 @@ static struct hwentry default_hw[] = { + .pgfailback = -FAILBACK_IMMEDIATE, + .no_path_retry = 12, + .prio_name = PRIO_ALUA, ++ .checker_name = DIRECTIO, ++ .detect_checker = DETECT_CHECKER_OFF, + }, + /* + * DataCore +-- +2.33.0 + diff --git a/0025-multipathd-make-pr-registration-consistent.patch b/0025-multipathd-make-pr-registration-consistent.patch new file mode 100644 index 0000000..6f25b45 --- /dev/null +++ b/0025-multipathd-make-pr-registration-consistent.patch @@ -0,0 +1,142 @@ +From e068f352dbb3b7fad76fb0c7b4dd8212c4f1f503 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Tue, 20 Dec 2022 17:41:10 -0600 +Subject: [PATCH] multipathd: make pr registration consistent + +multipathd was inconsistent on what it did with persistent reservations +when a multipath device was created. If a multipath device with a +configured reservation key was created during configure(), multipathd +would try to read the registered keys using an active path. If it saw a +matching key, it would set the prflag, but not attempt to register the +key on any of the other paths. This means that if a new path had +appeared while multipathd was not running, it wouldn't register the key +on this path. + +If the multipath device was created during ev_add_path(), multipathd +would used the added path to check if there was a matching key and if +there was, register the key only on the added path and then set the +prflag. This could be problematic if the device was created with +multiple paths, for instance because find_mutipaths was set to "yes" and +a second path just appeared. In this case, if the device happened to be +only registered on the second path, it would not get registered on the +first path. + +If the multipath device was added to multipathd during a call to +ev_add_map(), multipathd wouldn't set the prflag or register the key on +any paths. + +After a device was created with the prflag set, if a new path appeared +before the creation uevent, and multipathd was forced to delay adding +it, when it finally updated the multipath device, the key would be +registered on all paths, fixing any paths missed during creation. +However, if a new path appeared after the creation uevent, the key would +only be registered on that new path. Any paths that were missed on +creation would stay missed. + +persistent key registration needs to be handled consistently. This +patch does so by making sure that however a multipath device is added to +multipathd, it will check to see if the configured key is registered. If +it is, multipathd will set the prflag and register the key on all the +currently active paths. + +When a new path is added, multipathd will use it to check for active +keys, as before. But if it finds a matching key and prflag isn't +currently set, it will register the key on all paths. + +Conflict: multipathd/main.c +Reference:https://github.com/opensvc/multipath-tools/commit/8d64b0dac7b3fba9172b9c053bc46117138ab181 + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + multipathd/main.c | 32 +++++++++++++++++++++++++++++--- + 1 file changed, 29 insertions(+), 3 deletions(-) + +diff --git a/multipathd/main.c b/multipathd/main.c +index be7ae60..d8ed2f5 100644 +--- a/multipathd/main.c ++++ b/multipathd/main.c +@@ -485,6 +485,21 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset) + return 0; + } + ++static void ++pr_register_active_paths(struct multipath *mpp) ++{ ++ unsigned int i, j; ++ struct path *pp; ++ struct pathgroup *pgp; ++ ++ vector_foreach_slot (mpp->pg, pgp, i) { ++ vector_foreach_slot (pgp->paths, pp, j) { ++ if ((pp->state == PATH_UP) || (pp->state == PATH_GHOST)) ++ mpath_pr_event_handle(pp); ++ } ++ } ++} ++ + static int + update_map (struct multipath *mpp, struct vectors *vecs, int new_map) + { +@@ -527,6 +542,11 @@ fail: + + sync_map_state(mpp); + ++ if (!mpp->prflag) ++ update_map_pr(mpp); ++ if (mpp->prflag) ++ pr_register_active_paths(mpp); ++ + if (retries < 0) + condlog(0, "%s: failed reload in new map update", mpp->alias); + return 0; +@@ -1050,6 +1070,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) + int retries = 3; + int start_waiter = 0; + int ret; ++ unsigned long prflag = 0; + + /* if pp is local path,remove it and return 0. */ + if (!remove_local_path(vecs->pathvec, pp, 0)){ +@@ -1099,6 +1120,8 @@ rescan: + + verify_paths(mpp); + mpp->action = ACT_RELOAD; ++ prflag = mpp->prflag; ++ mpath_pr_event_handle(pp); + } else { + if (!should_multipath(pp, vecs->pathvec, vecs->mpvec)) { + orphan_path(pp, "only one path"); +@@ -1117,9 +1140,6 @@ rescan: + goto fail; /* leave path added to pathvec */ + } + +- /* persistent reservation check*/ +- mpath_pr_event_handle(pp); +- + if (!need_do_map) + return 0; + +@@ -1179,6 +1199,10 @@ rescan: + sync_map_state(mpp); + + if (retries >= 0) { ++ if (start_waiter) ++ update_map_pr(mpp); ++ if (mpp->prflag && !prflag) ++ pr_register_active_paths(mpp); + condlog(2, "%s [%s]: path added to devmap %s", + pp->dev, pp->dev_t, mpp->alias); + return 0; +@@ -2666,6 +2690,8 @@ configure (struct vectors * vecs) + if (remember_wwid(mpp->wwid) == 1) + trigger_paths_udev_change(mpp, true); + update_map_pr(mpp); ++ if (mpp->prflag) ++ pr_register_active_paths(mpp); + } + + /* +-- +2.33.0 + diff --git a/multipath-tools.spec b/multipath-tools.spec index 4c04e0e..3958ca3 100644 --- a/multipath-tools.spec +++ b/multipath-tools.spec @@ -1,7 +1,7 @@ #needsrootforbuild Name: multipath-tools Version: 0.8.7 -Release: 8 +Release: 9 Summary: Tools to manage multipath devices with the device-mapper License: GPL-2.0-or-later and LGPL-2.0-only URL: http://christophe.varoqui.free.fr/ @@ -32,6 +32,8 @@ Patch20: 0020-multipathd-make-all-cli_handlers-static.patch Patch21: 0021-multipathd-Fix-command-completion-in-interactive-mod.patch Patch22: 0022-multipathd-more-robust-command-parsing.patch Patch23: 0023-multipathd-Fixed-multipathd-parameter-invoking-seque.patch +Patch24: 0024-libmultipath-use-directio-checker-for-LIO-targets.patch +Patch25: 0025-multipathd-make-pr-registration-consistent.patch BuildRequires: multipath-tools, libcmocka, libcmocka-devel BuildRequires: gcc, libaio-devel, userspace-rcu-devel, device-mapper-devel >= 1.02.89 @@ -179,6 +181,9 @@ fi %changelog +* Thu Nov 16 2023 liubo - 0.8.7-9 +- backport patched from community + * Tue Nov 29 2022 Zhiqiang Liu - 0.8.7-8 - set Source0 to URL link. -- Gitee