[dm-devel] [PATCH v2 18/37] libmultipath: keep bindings in memory

2023-09-11 Thread mwilck
From: Martin Wilck Rather than opening the bindings file every time we must retrieve a binding, keep the contents in memory and write the file only if additions have been made. This simplifies the code, and should speed up alias lookups significantly. As a side effect, the aliases will be stored

[dm-devel] [PATCH v2 36/37] multipath-tools: allow prefixes with and w/o trailing slash

2023-09-11 Thread mwilck
From: Martin Wilck Add some logic to Makefile.inc that leads to the same result for "prefix=" and "prefix=/", or "prefix=/usr" and "prefix=/usr/". The logic does not work for multiple trailing slashes. It applies to all XYZ_prefix variables in Makefile.inc. Signed-off-by: Martin Wilck ---

[dm-devel] [PATCH v2 07/37] multipath-tools tests: add tests for get_user_friendly_alias()

2023-09-11 Thread mwilck
From: Martin Wilck Signed-off-by: Martin Wilck --- tests/alias.c | 441 ++ 1 file changed, 441 insertions(+) diff --git a/tests/alias.c b/tests/alias.c index 11f209e..7e443b0 100644 --- a/tests/alias.c +++ b/tests/alias.c @@ -81,6 +81,35 @@ int

[dm-devel] [PATCH v2 22/37] libmultipath: sort aliases by length and strcmp

2023-09-11 Thread mwilck
From: Martin Wilck The current sort order of aliases is alphabetical, which is does not match the actual order of aliases, where "mpathaa" > "mpathz". Change the ordering as follows: first sort by string length, then alphabetically. This will make sure that for aliases with the same prefix,

[dm-devel] [PATCH v2 33/37] multipath-tools: README.md: improve documentation for compile-time options

2023-09-11 Thread mwilck
From: Martin Wilck Signed-off-by: Martin Wilck --- README.md | 38 ++ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a7f994a..679e55b 100644 --- a/README.md +++ b/README.md @@ -89,9 +89,17 @@ The following

[dm-devel] [PATCH v2 35/37] multipath: add a missing newline

