libmpathpersist: factor out initialization and teardown
authorMartin Wilck <mwilck@suse.com>
Mon, 27 May 2019 12:59:38 +0000 (14:59 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 3 Jul 2019 06:28:31 +0000 (08:28 +0200)
commita839e39e5f124f8606d749cceab53f3841f0cba3
treeb6e9ca9a11935ea195c085d4adf9488953d6d180
parent188a8b499dd5efed121f441d6dae2440021db338
libmpathpersist: factor out initialization and teardown

mpath_presistent_reserve_{in,out} share a lot of common code
for initial data structure initialization (discovery) and teardown.
Factor this code out into mpath_persistent_reserve_init_vecs()
(global data structure initialization),
mpath_persistent_reserve_free_vecs (global teardown) and mpath_get_map()
(struct multipath setup for given map device).

Provide __mpath_presistent_reserve_{in,out}, which are the same
as their counterparts without leading underscores, but do not
call the global setup and teardown routines. This allows running
several PR commands in a row without having to re-initialize in
between. Because libmpathpersist is a public API, the previously
known functions don't change behavior.

Don't call path_discovery() any more during global initialization.
We rather do this lazily in the get_mpvec() call chain. dm_get_maps(),
OTOH, is part of the global initialization procedure. In get_mpvec(),
we don't delete non-matching maps any more, because we way want to
act on them later on.

Signed-off-by: Martin Wilck <mwilck@suse.com>
libmpathpersist/mpath_persist.c
libmpathpersist/mpath_persist.h