Thread (20 messages) 20 messages, 1 author, 1d ago

[PATCH v2 06/19] libmultipath: remove libcheck_thread related code

From: Martin Wilck <hidden>
Date: 2026-05-22 16:44:49
Subsystem: the rest · Maintainer: Linus Torvalds

After d1ebd97 ("libmultipath: TUR checker: use runner threads"),
this code is not used any more. Remove it.

Signed-off-by: Martin Wilck <redacted>
---
 libmultipath/checkers.c           | 40 +------------------------------
 libmultipath/checkers.h           | 22 +----------------
 libmultipath/libmultipath.version |  1 -
 3 files changed, 2 insertions(+), 61 deletions(-)
diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
index 8f18ca6..5655146 100644
--- a/libmultipath/checkers.c
+++ b/libmultipath/checkers.c
@@ -163,8 +163,7 @@ static struct checker_class *add_checker_class(const char *name)
 		goto out;
 
 	c->mp_init = (int (*)(struct checker *)) dlsym(c->handle, "libcheck_mp_init");
-	c->reset = (void (*)(void)) dlsym(c->handle, "libcheck_reset");
-	c->thread = (void *(*)(void*)) dlsym(c->handle, "libcheck_thread");
+	c->reset = (void (*)(void))dlsym(c->handle, "libcheck_reset");
 	c->pending = (int (*)(struct checker *)) dlsym(c->handle, "libcheck_pending");
 	c->need_wait = (bool (*)(struct checker *)) dlsym(c->handle, "libcheck_need_wait");
 	/* These 5 functions can be NULL. call dlerror() to clear out any
@@ -371,43 +370,6 @@ bad_id:
 	return generic_msg[CHECKER_MSGID_NONE];
 }
 
-static void checker_cleanup_thread(void *arg)
-{
-	struct checker_class *cls = arg;
-
-	free_checker_class(cls);
-	rcu_unregister_thread();
-}
-
-static void *checker_thread_entry(void *arg)
-{
-	struct checker_context *ctx = arg;
-	void *rv;
-
-	rcu_register_thread();
-	pthread_cleanup_push(checker_cleanup_thread, ctx->cls);
-	rv = ctx->cls->thread(ctx);
-	pthread_cleanup_pop(1);
-	return rv;
-}
-
-int start_checker_thread(pthread_t *thread, const pthread_attr_t *attr,
-			 struct checker_context *ctx)
-{
-	int rv;
-
-	assert(ctx && ctx->cls && ctx->cls->thread);
-	/* Take a ref here, lest the class be freed before the thread starts */
-	(void)checker_class_ref(ctx->cls);
-	rv = pthread_create(thread, attr, checker_thread_entry, ctx);
-	if (rv != 0) {
-		condlog(1, "failed to start checker thread for %s: %m",
-			ctx->cls->name);
-		checker_class_unref(ctx->cls);
-	}
-	return rv;
-}
-
 void checker_clear_message (struct checker *c)
 {
 	if (!c)
diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h
index 694dfa3..e69dfd9 100644
--- a/libmultipath/checkers.h
+++ b/libmultipath/checkers.h
@@ -143,7 +143,6 @@ struct checker_class {
 	int (*mp_init)(struct checker *); /* to allocate the mpcontext */
 	void (*free)(struct checker *);	  /* to free the context */
 	void (*reset)(void);		  /* to reset the global variables */
-	void *(*thread)(void *);	  /* async thread entry point */
 	int (*pending)(struct checker *); /* to recheck pending paths */
 	bool (*need_wait)(struct checker *); /* checker needs waiting for */
 	const char **msgtable;
@@ -179,29 +178,10 @@ void checker_set_sync (struct checker *);
 void checker_set_async (struct checker *);
 void checker_set_fd (struct checker *, int);
 void checker_enable (struct checker *);
-void checker_disable (struct checker *);
-/*
- * start_checker_thread(): start async path checker thread
- *
- * This function provides a wrapper around pthread_create().
- * The created thread will call the DSO's "libcheck_thread" function with the
- * checker context as argument.
- *
- * Rationale:
- * Path checkers that do I/O may hang forever. To avoid blocking, some
- * checkers therefore use asynchronous, detached threads for checking
- * the paths. These threads may continue hanging if multipathd is stopped.
- * In this case, we can't unload the checker DSO at exit. In order to
- * avoid race conditions and crashes, the entry point of the thread
- * needs to be in libmultipath, not in the DSO itself.
- *
- * @param arg: pointer to struct checker_context.
- */
+void checker_disable(struct checker *);
 struct checker_context {
 	struct checker_class *cls;
 };
-int start_checker_thread (pthread_t *thread, const pthread_attr_t *attr,
-			  struct checker_context *ctx);
 int checker_get_state(struct checker *c);
 bool checker_need_wait(struct checker *c);
 void checker_check (struct checker *, int);
diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version
index 78fa2d4..5deee32 100644
--- a/libmultipath/libmultipath.version
+++ b/libmultipath/libmultipath.version
@@ -221,7 +221,6 @@ global:
 	/* checkers */
 	checker_is_sync;
 	sg_read;
-	start_checker_thread;
 
 	/* prioritizers */
 	get_asymmetric_access_state;
-- 
2.54.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help