From: Martin Wilck <mwilck@suse.com>
To: Benjamin Marzinski <bmarzins@redhat.com>,
device-mapper development <dm-devel@redhat.com>
Subject: Re: [RFC PATCH 4/5] libmultipath: add helper functions
Date: Sat, 10 Feb 2018 20:12:24 +0100 [thread overview]
Message-ID: <1518289944.2937.32.camel@suse.com> (raw)
In-Reply-To: <1518239251-29392-5-git-send-email-bmarzins@redhat.com>
On Fri, 2018-02-09 at 23:07 -0600, Benjamin Marzinski wrote:
> Add the ability to reset a vector without completely freeing it, and
> to
> check the version of the device-mapper module. The existing version
> checking code checks the version of a specific device mapper target,
> and
> has been renamed for clarity's sake. These functions will be used in
> a
> later patch.
>
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
Reviewed-by: Martin Wilck <mwilck@suse.com>
> libmultipath/devmapper.c | 28 ++++++++++++++++++++++++----
> libmultipath/devmapper.h | 3 ++-
> libmultipath/vector.c | 16 ++++++++++++----
> libmultipath/vector.h | 1 +
> multipathd/main.c | 2 +-
> 5 files changed, 40 insertions(+), 10 deletions(-)
>
> diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
> index 573fc75..2960bf5 100644
> --- a/libmultipath/devmapper.c
> +++ b/libmultipath/devmapper.c
> @@ -132,7 +132,27 @@ dm_lib_prereq (void)
> }
>
> int
> -dm_drv_version (unsigned int * version, char * str)
> +dm_drv_version(unsigned int *v)
> +{
> + char buff[64];
> +
> + v[0] = 0;
> + v[1] = 0;
> + v[2] = 0;
> +
> + if (!dm_driver_version(buff, sizeof(buff))) {
> + condlog(0, "cannot get kernel dm version");
> + return 1;
> + }
> + if (sscanf(buff, "%u.%u.%u ", &v[0], &v[1], &v[2]) != 3) {
> + condlog(0, "invalid kernel dm version '%s'", buff);
> + return 1;
> + }
> + return 0;
> +}
> +
> +int
> +dm_tgt_version (unsigned int * version, char * str)
> {
> int r = 2;
> struct dm_task *dmt;
> @@ -179,13 +199,13 @@ out:
> }
>
> static int
> -dm_drv_prereq (unsigned int *ver)
> +dm_tgt_prereq (unsigned int *ver)
> {
> unsigned int minv[3] = {1, 0, 3};
> unsigned int version[3] = {0, 0, 0};
> unsigned int * v = version;
>
> - if (dm_drv_version(v, TGT_MPATH)) {
> + if (dm_tgt_version(v, TGT_MPATH)) {
> /* in doubt return not capable */
> return 1;
> }
> @@ -210,7 +230,7 @@ static int dm_prereq(unsigned int *v)
> {
> if (dm_lib_prereq())
> return 1;
> - return dm_drv_prereq(v);
> + return dm_tgt_prereq(v);
> }
>
> static int libmp_dm_udev_sync = 0;
> diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
> index 62e14d1..52d4af8 100644
> --- a/libmultipath/devmapper.h
> +++ b/libmultipath/devmapper.h
> @@ -28,7 +28,8 @@ void dm_init(int verbosity);
> void libmp_dm_init(void);
> void libmp_udev_set_sync_support(int on);
> struct dm_task *libmp_dm_task_create(int task);
> -int dm_drv_version (unsigned int * version, char * str);
> +int dm_drv_version (unsigned int * version);
> +int dm_tgt_version (unsigned int * version, char * str);
> int dm_simplecmd_flush (int, const char *, uint16_t);
> int dm_simplecmd_noflush (int, const char *, uint16_t);
> int dm_addmap_create (struct multipath *mpp, char *params);
> diff --git a/libmultipath/vector.c b/libmultipath/vector.c
> index 6266e0a..f741ae0 100644
> --- a/libmultipath/vector.c
> +++ b/libmultipath/vector.c
> @@ -145,18 +145,26 @@ vector_repack(vector v)
> vector_del_slot(v, i--);
> }
>
> -/* Free memory vector allocation */
> -void
> -vector_free(vector v)
> +vector
> +vector_reset(vector v)
> {
> if (!v)
> - return;
> + return NULL;
>
> if (v->slot)
> FREE(v->slot);
>
> v->allocated = 0;
> v->slot = NULL;
> + return v;
> +}
> +
> +/* Free memory vector allocation */
> +void
> +vector_free(vector v)
> +{
> + if (!vector_reset(v))
> + return;
> FREE(v);
> }
>
> diff --git a/libmultipath/vector.h b/libmultipath/vector.h
> index 5cfd4d0..d69cd0b 100644
> --- a/libmultipath/vector.h
> +++ b/libmultipath/vector.h
> @@ -45,6 +45,7 @@ typedef struct _vector *vector;
> /* Prototypes */
> extern vector vector_alloc(void);
> extern void *vector_alloc_slot(vector v);
> +vector vector_reset(vector v);
> extern void vector_free(vector v);
> extern void free_strvec(vector strvec);
> extern void vector_set_slot(vector v, void *value);
> diff --git a/multipathd/main.c b/multipathd/main.c
> index efc39d7..2963bde 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -2228,7 +2228,7 @@ reconfigure (struct vectors * vecs)
> /* Re-read any timezone changes */
> tzset();
>
> - dm_drv_version(conf->version, TGT_MPATH);
> + dm_tgt_version(conf->version, TGT_MPATH);
> if (verbosity)
> conf->verbosity = verbosity;
> if (bindings_read_only)
--
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2018-02-10 19:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-10 5:07 [RFC PATCH 0/5] alternate dmevents waiter method Benjamin Marzinski
2018-02-10 5:07 ` [RFC PATCH 1/5] libmultipath: move remove_map waiter code to multipathd Benjamin Marzinski
2018-02-10 16:15 ` Martin Wilck
2018-02-10 5:07 ` [RFC PATCH 2/5] move waiter code from libmultipath " Benjamin Marzinski
2018-02-10 16:16 ` Martin Wilck
2018-02-10 5:07 ` [RFC PATCH 3/5] call start_waiter_thread() before setup_multipath() Benjamin Marzinski
2018-02-10 17:43 ` Martin Wilck
2018-02-10 5:07 ` [RFC PATCH 4/5] libmultipath: add helper functions Benjamin Marzinski
2018-02-10 19:12 ` Martin Wilck [this message]
2018-02-10 5:07 ` [RFC PATCH 5/5] multipathd: RFC add new polling dmevents waiter thread Benjamin Marzinski
2018-02-10 19:55 ` Martin Wilck
2018-02-12 23:18 ` Benjamin Marzinski
2018-02-13 1:13 ` Alasdair G Kergon
2018-02-13 8:50 ` Martin Wilck
2018-02-13 16:49 ` Benjamin Marzinski
2018-02-13 19:55 ` Martin Wilck
2018-03-08 19:59 ` [RFC PATCH 0/5] alternate dmevents waiter method Xose Vazquez Perez
2018-03-08 20:08 ` Xose Vazquez Perez
2018-03-09 15:59 ` Benjamin Marzinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1518289944.2937.32.camel@suse.com \
--to=mwilck@suse.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.