Re: [dm-devel] [PATCH v2 23/23] multipathd: fix signal blocking logic

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> multipathd is supposed to block all signals in all threads, except
> the uxlsnr thread which handles termination and reconfiguration
> signals (SIGUSR1) in its ppoll() call, SIGUSR2 in the waiter thread
> and the marginal path checker thread, and occasional SIGALRM. The current
> logic does exactly the oppsite, it blocks termination signals in SIGPOLL and
> allows multipathd to be killed e.g. by SIGALRM.
> 
> Fix that by inverting the logic. The argument to pthread_sigmask and
> ppoll is the set of *blocked* signals, not vice versa.
> 
> The marginal paths code needs to unblock SIGUSR2 now explicity, as
> the dm-event waiter code already does. Doing this with pselect()
> avoids asynchronous cancellation.
> 
> Fixes: 810082e "libmultipath, multipathd: Rework SIGPIPE handling"
> Fixes: 534ec4c "multipathd: Ensure that SIGINT, SIGTERM, SIGHUP and SIGUSR1
> are delivered to the uxsock thread"
> 
> Signed-off-by: Martin Wilck 
> ---
>  libmultipath/io_err_stat.c | 17 -
>  multipathd/main.c  |  7 +--
>  multipathd/uxlsnr.c| 10 +-
>  3 files changed, 26 insertions(+), 8 deletions(-)
> 
Sigh.
Will we ever get signal handling correct?

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

Re: [dm-devel] [PATCH v2 22/23] multipathd: update path group prio in check_path

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> The previous patch "libmultipath: don't update path groups when printing"
> removed the call to path_group_prio_update() in the printing code path.
> To compensate for that, recalculate path group prio also when it's not
> strictly necessary (i.e. if failback "manual" is set).
> 
> Signed-off-by: Martin Wilck 
> ---
>  multipathd/main.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 20/23] multipathd: use foreign API

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> Call into the foreign library code when paths are discovered, uevents
> are received, and in the checker loop. Furthermore, use the foreign
> code to print information in the "multipathd show paths", "multipathd
> show maps", and "multipathd show topology" client commands.
> 
> We don't support foreign data in the individual "show map" and "show path"
> commands, and neither in the "json" commands. The former is a deliberate
> decision, the latter could be added if desired.
> 
> Signed-off-by: Martin Wilck 
> ---
>  multipathd/cli_handlers.c | 39 ++-
>  multipathd/main.c | 34 +++---
>  2 files changed, 65 insertions(+), 8 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 21/23] libmultipath: foreign/nvme: implement path display

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> implement display of path information for NVMe foreign paths and maps.
> With this patch, I get output like this for Linux NVMe soft targets:
> 
> nvme-submultipathd show topology
> sys0:NQN:subsysname (uuid.96926ba3-b207-437c-902c-4a4df6538c3f) [nvme] 
> nvme0n1 NVMe,Linux,4.15.0-r
> size=2097152 features='n/a' hwhandler='n/a' wp=rw
> `-+- policy='n/a' prio=n/a status=n/a
>   |- 0:1:1 nvme0c1n1 0:0 n/a n/a live
>   |- 0:2:1 nvme0c2n1 0:0 n/a n/a live
>   |- 0:3:1 nvme0c3n1 0:0 n/a n/a live
>   `- 0:4:1 nvme0c4n1 0:0 n/a n/a live
> 
> multipathd show paths format '%G %d %i %o %z %m %N'
> foreign dev   hcil  dev_st serial   multipath host WWNN
> [nvme]  nvme0c1n1 0:1:1 live   1c2c86659503a02f nvme0n1   
> rdma:traddr=192.168.201.101,trsvcid=4420
> [nvme]  nvme0c2n1 0:2:1 live   1c2c86659503a02f nvme0n1   
> rdma:traddr=192.168.202.101,trsvcid=4420
> [nvme]  nvme0c3n1 0:3:1 live   1c2c86659503a02f nvme0n1   
> rdma:traddr=192.168.203.101,trsvcid=4420
> [nvme]  nvme0c4n1 0:4:1 live   1c2c86659503a02f nvme0n1   
> rdma:traddr=192.168.204.101,trsvcid=4420
> 
> (admittedly, I abused the 'WWNN' wildcard here a bit to display information
> which is helpful for NVMe over RDMA).
> 
> Signed-off-by: Martin Wilck 
> ---
>  libmultipath/foreign/nvme.c | 334 
> ++--
>  1 file changed, 320 insertions(+), 14 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 19/23] multipath: use foreign API

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> Use the "foreign" code to print information about multipath maps
> owned by foreign libraries in print mode (multipath -ll, -l).
> 
> Signed-off-by: Martin Wilck 
> ---
>  multipath/main.c | 13 +
>  1 file changed, 13 insertions(+)
> 
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

Re: [dm-devel] [PATCH v2 18/23] libmultipath: pathinfo: call into foreign library

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> This actually enables the use of foreign paths.
> 
> Signed-off-by: Martin Wilck 
> ---
>  libmultipath/discovery.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
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

Re: [dm-devel] [PATCH v2 16/23] libmultipath/print: add "%G - foreign" wildcard

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> This adds a format field to identify foreign maps as such, and
> uses it in default-formatted topology output (generic_style()).
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/generic.c |  2 +-
>  libmultipath/print.c   | 14 ++
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
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

Re: [dm-devel] [PATCH v2 17/23] libmultipath/foreign: nvme foreign library

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:15 AM, Martin Wilck wrote:
> This still contains stubs for path handling and checking, but it's functional
> for printing already.
> 
> Signed-off-by: Martin Wilck 
> ---
>  Makefile  |   1 +
>  libmultipath/foreign/Makefile |  30 +++
>  libmultipath/foreign/nvme.c   | 455 
> ++
>  3 files changed, 486 insertions(+)
>  create mode 100644 libmultipath/foreign/Makefile
>  create mode 100644 libmultipath/foreign/nvme.c
> 
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

Re: [dm-devel] [PATCH v2 15/23] libmultipath: API for foreign multipath handling

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Add an API for "foreign" multipaths. Foreign libraries are loaded
> from ${multipath_dir}/libforeign-*.so, as we do for checkers.
> 
> Refer to "foreign.h" for details about the API itself. Like we do for
> checkers, high-level multipath code isn't supposed to call the API directly,
> but rather the wrapper functions declared in "foreign.h".
> 
> This API is used only for displaying information and for logging. An 
> extension to
> other functionality (such as monitoring or administration) might be feasible,
> but is not planned.
> 
> Foreign libraries communicate with libmultipath through the API defined in
> "foreign.h". The foreign library can implement multipath maps, pathgroups,
> and paths as it likes, they just need to provide the simple interfaces
> defined in "generic.h" to libmultipath. These interfaces are used in 
> libmultipath's
> "print" implementation to convey various bits of information to users. By
> using the same interfaces for printing that libmultipath uses internally,
> foreign library implementations can focus on the technical side without
> worrying about output formatting compatibility.
> 
> Signed-off-by: Martin Wilck 
> ---
>  libmultipath/Makefile  |   2 +-
>  libmultipath/foreign.c | 602 
> +
>  libmultipath/foreign.h | 322 ++
>  3 files changed, 925 insertions(+), 1 deletion(-)
>  create mode 100644 libmultipath/foreign.c
>  create mode 100644 libmultipath/foreign.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

Re: [dm-devel] [PATCH v2 14/23] libmultipath: print: use generic API for get_x_layout()

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Introduce new functions _get_path_layout and _get_multipath_layout
> using the new "generic" API to determine field widths, and map the
> old API to them.
> 
> Furthermore, replace the boolean "header" by an enum with 3 possible
> values. The new value LAYOUT_RESET_NOT allows calling the get_x_layout
> function several times and determine the overall field width.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/print.c | 73 
> 
>  libmultipath/print.h |  8 ++
>  2 files changed, 65 insertions(+), 16 deletions(-)
> 
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

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

Re: [dm-devel] [PATCH v2 13/23] libmultipath: print: convert API to generic data type

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Convert higher level API (snprint_multipath_topology() etc) to
> using the generic multipath API. This will allow "foreign"
> multipath objects that implement the generic API to be printed
> exactly like native multipathd objects.
> 
> The previous API (using "struct multipath*" and "struct path" remains
> in place through macros mapping to the new functions. By doing this
> and testing in regular setups, it's easily verified that the new
> API works and produces the same results.
> 
> Moreover, abstract out the code to determine the output format from multipath
> properties into snprint_multipath_style(), to be able to use it as generic
> ->style() method.
> 
> Signed-off-by: Martin Wilck 
> ---
>  libmultipath/configure.c  |   1 +
>  libmultipath/dm-generic.c |   2 +-
>  libmultipath/print.c  | 115 
> +-
>  libmultipath/print.h  |  24 +++---
>  multipath/main.c  |   1 +
>  multipathd/cli_handlers.c |   1 +
>  6 files changed, 95 insertions(+), 49 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 11/23] libmultipath: add vector_convert()

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> This is a handy helper for creating one vector from another,
> mapping each element of the origin vector to an element of
> the target vector with a given conversion function. It can
> also be used to "concatenate" vectors by passing in a non-NULL first
> argument.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/vector.h | 29 +
>  1 file changed, 29 insertions(+)
>
At one point we should consider moving vectors to lists ...
Anyway:

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

Re: [dm-devel] [PATCH v2 09/23] multipath-tools: Makefile.inc: use -Werror=cast-qual

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Casting "const" away is often an indicator for wrong code.
> Add a compiler flag to warn about such possible breakage.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  Makefile.inc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Makefile.inc b/Makefile.inc
> index eb99c36010c1..a5b9d4e3fa74 100644
> --- a/Makefile.inc
> +++ b/Makefile.inc
> @@ -87,6 +87,7 @@ STACKPROT := $(call 
> TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
>  OPTFLAGS = -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
> -Werror=implicit-function-declaration -Werror=format-security 
> \
> -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered \
> +   -Werror=cast-qual -Werror=discarded-qualifiers \
> -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
> --param=ssp-buffer-size=4
>  
> 
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

Re: [dm-devel] [PATCH v2 07/23] libmultipath: use "const" in devmapper code

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Improve use of "const" qualifiers in libmultipath's devmapper code.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/devmapper.c | 32 
>  libmultipath/devmapper.h | 16 
>  2 files changed, 24 insertions(+), 24 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 08/23] libmultipath: fix compiler warnings for -Wcast-qual

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Fix the warnings that were caused by adding the -Wcast-qual compiler
> flag in the previous patch.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  kpartx/devmapper.c  |  3 ++-
>  libmpathcmd/mpath_cmd.c |  2 +-
>  libmultipath/checkers/rbd.c |  4 ++--
>  libmultipath/devmapper.c|  3 ++-
>  libmultipath/discovery.c| 12 ++--
>  libmultipath/list.h |  4 ++--
>  libmultipath/memory.h   |  8 +++-
>  libmultipath/structs.c  |  2 +-
>  libmultipath/structs.h  |  2 +-
>  libmultipath/uevent.c   |  6 +++---
>  libmultipath/util.c |  6 +++---
>  multipathd/main.c   | 10 +-
>  12 files changed, 35 insertions(+), 27 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 10/23] libmultipath: add vector_free_const()

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> ... to dispose of constant vectors (const struct _vector*).
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/vector.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libmultipath/vector.h b/libmultipath/vector.h
> index 5cfd4d060412..3f6e579ae19a 100644
> --- a/libmultipath/vector.h
> +++ b/libmultipath/vector.h
> @@ -46,6 +46,7 @@ typedef struct _vector *vector;
>  extern vector vector_alloc(void);
>  extern void *vector_alloc_slot(vector v);
>  extern void vector_free(vector v);
> +#define vector_free_const(x) vector_free((vector)(long)(x))
>  extern void free_strvec(vector strvec);
>  extern void vector_set_slot(vector v, void *value);
>  extern void vector_del_slot(vector v, int slot);
> 
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

Re: [dm-devel] [PATCH v2 06/23] libmultipath/print: use "const" where appropriate

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Convert the print.h/print.c code to use "const" qualifiers
> properly. This is generally considered good programming practice,
> and the printing code shouldn't change any objects anyway.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/configure.h |   1 -
>  libmultipath/discovery.c |   6 +--
>  libmultipath/discovery.h |   6 ++-
>  libmultipath/print.c | 133 
> ---
>  libmultipath/print.h |  41 ---
>  5 files changed, 95 insertions(+), 92 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 05/23] libmultipath: don't update path groups when printing

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Updating the prio values for printing makes no sense. The user wants to see
> the prio values multipath is actually using for path group selection, and
> updating the values here means actually lying to the user if the prio values
> have changed, but multipathd hasn't updated them internally.
> 
> If we really don't update the pathgroup prios when we need to, this should be
> fixed elsewhere. The current wrong output would just hide that if it occured.
> 
> Moreover, correctness forbids changing properties so deeply in a code path
> that's supposed to print them only. Finally, this piece of code prevents the
> print.c code to be converted to proper "const" usage.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/print.c | 7 ---
>  1 file changed, 7 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 04/23] libmultipath: parser: use call-by-value for "snprint" methods

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Convert the snprint methods for all keywords to call-by-value,
> and use "const" qualifier for the "data" argument. This makes sure
> that "snprint" type functions don't modify the data they're print,
> helps compile-time correctness checking, and allows more proper
> "const" cleanups in the future.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/dict.c   | 206 
> --
>  libmultipath/parser.c |   9 ++-
>  libmultipath/parser.h |  12 ++-
>  3 files changed, 112 insertions(+), 115 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 02/23] libmultipath: remove unused "stdout helpers"

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/print.c | 26 --
>  libmultipath/print.h |  5 -
>  2 files changed, 31 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 01/23] multipath(d)/Makefile: add explicit dependency on libraries

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> Otherwise the binaries won't be re-linked if the libraries change.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  multipath/Makefile  | 2 +-
>  multipathd/Makefile | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
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

Re: [dm-devel] [PATCH v2 03/23] libmultipath: get rid of selector "hack" in print.c

2018-03-05 Thread Hannes Reinecke
On 03/06/2018 12:14 AM, Martin Wilck wrote:
> By properly linking the path groups with their parent multipath,
> we don't need this "hack" any more.
> 
> Signed-off-by: Martin Wilck 
> Reviewed-by: Benjamin Marzinski 
> ---
>  libmultipath/dmparser.c   |  2 +-
>  libmultipath/pgpolicies.c | 11 ++-
>  libmultipath/print.c  |  6 +++---
>  libmultipath/structs.c| 10 ++
>  libmultipath/structs.h|  3 ++-
>  5 files changed, 22 insertions(+), 10 deletions(-)
> 
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

Re: [dm-devel] confusion about multipath_prepare_ioctl

2018-03-05 Thread Mike Snitzer
On Mon, Mar 05 2018 at 10:35pm -0500,
Wang Sheng-Hui  wrote:

> Dear,
> 
> Sorry to trouble you.
> 
> I noticed some code in dm-*.c like:
> "
> static int multipath_prepare_ioctl(struct dm_target *ti,
>   struct block_device **bdev, fmode_t *mode)
> {
> ...
>   /*
>* Only pass ioctls through if the device sizes match exactly.
>*/
>   if (!r && ti->len != i_size_read((*bdev)->bd_inode) >> SECTOR_SHIFT)
>   return 1;
> ...
> }
> "
> Here, return value 1 means 
> "ioctl is being issued against a subset of the parent bdev; require extra 
> privileges."
> (comment in dm_blk_ioctl)
> 
> I'm confused by the comment and '!=' test for multipath. 
> In which cases, the size of low level single device is not equal to the 
> parent 
> size of multipath device?

Given that ti->len is sent down from userspace, the DM multipath
target's ti->len _could_ be smaller than the underlying path(s).  But in
practice that doesn't occur with multipathd.. a partitioned multipath
device is generally done, via kpartx, in terms of linear mappings ontop
of the multipath device.

The same != test is done in the dm linear target and is much more
relevant to concerns about ioctls being sent to partition.

Mike

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


[dm-devel] [PATCH RESEND] multipathd: check and cleanup zombie paths

