Re: [dm-devel] [PATCH] multipathd: fix missing persistent reseravtion for active path

2021-09-10 Thread lixiaokeng
On 2021/9/11 0:17, Martin Wilck wrote: > Hello lixiaokeng, > > thanks for your patch. > > On Fri, 2021-09-10 at 20:31 +0800, lixiaokeng wrote: >> There are two paths(sucu as sda and adb) for one LUN. The two >> paths log in, but before the two uevents have been processed >> (for example there

Re: [dm-devel] [PATCH] multipathd: fix missing persistent reseravtion for active path

2021-09-10 Thread Martin Wilck
Hello lixiaokeng, thanks for your patch. On Fri, 2021-09-10 at 20:31 +0800, lixiaokeng wrote: > There are two paths(sucu as sda and adb) for one LUN. The two > paths log in, but before the two uevents have been processed > (for example there are many uevent), users use multipathd add > path

[dm-devel] [PATCH 02/35] libmultipath: add trylock() helper

2021-09-10 Thread mwilck
From: Martin Wilck Add a small helper. Signed-off-by: Martin Wilck --- libmultipath/lock.h | 5 + 1 file changed, 5 insertions(+) diff --git a/libmultipath/lock.h b/libmultipath/lock.h index a170efe..d99eedb 100644 --- a/libmultipath/lock.h +++ b/libmultipath/lock.h @@ -12,6 +12,11 @@

[dm-devel] [PATCH 25/35] multipathd: use strbuf in cli_handler functions

2021-09-10 Thread mwilck
From: Martin Wilck This allows us to simplify callers by not having to track the reply length separately. Signed-off-by: Martin Wilck --- multipathd/cli.c | 7 +- multipathd/cli.h | 6 +- multipathd/cli_handlers.c | 316 +++---

[dm-devel] [PATCH 13/35] multipathd: cli.c: use ESRCH for "command not found"

2021-09-10 Thread mwilck
From: Martin Wilck EAGAIN is too generic, and doesn't fit semantically either. ESRCH in't used anywhere else in our code. Signed-off-by: Martin Wilck --- multipathd/cli.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/multipathd/cli.c b/multipathd/cli.c index

[dm-devel] [PATCH 05/35] libmultipath: improve cleanup of uevent queues on exit

2021-09-10 Thread mwilck
From: Martin Wilck uevents listed on merge_node must be cleaned up, too. uevents cancelled while being serviced and temporary queues, likewise. The global uevq must be cleaned out in the uevent listener thread, because it might have added events after the dispatcher thread had already finished.

[dm-devel] [PATCH 14/35] multipathd: add "force_reconfigure" option

2021-09-10 Thread mwilck
From: Martin Wilck Since e3270f7 ("multipathd: use weaker "force_reload" at startup"), (multipath-tools 0.7.0), we only reload those maps that must be reloaded during startup. "multipath reconfigure", OTOH, reloads every map, which may take a long time on systems with lots of storage devices, as

[dm-devel] [PATCH 15/35] multipathd: uxlsnr: avoid stalled clients during reconfigure

2021-09-10 Thread mwilck
From: Martin Wilck Since 47cc1d3 ("multipathd: fix client response for socket activation"), we hold back clients while reconfigure is running. The idea of 47cc1d3 was to fix the behavior during initial start up. When multipathd reconfigures itself during runtime, and the reconfiguration takes a

[dm-devel] [PATCH 12/35] multipathd: add and set cli_handlers in a single step

2021-09-10 Thread mwilck
From: Martin Wilck Modify set_handler_callback() such that a missing slot is created if no matching slot is found. This way, we can skip the initialization with NULL handlers on startup. Signed-off-by: Martin Wilck --- multipathd/cli.c | 85 +++-

[dm-devel] [PATCH 28/35] multipathd: uxlsnr: move handler execution to separate function

2021-09-10 Thread mwilck
From: Martin Wilck Move the actual execution of the handler out of parse_cmd(). For now, we do it in uxsock_trigger(). Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 47 - 1 file changed, 29 insertions(+), 18 deletions(-) diff --git

[dm-devel] [PATCH 34/35] multipathd: uxlsnr: drop client_lock

2021-09-10 Thread mwilck
From: Martin Wilck The list of clients is never changed anywhere except in uxsock_listen(). No need to lock. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 21 ++--- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c

[dm-devel] [PATCH 35/35] multipathd: uxclt: allow client mode for non-root, too

2021-09-10 Thread mwilck
From: Martin Wilck The server checks for root permissions anyway. "multipathd -k" should work for ordinary users as long as no priviledged commands are executed. Signed-off-by: Martin Wilck --- multipathd/main.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git

[dm-devel] [PATCH 32/35] multipathd: uxlsnr: add timeout handling

2021-09-10 Thread mwilck
From: Martin Wilck Our ppoll() call needs to wake up when a client request times out. This logic can be added by determining the first client that's about to time out. The logic in handle_client() will then cause a timeout reply to be sent to the client. This is more client-friendly as the

[dm-devel] [PATCH 33/35] multipathd: uxlsnr: use poll loop for sending, too

2021-09-10 Thread mwilck
From: Martin Wilck send_packet() may busy-loop. By polling for POLLOUT, we can avoid that, even if it's very unlikely in practice. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 39 --- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git

[dm-devel] [PATCH 07/35] multipathd: improve delayed reconfigure

2021-09-10 Thread mwilck
From: Martin Wilck When a reconfigure operation is requested, either by the admin or by some condition multipathd encounters, the current code attempts to set DAEMON_CONFIGURE state and gives up after a second if it doesn't succeed. Apart from shutdown, this happens only if multipathd is either

[dm-devel] [PATCH 23/35] multipathd: uxlsnr: move client handling to separate function

2021-09-10 Thread mwilck
From: Martin Wilck No functional changes at this point. handle_client() will become the state machine for handling client requests. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 67 ++--- 1 file changed, 32 insertions(+), 35 deletions(-) diff

[dm-devel] [PATCH 21/35] multipathd: move parse_cmd() to uxlsnr.c

2021-09-10 Thread mwilck
From: Martin Wilck parse_cmd() does more than the name says - it parses, executes handlers, and even provides reply strings for some cases. This doesn't work well with the state machine idea. Thus move it to uxlsnr.c, where later patches will move some functionality elsewhere. No functional

[dm-devel] [PATCH 27/35] multipathd: uxlsnr: pass struct client to uxsock_trigger() and parse_cmd()

2021-09-10 Thread mwilck
From: Martin Wilck As a next step towards the state machine, give the handler functions access to the state of the client connection. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 61 + 1 file changed, 29 insertions(+), 32 deletions(-) diff

[dm-devel] [PATCH 01/35] libmultipath: add timespeccmp() utility function

2021-09-10 Thread mwilck
From: Martin Wilck Add a small utility that will be used in later patches. Signed-off-by: Martin Wilck --- libmultipath/libmultipath.version | 5 + libmultipath/time-util.c | 12 libmultipath/time-util.h | 1 + 3 files changed, 18 insertions(+) diff --git

[dm-devel] [PATCH 04/35] libmultipath: print: add __snprint_config()

2021-09-10 Thread mwilck
From: Martin Wilck exactly like snprint_config(), but takes a struct strbuf * as argument. Signed-off-by: Martin Wilck --- libmultipath/libmultipath.version | 5 + libmultipath/print.c | 34 +-- libmultipath/print.h | 2 ++ 3 files

[dm-devel] [PATCH 10/35] multipathd: add prototype for cli_handler functions

2021-09-10 Thread mwilck
From: Martin Wilck Use a typedef instead of spelling out the function type everywhere. Signed-off-by: Martin Wilck --- multipathd/cli.c | 6 +++--- multipathd/cli.h | 10 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/multipathd/cli.c b/multipathd/cli.c index

[dm-devel] [PATCH 24/35] multipathd: uxlsnr: use main poll loop for receiving

2021-09-10 Thread mwilck
From: Martin Wilck As a first step towards our state machine, avoid the call to read_all() via recv_packet_from_client(). handle_client() is now invoked twice for the same connection. The first time it reads the command length, and later on it reads the command itself piece-wise, as sent by the

[dm-devel] [PATCH 19/35] multipathd: uxlsnr: data structure for stateful client connection

2021-09-10 Thread mwilck
From: Martin Wilck Currently the uxlsnr handles each client request (receive requset - handle request - respond) in a single loop iteration. This has severe disadvantages. In particular, the code may wait in poll() called from read_all(), or wait for the vecs lock, while other clients are ready

[dm-devel] [PATCH 17/35] multipathd: uxlsnr: use symbolic values for pollfd indices

2021-09-10 Thread mwilck
From: Martin Wilck Avoid hardcoding the indices as 0, 1, 2... Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c index 7e88538..6506109 100644 ---

[dm-devel] [PATCH 30/35] multipathd: uxlsnr: merge uxsock_trigger() into state machine

2021-09-10 Thread mwilck
From: Martin Wilck This patch sets up the bulk of the state machine. The idea is to fall through the case labels as long as possible (when steps succeed) and return to the caller if either an error occurs, or it becomes necessary to wait for some pollable condition. While doing this, switch to

[dm-devel] [PATCH 29/35] multipathd: uxlsnr: use parser to determine non-root commands

2021-09-10 Thread mwilck
From: Martin Wilck Rather than using a separate poor-man's parser for checking root commands, use the real parser. It will return "LIST" as first verb for the read-only commands that non-root users may execute. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 27

[dm-devel] [PATCH 09/35] multipathd: cli_del_map: fix reply for delayed action

2021-09-10 Thread mwilck
From: Martin Wilck Return code 2 from ev_remove_map means that a delayed remove has been started, which is not the same as failure. Signed-off-by: Martin Wilck --- multipathd/cli_handlers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/multipathd/cli_handlers.c

[dm-devel] [PATCH 22/35] multipathd: uxlsnr: remove check_timeout()

2021-09-10 Thread mwilck
From: Martin Wilck This function just prints a warning, anyway. If this warning is printed, the client will see a timeout and print a warning, too. A later patch will re-introduce this function with real functionality. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 21

[dm-devel] [PATCH 26/35] multipathd: uxlsnr: check root on connection startup

2021-09-10 Thread mwilck
From: Martin Wilck The SO_PEERCRED socket option returns "the credentials that were in effect at the time of the call to connect(2)" (see unix(7)). So we might as well fetch these credentials at that time. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 3 +-- 1 file changed, 1

[dm-devel] [PATCH 20/35] multipathd: move uxsock_trigger() to uxlsnr.c

2021-09-10 Thread mwilck
From: Martin Wilck uxsock_trigger() really belongs into cli.c. I suppose that way back in the past there were strong reasons to call this function via a pointer. I don't think these reasons are valid any more. Moving the function to cli.c allows restructuring the code. No functional changes.

[dm-devel] [PATCH 11/35] multipathd: make all cli_handlers static

2021-09-10 Thread mwilck
From: Martin Wilck The cli_handler functions are only called from the handler table and need not be exported. Signed-off-by: Martin Wilck --- multipathd/cli_handlers.c | 214 ++ multipathd/cli_handlers.h | 61 ++- multipathd/main.c | 58

[dm-devel] [PATCH 03/35] libmultipath: add optional wakeup functionality to lock.c

2021-09-10 Thread mwilck
From: Martin Wilck Have struct mutex_lock take an optional wakeup function. unlock() is renamed to __unlock() in order to prevent it from being called by mistake. Signed-off-by: Martin Wilck --- libmultipath/libmultipath.version | 5 + libmultipath/lock.c | 12 +++-

[dm-devel] [PATCH 16/35] multipathd: uxlsnr: handle client HUP

2021-09-10 Thread mwilck
From: Martin Wilck The unix socket listener thread doesn't even look at the revents returned by poll() while the daemon is configuring. This may cause a closed client socket to be kept open for a long time by the server, while the listener basically performs a busy loop, as ppoll() always

[dm-devel] [PATCH 18/35] multipathd: uxlsnr: avoid using fd -1 in ppoll()

2021-09-10 Thread mwilck
From: Martin Wilck Minor edit: if notifications are off, we set the poll fd to -1 but still use the POLLIN mask. It looks nicer if to poll the correct fd, but reset the event mask to 0 if we're not actually interested in it. Signed-off-by: Martin Wilck --- multipathd/uxlsnr.c | 6 +++--- 1

[dm-devel] [PATCH 00/35] multipathd: uxlsnr overhaul

2021-09-10 Thread mwilck
From: Martin Wilck Hello Christophe, hello Ben, The current multipathd unix listener code has various deficiencies. - client disconnects aren't handled correctly, - the uxsock_timeout is applied for receiving, handling, and responding to the client requests separately, rather than for

[dm-devel] [PATCH 08/35] multipathd: cli.h: formatting improvements

2021-09-10 Thread mwilck
From: Martin Wilck No functional changes. Just make the code a little easier to read. Signed-off-by: Martin Wilck --- multipathd/cli.h | 82 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/multipathd/cli.h b/multipathd/cli.h

[dm-devel] [PATCH] multipathd: fix missing persistent reseravtion for active path

2021-09-10 Thread lixiaokeng
There are two paths(sucu as sda and adb) for one LUN. The two paths log in, but before the two uevents have been processed (for example there are many uevent), users use multipathd add path /dev/sda to cause mpatha and use mpathpersist -o -I to register prkey for mpatha. The add map uevent is

Re: [dm-devel] [PATCH] multipath-tools: add info about IO affinity path selector to manpage

2021-09-10 Thread Martin Wilck
On Wed, 2021-09-08 at 22:33 +0200, Xose Vazquez Perez wrote: > Added in 5.11: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e4d2e82b2300b03f66b3ca8417590c86e661fab1 > > Cc: Mike Christie > Cc: Martin Wilck > Cc: Benjamin Marzinski > Cc: Christophe Varoqui >