2023-09-11 Thread mwilck
From: Martin Wilck Signed-off-by: Martin Wilck --- multipath/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multipath/main.c b/multipath/main.c index 45e9745..b91289e 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -1025,7 +1025,7 @@ main (int argc, char

[dm-devel] [PATCH v2 16/37] libmultipath: update_bindings_file: don't log temp file name

2023-09-11 Thread mwilck
From: Martin Wilck The name of the temp file is unlikely to be helpful for users, and hard to predict in the unit test. Omit it. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git

[dm-devel] [PATCH v2 29/37] multipath-tools Makefile: sanitize paths for configuration files

2023-09-11 Thread mwilck
From: Martin Wilck Make the path to multipath.conf configurable, and use the same prefix by default for multipath.conf and multipath/conf.d. For "usr-merged" distributions with immutable /usr, we'll want to have the configuration under a different prefix. This can be achieved by using e.g.

[dm-devel] [PATCH v2 19/37] multipath-tools tests: fix alias tests

2023-09-11 Thread mwilck
From: Martin Wilck The different implementation of get_user_friendly_alias() and its helpers necessitates changes in the unit tests. It would be nice if it didn't, but the unit tests are too closely bound to the implementation to make this possible. - The bindings table is held in memory in

[dm-devel] [PATCH v2 34/37] libmultipath: print built-in values for deprecated options

2023-09-11 Thread mwilck
From: Martin Wilck In the error messages we print when a deprecated option is encountered, print the compile-time value of the option. Signed-off-by: Martin Wilck --- libmultipath/dict.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libmultipath/dict.c

[dm-devel] [PATCH v2 21/37] libmultipath: adapt to new semantics of dm_get_uuid()

2023-09-11 Thread mwilck
From: Martin Wilck dm_get_uuid() will return 1 for non-existing maps. Thus we don't need to call dm_map_present() any more in alias_already_taken(). This changes our semantics: previously we'd avoid using an alias for which dm_get_uuid() had failed. Now we treat failure in dm_get_uuid() as

[dm-devel] [PATCH v2 37/37] libmultipath: deprecate bindings_file, wwids_file, prkeys_file

2023-09-11 Thread mwilck
From: Martin Wilck The options bindings_file, wwids_file, and prkeys_file have been deprecated since cb4d6db ("libmultipath: deprecate file and directory config options") (multipath-tools 0.8.8). Deprecate and ignore them now. Signed-off-by: Martin Wilck --- libmultipath/alias.c

[dm-devel] [PATCH v2 23/37] multipath-tools tests: fix alias test after sort order change

2023-09-11 Thread mwilck
From: Martin Wilck Signed-off-by: Martin Wilck --- tests/alias.c | 30 -- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/tests/alias.c b/tests/alias.c index d1cc487..8ed95d7 100644 --- a/tests/alias.c +++ b/tests/alias.c @@ -932,16 +932,15 @@ static

[dm-devel] [PATCH v2 30/37] multipath-tools: add compile time configuration for "/etc/multipath"

2023-09-11 Thread mwilck
From: Martin Wilck Instead of hard-conding "/etc/multipath" as the path for the state files "bindings", "prkeys", and "wwids", make this path configurable via the "statedir" compile-time option. The default is currently still /etc, it might change to /var/lib or similar in the future.

[dm-devel] [PATCH v2 10/37] multipath-tools test: use mock_bindings_file() consistently

2023-09-11 Thread mwilck
From: Martin Wilck Further improve test readablity. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- tests/alias.c | 178 +- 1 file changed, 76 insertions(+), 102 deletions(-) diff --git a/tests/alias.c b/tests/alias.c index

[dm-devel] [PATCH v2 28/37] multipath-tools tests: mock pthread_mutex_{lock, unlock}

2023-09-11 Thread mwilck
From: Martin Wilck If some test fails with a lock held, cmocka doesn't deal well with pthread_cleanup_pop(). Such tests can cause deadlock with the locking primitives in the alias code, because locks don't get properly unlocked. Just mock the lock/unlock functions and generate an error if they

[dm-devel] [PATCH v2 20/37] libmultipath: dm_get_uuid(): return emtpy UUID for non-existing maps

2023-09-11 Thread mwilck
From: Martin Wilck libdevmapper will most probably not return a UUID for non-existing maps anyway. But it's cheap to double-check here. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/devmapper.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-)

[dm-devel] [PATCH v2 25/37] multipath-tools tests: adapt alias tests for total ordering

2023-09-11 Thread mwilck
From: Martin Wilck The "unsorted" test fail now, and are removed. The algorithm is now better at finding "gaps". Signed-off-by: Martin Wilck --- tests/alias.c | 88 --- 1 file changed, 14 insertions(+), 74 deletions(-) diff --git

[dm-devel] [PATCH v2 31/37] multipath-tools man pages: generate with correct paths

2023-09-11 Thread mwilck
From: Martin Wilck Generate the man pages using the compile-time settings for paths to multipath.conf etc. Add a paragraph about the CONFIGDIR (/etc/multipath/conf.d) and the drop-in configuration files in the multipath.conf man page. Also, make sure all generated man pages and other files are

[dm-devel] [PATCH v2 17/37] libmultipath: alias.c: factor out read_binding()

2023-09-11 Thread mwilck
From: Martin Wilck This way we can test the parsing of input lines from the bindings file more easily. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 58 ++-- 1 file changed, 40 insertions(+), 18 deletions(-)

[dm-devel] [PATCH v2 32/37] libdmmp/Makefile: fix bug in install section

2023-09-11 Thread mwilck
From: Martin Wilck Signed-off-by: Martin Wilck --- libdmmp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdmmp/Makefile b/libdmmp/Makefile index 078eca8..172ba04 100644 --- a/libdmmp/Makefile +++ b/libdmmp/Makefile @@ -44,7 +44,7 @@ install:

[dm-devel] [PATCH v2 05/37] libmultipath: lookup_binding: add comment about the algorithm

2023-09-11 Thread mwilck
From: Martin Wilck When I read this code, I always get confused. Adding comments to explain the algorithm. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 35 +++ 1 file changed, 35 insertions(+) diff --git

[dm-devel] [PATCH v2 26/37] multipath-tools tests: add test for ordering of bindings

2023-09-11 Thread mwilck
From: Martin Wilck As the assignment of free aliases now relies on the bindings being properly sorted, add some unit tests to make sure the sorting algorithm works. --- tests/alias.c | 212 +- 1 file changed, 209 insertions(+), 3 deletions(-)

[dm-devel] [PATCH v2 15/37] libmultipath: update_bindings_file: use a single write()

2023-09-11 Thread mwilck
From: Martin Wilck Save code and syscalls by assembling the content in memory first. write() may return less bytes written than expected. Deal with it. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 26 +- 1 file changed, 17

[dm-devel] [PATCH v2 24/37] libmultipath: simplify get_free_id() assuming total ordering

2023-09-11 Thread mwilck
From: Martin Wilck If we can assume that the bindings array is totally ordered for every prefix, which the previous patch guarantees, the search for a free ID can be simplified. Signed-off-by: Martin Wilck --- libmultipath/alias.c | 87 ++-- 1 file

[dm-devel] [PATCH v2 11/37] libmultipath: add global variable for current bindings

2023-09-11 Thread mwilck
From: Martin Wilck Add a variable global_bindings that holds the currently active vector of bindings. This variable is freed at program exit. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 11 +-- libmultipath/alias.h

[dm-devel] [PATCH v2 13/37] libmultipath: alias.c: move bindings related code up

2023-09-11 Thread mwilck
From: Martin Wilck No code changes, just moving code. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 239 ++- 1 file changed, 120 insertions(+), 119 deletions(-) diff --git a/libmultipath/alias.c

[dm-devel] [PATCH v2 06/37] multipath-tools test: simplify debugging for condlog mismatch

2023-09-11 Thread mwilck
From: Martin Wilck If there's a mismatch between expected and actual log message, print both messages. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- tests/test-log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test-log.c b/tests/test-log.c

[dm-devel] [PATCH v2 14/37] libmultipath: update_bindings_file: take filename argument

2023-09-11 Thread mwilck
From: Martin Wilck This function just uses the file name, no other configuration parameters. Also, pass the Bindings argument first to use the same convention as the other functions in this file. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 12

[dm-devel] [PATCH v2 04/37] libmultipath: never allocate an alias that's already taken

2023-09-11 Thread mwilck
From: Martin Wilck If the bindings file is changed in a way that multipathd can't handle (e.g. by swapping the aliases of two maps), multipathd must not try to re-use an alias that is already used by another map. Creating or renaming a map with such an alias will fail. We already avoid this for

[dm-devel] [PATCH v2 01/37] libmultipath: sysfs_set_scsi_tmo: do nothing for ACT_DRY_RUN

2023-09-11 Thread mwilck
From: Martin Wilck "multipath -d" might change sysfs timeouts of SCSI devices. Make sure it doesn't. Signed-off-by: Martin Wilck Cc: Jehan Singh Reviewed-by: Benjamin Marzinski --- libmultipath/configure.c | 4 ++-- libmultipath/discovery.c | 3 +++ 2 files changed, 5 insertions(+), 2

[dm-devel] [PATCH v2 12/37] libmultipath: rename fix_bindings_file() to update_bindings_file()

2023-09-11 Thread mwilck
From: Martin Wilck We will use this function in a more generic way, give it a more generic name. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libmultipath/alias.c

[dm-devel] [PATCH v2 08/37] multipath-tools test: consistent use of macros in alias test

2023-09-11 Thread mwilck
From: Martin Wilck Use the macros introduced with the tests for get_user_friendly_alias() also in the previously existing tests. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- tests/alias.c | 80 --- 1 file changed, 38

[dm-devel] [PATCH v2 03/37] libmultipath: unify use_existing_alias() and get_user_friendly_alias()

2023-09-11 Thread mwilck
From: Martin Wilck These functions are only called from select_alias(). The logic is more obvious when unified in a single function. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/alias.c | 82 -- libmultipath/alias.h

[dm-devel] [PATCH v2 09/37] multipath-tools tests: convert mock_{failed, used}_alias to macros

2023-09-11 Thread mwilck
From: Martin Wilck This way we can further improve readability of the individual test cases. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- tests/alias.c | 92 +-- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git

[dm-devel] [PATCH v2 02/37] libmultipath: add alias_already_taken()

2023-09-11 Thread mwilck
From: Martin Wilck Factor out a trivial helper function. Signed-off-by: Martin Wilck --- libmultipath/alias.c | 32 +++- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/libmultipath/alias.c b/libmultipath/alias.c index c0139a2..83ded88 100644 ---

[dm-devel] [PATCH v2 00/37] multipath-tools: user-friendly names rework

2023-09-11 Thread mwilck
From: Martin Wilck This patch set contains a two-step rework of the user-friendly names code. Patch 2-5 change the current code such that it (well, almost) never attempts to use an alias that is currently in use by another map. We already have some checks for this, but they don't cover all

Re: [dm-devel] [PATCH 18/21] libmultipath: keep bindings in memory

2023-09-11 Thread Benjamin Marzinski
On Mon, Sep 11, 2023 at 08:25:05AM +0200, Martin Wilck wrote: > On Fri, 2023-09-08 at 12:22 -0500, Benjamin Marzinski wrote: > > On Thu, Sep 07, 2023 at 10:43:27PM +0200, Martin Wilck wrote:  > > > Our bindings list is now partially sorted, which is an improvement > > > wrt > > > the previous

Re: [dm-devel] [PATCH v15 04/12] block: add emulation for copy

2023-09-11 Thread Nitesh Shetty
On 11/09/23 09:39AM, Hannes Reinecke wrote: On 9/11/23 09:09, Nitesh Shetty wrote: On Fri, Sep 08, 2023 at 08:06:38AM +0200, Hannes Reinecke wrote: On 9/6/23 18:38, Nitesh Shetty wrote: For the devices which does not support copy, copy emulation is added. It is required for in-kernel users

[dm-devel] [PATCH v6 24/45] dm zoned: dynamically allocate the dm-zoned-meta shrinker

2023-09-11 Thread Qi Zheng
In preparation for implementing lockless slab shrink, use new APIs to dynamically allocate the dm-zoned-meta shrinker, so that it can be freed asynchronously via RCU. Then it doesn't need to wait for RCU read-side critical section when releasing the struct dmz_metadata. Signed-off-by: Qi Zheng

[dm-devel] [PATCH v6 23/45] dm: dynamically allocate the dm-bufio shrinker

2023-09-11 Thread Qi Zheng
In preparation for implementing lockless slab shrink, use new APIs to dynamically allocate the dm-bufio shrinker, so that it can be freed asynchronously via RCU. Then it doesn't need to wait for RCU read-side critical section when releasing the struct dm_bufio_client. Signed-off-by: Qi Zheng

Re: [dm-devel] [PATCH v15 09/12] dm: Add support for copy offload

2023-09-11 Thread Hannes Reinecke
On 9/11/23 09:07, Nitesh Shetty wrote: On Fri, Sep 08, 2023 at 08:13:37AM +0200, Hannes Reinecke wrote: On 9/6/23 18:38, Nitesh Shetty wrote: Before enabling copy for dm target, check if underlying devices and dm target support copy. Avoid split happening inside dm target. Fail early if the

Re: [dm-devel] [PATCH v15 04/12] block: add emulation for copy

2023-09-11 Thread Hannes Reinecke
On 9/11/23 09:09, Nitesh Shetty wrote: On Fri, Sep 08, 2023 at 08:06:38AM +0200, Hannes Reinecke wrote: On 9/6/23 18:38, Nitesh Shetty wrote: For the devices which does not support copy, copy emulation is added. It is required for in-kernel users like fabrics, where file descriptor is not

Re: [dm-devel] [PATCH v15 04/12] block: add emulation for copy

2023-09-11 Thread Nitesh Shetty
On Fri, Sep 08, 2023 at 08:06:38AM +0200, Hannes Reinecke wrote: > On 9/6/23 18:38, Nitesh Shetty wrote: > > For the devices which does not support copy, copy emulation is added. > > It is required for in-kernel users like fabrics, where file descriptor is > > not available and hence they can't

Re: [dm-devel] [PATCH v15 09/12] dm: Add support for copy offload

2023-09-11 Thread Nitesh Shetty
On Fri, Sep 08, 2023 at 08:13:37AM +0200, Hannes Reinecke wrote: > On 9/6/23 18:38, Nitesh Shetty wrote: > > Before enabling copy for dm target, check if underlying devices and > > dm target support copy. Avoid split happening inside dm target. > > Fail early if the request needs split, currently

Re: [dm-devel] [PATCH 18/21] libmultipath: keep bindings in memory

2023-09-11 Thread Martin Wilck
On Fri, 2023-09-08 at 12:22 -0500, Benjamin Marzinski wrote: > On Thu, Sep 07, 2023 at 10:43:27PM +0200, Martin Wilck wrote:  > > Our bindings list is now partially sorted, which is an improvement > > wrt > > the previous situation. "missing the gap" is not really an awful > > problem [*]. Perhaps