2018-03-05 Thread Chongyun Wu
The same LUN have been exported to the host from different lun
number twice, each time create multipath for this lun, after
second time the multipath might have zombie paths which devices
doesn't actually exist.

Check zombie paths:
If a failed path have the same wwid with an active path, but its
sg_id.lun are not equal to this active path. This failed path
might be a zombie path(a lun can't be exported from a different
lun number to a host at the same time).

cleanup zombie paths:
delete the zombie paths' device from sysfs, which will clean up
the zombie paths both in kernel and userspace.

Signed-off-by: Chongyun Wu 
---
   multipathd/main.c |   42 ++
   1 file changed, 42 insertions(+)

diff --git a/multipathd/main.c b/multipathd/main.c
index 27cf234..e74a448 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1511,6 +1511,44 @@ void repair_path(struct path * pp)
LOG_MSG(1, checker_message(&pp->checker));
   }

+void try_cleanup_zombie_path(struct vectors *vecs, struct path *pp)
+{
+   struct path *pp_tmp;
+   unsigned int i;
+   struct config *conf;
+   int path_state;
+   const char delete[] = "1";
+
+   /*check if this given path is a zombie path*/
+   vector_foreach_slot(vecs->pathvec, pp_tmp, i) {
+   if ((strcmp(pp_tmp->wwid, pp->wwid) == 0) &&
+   (pp_tmp->state == PATH_UP)) {
+   /*to get the state again to avoid getting
+*the old state
+*/
+   conf = get_multipath_config();
+   path_state = get_state(pp_tmp, conf, 1);
+   put_multipath_config(conf);
+
+   if ((path_state == PATH_UP) &&
+   (pp_tmp->sg_id.lun != pp->sg_id.lun)) {
+   /*
+* The given path is a failed path,
+* found a active path with the same wwid and
+* it's sg_id.lun isn't equal to the given path,
+* that means that the given is a zombie path!
+* Clean up zombie path then.
+*/
+   condlog(2, "clean up zombie path %s(%s)",
+   pp->dev, pp->wwid);
+   sysfs_attr_set_value(pp->udev, "device/delete",
+   delete, strlen(delete));
+   break;
+   }
+   }
+   }
+}
+
   /*
* Returns '1' if the path has been checked, '-1' if it was blacklisted
* and '0' otherwise
@@ -1580,6 +1618,10 @@ check_path (struct vectors * vecs, struct path *
pp, int ticks)
newstate = PATH_DOWN;
}

+   if (newstate == PATH_DOWN) {
+   try_cleanup_zombie_path(vecs, pp);
+   }
+
if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) {
condlog(2, "%s: unusable path", pp->dev);
conf = get_multipath_config();
-- 
1.7.9.5

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


[dm-devel] [PATCH] multipathd: use nanosleep for sleeping

2018-03-05 Thread Benjamin Marzinski
In order to safely use SIGALRM in a multi-threaded program, only one
thread can schedule and wait on SIGALRM at a time. All other threads
must have SIGALRM blocked, and be unable to schedule an alarm. The
strict_timing code in checkerloop was unblocking SIGALRM, and calling
setitimer(), without any locking.  Instead, it should use nanosleep()
to sleep for the correct length of time, since that doesn't depend or
interfere with signals. io_err_stat_loop() was calling usleep() without
any locking. According to the POSIX standards, the result of a SIGARLM
occuring during a usleep call is undefined, even if the calling thread
blocks the signal. While this is unlikely to cause a problem on a
modern linux system, nanosleep is guaranteed to not interact with
SIGALRM, as long as the signal is blocked by the calling thread.

Signed-off-by: Benjamin Marzinski 
---
 libmultipath/io_err_stat.c |  3 ++-
 multipathd/main.c  | 27 +--
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c
index 5b10f03..555af5d 100644
--- a/libmultipath/io_err_stat.c
+++ b/libmultipath/io_err_stat.c
@@ -697,8 +697,9 @@ static void *io_err_stat_loop(void *data)
 
mlockall(MCL_CURRENT | MCL_FUTURE);
while (1) {
+   struct timespec delay = {0, 1}; /* .1 sec */
service_paths();
-   usleep(10);
+   nanosleep(&delay, NULL);
}
 
pthread_cleanup_pop(1);
diff --git a/multipathd/main.c b/multipathd/main.c
index 889670c..55b92be 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1834,7 +1834,6 @@ checkerloop (void *ap)
struct path *pp;
int count = 0;
unsigned int i;
-   struct itimerval timer_tick_it;
struct timespec last_time;
struct config *conf;
 
@@ -1852,8 +1851,7 @@ checkerloop (void *ap)
 
