Re: [PATCH 09/18] libmultipath: add generic async path checker code
Benjamin Marzinski <[email protected]>
| Newsgroups | dev.linux.lists.dm-devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, May 05, 2026 at 05:43:23PM +0200, Martin Wilck wrote: > Add a framework for an asynchronous path checker utilizing the > recently added runner code for thread handling. > > This code has been derived from the TUR checker code by removing > all references to the actual sending of TUR ioctls. > > Follow-up patches will convert the current TUR checker into an > instance of this async checker class. > > Signed-off-by: Martin Wilck <[email protected]> > --- > libmultipath/Makefile | 2 +- > libmultipath/async_checker.c | 216 +++++++++++++++++++++++++++++++++++ > libmultipath/async_checker.h | 35 ++++++ > libmultipath/checkers.c | 1 + > libmultipath/checkers.h | 2 + > 5 files changed, 255 insertions(+), 1 deletion(-) > create mode 100644 libmultipath/async_checker.c > create mode 100644 libmultipath/async_checker.h > [...] > diff --git a/libmultipath/async_checker.h b/libmultipath/async_checker.h > new file mode 100644 > index 0000000..835de2a > --- /dev/null > +++ b/libmultipath/async_checker.h > @@ -0,0 +1,35 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +// Copyright (c) 2026 SUSE LLC > +#ifndef ASYNC_CHECKER_H_INCLUDED > +#define ASYNC_CHECKER_H_INCLUDED > + > +struct runner_data; > +struct checker; > +typedef int (*async_checker_func)(struct runner_data *); > + > +struct runner_data { > + int fd; > + dev_t devt; > + async_checker_func afunc; > + unsigned int timeout; > + int state; > + short msgid; > + char checker_ctx[]; checker_ctx should be probably be aligned. -Ben > +}; > + > +int async_check_init(struct checker *c); > +void async_check_free(struct checker *c); > +bool async_check_need_wait(struct checker *c); > +int async_check_pending(struct checker *c); > +int async_check_check(struct checker *c); > + > +#define CHECKER_MAX_CONTEXT_SIZE 1024 > + > +/* For testing handling of async checker timeouts */ > +#ifdef ASYNC_TEST_MAJOR > +static void async_deep_sleep(const struct runner_data *rdata); > +#else > +#define async_deep_sleep(x) do {} while (0) > +#endif > + > +#endif > diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c > index a3b9cc8..3a1663f 100644 > --- a/libmultipath/checkers.c > +++ b/libmultipath/checkers.c > @@ -9,6 +9,7 @@ > > #include "debug.h" > #include "checkers.h" > +#include "async_checker.h" > #include "vector.h" > #include "util.h" > > diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h > index 630e987..744be54 100644 > --- a/libmultipath/checkers.h > +++ b/libmultipath/checkers.h > @@ -132,6 +132,7 @@ enum { > }; > > struct checker; > +struct runner_data; > struct checker_class { > struct list_head node; > void *handle; > @@ -144,6 +145,7 @@ struct checker_class { > void (*reset)(void); /* to reset the global variables */ > int (*pending)(struct checker *); /* to recheck pending paths */ > bool (*need_wait)(struct checker *); /* checker needs waiting for */ > + int (*async_func)(struct runner_data *); /* callback for async_checker */ > const char **msgtable; > short msgtable_size; > }; > -- > 2.54.0