summaryrefslogtreecommitdiff
path: root/libmultipath/structs_vec.c
diff options
context:
space:
mode:
authorChristophe Varoqui <christophe.varoqui@free.fr>2008-04-04 00:58:41 +0200
committerChristophe Varoqui <christophe.varoqui@free.fr>2008-04-04 00:58:41 +0200
commit27c93c5efff1d425b9b71a62efe59465b4150303 (patch)
tree4685f20f1dfddf57c290752394873920a1202870 /libmultipath/structs_vec.c
parent3aaecad682efef27ce6196c6d29db4cb93c9f2fb (diff)
downloadmultipath-tools-27c93c5efff1d425b9b71a62efe59465b4150303.tar.gz
multipath-tools-27c93c5efff1d425b9b71a62efe59465b4150303.tar.bz2
multipath-tools-27c93c5efff1d425b9b71a62efe59465b4150303.zip
Move to a shared lib model for
1) checkers (one lib for all checkers for a start) 2) prioritizers (one helper lib, plus one lib per prioritizer) 3) libmultipath Collaterals include : o Remove old prioritizer callouts. o Drop the klibc support o Add remove_map(s)/remove_map(s)_and_stop_waiter(s) helpers Regression testing is needed now.
Diffstat (limited to 'libmultipath/structs_vec.c')
-rw-r--r--libmultipath/structs_vec.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 807d7ab..8f8406c 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -8,6 +8,7 @@
#include "vector.h"
#include "defaults.h"
#include "debug.h"
+#include "waiter.h"
#include "structs.h"
#include "structs_vec.h"
#include "devmapper.h"
@@ -16,7 +17,6 @@
#include "propsel.h"
#include "sysfs.h"
#include "discovery.h"
-#include "waiter.h"
/*
* creates or updates mpp->paths reading mpp->pg
@@ -112,9 +112,14 @@ set_multipath_wwid (struct multipath * mpp)
dm_get_uuid(mpp->alias, mpp->wwid);
}
-extern void
-remove_map (struct multipath * mpp, struct vectors * vecs,
- stop_waiter_thread_func *stop_waiter, int purge_vec)
+#define KEEP_WAITER 0
+#define STOP_WAITER 1
+#define KEEP_VEC 1
+#define PURGE_VEC 1
+
+static void
+_remove_map (struct multipath * mpp, struct vectors * vecs,
+ int stop_waiter, int purge_vec)
{
int i;
@@ -124,7 +129,7 @@ remove_map (struct multipath * mpp, struct vectors * vecs,
* stop the DM event waiter thread
*/
if (stop_waiter)
- stop_waiter(mpp, vecs);
+ stop_waiter_thread(mpp, vecs);
/*
* clear references to this map
@@ -142,14 +147,26 @@ remove_map (struct multipath * mpp, struct vectors * vecs,
}
extern void
-remove_maps (struct vectors * vecs,
- stop_waiter_thread_func *stop_waiter)
+remove_map (struct multipath * mpp, struct vectors * vecs, int purge_vec)
+{
+ _remove_map(mpp, vecs, KEEP_WAITER, purge_vec);
+}
+
+extern void
+remove_map_and_stop_waiter (struct multipath * mpp, struct vectors * vecs,
+ int purge_vec)
+{
+ _remove_map(mpp, vecs, STOP_WAITER, purge_vec);
+}
+
+static void
+_remove_maps (struct vectors * vecs, int stop_waiter)
{
int i;
struct multipath * mpp;
vector_foreach_slot (vecs->mpvec, mpp, i) {
- remove_map(mpp, vecs, stop_waiter, 1);
+ _remove_map(mpp, vecs, stop_waiter, 1);
i--;
}
@@ -157,6 +174,18 @@ remove_maps (struct vectors * vecs,
vecs->mpvec = NULL;
}
+extern void
+remove_maps (struct vectors * vecs)
+{
+ _remove_maps(vecs, KEEP_WAITER);
+}
+
+extern void
+remove_maps_and_stop_waiters (struct vectors * vecs)
+{
+ _remove_maps(vecs, STOP_WAITER);
+}
+
static struct hwentry *
extract_hwe_from_path(struct multipath * mpp)
{
@@ -294,14 +323,13 @@ retry:
return 0;
out:
- remove_map(mpp, vecs, NULL, 1);
+ remove_map(mpp, vecs, PURGE_VEC);
return 1;
}
extern struct multipath *
add_map_without_path (struct vectors * vecs,
- int minor, char * alias,
- start_waiter_thread_func *start_waiter)
+ int minor, char * alias)
{
struct multipath * mpp = alloc_multipath();
@@ -321,12 +349,12 @@ add_map_without_path (struct vectors * vecs,
vector_set_slot(vecs->mpvec, mpp);
- if (start_waiter(mpp, vecs))
+ if (start_waiter_thread(mpp, vecs))
goto out;
return mpp;
out:
- remove_map(mpp, vecs, NULL, 1);
+ remove_map(mpp, vecs, PURGE_VEC);
return NULL;
}
@@ -359,7 +387,7 @@ add_map_with_path (struct vectors * vecs,
return mpp;
out:
- remove_map(mpp, vecs, NULL, add_vec);
+ remove_map(mpp, vecs, PURGE_VEC);
return NULL;
}