while (1) {
struct timespec diff_time, start_time, end_time;
-   int num_paths = 0, ticks = 0, signo, strict_timing, rc = 0;
-   sigset_t mask;
+   int num_paths = 0, ticks = 0, strict_timing, rc = 0;
 
if (clock_gettime(CLOCK_MONOTONIC, &start_time) != 0)
start_time.tv_sec = 0;
@@ -1941,25 +1939,18 @@ checkerloop (void *ap)
if (!strict_timing)
sleep(1);
else {
-   timer_tick_it.it_interval.tv_sec = 0;
-   timer_tick_it.it_interval.tv_usec = 0;
if (diff_time.tv_nsec) {
-   timer_tick_it.it_value.tv_sec = 0;
-   timer_tick_it.it_value.tv_usec =
+   diff_time.tv_sec = 0;
+   diff_time.tv_nsec =
 1000UL * 1000 * 1000 - diff_time.tv_nsec;
-   } else {
-   timer_tick_it.it_value.tv_sec = 1;
-   timer_tick_it.it_value.tv_usec = 0;
-   }
-   setitimer(ITIMER_REAL, &timer_tick_it, NULL);
+   } else
+   diff_time.tv_sec = 1;
 
-   sigemptyset(&mask);
-   sigaddset(&mask, SIGALRM);
condlog(3, "waiting for %lu.%06lu secs",
-   timer_tick_it.it_value.tv_sec,
-   timer_tick_it.it_value.tv_usec);
-   if (sigwait(&mask, &signo) != 0) {
-   condlog(3, "sigwait failed with error %d",
+   diff_time.tv_sec,
+   diff_time.tv_nsec / 1000);
+   if (nanosleep(&diff_time, NULL) != 0) {
+   condlog(3, "nanosleep failed with error %d",
errno);
conf = get_multipath_config();
conf->strict_timing = 0;
-- 
2.7.4

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


Re: [dm-devel] [PATCH v2 10/23] libmultipath: add vector_free_const()

2018-03-05 Thread Bart Van Assche
On Tue, 2018-03-06 at 00:14 +0100, Martin Wilck wrote:
> ... to dispose of constant vectors (const struct _vector*).

This patch is not useful by itself so if you repost this series please
combine it with the next patch.

Thanks,

Bart.



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


Re: [dm-devel] [PATCH] multipathd: fix inverted signal blocking logic

2018-03-05 Thread Benjamin Marzinski
On Mon, Mar 05, 2018 at 06:28:05PM +0100, Martin Wilck wrote:
> Hello Bart,
> 
> On Mon, 2018-03-05 at 16:27 +, Bart Van Assche wrote:
> > On Sat, 2018-03-03 at 01:31 +0100, Martin Wilck wrote:
> > > So, there's no reason not to block them, right? Is it expected
> > > behavior
> > > that a user running 'kill -USR2 $(pidof multipathd)' terminates the
> > > process? Why do you think these signals should interrupt ppoll()
> > > although the uxlsnr can't can't handle them? Isn't it sufficient
> > > that
> > > they're handled by the threads that are meant to do that?
> > 
> > Blocking all signals except the ones for which we installed a handler
> > sounds
> > weird to me. I think users expect daemons to process signals instead
> > of
> > blocking all but a specific set of signals. This is a rather
> > philosophical
> > argument and not an argument of which I think that it is strong
> > enough to
> > prevent this patch of being integrated in the upstream multipath-
> > tools
> > repository.
> 
> Thank you. Meanwhile, I found that this patch requires a change in the
> "marginal paths" code. I'll post an official patch as update.
> 
> Regarding the philosophical discussion, may I remind you of your own
> words from 534ec4c?
> 
> The POSIX standard mentions that the only way to guarantee that
> signals are delivered to a specific thread is:
>  * Block all signals before the first pthread_create() call.
>  * Unblock signals from the thread that should receive signals.
> 
> If we unblock signals with a default disposition of "Term" for which we
> have no handler, stray signals caught would terminate multipathd. I
> don't think that's what we want. Of course we must react on
> SIGINT/SIGTERM/SIGHUP in the way the user expects us to, but
> terminating on other signals would be wrong.
> 
> Let's see if others have to say anything about this.

This is prety close to what I had in mind. The only things missing, that
I noticed when I was looking at multipathd's signal handling, is dealing
with SIGUSR2 in io_err_stat.c, which it sounds like you have already
spotted, and changing the calls to setitimer and usleep outside of the
vecs lock to use nanosleep, so they don't interact with SIGALRM.

I'll send a patch based on yours, to fix these.

-Ben

> 
> Martin
> 
> -- 
> Dr. Martin Wilck , 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


[dm-devel] [PATCH v2 18/23] libmultipath: pathinfo: call into foreign library

2018-03-05 Thread Martin Wilck
This actually enables the use of foreign paths.

Signed-off-by: Martin Wilck 
---
 libmultipath/discovery.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 645224c1029c..45a4d8378893 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -31,6 +31,7 @@
 #include "prio.h"
 #include "defaults.h"
 #include "prioritizers/alua_rtpg.h"
+#include "foreign.h"
 
 int
 alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
@@ -1909,7 +1910,8 @@ int pathinfo(struct path *pp, struct config *conf, int 
mask)
 * limited by DI_BLACKLIST and occurs before this debug
 * message with the mask value.
 */
-   if (pp->udev && filter_property(conf, pp->udev) > 0)
+   if (pp->udev && (is_claimed_by_foreign(pp->udev) ||
+filter_property(conf, pp->udev) > 0))
return PATHINFO_SKIPPED;
 
if (filter_devnode(conf->blist_devnode,
-- 
2.16.1

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


[dm-devel] [PATCH v2 07/23] libmultipath: use "const" in devmapper code

2018-03-05 Thread Martin Wilck
Improve use of "const" qualifiers in libmultipath's devmapper code.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/devmapper.c | 32 
 libmultipath/devmapper.h | 16 
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index f112e1cb0e66..f61838cbe369 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -583,7 +583,7 @@ is_mpath_part(const char *part_name, const char *map_name)
return 0;
 }
 
-int dm_get_status(char *name, char *outstatus)
+int dm_get_status(const char *name, char *outstatus)
 {
int r = 1;
struct dm_task *dmt;
@@ -807,7 +807,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int 
deferred_remove,
if (need_suspend &&
!dm_get_map(mapname, &mapsize, params) &&
strstr(params, "queue_if_no_path")) {
-   if (!dm_queue_if_no_path((char *)mapname, 0))
+   if (!dm_queue_if_no_path(mapname, 0))
queue_if_no_path = 1;
else
/* Leave queue_if_no_path alone if unset failed */
@@ -850,7 +850,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int 
deferred_remove,
} while (retries-- > 0);
 
if (queue_if_no_path == 1)
-   dm_queue_if_no_path((char *)mapname, 1);
+   dm_queue_if_no_path(mapname, 1);
 
return 1;
 }
@@ -938,7 +938,7 @@ out:
 }
 
 int
-dm_fail_path(char * mapname, char * path)
+dm_fail_path(const char * mapname, char * path)
 {
char message[32];
 
@@ -949,7 +949,7 @@ dm_fail_path(char * mapname, char * path)
 }
 
 int
-dm_reinstate_path(char * mapname, char * path)
+dm_reinstate_path(const char * mapname, char * path)
 {
char message[32];
 
@@ -960,7 +960,7 @@ dm_reinstate_path(char * mapname, char * path)
 }
 
 int
-dm_queue_if_no_path(char *mapname, int enable)
+dm_queue_if_no_path(const char *mapname, int enable)
 {
char *message;
 
@@ -973,7 +973,7 @@ dm_queue_if_no_path(char *mapname, int enable)
 }
 
 static int
-dm_groupmsg (char * msg, char * mapname, int index)
+dm_groupmsg (const char * msg, const char * mapname, int index)
 {
char message[32];
 
@@ -984,19 +984,19 @@ dm_groupmsg (char * msg, char * mapname, int index)
 }
 
 int
-dm_switchgroup(char * mapname, int index)
+dm_switchgroup(const char * mapname, int index)
 {
return dm_groupmsg("switch", mapname, index);
 }
 
 int
-dm_enablegroup(char * mapname, int index)
+dm_enablegroup(const char * mapname, int index)
 {
return dm_groupmsg("enable", mapname, index);
 }
 
 int
-dm_disablegroup(char * mapname, int index)
+dm_disablegroup(const char * mapname, int index)
 {
return dm_groupmsg("disable", mapname, index);
 }
@@ -1080,7 +1080,7 @@ out:
 }
 
 int
-dm_geteventnr (char *name)
+dm_geteventnr (const char *name)
 {
struct dm_info info;
 
@@ -1139,7 +1139,7 @@ dm_mapname(int major, int minor)
 
map = dm_task_get_name(dmt);
if (map && strlen(map))
-   response = STRDUP((char *)dm_task_get_name(dmt));
+   response = STRDUP((const char *)dm_task_get_name(dmt));
 
dm_task_destroy(dmt);
return response;
@@ -1264,7 +1264,7 @@ cancel_remove_partmap (const char *name, void *unused)
 }
 
 static int
-dm_get_deferred_remove (char * mapname)
+dm_get_deferred_remove (const char * mapname)
 {
struct dm_info info;
 
@@ -1412,10 +1412,10 @@ out:
return r;
 }
 
-void dm_reassign_deps(char *table, char *dep, char *newdep)
+void dm_reassign_deps(char *table, const char *dep, const char *newdep)
 {
-   char *p, *n;
-   char *newtable;
+   char *n;
+   const char *p, *newtable;
 
newtable = strdup(table);
if (!newtable)
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index 558e6914074f..8c8ea6c29b27 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -38,7 +38,7 @@ int dm_addmap_create (struct multipath *mpp, char *params);
 int dm_addmap_reload (struct multipath *mpp, char *params, int flush);
 int dm_map_present (const char *);
 int dm_get_map(const char *, unsigned long long *, char *);
-int dm_get_status(char *, char *);
+int dm_get_status(const char *, char *);
 int dm_type(const char *, char *);
 int dm_is_mpath(const char *);
 int _dm_flush_map (const char *, int, int, int, int);
@@ -49,14 +49,14 @@ int dm_flush_map_nopaths(const char * mapname, int 
deferred_remove);
_dm_flush_map(mapname, 1, 0, 1, retries)
 int dm_cancel_deferred_remove(struct multipath *mpp);
 int dm_flush_maps (int retries);
-int dm_fail_path(char * mapname, char * path);
-int dm_reinstate_path(char * mapname, char * path);
-int dm_queue_if_no_path(char *mapname, int enable);
-int dm_switchgroup(char * mapname, int index);
-int dm_enablegroup(char * mapname, int index);
-int dm_disablegroup(char

Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Martin Wilck
On Tue, 2018-03-06 at 00:24 +0100, Martin Wilck wrote:
> On Mon, 2018-03-05 at 21:13 +, Bart Van Assche wrote:
> > Yes. "PATCH v2 00/20] Various multipath-tools fixes" ff.
> > > https://www.redhat.com/archives/dm-devel/2018-January/msg00219.ht
> > > ml
> > 
> > Ah, thanks, but unfortunately these patches are no longer in my
> > mailbox. I
> > pulled these from https://github.com/openSUSE/multipath-tools. I'm
> > fine with
> > my patches being rebased on top of your series, whether or not the
> > following
> > issues get addressed:

I pushed my latest state, including my rebase of your patches, 
to https://github.com/openSUSE/multipath-tools/commits/upstream-queue.
I plan to merge also Ben's and Chongyun's late submissions, but
I didn't get around to it yet.

Regards,
Martin

-- 
Dr. Martin Wilck , 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

[dm-devel] [PATCH] multipathd: start marginal path checker thread lazily

2018-03-05 Thread Martin Wilck
I noticed that the io_error checker thread accounts for most of the
activity of multipathd even if the marginal path checking paramters
are not set (which is still the default in most installations I assume).

Therefore, start the io_error checker thread only if there's at least
one map with marginal error path checking configured. Also, make sure
the thread is really up when start_io_err_stat_thread() returns.

This requires adding a "vecs" argument to setup_map, because vecs
needs to be passed to the io_error checking code.

Signed-off-by: Martin Wilck 
---
 libmultipath/configure.c   | 14 +---
 libmultipath/configure.h   |  3 ++-
 libmultipath/io_err_stat.c | 54 +++---
 libmultipath/structs_vec.c |  3 ++-
 multipathd/cli_handlers.c  |  2 +-
 multipathd/main.c  |  8 ++-
 6 files changed, 69 insertions(+), 15 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 42b7c896ee65..fa6e21cb31af 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -41,6 +41,7 @@
 #include "uxsock.h"
 #include "wwids.h"
 #include "sysfs.h"
+#include "io_err_stat.h"
 
 /* group paths in pg by host adapter
  */
@@ -255,7 +256,8 @@ int rr_optimize_path_order(struct pathgroup *pgp)
return 0;
 }
 
-int setup_map(struct multipath *mpp, char *params, int params_size)
+int setup_map(struct multipath *mpp, char *params, int params_size,
+ struct vectors *vecs)
 {
struct pathgroup * pgp;
struct config *conf;
@@ -315,6 +317,12 @@ int setup_map(struct multipath *mpp, char *params, int 
params_size)
 
sysfs_set_scsi_tmo(mpp, conf->checkint);
put_multipath_config(conf);
+
+   if (mpp->marginal_path_double_failed_time > 0 &&
+   mpp->marginal_path_err_sample_time > 0 &&
+   mpp->marginal_path_err_recheck_gap_time > 0 &&
+   mpp->marginal_path_err_rate_threshold >= 0)
+   start_io_err_stat_thread(vecs);
/*
 * assign paths to path groups -- start with no groups and all paths
 * in mpp->paths
@@ -1019,7 +1027,7 @@ int coalesce_paths (struct vectors * vecs, vector newmp, 
char * refwwid,
verify_paths(mpp, vecs);
 
params[0] = '\0';
-   if (setup_map(mpp, params, PARAMS_SIZE)) {
+   if (setup_map(mpp, params, PARAMS_SIZE, vecs)) {
remove_map(mpp, vecs, 0);
continue;
}
@@ -1348,7 +1356,7 @@ int reload_map(struct vectors *vecs, struct multipath 
*mpp, int refresh,
}
}
}
-   if (setup_map(mpp, params, PARAMS_SIZE)) {
+   if (setup_map(mpp, params, PARAMS_SIZE, vecs)) {
condlog(0, "%s: failed to setup map", mpp->alias);
return 1;
}
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
index 0f5d30a540ca..27a7e6f60a63 100644
--- a/libmultipath/configure.h
+++ b/libmultipath/configure.h
@@ -28,7 +28,8 @@ enum actions {
 
 struct vectors;
 
-int setup_map (struct multipath * mpp, char * params, int params_size );
+int setup_map (struct multipath * mpp, char * params, int params_size,
+  struct vectors *vecs );
 int domap (struct multipath * mpp, char * params, int is_daemon);
 int reinstate_paths (struct multipath *mpp);
 int coalesce_paths (struct vectors *vecs, vector curmp, char * refwwid, int 
force_reload, enum mpath_cmds cmd);
diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c
index 00bac9e0e755..99731d5fe2f2 100644
--- a/libmultipath/io_err_stat.c
+++ b/libmultipath/io_err_stat.c
@@ -74,6 +74,10 @@ struct io_err_stat_path {
 pthread_t  io_err_stat_thr;
 pthread_attr_t io_err_stat_attr;
 
+static pthread_mutex_t io_err_thread_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t io_err_thread_cond = PTHREAD_COND_INITIALIZER;
+static int io_err_thread_running = 0;
+
 static struct io_err_stat_pathvec *paths;
 struct vectors *vecs;
 io_context_t   ioctx;
@@ -316,6 +320,9 @@ int io_err_stat_handle_pathfail(struct path *path)
struct timespec curr_time;
int res;
 
+   if (uatomic_read(&io_err_thread_running) == 0)
+   return 1;
+
if (path->io_err_disable_reinstate) {
io_err_stat_log(3, "%s: reinstate is already disabled",
path->dev);
@@ -380,6 +387,8 @@ int hit_io_err_recheck_time(struct path *pp)
struct timespec curr_time;
int r;
 
+   if (uatomic_read(&io_err_thread_running) == 0)
+   return 0;
if (pp->mpp->nr_active <= 0) {
io_err_stat_log(2, "%s: recover path early", pp->dev);
goto recover;
@@ -690,6 +699,16 @@ static void service_paths(void)
pthread_mutex_unlock(&paths->mutex);
 }
 
+static void cleanup_unlock(void *arg)
+{
+   pthread_mutex_unlock((pthread_mutex_t*) arg);
+}
+
+static

Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Martin Wilck
On Mon, 2018-03-05 at 21:13 +, Bart Van Assche wrote:
> On Mon, 2018-03-05 at 21:47 +0100, Martin Wilck wrote:
> > On Mon, 2018-03-05 at 19:18 +, Bart Van Assche wrote:
> > > On Mon, 2018-03-05 at 20:14 +0100, Martin Wilck wrote:
> > > > Unless you object, I'll repost your series rebased on mine.
> > > 
> > > Hello Martin,
> > > 
> > > Before you start working on that: has your patch series already
> > > been
> > > posted
> > > on the dm-devel mailing list?
> > 
> > Yes. "PATCH v2 00/20] Various multipath-tools fixes" ff.
> > https://www.redhat.com/archives/dm-devel/2018-January/msg00219.html
> 
> Ah, thanks, but unfortunately these patches are no longer in my
> mailbox. I
> pulled these from https://github.com/openSUSE/multipath-tools. I'm
> fine with
> my patches being rebased on top of your series, whether or not the
> following
> issues get addressed:
> * Several patches that are on the upstream-queue branch introduce
> trailing
>   whitespace.
> * The macro FREE_CONST() should never have been introduced.
> Introducing such
>   a macro namely introduces the risk of calling free() for a string
> constant,
>   something that should never happen. Have you considered to declare
>   dynamically allocated strings, e.g. the result of strdup(), as char
> *
>   instead of const char * ? I think with that change the FREE_CONST()
> macro
>   definitions can be removed again.

Another philosophical issue :-) I disagree with you here. The name
FREE_CONST is obvious enough that people should think twice before
using it. I have indeed considered what you propse, but I like being
able to use "const char*" when I work with strings that shouldn't be
changed. An accidental write to a const location is much easier to
overlook than a FREE_CONST(). Freeing a "const char*" isn't always
wrong, just if the pointer was passed in from elsewhere.

This issue is philosophical but not religious to me, so if you and
maybe others are offended so much by FREE_CONST, I may ditch it again.

Regards,
Martin

-- 
Dr. Martin Wilck , 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

[dm-devel] [PATCH v2 00/23] "Foreign" NVMe support for multipath-tools

2018-03-05 Thread Martin Wilck
Hello Christophe,

This patch series adds limited support for "foreign" multipath devices
to multipath and multipathd, and implements the respective API for
"native" NVMe multipath devices. The implementation is done using
a shared library approach similar to checkers, so other non-dm multipath
implementations could hook into this API easily.

"Limited support" means here that multipath and multipathd are able
to print information about "foreign" multipath maps with the commands
"multipath -l[l]", "multipathd show topology", "multipathd show maps", and
"multipathd show paths", and that multipathd checks the devices in the
checker loop and prints log messages if something interesting is detected.
No support for other functionality such real health monitoring or
administration is currently planned, although it might be be doable
by extending the code from this patch set.

Sample output from multipathd with this patch set:

multipathd show topology
sys0:NQN:subsysname (uuid.96926ba3-b207-437c-902c-4a4df6538c3f) [nvme] nvme0n1 
NVMe,Linux,4.15.0-r
size=2097152 features='n/a' hwhandler='n/a' wp=rw
`-+- policy='n/a' prio=n/a status=n/a
  |- 0:1:1 nvme0c1n1 0:0 n/a n/a live
  |- 0:2:1 nvme0c2n1 0:0 n/a n/a live
  |- 0:3:1 nvme0c3n1 0:0 n/a n/a live
  `- 0:4:1 nvme0c4n1 0:0 n/a n/a live

The first part of the set (01-09) consists only of cleanup patches, improving 
the
usage of "const" qualifiers in the part of the code I've been working with.
(I'm routinely trying to do at least some cleanup work when I look more deeply
into parts of the code). These patches don't change functionality. 10 and
11 are two minor helpers for the patches that follow.

Patch 12 and 15 represent the actual new APIs. Patch 13, 14 change the
libmultipath printing code to work with the strongly simplified "generic"
multipath API from patch 12. This allows to provide foreign library code
without replicating the complex data structures libmultipath is using
internally, and yet use libmultipath's native printing code for displaying
map and path properties.

Patch 15 defines the actual API for "foreign" libraries. It is built on
top of the "generic" API which defines the data structures with which objects
like multipath maps and paths are described.

Patch 17 and 21 provide the implementation of NVMe native multipath
support using these APIs. Patch 18 - 20 contain the necessary changes
to multipath and multipathd to call into the new APIs.
(Note the numbering has changed from v1, as patch 18 has been split off
patch 20).

Patch 22 makes multipathd update path group priorities also when not strictly
necessary. This was added because patch 05 removed code that updated the
pg prios in the printing code path.

Patch 23 fixes multipathd's signal blocking logic, a response to the discussion
that came up on the first submission of this patch set.

The patch set is based on the previous multipath-tools patches I
sent to dm-devel:
 - "[PATCH v2 00/20] Various multipath-tools fixes" ff.
 - "[PATCH 0/7] multipath-tools: uevent processing fixes and unit tests" ff.
   (7/7 replaced by "[PATCH v2] multipathd: ignore uevents for non-mpath
   devices")
 - "[PATCH 1/3] multipath.rules: handle NVME devices" ff.
 - "[PATCH] libmultipath: increase path product_id/rev field size for NVMe"

To try and reduce confusion, the full series is available here:
https://github.com/openSUSE/multipath-tools/tree/upstream-queue

Reviews and comments are of course welcome.

Changes v1 -> v2:
 - 12/23: added '#include "dm-generic.h"' to print.h (Ben Marzinski)
 - 12/23: added "%d %s" formats in generic_style() to print device and product 
info
   in topology printout by default
 - 13/23: removed double "%d %s" format (Ben Marzinski)
 - 15/23: added locking to the foreign implementation to avoid use of 
deallocated
   data structures in foreign libraries (because of Ben's comment on 17/20)
 - 15/23: avoid "name" pointer (Ben Marzinski)
 - 15/23: simplify prototype of free_foreign()
 - 15/23: use scandir() rather than glob() for scanning foreign libraries
 - 17/23: avoid superfluous udev references (Ben Marzinski)
 - 17/23: add commend about locking in cleanup() (Ben Marzinski)
 - 17/23: substitute __attribute__ ((fallthrough)) by comment (Ben Marzinski)
 - 18/23 is new (it has been split off former 20/23 because of Ben's comment on
   19/23); numbering has changed from here (18 becomes 19, 19->20, 20->21).
 - 20/23: don't call foreign libraries in ev_add_path(), as foreign paths are 
never
   added to pathvec anyway
 - 21/23: nvme: use scandir() rather than glob() for looking for path devices
   (Ben Marzinski)
 - 22/23: new, because of Ben's comment on patch 5
 - 23/23: new, result of discussion about signal blocking
(Patches not mentioned are identical to the first series, except 19/23 they have
Reviewed-by: tags by Ben).

Martin Wilck (23):
  multipath(d)/Makefile: add explicit dependency on libraries
  libmultipath: remove unused "stdout helpers"
  libmultipath: get rid of se

[dm-devel] [PATCH v2 20/23] multipathd: use foreign API

2018-03-05 Thread Martin Wilck
Call into the foreign library code when paths are discovered, uevents
are received, and in the checker loop. Furthermore, use the foreign
code to print information in the "multipathd show paths", "multipathd
show maps", and "multipathd show topology" client commands.

We don't support foreign data in the individual "show map" and "show path"
commands, and neither in the "json" commands. The former is a deliberate
decision, the latter could be added if desired.

Signed-off-by: Martin Wilck 
---
 multipathd/cli_handlers.c | 39 ++-
 multipathd/main.c | 34 +++---
 2 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 78f2a12bc2f8..c0ae54aae841 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -27,6 +27,7 @@
 #include "main.h"
 #include "cli.h"
 #include "uevent.h"
+#include "foreign.h"
 
 int
 show_paths (char ** r, int * len, struct vectors * vecs, char * style,
@@ -35,11 +36,13 @@ show_paths (char ** r, int * len, struct vectors * vecs, 
char * style,
int i;
struct path * pp;
char * c;
-   char * reply;
+   char * reply, * header;
unsigned int maxlen = INITIAL_REPLY_LEN;
int again = 1;
 
get_path_layout(vecs->pathvec, 1);
+   foreign_path_layout();
+
reply = MALLOC(maxlen);
 
while (again) {
@@ -48,18 +51,29 @@ show_paths (char ** r, int * len, struct vectors * vecs, 
char * style,
 
c = reply;
 
-   if (pretty && VECTOR_SIZE(vecs->pathvec) > 0)
+   if (pretty)
c += snprint_path_header(c, reply + maxlen - c,
 style);
+   header = c;
 
vector_foreach_slot(vecs->pathvec, pp, i)
c += snprint_path(c, reply + maxlen - c,
  style, pp, pretty);
 
+   c += snprint_foreign_paths(c, reply + maxlen - c,
+  style, pretty);
+
again = ((c - reply) == (maxlen - 1));
 
REALLOC_REPLY(reply, again, maxlen);
}
+
+   if (pretty && c == header) {
+   /* No output - clear header */
+   *reply = '\0';
+   c = reply;
+   }
+
*r = reply;
*len = (int)(c - reply + 1);
return 0;
@@ -134,6 +148,8 @@ show_maps_topology (char ** r, int * len, struct vectors * 
vecs)
int again = 1;
 
get_path_layout(vecs->pathvec, 0);
+   foreign_path_layout();
+
reply = MALLOC(maxlen);
 
while (again) {
@@ -150,11 +166,13 @@ show_maps_topology (char ** r, int * len, struct vectors 
* vecs)
c += snprint_multipath_topology(c, reply + maxlen - c,
mpp, 2);
}
+   c += snprint_foreign_topology(c, reply + maxlen - c, 2);
 
again = ((c - reply) == (maxlen - 1));
 
REALLOC_REPLY(reply, again, maxlen);
}
+
*r = reply;
*len = (int)(c - reply + 1);
return 0;
@@ -499,12 +517,14 @@ show_maps (char ** r, int *len, struct vectors * vecs, 
char * style,
 {
int i;
struct multipath * mpp;
-   char * c;
+   char * c, *header;
char * reply;
unsigned int maxlen = INITIAL_REPLY_LEN;
int again = 1;
 
get_multipath_layout(vecs->mpvec, 1);
+   foreign_multipath_layout();
+
reply = MALLOC(maxlen);
 
while (again) {
@@ -512,9 +532,10 @@ show_maps (char ** r, int *len, struct vectors * vecs, 
char * style,
return 1;
 
c = reply;
-   if (pretty && VECTOR_SIZE(vecs->mpvec) > 0)
+   if (pretty)
c += snprint_multipath_header(c, reply + maxlen - c,
  style);
+   header = c;
 
vector_foreach_slot(vecs->mpvec, mpp, i) {
if (update_multipath(vecs, mpp->alias, 0)) {
@@ -523,12 +544,20 @@ show_maps (char ** r, int *len, struct vectors * vecs, 
char * style,
}
c += snprint_multipath(c, reply + maxlen - c,
   style, mpp, pretty);
-   }
 
+   }
+   c += snprint_foreign_multipaths(c, reply + maxlen - c,
+   style, pretty);
again = ((c - reply) == (maxlen - 1));
 
REALLOC_REPLY(reply, again, maxlen);
}
+
+   if (pretty && c == header) {
+   /* No output - clear header */
+   *reply = '\0';
+   c = reply;
+   }
*r = reply;
*len = (int)(c - reply + 1);
return 0;
di

[dm-devel] [PATCH v2 04/23] libmultipath: parser: use call-by-value for "snprint" methods

2018-03-05 Thread Martin Wilck
Convert the snprint methods for all keywords to call-by-value,
and use "const" qualifier for the "data" argument. This makes sure
that "snprint" type functions don't modify the data they're print,
helps compile-time correctness checking, and allows more proper
"const" cleanups in the future.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/dict.c   | 206 --
 libmultipath/parser.c |   9 ++-
 libmultipath/parser.h |  12 ++-
 3 files changed, 112 insertions(+), 115 deletions(-)

diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index e52f1f798f7a..47dc2a38f1ac 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -92,46 +92,35 @@ set_yes_no_undef(vector strvec, void *ptr)
 }
 
 static int
-print_int (char *buff, int len, void *ptr)
+print_int (char *buff, int len, long v)
 {
-   int *int_ptr = (int *)ptr;
-   return snprintf(buff, len, "%i", *int_ptr);
+   return snprintf(buff, len, "%li", v);
 }
 
 static int
-print_nonzero (char *buff, int len, void *ptr)
+print_nonzero (char *buff, int len, long v)
 {
-   int *int_ptr = (int *)ptr;
-   if (!*int_ptr)
-   return 0;
-   return snprintf(buff, len, "%i", *int_ptr);
+   return snprintf(buff, len, "%li", v);
 }
 
 static int
-print_str (char *buff, int len, void *ptr)
+print_str (char *buff, int len, const char *ptr)
 {
-   char **str_ptr = (char **)ptr;
-   if (!*str_ptr)
-   return 0;
-   return snprintf(buff, len, "\"%s\"", *str_ptr);
+   return snprintf(buff, len, "\"%s\"", ptr);
 }
 
 static int
-print_yes_no (char *buff, int len, void *ptr)
+print_yes_no (char *buff, int len, long v)
 {
-   int *int_ptr = (int *)ptr;
return snprintf(buff, len, "\"%s\"",
-   (*int_ptr == YN_NO)? "no" : "yes");
+   (v == YN_NO)? "no" : "yes");
 }
 
 static int
-print_yes_no_undef (char *buff, int len, void *ptr)
+print_yes_no_undef (char *buff, int len, long v)
 {
-   int *int_ptr = (int *)ptr;
-   if (!*int_ptr)
-   return 0;
return snprintf(buff, len, "\"%s\"",
-   (*int_ptr == YNU_NO)? "no" : "yes");
+   (v == YNU_NO)? "no" : "yes");
 }
 
 #define declare_def_handler(option, function)  \
@@ -143,29 +132,32 @@ def_ ## option ## _handler (struct config *conf, vector 
strvec)   \
 
 #define declare_def_snprint(option, function)  \
 static int \
-snprint_def_ ## option (struct config *conf, char * buff, int len, void * 
data) \
+snprint_def_ ## option (struct config *conf, char * buff, int len, \
+   const void * data)  \
 {  \
-   return function (buff, len, &conf->option); \
+   return function (buff, len, conf->option);  \
 }
 
 #define declare_def_snprint_defint(option, function, value)\
 static int \
