From 5f9ba5652551ab0e0d5286e4e13ae36e051e110b Mon Sep 17 00:00:00 2001 From: xueyamao Date: Thu, 30 Oct 2025 15:42:10 +0800 Subject: [PATCH] libmpathpersist: set mpp->mpe before selecting reservation_key (cherry picked from commit a6757e4ae309591c1c29c635614ce5760724e8d5) --- ...set-mpp-mpe-before-selecting-reserva.patch | 55 +++++++++++++++++++ multipath-tools.spec | 6 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 0038-libmpathpersist-set-mpp-mpe-before-selecting-reserva.patch diff --git a/0038-libmpathpersist-set-mpp-mpe-before-selecting-reserva.patch b/0038-libmpathpersist-set-mpp-mpe-before-selecting-reserva.patch new file mode 100644 index 0000000..741f102 --- /dev/null +++ b/0038-libmpathpersist-set-mpp-mpe-before-selecting-reserva.patch @@ -0,0 +1,55 @@ +From db1e72679bf1ba04b75f93936272b5a420918359 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 24 Jul 2024 14:17:12 -0400 +Subject: [PATCH] libmpathpersist: set mpp->mpe before selecting + reservation_key + +libmpathpersist was not setting mpp->mpe before calling +select_reservation_key(). This means that if the reservation key was set +in the multipaths sections, it wasn't being selected. + +This appeared to work for many commands because of an error in checking +if the correct reservation key was used. If mpp->reservation key was +unset, then it would considered to match if either the RK or SARK was +unset in the command. mpathpersist should fail if it doesn't find a +configured mpp->resevation key, with one exception. To make it easier to +remove old keys, if --register-ignore is called, and the command SARK is +0x0 so the device is being unregistered, allow mpp->reservation_key to +be unset. The code already allows mpp->reservation_key to not match the +command RK in this case. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmpathpersist/mpath_persist.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c +index d88499a..e3c2137 100644 +--- a/libmpathpersist/mpath_persist.c ++++ b/libmpathpersist/mpath_persist.c +@@ -666,6 +666,7 @@ int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd, + return ret; + + conf = get_multipath_config(); ++ mpp->mpe = find_mpe(conf->mptable, mpp->wwid); + select_reservation_key(conf, mpp); + select_all_tg_pt(conf, mpp); + put_multipath_config(conf); +@@ -687,6 +688,13 @@ int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd, + } + + uireservation = get_be64(mpp->reservation_key); ++ ++ if (!uireservation && ++ (prkey || rq_servact != MPATH_PROUT_REG_IGN_SA)) { ++ condlog(0, "%s: no configured reservation key", mpp->alias); ++ return MPATH_PR_SYNTAX_ERROR; ++ } ++ + for (j = 7; j >= 0; --j) { + uitmp[j] = (uireservation & 0xff); + uireservation >>= 8; +-- +2.43.0 + diff --git a/multipath-tools.spec b/multipath-tools.spec index d287bf0..68ff7ed 100644 --- a/multipath-tools.spec +++ b/multipath-tools.spec @@ -1,7 +1,7 @@ #needsrootforbuild Name: multipath-tools Version: 0.8.7 -Release: 21 +Release: 22 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/ @@ -46,6 +46,7 @@ Patch34: 0034-multipathd-Stop-double-counting-map-failures-for-no_.patch Patch35: 0035-libmultipath-set-clear-handled-flag-only-in-coalesce.patch Patch36: 0036-11-dm-mpath.rules-fix-warnings-reported-by-udevadm-v.patch Patch37: 0037-dm-parts.rules-fix-warning-reported-by-udevadm-verif.patch +Patch38: 0038-libmpathpersist-set-mpp-mpe-before-selecting-reserva.patch BuildRequires: multipath-tools, libcmocka, libcmocka-devel BuildRequires: gcc, libaio-devel, userspace-rcu-devel, device-mapper-devel >= 1.02.89 @@ -194,6 +195,9 @@ fi %changelog +* Thu Oct 30 2025 xueyamao - 0.8.7-22 +- libmpathpersist: set mpp->mpe before selecting reservation_key + * Tue Sep 30 2025 xueyamao - 0.8.7-21 - fix warnings reported by udevadm verify -- Gitee