When you register or switch keys in libmpathpersist, it updates mpp->reservation_key in multipathd before doing the registration. This means that any paths that come online while you are doing the registration get the new key registered. libmpathpersist didn't do this when unregistering a key. This could cause the same problem. A path that got restored while unregistering the device could end up getting the old key registered on it. Fix this by unsetting the key before doing the unregister, instead of afterwards.
There is still a race condition associated with updating mpp->reservation_key before doing the registration (but not on unregistration). This will be dealt with by a future patch. Signed-off-by: Benjamin Marzinski <bmarz...@redhat.com> --- libmpathpersist/mpath_persist_int.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libmpathpersist/mpath_persist_int.c b/libmpathpersist/mpath_persist_int.c index ad98001d..dfdadab6 100644 --- a/libmpathpersist/mpath_persist_int.c +++ b/libmpathpersist/mpath_persist_int.c @@ -747,7 +747,7 @@ int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd, set_ignored_key(mpp, paramp->key); unregistering = (memcmp(&zerokey, paramp->sa_key, 8) == 0); - if (mpp->prkey_source == PRKEY_SOURCE_FILE && !unregistering && + if (mpp->prkey_source == PRKEY_SOURCE_FILE && (rq_servact == MPATH_PROUT_REG_IGN_SA || (rq_servact == MPATH_PROUT_REG_SA && (!get_be64(mpp->reservation_key) || @@ -824,10 +824,9 @@ int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd, switch (rq_servact) { case MPATH_PROUT_REG_SA: case MPATH_PROUT_REG_IGN_SA: - if (unregistering) { + if (unregistering) update_prflag(mpp->alias, 0); - update_prkey(mpp->alias, 0); - } else + else update_prflag(mpp->alias, 1); break; case MPATH_PROUT_CLEAR_SA: -- 2.48.1