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 <[email protected]> Reviewed-by: Martin Wilck <[email protected]> --- 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 eef31174..df77ac98 100644 --- a/libmpathpersist/mpath_persist_int.c +++ b/libmpathpersist/mpath_persist_int.c @@ -754,7 +754,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) || @@ -832,10 +832,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.50.1