-snprint_def_ ## option (struct config *conf, char * buff, int len, void * 
data) \
+snprint_def_ ## option (struct config *conf, char * buff, int len, \
+   const void * data)  \
 {  \
int i = value;  \
if (!conf->option)  \
-   return function (buff, len, &i);\
-   return function (buff, len, &conf->option); \
+   return function (buff, len, i); \
+   return function (buff, len, conf->option);  \
 }
 
 #define declare_def_snprint_defstr(option, function, value)\
 static int \
-snprint_def_ ## option (struct config *conf, char * buff, int len, void * 
data) \
+snprint_def_ ## option (struct config *conf, char * buff, int len, \
+   const void * data)  \
 {  \
-   char *s = value;\
+   static const char *s = value;   \
if (!conf->option)  \
-   return function (buff, len, &s);\
-   return function (buff, len, &conf->option); \
+   return function (buff, len, s); \
+   return function (buff, len, conf->option);  \
 }
 
 #define declare_hw_handler(option, function)   

[dm-devel] [PATCH v2 11/23] libmultipath: add vector_convert()

2018-03-05 Thread Martin Wilck
This is a handy helper for creating one vector from another,
mapping each element of the origin vector to an element of
the target vector with a given conversion function. It can
also be used to "concatenate" vectors by passing in a non-NULL first
argument.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/vector.h | 29 +
 1 file changed, 29 insertions(+)

diff --git a/libmultipath/vector.h b/libmultipath/vector.h
index 3f6e579ae19a..6018b57525bf 100644
--- a/libmultipath/vector.h
+++ b/libmultipath/vector.h
@@ -42,6 +42,35 @@ typedef struct _vector *vector;
 #define vector_foreach_slot_backwards(v,p,i) \
for (i = VECTOR_SIZE(v); i > 0 && ((p) = (v)->slot[i-1]); i--)
 
+#define identity(x) (x)
+/*
+ * Given a vector vec with elements of given type,
+ * return a newly allocated vector with elements conv(e) for each element
+ * e in vec. "conv" may be a macro or a function.
+ * Use "identity" for a simple copy.
+ */
+#define vector_convert(new, vec, type, conv)   \
+   ({  \
+   const struct _vector *__v = (vec);  \
+   vector __t = (new); \
+   type *__j;  \
+   int __i;\
+   \
+   if (__t == NULL)\
+   __t = vector_alloc();   \
+   if (__t != NULL) {  \
+   vector_foreach_slot(__v, __j, __i) {\
+   if (vector_alloc_slot(__t) == NULL) {   \
+   vector_free(__t);   \
+   __t = NULL; \
+   break;  \
+   }   \
+   vector_set_slot(__t, conv(__j));\
+   }   \
+   }   \
+   __t;\
+   })
+
 /* Prototypes */
 extern vector vector_alloc(void);
 extern void *vector_alloc_slot(vector v);
-- 
2.16.1

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


[dm-devel] [PATCH v2 17/23] libmultipath/foreign: nvme foreign library

2018-03-05 Thread Martin Wilck
This still contains stubs for path handling and checking, but it's functional
for printing already.

Signed-off-by: Martin Wilck 
---
 Makefile  |   1 +
 libmultipath/foreign/Makefile |  30 +++
 libmultipath/foreign/nvme.c   | 455 ++
 3 files changed, 486 insertions(+)
 create mode 100644 libmultipath/foreign/Makefile
 create mode 100644 libmultipath/foreign/nvme.c

diff --git a/Makefile b/Makefile
index 11c46eb4dbc9..4b145c593605 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ BUILDDIRS = \
libmultipath \
libmultipath/prioritizers \
libmultipath/checkers \
+   libmultipath/foreign \
libmpathpersist \
multipath \
multipathd \
diff --git a/libmultipath/foreign/Makefile b/libmultipath/foreign/Makefile
new file mode 100644
index ..dfba11e86d76
--- /dev/null
+++ b/libmultipath/foreign/Makefile
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2003 Christophe Varoqui, 
+#
+include ../../Makefile.inc
+
+CFLAGS += $(LIB_CFLAGS) -I..
+
+# If you add or remove a checker also update multipath/multipath.conf.5
+LIBS= \
+   libforeign-nvme.so
+
+all: $(LIBS)
+
+libforeign-%.so: %.o
+   $(CC) $(LDFLAGS) $(SHARED_FLAGS) -o $@ $^
+
+install:
+   $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(libdir)
+
+uninstall:
+   for file in $(LIBS); do $(RM) $(DESTDIR)$(libdir)/$$file; done
+
+clean: dep_clean
+   $(RM) core *.a *.o *.gz *.so
+
+OBJS := $(LIBS:libforeign-%.so=%.o)
+include $(wildcard $(OBJS:.o=.d))
+
+dep_clean:
+   $(RM) $(OBJS:.o=.d)
diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c
new file mode 100644
index ..32bd5c96c44a
--- /dev/null
+++ b/libmultipath/foreign/nvme.c
@@ -0,0 +1,455 @@
+/*
+  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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "vector.h"
+#include "generic.h"
+#include "foreign.h"
+#include "debug.h"
+
+const char *THIS;
+
+struct nvme_map {
+   struct gen_multipath gen;
+   struct udev_device *udev;
+   struct udev_device *subsys;
+   dev_t devt;
+};
+
+#define NAME_LEN 64 /* buffer length temp model name */
+#define const_gen_mp_to_nvme(g) ((const struct nvme_map*)(g))
+#define gen_mp_to_nvme(g) ((struct nvme_map*)(g))
+#define nvme_mp_to_gen(n) &((n)->gen)
+
+static void cleanup_nvme_map(struct nvme_map *map)
+{
+   if (map->udev)
+   udev_device_unref(map->udev);
+   if (map->subsys)
+   udev_device_unref(map->subsys);
+   free(map);
+}
+
+static const struct _vector*
+nvme_mp_get_pgs(const struct gen_multipath *gmp) {
+   return NULL;
+}
+
+static void
+nvme_mp_rel_pgs(const struct gen_multipath *gmp, const struct _vector *v)
+{
+}
+
+static void rstrip(char *str)
+{
+   int n;
+
+   for (n = strlen(str) - 1; n >= 0 && str[n] == ' '; n--);
+   str[n+1] = '\0';
+}
+
+static int snprint_nvme_map(const struct gen_multipath *gmp,
+   char *buff, int len, char wildcard)
+{
+   const struct nvme_map *nvm = const_gen_mp_to_nvme(gmp);
+   static const char nvme_vendor[] = "NVMe";
+   char fld[NAME_LEN];
+   const char *val;
+
+   switch (wildcard) {
+   case 'd':
+   return snprintf(buff, len, "%s",
+   udev_device_get_sysname(nvm->udev));
+   case 'n':
+   return snprintf(buff, len, "%s:NQN:%s",
+   udev_device_get_sysname(nvm->subsys),
+   udev_device_get_sysattr_value(nvm->subsys,
+ "subsysnqn"));
+   case 'w':
+   return snprintf(buff, len, "%s",
+   udev_device_get_sysattr_value(nvm->udev,
+ "wwid"));
+   case 'S':
+   return snprintf(buff, len, "%s",
+   udev_device_get_sysattr_value(nvm->udev,
+ "size"));
+   case 'v':
+   return snprintf(buff, len, "%s", nvme_vendor);
+   case 's':
+   case 'p':
+   

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

2018-03-05 Thread Martin Wilck
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

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 @@
+/*
+  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

[dm-devel] [PATCH v2 19/23] multipath: use foreign API

2018-03-05 Thread Martin Wilck
Use the "foreign" code to print information about multipath maps
owned by foreign libraries in print mode (multipath -ll, -l).

Signed-off-by: Martin Wilck 
---
 multipath/main.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/multipath/main.c b/multipath/main.c
index a0c750e6f623..4fae49ee4325 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -59,6 +59,7 @@
 #include "wwids.h"
 #include "uxsock.h"
 #include "mpath_cmd.h"
+#include "foreign.h"
 
 int logsink;
 struct udev *udev;
@@ -257,6 +258,14 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector 
pathvec, char * refwwid)
if (cmd == CMD_CREATE)
reinstate_paths(mpp);
}
+
+   if (cmd == CMD_LIST_SHORT || cmd == CMD_LIST_LONG) {
+   struct config *conf = get_multipath_config();
+
+   print_foreign_topology(conf->verbosity);
+   put_multipath_config(conf);
+   }
+
return 0;
 }
 
@@ -460,6 +469,7 @@ configure (struct config *conf, enum mpath_cmds cmd,
print_all_paths(pathvec, 1);
 
get_path_layout(pathvec, 0);
+   foreign_path_layout();
 
if (get_dm_mpvec(cmd, curmp, pathvec, refwwid))
goto out;
@@ -817,6 +827,8 @@ main (int argc, char *argv[])
condlog(0, "failed to initialize prioritizers");
goto out;
}
+   /* Failing here is non-fatal */
+   init_foreign(conf->multipath_dir);
if (cmd == CMD_USABLE_PATHS) {
r = check_usable_paths(conf, dev, dev_type);
goto out;
@@ -892,6 +904,7 @@ out:
dm_lib_release();
dm_lib_exit();
 
+   cleanup_foreign();
cleanup_prio();
cleanup_checkers();
 
-- 
2.16.1

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


[dm-devel] [PATCH v2 06/23] libmultipath/print: use "const" where appropriate

2018-03-05 Thread Martin Wilck
Convert the print.h/print.c code to use "const" qualifiers
properly. This is generally considered good programming practice,
and the printing code shouldn't change any objects anyway.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/configure.h |   1 -
 libmultipath/discovery.c |   6 +--
 libmultipath/discovery.h |   6 ++-
 libmultipath/print.c | 133 ---
 libmultipath/print.h |  41 ---
 5 files changed, 95 insertions(+), 92 deletions(-)

diff --git a/libmultipath/configure.h b/libmultipath/configure.h
index 0ffc28efdaf7..0f5d30a540ca 100644
--- a/libmultipath/configure.h
+++ b/libmultipath/configure.h
@@ -35,5 +35,4 @@ int coalesce_paths (struct vectors *vecs, vector curmp, char 
* refwwid, int forc
 int get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
 vector pathvec, char **wwid);
 int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, int 
is_daemon);
-int sysfs_get_host_adapter_name(struct path *pp, char *adapter_name);
 struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type);
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 88e9f3b61510..98bddee52c8f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -401,7 +401,7 @@ sysfs_get_tgt_nodename (struct path *pp, char * node)
return 0;
 }
 
-int sysfs_get_host_adapter_name(struct path *pp, char *adapter_name)
+int sysfs_get_host_adapter_name(const struct path *pp, char *adapter_name)
 {
int proto_id;
 
@@ -427,7 +427,7 @@ int sysfs_get_host_adapter_name(struct path *pp, char 
*adapter_name)
return sysfs_get_host_pci_name(pp, adapter_name);
 }
 
-int sysfs_get_host_pci_name(struct path *pp, char *pci_name)
+int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
 {
struct udev_device *hostdev, *parent;
char host_name[HOST_NAME_LEN];
@@ -466,7 +466,7 @@ int sysfs_get_host_pci_name(struct path *pp, char *pci_name)
return 1;
 }
 
-int sysfs_get_iscsi_ip_address(struct path *pp, char *ip_address)
+int sysfs_get_iscsi_ip_address(const struct path *pp, char *ip_address)
 {
struct udev_device *hostdev;
char host_name[HOST_NAME_LEN];
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index bd5e6678a26d..9aacf75bfeb0 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -44,8 +44,10 @@ int store_pathinfo (vector pathvec, struct config *conf,
struct path **pp_ptr);
 int sysfs_set_scsi_tmo (struct multipath *mpp, int checkint);
 int sysfs_get_timeout(struct path *pp, unsigned int *timeout);
-int sysfs_get_host_pci_name(struct path *pp, char *pci_name);
-int sysfs_get_iscsi_ip_address(struct path *pp, char *ip_address);
+int sysfs_get_host_pci_name(const struct path *pp, char *pci_name);
+int sysfs_get_iscsi_ip_address(const struct path *pp, char *ip_address);
+int sysfs_get_host_adapter_name(const struct path *pp,
+   char *adapter_name);
 ssize_t sysfs_get_vpd (struct udev_device * udev, int pg, unsigned char * buff,
   size_t len);
 int sysfs_get_asymmetric_access_state(struct path *pp,
diff --git a/libmultipath/print.c b/libmultipath/print.c
index b5c00bfe69a5..594ca567e22a 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -28,6 +28,7 @@
 #include "devmapper.h"
 #include "uevent.h"
 #include "debug.h"
+#include "discovery.h"
 
 #define MAX(x,y) (x > y) ? x : y
 #define TAIL (line + len - 1 - c)
@@ -97,7 +98,7 @@ snprint_size (char * buff, size_t len, unsigned long long 
size)
  * multipath info printing functions
  */
 static int
-snprint_name (char * buff, size_t len, struct multipath * mpp)
+snprint_name (char * buff, size_t len, const struct multipath * mpp)
 {
if (mpp->alias)
return snprintf(buff, len, "%s", mpp->alias);
@@ -106,7 +107,7 @@ snprint_name (char * buff, size_t len, struct multipath * 
mpp)
 }
 
 static int
-snprint_sysfs (char * buff, size_t len, struct multipath * mpp)
+snprint_sysfs (char * buff, size_t len, const struct multipath * mpp)
 {
if (mpp->dmi)
return snprintf(buff, len, "dm-%i", mpp->dmi->minor);
@@ -115,7 +116,7 @@ snprint_sysfs (char * buff, size_t len, struct multipath * 
mpp)
 }
 
 static int
-snprint_ro (char * buff, size_t len, struct multipath * mpp)
+snprint_ro (char * buff, size_t len, const struct multipath * mpp)
 {
if (!mpp->dmi)
return snprintf(buff, len, "undef");
@@ -154,7 +155,7 @@ out:
 }
 
 static int
-snprint_failback (char * buff, size_t len, struct multipath * mpp)
+snprint_failback (char * buff, size_t len, const struct multipath * mpp)
 {
if (mpp->pgfailback == -FAILBACK_IMMEDIATE)
return snprintf(buff, len, "immediate");
@@ -169,7 +170,7 @@ snprint_failback (char * buff, size_t len, struct multipath 
* mpp)
 }
 
 stat

[dm-devel] [PATCH v2 03/23] libmultipath: get rid of selector "hack" in print.c

2018-03-05 Thread Martin Wilck
By properly linking the path groups with their parent multipath,
we don't need this "hack" any more.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/dmparser.c   |  2 +-
 libmultipath/pgpolicies.c | 11 ++-
 libmultipath/print.c  |  6 +++---
 libmultipath/structs.c| 10 ++
 libmultipath/structs.h|  3 ++-
 5 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index 027ae989781e..783c934f1154 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -267,7 +267,7 @@ int disassemble_map(vector pathvec, char *params, struct 
multipath *mpp,
if (!pgp)
goto out;
 
-   if (store_pathgroup(mpp->pg, pgp))
+   if (add_pathgroup(mpp, pgp))
goto out;
 
p += get_word(p, &word);
diff --git a/libmultipath/pgpolicies.c b/libmultipath/pgpolicies.c
index 4ae4afbccdb7..ac2596ada442 100644
--- a/libmultipath/pgpolicies.c
+++ b/libmultipath/pgpolicies.c
@@ -120,7 +120,7 @@ int group_by_node_name(struct multipath * mp)
if (!pgp)
goto out1;
 
-   if (store_pathgroup(mp->pg, pgp))
+   if (add_pathgroup(mp, pgp))
goto out2;
 
/* feed the first path */
@@ -196,7 +196,7 @@ int group_by_serial(struct multipath * mp)
if (!pgp)
goto out1;
 
-   if (store_pathgroup(mp->pg, pgp))
+   if (add_pathgroup(mp, pgp))
goto out2;
 
/* feed the first path */
@@ -254,7 +254,7 @@ int one_path_per_group(struct multipath *mp)
if (!pgp)
goto out;
 
-   if (store_pathgroup(mp->pg, pgp))
+   if (add_pathgroup(mp, pgp))
goto out1;
 
if (store_path(pgp->paths, pp))
@@ -293,7 +293,7 @@ int one_group(struct multipath *mp) /* aka multibus */
 
vector_free(pgp->paths);
 
-   if (store_pathgroup(mp->pg, pgp))
+   if (add_pathgroup(mp, pgp))
goto out1;
 
pgp->paths = mp->paths;
@@ -367,8 +367,9 @@ int group_by_prio(struct multipath *mp)
if (i < VECTOR_SIZE(mp->pg)) {
if (!vector_insert_slot(mp->pg, i, pgp))
goto out2;
+   pgp->mpp = mp;
} else {
-   if (store_pathgroup(mp->pg, pgp))
+   if (add_pathgroup(mp, pgp))
goto out2;
}
 
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 27636c35e5ff..8fb5c5058965 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -476,7 +476,9 @@ snprint_pri (char * buff, size_t len, struct path * pp)
 static int
 snprint_pg_selector (char * buff, size_t len, struct pathgroup * pgp)
 {
-   return snprint_str(buff, len, pgp->selector);
+   const char *s = pgp->mpp->selector;
+
+   return snprint_str(buff, len, s ? s : "");
 }
 
 static int
@@ -1030,7 +1032,6 @@ int snprint_multipath_topology(char *buff, int len, 
struct multipath *mpp,
 
vector_foreach_slot (mpp->pg, pgp, j) {
f=fmt;
-   pgp->selector = mpp->selector; /* hack */
if (j + 1 < VECTOR_SIZE(mpp->pg)) {
strcpy(f, "|-+- " PRINT_PG_INDENT);
} else
@@ -1122,7 +1123,6 @@ snprint_multipath_fields_json (char * buff, int len,
 
vector_foreach_slot (mpp->pg, pgp, i) {
 
-   pgp->selector = mpp->selector;
fwd += snprint_pathgroup(buff + fwd, len - fwd, 
PRINT_JSON_GROUP, pgp);
if (fwd >= len)
return fwd;
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 4caad2a40302..1ade1a6705ad 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -318,6 +318,16 @@ store_pathgroup (vector pgvec, struct pathgroup * pgp)
return 0;
 }
 
+int add_pathgroup(struct multipath *mpp, struct pathgroup *pgp)
+{
+   int ret = store_pathgroup(mpp->pg, pgp);
+
+   if (ret)
+   return ret;
+   pgp->mpp = mpp;
+   return 0;
+}
+
 int
 store_hostgroup(vector hostgroupvec, struct host_group * hgp)
 {
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index b951c7b0e157..71b37cc20674 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -340,7 +340,7 @@ struct pathgroup {
int priority;
int enabled_paths;
vector paths;
-   char * selector;
+   struct multipath *mpp;
 };
 
 struct adapter_group {
@@ -379,6 +379,7 @@ int store_hostgroup(vector hostgroupvec, struct host_group 
*hgp);
 
 int store_path (vector pathvec, struct path * pp);
 int store_pathgroup (vector pgvec, struct pathgroup * p

[dm-devel] [PATCH v2 23/23] multipathd: fix signal blocking logic

2018-03-05 Thread Martin Wilck
multipathd is supposed to block all signals in all threads, except
the uxlsnr thread which handles termination and reconfiguration
signals (SIGUSR1) in its ppoll() call, SIGUSR2 in the waiter thread
and the marginal path checker thread, and occasional SIGALRM. The current
logic does exactly the oppsite, it blocks termination signals in SIGPOLL and
allows multipathd to be killed e.g. by SIGALRM.

Fix that by inverting the logic. The argument to pthread_sigmask and
ppoll is the set of *blocked* signals, not vice versa.

The marginal paths code needs to unblock SIGUSR2 now explicity, as
the dm-event waiter code already does. Doing this with pselect()
avoids asynchronous cancellation.

Fixes: 810082e "libmultipath, multipathd: Rework SIGPIPE handling"
Fixes: 534ec4c "multipathd: Ensure that SIGINT, SIGTERM, SIGHUP and SIGUSR1
are delivered to the uxsock thread"

Signed-off-by: Martin Wilck 
---
 libmultipath/io_err_stat.c | 17 -
 multipathd/main.c  |  7 +--
 multipathd/uxlsnr.c| 10 +-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c
index 5b10f0372f9f..00bac9e0e755 100644
--- a/libmultipath/io_err_stat.c
+++ b/libmultipath/io_err_stat.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vector.h"
 #include "memory.h"
@@ -691,14 +692,28 @@ static void service_paths(void)
 
 static void *io_err_stat_loop(void *data)
 {
+   sigset_t set;
+
vecs = (struct vectors *)data;
pthread_cleanup_push(rcu_unregister, NULL);
rcu_register_thread();
 
+   sigfillset(&set);
+   sigdelset(&set, SIGUSR2);
+
mlockall(MCL_CURRENT | MCL_FUTURE);
while (1) {
+   struct timespec ts;
+
service_paths();
-   usleep(10);
+
+   ts.tv_sec = 0;
+   ts.tv_nsec = 100 * 1000 * 1000;
+   /*
+* pselect() with no fds, a timeout, and a sigmask:
+* sleep for 100ms and react on SIGUSR2.
+*/
+   pselect(1, NULL, NULL, NULL, &ts, &set);
}
 
pthread_cleanup_pop(1);
diff --git a/multipathd/main.c b/multipathd/main.c
index 4abdd8f071c3..68595836d723 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2261,10 +2261,13 @@ signal_init(void)
 {
sigset_t set;
 
-   sigemptyset(&set);
-   sigaddset(&set, SIGUSR2);
+   /* block all signals */
+   sigfillset(&set);
+   /* SIGPIPE occurs if logging fails */
+   sigdelset(&set, SIGPIPE);
pthread_sigmask(SIG_SETMASK, &set, NULL);
 
+   /* Other signals will be unblocked in the uxlsnr thread */
signal_set(SIGHUP, sighup);
signal_set(SIGUSR1, sigusr1);
signal_set(SIGUSR2, sigusr2);
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
index 98ac25a68c43..a2ca36ba1653 100644
--- a/multipathd/uxlsnr.c
+++ b/multipathd/uxlsnr.c
@@ -170,11 +170,11 @@ void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, 
void * trigger_data)
condlog(0, "uxsock: failed to allocate poll fds");
return NULL;
}
-   sigemptyset(&mask);
-   sigaddset(&mask, SIGINT);
-   sigaddset(&mask, SIGTERM);
-   sigaddset(&mask, SIGHUP);
-   sigaddset(&mask, SIGUSR1);
+   sigfillset(&mask);
+   sigdelset(&mask, SIGINT);
+   sigdelset(&mask, SIGTERM);
+   sigdelset(&mask, SIGHUP);
+   sigdelset(&mask, SIGUSR1);
while (1) {
struct client *c, *tmp;
int i, poll_count, num_clients;
-- 
2.16.1

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


[dm-devel] [PATCH v2 09/23] multipath-tools: Makefile.inc: use -Werror=cast-qual

2018-03-05 Thread Martin Wilck
Casting "const" away is often an indicator for wrong code.
Add a compiler flag to warn about such possible breakage.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 Makefile.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.inc b/Makefile.inc
index eb99c36010c1..a5b9d4e3fa74 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -87,6 +87,7 @@ STACKPROT := $(call 
TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
 OPTFLAGS   = -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
  -Werror=implicit-function-declaration -Werror=format-security 
\
  -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered \
+ -Werror=cast-qual -Werror=discarded-qualifiers \
  -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
  --param=ssp-buffer-size=4
 
-- 
2.16.1

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


[dm-devel] [PATCH v2 05/23] libmultipath: don't update path groups when printing

2018-03-05 Thread Martin Wilck
Updating the prio values for printing makes no sense. The user wants to see
the prio values multipath is actually using for path group selection, and
updating the values here means actually lying to the user if the prio values
have changed, but multipathd hasn't updated them internally.

If we really don't update the pathgroup prios when we need to, this should be
fixed elsewhere. The current wrong output would just hide that if it occured.

Moreover, correctness forbids changing properties so deeply in a code path
that's supposed to print them only. Finally, this piece of code prevents the
print.c code to be converted to proper "const" usage.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/print.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 8fb5c5058965..b5c00bfe69a5 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -484,13 +484,6 @@ snprint_pg_selector (char * buff, size_t len, struct 
pathgroup * pgp)
 static int
 snprint_pg_pri (char * buff, size_t len, struct pathgroup * pgp)
 {
-   /*
-* path group priority is not updated for every path prio change,
-* but only on switch group code path.
-*
-* Printing is another reason to update.
-*/
-   path_group_prio_update(pgp);
return snprint_int(buff, len, pgp->priority);
 }
 
-- 
2.16.1

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


[dm-devel] [PATCH v2 13/23] libmultipath: print: convert API to generic data type

2018-03-05 Thread Martin Wilck
Convert higher level API (snprint_multipath_topology() etc) to
using the generic multipath API. This will allow "foreign"
multipath objects that implement the generic API to be printed
exactly like native multipathd objects.

The previous API (using "struct multipath*" and "struct path" remains
in place through macros mapping to the new functions. By doing this
and testing in regular setups, it's easily verified that the new
API works and produces the same results.

Moreover, abstract out the code to determine the output format from multipath
properties into snprint_multipath_style(), to be able to use it as generic
->style() method.

Signed-off-by: Martin Wilck 
---
 libmultipath/configure.c  |   1 +
 libmultipath/dm-generic.c |   2 +-
 libmultipath/print.c  | 115 +-
 libmultipath/print.h  |  24 +++---
 multipath/main.c  |   1 +
 multipathd/cli_handlers.c |   1 +
 6 files changed, 95 insertions(+), 49 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 13e14cc25fff..42b7c896ee65 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -30,6 +30,7 @@
 #include "discovery.h"
 #include "debug.h"
 #include "switchgroup.h"
+#include "dm-generic.h"
 #include "print.h"
 #include "configure.h"
 #include "pgpolicies.h"
diff --git a/libmultipath/dm-generic.c b/libmultipath/dm-generic.c
index 42a26085d087..bdc9ca0a488b 100644
--- a/libmultipath/dm-generic.c
+++ b/libmultipath/dm-generic.c
@@ -56,7 +56,7 @@ 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 */
+   .style = snprint_multipath_style,
 };
 
 const struct gen_pathgroup_ops dm_gen_pathgroup_ops = {
diff --git a/libmultipath/print.c b/libmultipath/print.c
index e9b8fdd6e581..8701a3584859 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -30,7 +30,8 @@
 #include "debug.h"
 #include "discovery.h"
 
-#define MAX(x,y) (x > y) ? x : y
+#define MAX(x,y) (((x) > (y)) ? (x) : (y))
+#define MIN(x,y) (((x) > (y)) ? (y) : (x))
 #define TAIL (line + len - 1 - c)
 #define NOPADs = c
 #define PAD(x) \
@@ -845,8 +846,8 @@ snprint_multipath_header (char * line, int len, const char 
* format)
 }
 
 int
-snprint_multipath (char * line, int len, const char * format,
-const struct multipath * mpp, int pad)
+_snprint_multipath (const struct gen_multipath * gmp,
+   char * line, int len, const char * format, int pad)
 {
char * c = line;   /* line cursor */
char * s = line;   /* for padding */
@@ -869,7 +870,7 @@ snprint_multipath (char * line, int len, const char * 
format,
if (!(data = mpd_lookup(*f)))
continue;
 
-   data->snprint(buff, MAX_FIELD_LEN, mpp);
+   gmp->ops->snprint(gmp, buff, MAX_FIELD_LEN, *f);
PRINT(c, TAIL, "%s", buff);
if (pad)
PAD(data->width);
@@ -912,8 +913,8 @@ snprint_path_header (char * line, int len, const char * 
format)
 }
 
 int
-snprint_path (char * line, int len, const char * format,
-const struct path * pp, int pad)
+_snprint_path (const struct gen_path * gp, char * line, int len,
+  const char * format, int pad)
 {
char * c = line;   /* line cursor */
char * s = line;   /* for padding */
@@ -936,7 +937,7 @@ snprint_path (char * line, int len, const char * format,
if (!(data = pd_lookup(*f)))
continue;
 
-   data->snprint(buff, MAX_FIELD_LEN, pp);
+   gp->ops->snprint(gp, buff, MAX_FIELD_LEN, *f);
PRINT(c, TAIL, "%s", buff);
if (pad)
PAD(data->width);
@@ -947,8 +948,8 @@ snprint_path (char * line, int len, const char * format,
 }
 
 int
-snprint_pathgroup (char * line, int len, char * format,
-  const struct pathgroup * pgp)
+_snprint_pathgroup (const struct gen_pathgroup * ggp, char * line, int len,
+   char * format)
 {
char * c = line;   /* line cursor */
char * s = line;   /* for padding */
@@ -971,7 +972,7 @@ snprint_pathgroup (char * line, int len, char * format,
if (!(data = pgd_lookup(*f)))
continue;
 
-   data->snprint(buff, MAX_FIELD_LEN, pgp);
+   ggp->ops->snprint(ggp, buff, MAX_FIELD_LEN, *f);
PRINT(c, TAIL, "%s", buff);
PAD(data->width);
} while (*f++);
@@ -979,8 +980,10 @@ snprint_pathgroup (char * line, int len, char * format,
__endline(line, len, c);
return (c - line);
 }
+#define snprint_pathgroup(line, len, fmt, pgp) \
+   _snprint_pathgroup(dm_pathgroup_to_gen(pgp), line, len, fmt)
 
-void print_multipath_topology(struct multipat

[dm-devel] [PATCH v2 01/23] multipath(d)/Makefile: add explicit dependency on libraries

2018-03-05 Thread Martin Wilck
Otherwise the binaries won't be re-linked if the libraries change.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 multipath/Makefile  | 2 +-
 multipathd/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/multipath/Makefile b/multipath/Makefile
index 654568af3576..0828a8f72db7 100644
--- a/multipath/Makefile
+++ b/multipath/Makefile
@@ -14,7 +14,7 @@ OBJS = main.o
 
 all: $(EXEC)
 
-$(EXEC): $(OBJS)
+$(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so
$(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
$(GZIP) $(EXEC).8 > $(EXEC).8.gz
$(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
diff --git a/multipathd/Makefile b/multipathd/Makefile
index 251690ec5e2a..4c9d29634160 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -28,7 +28,7 @@ EXEC = multipathd
 
 all : $(EXEC)
 
-$(EXEC): $(OBJS)
+$(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) $(LIBDEPS)
$(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
-- 
2.16.1

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


[dm-devel] [PATCH v2 16/23] libmultipath/print: add "%G - foreign" wildcard

2018-03-05 Thread Martin Wilck
This adds a format field to identify foreign maps as such, and
uses it in default-formatted topology output (generic_style()).

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/generic.c |  2 +-
 libmultipath/print.c   | 14 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/libmultipath/generic.c b/libmultipath/generic.c
index 45012d0e1d95..6f7a2cdcad3e 100644
--- a/libmultipath/generic.c
+++ b/libmultipath/generic.c
@@ -32,7 +32,7 @@ int generic_style(const struct gen_multipath* gm,
gm->ops->snprint(gm, alias_buf, sizeof(alias_buf), 'n');
gm->ops->snprint(gm, wwid_buf, sizeof(wwid_buf), 'w');
 
-   n += snprintf(buf, len, "%%n %s%%d %%s",
+   n += snprintf(buf, len, "%%n %s[%%G]:%%d %%s",
  strcmp(alias_buf, wwid_buf) ? "(%w) " : "");
 
return (n < len ? n : len - 1);
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 01e7483e3e44..d5329942e795 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -341,6 +341,12 @@ snprint_multipath_rev (char * buff, size_t len, const 
struct multipath * mpp)
return snprintf(buff, len, "##");
 }
 
+static int
+snprint_multipath_foreign (char * buff, size_t len, const struct multipath * 
pp)
+{
+   return snprintf(buff, len, "%s", "--");
+}
+
 static int
 snprint_action (char * buff, size_t len, const struct multipath * mpp)
 {
@@ -620,6 +626,12 @@ snprint_path_checker (char * buff, size_t len, const 
struct path * pp)
return snprint_str(buff, len, c->name);
 }
 
+static int
+snprint_path_foreign (char * buff, size_t len, const struct path * pp)
+{
+   return snprintf(buff, len, "%s", "--");
+}
+
 struct multipath_data mpd[] = {
{'n', "name",  0, snprint_name},
{'w', "uuid",  0, snprint_multipath_uuid},
@@ -643,6 +655,7 @@ struct multipath_data mpd[] = {
{'v', "vend",  0, snprint_multipath_vend},
{'p', "prod",  0, snprint_multipath_prod},
{'e', "rev",   0, snprint_multipath_rev},
+   {'G', "foreign",   0, snprint_multipath_foreign},
{0, NULL, 0 , NULL}
 };
 
@@ -666,6 +679,7 @@ struct path_data pd[] = {
{'R', "host WWPN", 0, snprint_host_wwpn},
{'r', "target WWPN",   0, snprint_tgt_wwpn},
{'a', "host adapter",  0, snprint_host_adapter},
+   {'G', "foreign",   0, snprint_path_foreign},
{0, NULL, 0 , NULL}
 };
 
-- 
2.16.1

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


[dm-devel] [PATCH v2 14/23] libmultipath: print: use generic API for get_x_layout()

2018-03-05 Thread Martin Wilck
Introduce new functions _get_path_layout and _get_multipath_layout
using the new "generic" API to determine field widths, and map the
old API to them.

Furthermore, replace the boolean "header" by an enum with 3 possible
values. The new value LAYOUT_RESET_NOT allows calling the get_x_layout
function several times and determine the overall field width.

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/print.c | 73 
 libmultipath/print.h |  8 ++
 2 files changed, 65 insertions(+), 16 deletions(-)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 8701a3584859..01e7483e3e44 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -697,20 +697,48 @@ snprint_wildcards (char * buff, int len)
 }
 
 void
-get_path_layout (vector pathvec, int header)
+get_path_layout(vector pathvec, int header)
+{
+   vector gpvec = vector_convert(NULL, pathvec, struct path,
+ dm_path_to_gen);
+   _get_path_layout(gpvec,
+header ? LAYOUT_RESET_HEADER : LAYOUT_RESET_ZERO);
+   vector_free(gpvec);
+}
+
+static void
+reset_width(int *width, enum layout_reset reset, const char *header)
+{
+   switch (reset) {
+   case LAYOUT_RESET_HEADER:
+   *width = strlen(header);
+   break;
+   case LAYOUT_RESET_ZERO:
+   *width = 0;
+   break;
+   default:
+   /* don't reset */
+   break;
+   }
+}
+
+void
+_get_path_layout (const struct _vector *gpvec, enum layout_reset reset)
 {
int i, j;
char buff[MAX_FIELD_LEN];
-   struct path * pp;
+   const struct gen_path *gp;
 
for (j = 0; pd[j].header; j++) {
-   if (header)
-   pd[j].width = strlen(pd[j].header);
-   else
-   pd[j].width = 0;
 
-   vector_foreach_slot (pathvec, pp, i) {
-   pd[j].snprint(buff, MAX_FIELD_LEN, pp);
+   reset_width(&pd[j].width, reset, pd[j].header);
+
+   if (gpvec == NULL)
+   continue;
+
+   vector_foreach_slot (gpvec, gp, i) {
+   gp->ops->snprint(gp, buff, MAX_FIELD_LEN,
+pd[j].wildcard);
pd[j].width = MAX(pd[j].width, strlen(buff));
}
}
@@ -726,22 +754,35 @@ reset_multipath_layout (void)
 }
 
 void
-get_multipath_layout (vector mpvec, int header)
+get_multipath_layout (vector mpvec, int header) {
+   vector gmvec = vector_convert(NULL, mpvec, struct multipath,
+ dm_multipath_to_gen);
+   _get_multipath_layout(gmvec,
+header ? LAYOUT_RESET_HEADER : LAYOUT_RESET_ZERO);
+   vector_free(gmvec);
+}
+
+void
+_get_multipath_layout (const struct _vector *gmvec,
+   enum layout_reset reset)
 {
int i, j;
char buff[MAX_FIELD_LEN];
-   struct multipath * mpp;
+   const struct gen_multipath * gm;
 
for (j = 0; mpd[j].header; j++) {
-   if (header)
-   mpd[j].width = strlen(mpd[j].header);
-   else
-   mpd[j].width = 0;
 
-   vector_foreach_slot (mpvec, mpp, i) {
-   mpd[j].snprint(buff, MAX_FIELD_LEN, mpp);
+   reset_width(&mpd[j].width, reset, mpd[j].header);
+
+   if (gmvec == NULL)
+   continue;
+
+   vector_foreach_slot (gmvec, gm, i) {
+   gm->ops->snprint(gm, buff, MAX_FIELD_LEN,
+mpd[j].wildcard);
mpd[j].width = MAX(mpd[j].width, strlen(buff));
}
+   condlog(4, "%s: width %d", mpd[j].header, mpd[j].width);
}
 }
 
diff --git a/libmultipath/print.h b/libmultipath/print.h
index b8b9ecbd204f..7ba643892579 100644
--- a/libmultipath/print.h
+++ b/libmultipath/print.h
@@ -94,7 +94,15 @@ struct pathgroup_data {
int (*snprint)(char * buff, size_t len, const struct pathgroup * pgp);
 };
 
+enum layout_reset {
+   LAYOUT_RESET_NOT,
+   LAYOUT_RESET_ZERO,
+   LAYOUT_RESET_HEADER,
+};
+
+void _get_path_layout (const struct _vector *gpvec, enum layout_reset);
 void get_path_layout (vector pathvec, int header);
+void _get_multipath_layout (const struct _vector *gmvec, enum layout_reset);
 void get_multipath_layout (vector mpvec, int header);
 int snprint_path_header (char *, int, const char *);
 int snprint_multipath_header (char *, int, const char *);
-- 
2.16.1

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


[dm-devel] [PATCH v2 15/23] libmultipath: API for foreign multipath handling

2018-03-05 Thread Martin Wilck
Add an API for "foreign" multipaths. Foreign libraries are loaded
from ${multipath_dir}/libforeign-*.so, as we do for checkers.

Refer to "foreign.h" for details about the API itself. Like we do for
checkers, high-level multipath code isn't supposed to call the API directly,
but rather the wrapper functions declared in "foreign.h".

This API is used only for displaying information and for logging. An extension 
to
other functionality (such as monitoring or administration) might be feasible,
but is not planned.

Foreign libraries communicate with libmultipath through the API defined in
"foreign.h". The foreign library can implement multipath maps, pathgroups,
and paths as it likes, they just need to provide the simple interfaces
defined in "generic.h" to libmultipath. These interfaces are used in 
libmultipath's
"print" implementation to convey various bits of information to users. By
using the same interfaces for printing that libmultipath uses internally,
foreign library implementations can focus on the technical side without
worrying about output formatting compatibility.

Signed-off-by: Martin Wilck 
---
 libmultipath/Makefile  |   2 +-
 libmultipath/foreign.c | 602 +
 libmultipath/foreign.h | 322 ++
 3 files changed, 925 insertions(+), 1 deletion(-)
 create mode 100644 libmultipath/foreign.c
 create mode 100644 libmultipath/foreign.h

diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index 0099d9d6cc39..806aaa24f84e 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 dm-generic.o generic.o
+   io_err_stat.o dm-generic.o generic.o foreign.o
 
 all: $(LIBS)
 
diff --git a/libmultipath/foreign.c b/libmultipath/foreign.c
new file mode 100644
index ..72171840e995
--- /dev/null
+++ b/libmultipath/foreign.c
@@ -0,0 +1,602 @@
+/*
+  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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "vector.h"
+#include "debug.h"
+#include "util.h"
+#include "foreign.h"
+#include "structs.h"
+#include "structs_vec.h"
+#include "print.h"
+
+static vector foreigns;
+
+/* This protects vector foreigns */
+static pthread_rwlock_t foreign_lock = PTHREAD_RWLOCK_INITIALIZER;
+
+static void rdlock_foreigns(void)
+{
+   pthread_rwlock_rdlock(&foreign_lock);
+}
+
+static void wrlock_foreigns(void)
+{
+   pthread_rwlock_wrlock(&foreign_lock);
+}
+
+static void unlock_foreigns(void *unused)
+{
+   pthread_rwlock_unlock(&foreign_lock);
+}
+
+#define get_dlsym(foreign, sym, lbl)   \
+   do {\
+   foreign->sym =  dlsym(foreign->handle, #sym);   \
+   if (foreign->sym == NULL) { \
+   condlog(0, "%s: symbol \"%s\" not found in \"%s\"", \
+   __func__, #sym, foreign->name); \
+   goto lbl;   \
+   }   \
+   } while(0)
+
+static void free_foreign(struct foreign *fgn)
+{
+   struct context *ctx;
+
+   if (fgn == NULL)
+   return;
+
+   ctx = fgn->context;
+   fgn->context = NULL;
+   if (ctx != NULL)
+   fgn->cleanup(ctx);
+
+   if (fgn->handle != NULL)
+   dlclose(fgn->handle);
+   free(fgn);
+}
+
+void _cleanup_foreign(void)
+{
+   struct foreign *fgn;
+   int i;
+
+   if (foreigns == NULL)
+   return;
+
+   vector_foreach_slot_backwards(foreigns, fgn, i) {
+   vector_del_slot(foreigns, i);
+   free_foreign(fgn);
+   }
+   vector_free(foreigns);
+   foreigns = NULL;
+}
+
+void cleanup_foreign(void)
+{
+   wrlock_foreigns();
+   _cleanup

[dm-devel] [PATCH v2 10/23] libmultipath: add vector_free_const()

2018-03-05 Thread Martin Wilck
... to dispose of constant vectors (const struct _vector*).

Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/vector.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libmultipath/vector.h b/libmultipath/vector.h
index 5cfd4d060412..3f6e579ae19a 100644
--- a/libmultipath/vector.h
+++ b/libmultipath/vector.h
@@ -46,6 +46,7 @@ typedef struct _vector *vector;
 extern vector vector_alloc(void);
 extern void *vector_alloc_slot(vector v);
 extern void vector_free(vector v);
+#define vector_free_const(x) vector_free((vector)(long)(x))
 extern void free_strvec(vector strvec);
 extern void vector_set_slot(vector v, void *value);
 extern void vector_del_slot(vector v, int slot);
-- 
2.16.1

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


[dm-devel] [PATCH v2 21/23] libmultipath: foreign/nvme: implement path display

2018-03-05 Thread Martin Wilck
implement display of path information for NVMe foreign paths and maps.
With this patch, I get output like this for Linux NVMe soft targets:

nvme-submultipathd show topology
sys0:NQN:subsysname (uuid.96926ba3-b207-437c-902c-4a4df6538c3f) [nvme] nvme0n1 
NVMe,Linux,4.15.0-r
size=2097152 features='n/a' hwhandler='n/a' wp=rw
`-+- policy='n/a' prio=n/a status=n/a
  |- 0:1:1 nvme0c1n1 0:0 n/a n/a live
  |- 0:2:1 nvme0c2n1 0:0 n/a n/a live
  |- 0:3:1 nvme0c3n1 0:0 n/a n/a live
  `- 0:4:1 nvme0c4n1 0:0 n/a n/a live

multipathd show paths format '%G %d %i %o %z %m %N'
foreign dev   hcil  dev_st serial   multipath host WWNN
[nvme]  nvme0c1n1 0:1:1 live   1c2c86659503a02f nvme0n1   
rdma:traddr=192.168.201.101,trsvcid=4420
[nvme]  nvme0c2n1 0:2:1 live   1c2c86659503a02f nvme0n1   
rdma:traddr=192.168.202.101,trsvcid=4420
[nvme]  nvme0c3n1 0:3:1 live   1c2c86659503a02f nvme0n1   
rdma:traddr=192.168.203.101,trsvcid=4420
[nvme]  nvme0c4n1 0:4:1 live   1c2c86659503a02f nvme0n1   
rdma:traddr=192.168.204.101,trsvcid=4420

(admittedly, I abused the 'WWNN' wildcard here a bit to display information
which is helpful for NVMe over RDMA).

Signed-off-by: Martin Wilck 
---
 libmultipath/foreign/nvme.c | 334 ++--
 1 file changed, 320 insertions(+), 14 deletions(-)

diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c
index 32bd5c96c44a..235f75dd2add 100644
--- a/libmultipath/foreign/nvme.c
+++ b/libmultipath/foreign/nvme.c
@@ -25,42 +25,98 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include "vector.h"
 #include "generic.h"
 #include "foreign.h"
 #include "debug.h"
+#include "structs.h"
+#include "sysfs.h"
 
+static const char nvme_vendor[] = "NVMe";
+static const char N_A[] = "n/a";
 const char *THIS;
 
+struct nvme_map;
+struct nvme_path {
+   struct gen_path gen;
+   struct udev_device *udev;
+   struct udev_device *ctl;
+   struct nvme_map *map;
+   bool seen;
+};
+
+struct nvme_pathgroup {
+   struct gen_pathgroup gen;
+   vector pathvec;
+};
+
 struct nvme_map {
struct gen_multipath gen;
struct udev_device *udev;
struct udev_device *subsys;
dev_t devt;
+   /* Just one static pathgroup for NVMe for now */
+   struct nvme_pathgroup pg;
+   struct gen_pathgroup *gpg;
+   struct _vector pgvec;
+   vector pathvec;
+   int nr_live;
 };
 
-#define NAME_LEN 64 /* buffer length temp model name */
+#define NAME_LEN 64 /* buffer length for temp attributes */
 #define const_gen_mp_to_nvme(g) ((const struct nvme_map*)(g))
 #define gen_mp_to_nvme(g) ((struct nvme_map*)(g))
 #define nvme_mp_to_gen(n) &((n)->gen)
+#define const_gen_pg_to_nvme(g) ((const struct nvme_pathgroup*)(g))
+#define gen_pg_to_nvme(g) ((struct nvme_pathgroup*)(g))
+#define nvme_pg_to_gen(n) &((n)->gen)
+#define const_gen_path_to_nvme(g) ((const struct nvme_path*)(g))
+#define gen_path_to_nvme(g) ((struct nvme_path*)(g))
+#define nvme_path_to_gen(n) &((n)->gen)
+
+static void cleanup_nvme_path(struct nvme_path *path)
+{
+   condlog(5, "%s: %p %p", __func__, path, path->udev);
+   if (path->udev)
+   udev_device_unref(path->udev);
+   /* ctl is implicitly referenced by udev, no need to unref */
+   free(path);
+}
 
 static void cleanup_nvme_map(struct nvme_map *map)
 {
+   if (map->pathvec) {
+   struct nvme_path *path;
+   int i;
+
+   vector_foreach_slot_backwards(map->pathvec, path, i) {
+   condlog(5, "%s: %d %p", __func__, i, path);
+   cleanup_nvme_path(path);
+   vector_del_slot(map->pathvec, i);
+   }
+   }
+   vector_free(map->pathvec);
if (map->udev)
udev_device_unref(map->udev);
-   if (map->subsys)
-   udev_device_unref(map->subsys);
+   /* subsys is implicitly referenced by udev, no need to unref */
free(map);
 }
 
 static const struct _vector*
 nvme_mp_get_pgs(const struct gen_multipath *gmp) {
-   return NULL;
+   const struct nvme_map *nvme = const_gen_mp_to_nvme(gmp);
+
+   /* This is all used under the lock, no need to copy */
+   return &nvme->pgvec;
 }
 
 static void
 nvme_mp_rel_pgs(const struct gen_multipath *gmp, const struct _vector *v)
 {
+   /* empty */
 }
 
 static void rstrip(char *str)
@@ -75,7 +131,6 @@ static int snprint_nvme_map(const struct gen_multipath *gmp,
char *buff, int len, char wildcard)
 {
const struct nvme_map *nvm = const_gen_mp_to_nvme(gmp);
-   static const char nvme_vendor[] = "NVMe";
char fld[NAME_LEN];
const char *val;
 
@@ -92,6 +147,8 @@ static int snprint_nvme_map(const struct gen_multipath *gmp,
return snprintf(buff, len, "%s",
udev_device_get_sysattr_value(nvm->udev,

[dm-devel] [PATCH v2 22/23] multipathd: update path group prio in check_path

2018-03-05 Thread Martin Wilck
The previous patch "libmultipath: don't update path groups when printing"
removed the call to path_group_prio_update() in the printing code path.
To compensate for that, recalculate path group prio also when it's not
strictly necessary (i.e. if failback "manual" is set).

Signed-off-by: Martin Wilck 
---
 multipathd/main.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 465a1e291226..4abdd8f071c3 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -252,8 +252,9 @@ need_switch_pathgroup (struct multipath * mpp, int refresh)
struct path * pp;
unsigned int i, j;
struct config *conf;
+   int bestpg;
 
-   if (!mpp || mpp->pgfailback == -FAILBACK_MANUAL)
+   if (!mpp)
return 0;
 
/*
@@ -272,8 +273,11 @@ need_switch_pathgroup (struct multipath * mpp, int refresh)
if (!mpp->pg || VECTOR_SIZE(mpp->paths) == 0)
return 0;
 
-   mpp->bestpg = select_path_group(mpp);
+   bestpg = select_path_group(mpp);
+   if (mpp->pgfailback == -FAILBACK_MANUAL)
+   return 0;
 
+   mpp->bestpg = bestpg;
if (mpp->bestpg != mpp->nextpg)
return 1;
 
-- 
2.16.1

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


[dm-devel] [PATCH v2 02/23] libmultipath: remove unused "stdout helpers"

2018-03-05 Thread Martin Wilck
Signed-off-by: Martin Wilck 
Reviewed-by: Benjamin Marzinski 
---
 libmultipath/print.c | 26 --
 libmultipath/print.h |  5 -
 2 files changed, 31 deletions(-)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 65a98247a753..27636c35e5ff 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -1765,32 +1765,6 @@ void print_path(struct path *pp, char *style)
printf("%s", line);
 }
 
-void print_multipath(struct multipath *mpp, char *style)
-{
-   char line[MAX_LINE_LEN];
-
-   memset(&line[0], 0, MAX_LINE_LEN);
-   snprint_multipath(&line[0], MAX_LINE_LEN, style, mpp, 1);
-   printf("%s", line);
-}
-
-void print_pathgroup(struct pathgroup *pgp, char *style)
-{
-   char line[MAX_LINE_LEN];
-
-   memset(&line[0], 0, MAX_LINE_LEN);
-   snprint_pathgroup(&line[0], MAX_LINE_LEN, style, pgp);
-   printf("%s", line);
-}
-
-void print_map(struct multipath *mpp, char *params)
-{
-   if (mpp->size && params)
-   printf("0 %llu %s %s\n",
-mpp->size, TGT_MPATH, params);
-   return;
-}
-
 void print_all_paths(vector pathvec, int banner)
 {
print_all_paths_custo(pathvec, banner, PRINT_PATH_LONG);
diff --git a/libmultipath/print.h b/libmultipath/print.h
index b8c343679e15..734f43fd4cb6 100644
--- a/libmultipath/print.h
+++ b/libmultipath/print.h
@@ -119,10 +119,5 @@ int snprint_tgt_wwnn (char *, size_t, struct path *);
 int snprint_tgt_wwpn (char *, size_t, struct path *);
 
 void print_multipath_topology (struct multipath * mpp, int verbosity);
-void print_path (struct path * pp, char * style);
-void print_multipath (struct multipath * mpp, char * style);
-void print_pathgroup (struct pathgroup * pgp, char * style);
-void print_map (struct multipath * mpp, char * params);
 void print_all_paths (vector pathvec, int banner);
 void print_all_paths_custo (vector pathvec, int banner, char *fmt);
-void print_hwtable (vector hwtable);
-- 
2.16.1

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


Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Bart Van Assche
On Mon, 2018-03-05 at 21:47 +0100, Martin Wilck wrote:
> On Mon, 2018-03-05 at 19:18 +, Bart Van Assche wrote:
> > On Mon, 2018-03-05 at 20:14 +0100, Martin Wilck wrote:
> > > Unless you object, I'll repost your series rebased on mine.
> > 
> > Hello Martin,
> > 
> > Before you start working on that: has your patch series already been
> > posted
> > on the dm-devel mailing list?
> 
> Yes. "PATCH v2 00/20] Various multipath-tools fixes" ff.
> https://www.redhat.com/archives/dm-devel/2018-January/msg00219.html

Ah, thanks, but unfortunately these patches are no longer in my mailbox. I
pulled these from https://github.com/openSUSE/multipath-tools. I'm fine with
my patches being rebased on top of your series, whether or not the following
issues get addressed:
* Several patches that are on the upstream-queue branch introduce trailing
  whitespace.
* The macro FREE_CONST() should never have been introduced. Introducing such
  a macro namely introduces the risk of calling free() for a string constant,
  something that should never happen. Have you considered to declare
  dynamically allocated strings, e.g. the result of strdup(), as char *
  instead of const char * ? I think with that change the FREE_CONST() macro
  definitions can be removed again.

Thanks,

Bart.



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


Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Martin Wilck
On Mon, 2018-03-05 at 19:18 +, Bart Van Assche wrote:
> On Mon, 2018-03-05 at 20:14 +0100, Martin Wilck wrote:
> > Unless you object, I'll repost your series rebased on mine.
> 
> Hello Martin,
> 
> Before you start working on that: has your patch series already been
> posted
> on the dm-devel mailing list?

Yes. "PATCH v2 00/20] Various multipath-tools fixes" ff.
https://www.redhat.com/archives/dm-devel/2018-January/msg00219.html

Regards,
Martin

-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Bart Van Assche
On Mon, 2018-03-05 at 20:14 +0100, Martin Wilck wrote:
> Unless you object, I'll repost your series rebased on mine.

Hello Martin,

Before you start working on that: has your patch series already been posted
on the dm-devel mailing list?

Thanks,

Bart.





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


Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Martin Wilck
On Mon, 2018-03-05 at 18:09 +0100, Martin Wilck wrote:
> On Mon, 2018-03-05 at 17:53 +0100, Martin Wilck wrote:
> > On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> > > Pass the VPD page number to sgio_get_vpd() such that the page
> > > needed
> > > by the caller is queried instead of page 0x83. Fix the statement
> > > that
> > > computes the length of the page returned by do_inq(). Fix the
> > > return
> > > code check in the caller of sgio_get_vpd().
> > > 
> > > Signed-off-by: Bart Van Assche 
> > > ---
> > 
> > Bart, thanks for the patch. Please consider rebasing your work on
> > my
> > previously submitted patches which have already been positively
> > reviewed ([1], [2]):
> > 
> >  libmultipath: get_vpd_sgio: support VPD 0xc9
> >  libmultipath: sgio_get_vpd: add page argument
> >  libmultipath: fix return code of sgio_get_vpd()
> > 
> > Otherwise, ACK.
> 
> Sorry, I found a glitch.
> 
> With the change of the "len" calculation and the return value check,
> we
>   need to make sure sufficient data has been read:

Replying to self - this is actually not necessary, as we're looking at
the response buffer of a successful VPD INQUIRY, so we have to assume
that at least the header has been read correctly.

All we need to change is the return code and the respective comment,
because the function actually returns the number of INQUIRY bytes if
INQUIRY was successful (before my patch "libmultipath: fix return code
of sgio_get_vpd()", the function behaved rather strange, returning -1
on failure, 0 on success, and len > buffer length on buffer overflow).

Unless you object, I'll repost your series rebased on mine.

Martin

-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH 4/6] kpartx: Improve reliability of find_loop_by_file()

2018-03-05 Thread Martin Wilck
On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> Avoid that the strchr() call in this function examines uninitialized
> data on the stack. This patch avoids that Coverity reports the
> following:
> 
> CID 173252:  Error handling issues  (CHECKED_RETURN)
> "read(int, void *, size_t)" returns the number of bytes read, but
> it is ignored.
> 
> Signed-off-by: Bart Van Assche 

Reviewed-by: Martin Wilck 


> ---
>  kpartx/lopart.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/kpartx/lopart.c b/kpartx/lopart.c
> index 02b29e8cf91d..69c1eda1cc5c 100644
> --- a/kpartx/lopart.c
> +++ b/kpartx/lopart.c
> @@ -64,7 +64,7 @@ char *find_loop_by_file(const char *filename)
>   DIR *dir;
>   struct dirent *dent;
>   char dev[64], *found = NULL, *p;
> - int fd;
> + int fd, bytes_read;
>   struct stat statbuf;
>   struct loop_info loopinfo;
>   const char VIRT_BLOCK[] = "/sys/devices/virtual/block";
> @@ -86,14 +86,15 @@ char *find_loop_by_file(const char *filename)
>   if (fd < 0)
>   continue;
>  
> - if (read(fd, dev, sizeof(dev)) <= 0) {
> + bytes_read = read(fd, dev, sizeof(dev) - 1);
> + if (bytes_read <= 0) {
>   close(fd);
>   continue;
>   }
>  
>   close(fd);
>  
> - dev[sizeof(dev)-1] = '\0';
> + dev[bytes_read] = '\0';
>   p = strchr(dev, '\n');
>   if (p != NULL)
>   *p = '\0';

-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH] libmultipath: enable feature disable changed wwid by default

2018-03-05 Thread Martin Wilck
On Tue, 2018-02-27 at 08:34 +, Chongyun Wu wrote:
> enable feature disable changed wwid by default.
> 
> Signed-off-by: Chongyun Wu 
> ---
Acked-by: Martin Wilck 

>  libmultipath/defaults.h |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
> index c9e3411..2b270ca 100644
> --- a/libmultipath/defaults.h
> +++ b/libmultipath/defaults.h
> @@ -38,7 +38,7 @@
>  #define DEFAULT_FORCE_SYNC   0
>  #define DEFAULT_PARTITION_DELIM  NULL
>  #define DEFAULT_SKIP_KPARTX SKIP_KPARTX_OFF
> -#define DEFAULT_DISABLE_CHANGED_WWIDS 0
> +#define DEFAULT_DISABLE_CHANGED_WWIDS 1
>  #define DEFAULT_MAX_SECTORS_KB MAX_SECTORS_KB_UNDEF
>  #define DEFAULT_GHOST_DELAY GHOST_DELAY_OFF
>  


-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH] multipathd: fix inverted signal blocking logic

2018-03-05 Thread Martin Wilck
Hello Bart,

On Mon, 2018-03-05 at 16:27 +, Bart Van Assche wrote:
> On Sat, 2018-03-03 at 01:31 +0100, Martin Wilck wrote:
> > So, there's no reason not to block them, right? Is it expected
> > behavior
> > that a user running 'kill -USR2 $(pidof multipathd)' terminates the
> > process? Why do you think these signals should interrupt ppoll()
> > although the uxlsnr can't can't handle them? Isn't it sufficient
> > that
> > they're handled by the threads that are meant to do that?
> 
> Blocking all signals except the ones for which we installed a handler
> sounds
> weird to me. I think users expect daemons to process signals instead
> of
> blocking all but a specific set of signals. This is a rather
> philosophical
> argument and not an argument of which I think that it is strong
> enough to
> prevent this patch of being integrated in the upstream multipath-
> tools
> repository.

Thank you. Meanwhile, I found that this patch requires a change in the
"marginal paths" code. I'll post an official patch as update.

Regarding the philosophical discussion, may I remind you of your own
words from 534ec4c?

The POSIX standard mentions that the only way to guarantee that
signals are delivered to a specific thread is:
 * Block all signals before the first pthread_create() call.
 * Unblock signals from the thread that should receive signals.

If we unblock signals with a default disposition of "Term" for which we
have no handler, stray signals caught would terminate multipathd. I
don't think that's what we want. Of course we must react on
SIGINT/SIGTERM/SIGHUP in the way the user expects us to, but
terminating on other signals would be wrong.

Let's see if others have to say anything about this.

Martin

-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH 6/6] Introduce the ibmultipath/unaligned.h header file

2018-03-05 Thread Martin Wilck
On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> This patch avoids that Coverity reports the following for the code
> in libmultipath/prioritizers/alua_rtpg.c:
> 
>CID 173256:  Integer handling issues  (SIGN_EXTENSION)
> Suspicious implicit sign extension: "buf[0]" with type "unsigned
> char" (8 bits, unsigned) is promoted in "((buf[0] << 24) | (buf[1] <<
> 16) | (buf[2] << 8) | buf[3]) + 4" to type "int" (32 bits, signed),
> then sign-extended to type "unsigned long" (64 bits, unsigned).  If
> "((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]) + 4" is
> greater than 0x7FFF, the upper bits of the result will all be 1.
> 
> Signed-off-by: Bart Van Assche 

Reviewed-by: Martin Wilck 

-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Martin Wilck
On Mon, 2018-03-05 at 17:53 +0100, Martin Wilck wrote:
> On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> > Pass the VPD page number to sgio_get_vpd() such that the page
> > needed
> > by the caller is queried instead of page 0x83. Fix the statement
> > that
> > computes the length of the page returned by do_inq(). Fix the
> > return
> > code check in the caller of sgio_get_vpd().
> > 
> > Signed-off-by: Bart Van Assche 
> > ---
> 
> Bart, thanks for the patch. Please consider rebasing your work on my
> previously submitted patches which have already been positively
> reviewed ([1], [2]):
> 
>  libmultipath: get_vpd_sgio: support VPD 0xc9
>  libmultipath: sgio_get_vpd: add page argument
>  libmultipath: fix return code of sgio_get_vpd()
> 
> Otherwise, ACK.

Sorry, I found a glitch.

With the change of the "len" calculation and the return value check, we
  need to make sure sufficient data has been read:

@@ -1100,13 +1101,19 @@ get_vpd_sgio (int fd, int pg, char * str, int maxlen)
unsigned char buff[4096];
 
memset(buff, 0x0, 4096);
-   if (sgio_get_vpd(buff, 4096, fd, pg) <= 0) {
+   buff_len = sgio_get_vpd(buff, 4096, fd, pg);
+   if (buff_len < 0) {
condlog(3, "failed to issue vpd inquiry for pg%02x",
pg);
-   return -errno;
+   return errno != 0 ? -errno : -1;
}
 
-   if (buff[1] != pg) {
+   if (buff_len < 4) {
+   condlog(3, "vpd pg%02x error, short read", pg);
+   return -ENODATA;
+   }
+
+   if ( buff[1] != pg) {
condlog(3, "vpd pg%02x error, invalid vpd page %02x",
pg, buff[1]);
return -ENODATA;

As you can see I added also a small hunk that makes it explcicit that
we don't return 0 on failure by accident.

Regards,
Martin

-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd()

2018-03-05 Thread Martin Wilck
On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> Pass the VPD page number to sgio_get_vpd() such that the page needed
> by the caller is queried instead of page 0x83. Fix the statement that
> computes the length of the page returned by do_inq(). Fix the return
> code check in the caller of sgio_get_vpd().
> 
> Signed-off-by: Bart Van Assche 
> ---

Bart, thanks for the patch. Please consider rebasing your work on my
previously submitted patches which have already been positively
reviewed ([1], [2]):

 libmultipath: get_vpd_sgio: support VPD 0xc9
 libmultipath: sgio_get_vpd: add page argument
 libmultipath: fix return code of sgio_get_vpd()

Otherwise, ACK.

[1] https://www.redhat.com/archives/dm-devel/2018-January/msg00241.html
[2] https://www.redhat.com/archives/dm-devel/2018-January/msg00370.html

Martin

>  libmultipath/discovery.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> index d84715e15db1..780feb253797 100644
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -836,8 +836,9 @@ detect_alua(struct path * pp, struct config
> *conf)
>  
>  #define DEFAULT_SGIO_LEN 254
>  
> +/* Query VPD page @pg. Returns 0 upon success and -1 upon failure.
> */
>  static int
> -sgio_get_vpd (unsigned char * buff, int maxlen, int fd)
> +sgio_get_vpd (unsigned char * buff, int maxlen, int fd, int pg)
>  {
>   int len = DEFAULT_SGIO_LEN;
>  
> @@ -846,8 +847,8 @@ sgio_get_vpd (unsigned char * buff, int maxlen,
> int fd)
>   return -1;
>   }
>  retry:
> - if (0 == do_inq(fd, 0, 1, 0x83, buff, len)) {
> - len = buff[3] + (buff[2] << 8);
> + if (0 == do_inq(fd, 0, 1, pg, buff, len)) {
> + len = buff[3] + (buff[2] << 8) + 4;
>   if (len >= maxlen)
>   return len;
>   if (len > DEFAULT_SGIO_LEN)
> @@ -1099,7 +1100,7 @@ get_vpd_sgio (int fd, int pg, char * str, int
> maxlen)
>   unsigned char buff[4096];
>  
>   memset(buff, 0x0, 4096);
> - if (sgio_get_vpd(buff, 4096, fd) <= 0) {
> + if (sgio_get_vpd(buff, 4096, fd, pg) < 0) {
>   condlog(3, "failed to issue vpd inquiry for pg%02x",
>   pg);
>   return -errno;


-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH] multipathd: fix inverted signal blocking logic

2018-03-05 Thread Bart Van Assche
On Sat, 2018-03-03 at 01:31 +0100, Martin Wilck wrote:
> So, there's no reason not to block them, right? Is it expected behavior
> that a user running 'kill -USR2 $(pidof multipathd)' terminates the
> process? Why do you think these signals should interrupt ppoll()
> although the uxlsnr can't can't handle them? Isn't it sufficient that
> they're handled by the threads that are meant to do that?

Blocking all signals except the ones for which we installed a handler sounds
weird to me. I think users expect daemons to process signals instead of
blocking all but a specific set of signals. This is a rather philosophical
argument and not an argument of which I think that it is strong enough to
prevent this patch of being integrated in the upstream multipath-tools
repository.

Bart.



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


Re: [dm-devel] [PATCH 3/6] libmultipath, alloc_path_with_pathinfo(): Declare third argument const

2018-03-05 Thread Bart Van Assche
On Mon, 2018-03-05 at 17:18 +0100, Martin Wilck wrote:
> On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> > Since the third argument of this function is not modified inside that
> > function, declare it const.
> > 
> > Signed-off-by: Bart Van Assche 
> 
> ACK, but this hunk is part of my previously posted patch "libmultipath:
> const qualifier for wwid and alias", which includes some more changes
> along similar lines and is part of a larger patch set that tries to
> improve "const" usage in libmultipath.

Hello Martin,

If this patch duplicates some of your work then I'm fine with dropping this
patch.

Bart.



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


Re: [dm-devel] [PATCH 3/6] libmultipath, alloc_path_with_pathinfo(): Declare third argument const

2018-03-05 Thread Martin Wilck
On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> Since the third argument of this function is not modified inside that
> function, declare it const.
> 
> Signed-off-by: Bart Van Assche 

ACK, but this hunk is part of my previously posted patch "libmultipath:
const qualifier for wwid and alias", which includes some more changes
along similar lines and is part of a larger patch set that tries to
improve "const" usage in libmultipath.


> ---
>  libmultipath/discovery.c | 2 +-
>  libmultipath/discovery.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> index fe50ce5062ea..d84715e15db1 100644
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -34,7 +34,7 @@
>  
>  int
>  alloc_path_with_pathinfo (struct config *conf, struct udev_device
> *udevice,
> -   char *wwid, int flag, struct path
> **pp_ptr)
> +   const char *wwid, int flag, struct path
> **pp_ptr)
>  {
>   int err = PATHINFO_FAILED;
>   struct path * pp;
> diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
> index b151cc7a39a8..bd5e6678a26d 100644
> --- a/libmultipath/discovery.h
> +++ b/libmultipath/discovery.h
> @@ -38,7 +38,7 @@ int get_state (struct path * pp, struct config *
> conf, int daemon, int state);
>  int get_vpd_sgio (int fd, int pg, char * str, int maxlen);
>  int pathinfo (struct path * pp, struct config * conf, int mask);
>  int alloc_path_with_pathinfo (struct config *conf, struct
> udev_device *udevice,
> -   char *wwid, int flag, struct path
> **pp_ptr);
> +   const char *wwid, int flag, struct
> path **pp_ptr);
>  int store_pathinfo (vector pathvec, struct config *conf,
>   struct udev_device *udevice, int flag,
>   struct path **pp_ptr);

-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH 2/6] libmultipath, alloc_path_with_pathinfo(): Ensure that pp->wwid is '\0'-terminated

2018-03-05 Thread Martin Wilck
On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> Discovered by Coverity (CID 173257).
> 
> Signed-off-by: Bart Van Assche 

Reviewed-by: Martin Wilck 

> ---
>  libmultipath/discovery.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> index 4b31ddef23f0..fe50ce5062ea 100644
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -52,8 +52,8 @@ alloc_path_with_pathinfo (struct config *conf,
> struct udev_device *udevice,
>   if (!pp)
>   return PATHINFO_FAILED;
>  
> - if(wwid)
> - strncpy(pp->wwid, wwid, sizeof(pp->wwid));
> + if (wwid)
> + strlcpy(pp->wwid, wwid, sizeof(pp->wwid));
>  
>   if (safe_sprintf(pp->dev, "%s", devname)) {
>   condlog(0, "pp->dev too small");



-- 
Dr. Martin Wilck , 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

Re: [dm-devel] [PATCH 1/6] multipathd/main.c: Fix indentation

2018-03-05 Thread Martin Wilck
On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> This patch avoids that gcc reports the following:
> 
> main.c: In function 'uev_pathfail_check':
> main.c:1022:5: warning: this 'if' clause does not guard... [-
> Wmisleading-indentation]
>  if (!pp)
>  ^~
> main.c:1024:2: note: ...this statement, but the latter is
> misleadingly indented as if it were guarded by the 'if'
>   r = io_err_stat_handle_pathfail(pp);
>   ^
> 
> Signed-off-by: Bart Van Assche 

Reviewed-by: Martin Wilck 

> ---
>  multipathd/main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/multipathd/main.c b/multipathd/main.c
> index 27cf234623d0..ccbb0ad13d32 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -1020,8 +1020,8 @@ uev_pathfail_check(struct uevent *uev, struct
> vectors *vecs)
>   lock(&vecs->lock);
>   pthread_testcancel();
>   pp = find_path_by_devt(vecs->pathvec, devt);
> -if (!pp)
> -goto out_lock;
> + if (!pp)
> + goto out_lock;
>   r = io_err_stat_handle_pathfail(pp);
>   if (r)
>   condlog(3, "io_err_stat: %s: cannot handle pathfail
> uevent",

-- 
Dr. Martin Wilck , 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

[dm-devel] [PATCH AUTOSEL for 4.4 105/115] scsi: dh: add new rdac devices

2018-03-05 Thread Sasha Levin
From: Xose Vazquez Perez 

[ Upstream commit 4b3aec2bbbce1c35f50e7475a9fd78d24b9ea4ea ]

Add IBM 3542 and 3552, arrays: FAStT200 and FAStT500.

Add full STK OPENstorage family, arrays: 9176, D173, D178, D210, D220,
D240 and D280.

Add STK BladeCtlr family, arrays: B210, B220, B240 and B280.

These changes were done in multipath-tools time ago.

Cc: NetApp RDAC team 
Cc: Hannes Reinecke 
Cc: Christophe Varoqui 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Cc: device-mapper development 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/scsi_dh.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
index 4d655b568269..5711d58f9e81 100644
--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
{"IBM", "1815", "rdac", },
{"IBM", "1818", "rdac", },
{"IBM", "3526", "rdac", },
+   {"IBM", "3542", "rdac", },
+   {"IBM", "3552", "rdac", },
{"SGI", "TP9",  "rdac", },
{"SGI", "IS",   "rdac", },
-   {"STK", "OPENstorage D280", "rdac", },
+   {"STK", "OPENstorage",  "rdac", },
{"STK", "FLEXLINE 380", "rdac", },
+   {"STK", "BladeCtlr","rdac", },
{"SUN", "CSM",  "rdac", },
{"SUN", "LCSM100",  "rdac", },
{"SUN", "STK6580_6780", "rdac", },
-- 
2.14.1

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


[dm-devel] [PATCH AUTOSEL for 4.15 076/102] scsi: dh: add new rdac devices

2018-03-05 Thread Sasha Levin
From: Xose Vazquez Perez 

[ Upstream commit 4b3aec2bbbce1c35f50e7475a9fd78d24b9ea4ea ]

Add IBM 3542 and 3552, arrays: FAStT200 and FAStT500.

Add full STK OPENstorage family, arrays: 9176, D173, D178, D210, D220,
D240 and D280.

Add STK BladeCtlr family, arrays: B210, B220, B240 and B280.

These changes were done in multipath-tools time ago.

Cc: NetApp RDAC team 
Cc: Hannes Reinecke 
Cc: Christophe Varoqui 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Cc: device-mapper development 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/scsi_dh.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
index 2b785d09d5bd..b88b5dbbc444 100644
--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
{"IBM", "1815", "rdac", },
{"IBM", "1818", "rdac", },
{"IBM", "3526", "rdac", },
+   {"IBM", "3542", "rdac", },
+   {"IBM", "3552", "rdac", },
{"SGI", "TP9",  "rdac", },
{"SGI", "IS",   "rdac", },
-   {"STK", "OPENstorage D280", "rdac", },
+   {"STK", "OPENstorage",  "rdac", },
{"STK", "FLEXLINE 380", "rdac", },
+   {"STK", "BladeCtlr","rdac", },
{"SUN", "CSM",  "rdac", },
{"SUN", "LCSM100",  "rdac", },
{"SUN", "STK6580_6780", "rdac", },
-- 
2.14.1

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


[dm-devel] [PATCH AUTOSEL for 4.14 60/84] scsi: dh: add new rdac devices

2018-03-05 Thread Sasha Levin
From: Xose Vazquez Perez 

[ Upstream commit 4b3aec2bbbce1c35f50e7475a9fd78d24b9ea4ea ]

Add IBM 3542 and 3552, arrays: FAStT200 and FAStT500.

Add full STK OPENstorage family, arrays: 9176, D173, D178, D210, D220,
D240 and D280.

Add STK BladeCtlr family, arrays: B210, B220, B240 and B280.

These changes were done in multipath-tools time ago.

Cc: NetApp RDAC team 
Cc: Hannes Reinecke 
Cc: Christophe Varoqui 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Cc: device-mapper development 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/scsi_dh.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
index 84addee05be6..a5e30e9449ef 100644
--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
{"IBM", "1815", "rdac", },
{"IBM", "1818", "rdac", },
{"IBM", "3526", "rdac", },
+   {"IBM", "3542", "rdac", },
+   {"IBM", "3552", "rdac", },
{"SGI", "TP9",  "rdac", },
{"SGI", "IS",   "rdac", },
-   {"STK", "OPENstorage D280", "rdac", },
+   {"STK", "OPENstorage",  "rdac", },
{"STK", "FLEXLINE 380", "rdac", },
+   {"STK", "BladeCtlr","rdac", },
{"SUN", "CSM",  "rdac", },
{"SUN", "LCSM100",  "rdac", },
{"SUN", "STK6580_6780", "rdac", },
-- 
2.14.1

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


[dm-devel] [PATCH AUTOSEL for 4.9 206/219] scsi: dh: add new rdac devices

2018-03-05 Thread Sasha Levin
From: Xose Vazquez Perez 

[ Upstream commit 4b3aec2bbbce1c35f50e7475a9fd78d24b9ea4ea ]

Add IBM 3542 and 3552, arrays: FAStT200 and FAStT500.

Add full STK OPENstorage family, arrays: 9176, D173, D178, D210, D220,
D240 and D280.

Add STK BladeCtlr family, arrays: B210, B220, B240 and B280.

These changes were done in multipath-tools time ago.

Cc: NetApp RDAC team 
Cc: Hannes Reinecke 
Cc: Christophe Varoqui 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Cc: device-mapper development 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/scsi_dh.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
index 84addee05be6..a5e30e9449ef 100644
--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
{"IBM", "1815", "rdac", },
{"IBM", "1818", "rdac", },
{"IBM", "3526", "rdac", },
+   {"IBM", "3542", "rdac", },
+   {"IBM", "3552", "rdac", },
{"SGI", "TP9",  "rdac", },
{"SGI", "IS",   "rdac", },
-   {"STK", "OPENstorage D280", "rdac", },
+   {"STK", "OPENstorage",  "rdac", },
{"STK", "FLEXLINE 380", "rdac", },
+   {"STK", "BladeCtlr","rdac", },
{"SUN", "CSM",  "rdac", },
{"SUN", "LCSM100",  "rdac", },
{"SUN", "STK6580_6780", "rdac", },
-- 
2.14.1

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