Re: [PATCH 06/18] libmultipath: use shared_ptr for checker classes
Benjamin Marzinski <[email protected]>
| Newsgroups | dev.linux.lists.dm-devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, May 17, 2026 at 11:57:25AM +0200, Martin Wilck wrote: > On Tue, 2026-05-12 at 20:49 -0400, Benjamin Marzinski wrote: > > On Tue, May 05, 2026 at 05:43:20PM +0200, Martin Wilck wrote: > > > Utilize the share_ptr code for tracking the refcount of checker > > > classes. > > > > > > Signed-off-by: Martin Wilck <[email protected]> > > > --- > > > Â libmultipath/checkers.c | 98 +++++++++---------------------------- > > > ---- > > > Â libmultipath/checkers.h |Â 2 - > > > Â 2 files changed, 20 insertions(+), 80 deletions(-) > > > > > > diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c > > > index 8f18ca6..a3b9cc8 100644 > > > --- a/libmultipath/checkers.c > > > +++ b/libmultipath/checkers.c > > [...] > > > @@ -163,8 +143,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"); > > > > Nitpick. Dropped a space here. > > I didn't do that. clang-format did, as it also reformats context lines > in patches. I think clang-format is correct. We usually don't use space > after cast, do we? (As usual, our code base is inconsistent in this > respect). > > While I don't want to enforce formatting style throughout the entire > code base, I tend to keep the changes that clang-format applies to > context lines (be it only to avoid red lights from the GitHub CI). > > Do you disagree with this policy? It's fine. It just doesn't match the dlsym lines around it, which is fine. -Ben > > Regards > Martin > > > > > > Â 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 +350,6 @@ bad_id: > > > Â return generic_msg[CHECKER_MSGID_NONE]; > > > Â } > > > > Removing the checker thread stuff is more of a cleanup from d1ebd977. > > It > > should probably either be it's own cleanup patch, or it should at > > least > > get mentioned in the commit message. > > Â > > > -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; > > > -} > > > - > > > > Also, start_checker_thread() is stil declared in > > libmultipath/checkers.h, > > along with a comment. > > > > -Ben > > > > > -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)