Re: [dm-devel] [PATCH v2 12/23] libmultipath: "generic multipath" interface

2018-03-07 Thread Benjamin Marzinski
On Tue, Mar 06, 2018 at 12:14:56AM +0100, Martin Wilck wrote:
> This patch adds a simplified abstract interface to the multipath data 
> structures.
> The idea is to allow "foreign" data structures to be treated by libmultipath
> if they implement the same interface. Currently, the intention is to use this
> only to provide formatted output about from this interface.
> 
> This interface assumes only that the data structure is organized in maps
> containing path groups containing paths, and that formatted printing (using
> the wildcards defined in libmultipath) is possible on each level of the data
> structure.
> 
> The patch also implements the interface for the internal dm_multipath data
> structure.
> 
> The style() method looks a bit exotic, but it's necessary because
> print_multipath_topology() uses different formats depending on the mpp
> properties. This needs to be in the generic interface, too, if we want to
> produce identical output.
> 

Reviewed-by: Benjamin Marzinski 

> Signed-off-by: Martin Wilck 
> ---
>  libmultipath/Makefile |   2 +-
>  libmultipath/dm-generic.c |  70 
>  libmultipath/dm-generic.h |  41 ++
>  libmultipath/generic.c|  39 +
>  libmultipath/generic.h| 136 
> ++
>  libmultipath/list.h   |   4 ++
>  libmultipath/print.c  |  33 +++
>  libmultipath/print.h  |  12 
>  libmultipath/structs.c|   4 ++
>  libmultipath/structs.h|   4 ++
>  10 files changed, 344 insertions(+), 1 deletion(-)
>  create mode 100644 libmultipath/dm-generic.c
>  create mode 100644 libmultipath/dm-generic.h
>  create mode 100644 libmultipath/generic.c
>  create mode 100644 libmultipath/generic.h
> 
> diff --git a/libmultipath/Makefile b/libmultipath/Makefile
> index 25b052729d48..0099d9d6cc39 100644
> --- a/libmultipath/Makefile
> +++ b/libmultipath/Makefile
> @@ -43,7 +43,7 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \
>   switchgroup.o uxsock.o print.o alias.o log_pthread.o \
>   log.o configure.o structs_vec.o sysfs.o prio.o checkers.o \
>   lock.o waiter.o file.o wwids.o prioritizers/alua_rtpg.o prkey.o \
> - io_err_stat.o
> + io_err_stat.o dm-generic.o generic.o
>  
>  all: $(LIBS)
>  
> diff --git a/libmultipath/dm-generic.c b/libmultipath/dm-generic.c
> new file mode 100644
> index ..42a26085d087
> --- /dev/null
> +++ b/libmultipath/dm-generic.c
> @@ -0,0 +1,70 @@
> +/*
> +  Copyright (c) 2018 Martin Wilck, SUSE Linux GmbH
> +
> +  This program is free software; you can redistribute it and/or
> +  modify it under the terms of the GNU General Public License
> +  as published by the Free Software Foundation; either version 2
> +  of the License, or (at your option) any later version.
> +
> +  This program is distributed in the hope that it will be useful,
> +  but WITHOUT ANY WARRANTY; without even the implied warranty of
> +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +  GNU General Public License for more details.
> +
> +  You should have received a copy of the GNU General Public License
> +  along with this program; if not, write to the Free Software
> +  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
> +  USA.
> + */
> +
> +#include 
> +#include 
> +#include "generic.h"
> +#include "dm-generic.h"
> +#include "structs.h"
> +#include "structs_vec.h"
> +#include "config.h"
> +#include "print.h"
> +
> +static const struct _vector*
> +dm_mp_get_pgs(const struct gen_multipath *gmp)
> +{
> + return vector_convert(NULL, gen_multipath_to_dm(gmp)->pg,
> +   struct pathgroup, dm_pathgroup_to_gen);
> +}
> +
> +static void dm_mp_rel_pgs(const struct gen_multipath *gmp,
> +   const struct _vector* v)
> +{
> + vector_free_const(v);
> +}
> +
> +static const struct _vector*
> +dm_pg_get_paths(const struct gen_pathgroup *gpg)
> +{
> + return vector_convert(NULL, gen_pathgroup_to_dm(gpg)->paths,
> +   struct path, dm_path_to_gen);
> +}
> +
> +static void dm_mp_rel_paths(const struct gen_pathgroup *gpg,
> + const struct _vector* v)
> +{
> + vector_free_const(v);
> +}
> +
> +const struct gen_multipath_ops dm_gen_multipath_ops = {
> + .get_pathgroups = dm_mp_get_pgs,
> + .rel_pathgroups = dm_mp_rel_pgs,
> + .snprint = snprint_multipath_attr,
> + /* .style = snprint_multipath_style, TBD */
> +};
> +
> +const struct gen_pathgroup_ops dm_gen_pathgroup_ops = {
> + .get_paths = dm_pg_get_paths,
> + .rel_paths = dm_mp_rel_paths,
> + .snprint = snprint_pathgroup_attr,
> +};
> +
> +const struct gen_path_ops dm_gen_path_ops = {
> + .snprint = snprint_path_attr,
> +};
> diff --git a/libmultipath/dm-generic.h b/libmultipath/dm-generic.h
> new file mode 100644
> index ..5d5972406819
> --- /dev/null
> +++ b/libmultipath/dm-generic.h
> @@ -0,0 +1,41 @@
> +/*

Re: [dm-devel] [PATCH v2 12/23] libmultipath: "generic multipath" interface

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> This patch adds a simplified abstract interface to the multipath data 
> structures.
> The idea is to allow "foreign" data structures to be treated by libmultipath
> if they implement the same interface. Currently, the intention is to use this
> only to provide formatted output about from this interface.
> 
> This interface assumes only that the data structure is organized in maps
> containing path groups containing paths, and that formatted printing (using
> the wildcards defined in libmultipath) is possible on each level of the data
> structure.
> 
> The patch also implements the interface for the internal dm_multipath data
> structure.
> 
> The style() method looks a bit exotic, but it's necessary because
> print_multipath_topology() uses different formats depending on the mpp
> properties. This needs to be in the generic interface, too, if we want to
> produce identical output.
> 
> Signed-off-by: Martin Wilck 
> ---
>  libmultipath/Makefile |   2 +-
>  libmultipath/dm-generic.c |  70 
>  libmultipath/dm-generic.h |  41 ++
>  libmultipath/generic.c|  39 +
>  libmultipath/generic.h| 136 
> ++
>  libmultipath/list.h   |   4 ++
>  libmultipath/print.c  |  33 +++
>  libmultipath/print.h  |  12 
>  libmultipath/structs.c|   4 ++
>  libmultipath/structs.h|   4 ++
>  10 files changed, 344 insertions(+), 1 deletion(-)
>  create mode 100644 libmultipath/dm-generic.c
>  create mode 100644 libmultipath/dm-generic.h
>  create mode 100644 libmultipath/generic.c
>  create mode 100644 libmultipath/generic.h
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel