multipath-tools: Yet Another PR fix
Benjamin Marzinski
maintainercover multipath-tools: Yet Another PR fix
I ran into some cases where checking the number of registered keys made multipathd think all paths had been registered, when they hadn't. The last two patches in this patchset rework that code. The first two are just fixes to other issues I happened to notice while working on this code.
Benjamin Marzinski (4):
libmpathpersist: fix register retry status checking multipath-tools man pages: fix multipathd commands keyword ordering
multipathd: remember number of registered keys when ioctl fails
libmpathpersist: fix code for skipping multipathd path registration
libmpathpersist/mpath_persist_int.c | 20 ++++---- libmpathpersist/mpath_updatepr.c | 48 ++++++++++++++----- libmpathpersist/mpathpr.h | 4 +- multipathd/callbacks.c | 1 + multipathd/cli.c | 1 + multipathd/cli.h | 2 + multipathd/cli_handlers.c | 39 ++++++++++++++-- multipathd/main.c | 72 +++++++++++++++++++---------- multipathd/main.h | 3 +- multipathd/multipathd.8.in | 24 ++++++---- 10 files changed, 155 insertions(+), 59 deletions(-)
Signature · 1 line
2.50.1
Benjamin Marzinski
maintainerPATCH 1/4 libmpathpersist: fix register retry status checking
If there libmpathpersist failed to create a thread to retry the register and ignore command, mpath_prout_reg should fail. Instead, the code was simply ignoring the failed threads. Fix that.
--- libmpathpersist/mpath_persist_int.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
libmpathpersist/mpath_persist_int.c +7 -7
@@ -536,19 +536,19 @@ static int mpath_prout_reg(struct multipath *mpp,int rq_servact, int rq_scope, } }for (i =0 ; i < count; i++) { -if (thread[i].param.status !=MPATH_PR_SKIP && - thread[i].param.status !=MPATH_PR_THREAD_ERROR ) { +if (thread[i].param.status ==MPATH_PR_SKIP ) +continue ; +if (thread[i].param.status !=MPATH_PR_THREAD_ERROR ) { rc =pthread_join (thread[i].id,NULL );if (rc) {condlog (3 ,"%s: failed to join thread while retrying %d" , mpp->wwid, i); } -if (thread[i].param.status == -MPATH_PR_RETRYABLE_ERROR ) - retryable_error = true; -else if (status ==MPATH_PR_SUCCESS ) - status = thread[i].param.status; } +if (thread[i].param.status ==MPATH_PR_RETRYABLE_ERROR ) + retryable_error = true; +else if (status ==MPATH_PR_SUCCESS ) + status = thread[i].param.status; } need_retry = false; }
Signature · 1 line
2.50.1
Benjamin Marzinski
maintainerPATCH 2/4 multipath-tools man pages: fix multipathd commands keyword ordering
In reply to Benjamin Marzinskimultipathd now has a fixed ordering of the keywords. Specifically, verbs must come first. Fix the man page to reflect the ordering.
--- multipathd/multipathd.8.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
multipathd/multipathd.8.in +9 -9
@@ -344,48 +344,48 @@ will not be disabled when the daemon stops. Restores configured queue_without_daemon mode. . .TP -.B map|multipath $map setprstatus +.B setprstatus map|multipath $map Enable persistent reservation management on $map. . .TP -.B map|multipath $map unsetprstatus +.B unsetprstatus map|multipath $map Disable persistent reservation management on $map. . .TP -.B map|multipath $map getprstatus +.B getprstatus map|multipath $map Get the current persistent reservation management status of $map. . .TP -.B map|multipath $map getprkey +.B getprkey map|multipath $map Get the current persistent reservation key associated with $map. . .TP -.B map|multipath $map setprkey key $key +.B setprkey map|multipath $map key $key Set the persistent reservation key associated with $map to $key in the \fIprkeys_file\fR. This key will only be used by multipathd if \fIreservation_key\fR is set to \fBfile\fR in \fI@CONFIGFILE@\fR. . .TP -.B map|multipath $map unsetprkey +.B unsetprkey map|multipath $map Remove the persistent reservation key associated with $map from the \fIprkeys_file\fR. This will only unset the key used by multipathd if \fIreservation_key\fR is set to \fBfile\fR in \fI@CONFIGFILE@\fR. . .TP -.B path $path setmarginal +.B setmarginal path $path move $path to a marginal pathgroup. The path will remain in the marginal path group until \fIunsetmarginal\fR is called. This command will only work if \fImarginal_pathgroups\fR is enabled and there is no Shaky paths detection method configured (see the multipath.conf man page for details). . .TP -.B path $path unsetmarginal +.B unsetmarginal path $path return marginal path $path to its normal pathgroup. This command will only work if \fImarginal_pathgroups\fR is enabled and there is no Shaky paths detection method configured (see the multipath.conf man page for details). . .TP -.B map $map unsetmarginal +.B unsetmarginal map $map return all marginal paths in $map to their normal pathgroups. This command will only work if \fImarginal_pathgroups\fR is enabled and there is no Shaky paths detection method configured (see the multipath.conf man page for details).
Signature · 1 line
2.50.1
Benjamin Marzinski
maintainerPATCH 3/4 multipathd: remember number of registered keys when ioctl fails
In reply to Benjamin MarzinskiIf prin_do_scsi_ioctl() fails in update_map_pr() for some reason other than Persistent Reservations not being supported, It shouldn't clear the number of registered keys, since there's no reason to think that it has changed. Similarly, if update_map_pr() fails in mpath_pr_event_handle(), don't assume that the nr_keys_needed was cleared. Just return whatever the value is now. This saves multipathd from doing pointless calls to update_map_pr(), if one of the paths is failing.
--- multipathd/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
multipathd/main.c +7 -4
@@ -4278,7 +4278,9 @@ void unset_pr(struct multipath *mpp)* The number of found keys must be at least as large as *nr_keys, * and if MPATH_PR_SUCCESS is returned and mpp->prflag is PR_SET after * the call, *nr_keys will be set to the number of found keys. Otherwise -* it will be set to 0. +* if mpp->prflag is PR_UNSET it will be set to 0. If MPATH_PR_SUCCESS +* is not returned and mpp->prflag is not PR_UNSET, nr_keys will not be +* changed. */ static int update_map_pr (struct multipath *mpp,struct path *pp,unsigned int *nr_keys) {
@@ -4307,11 +4309,12 @@ static int update_map_pr(struct multipath *mpp, struct path *pp, unsigned int *n ret =prin_do_scsi_ioctl (pp->dev,MPATH_PRIN_RKEY_SA , &resp,0 );if (ret !=MPATH_PR_SUCCESS ) { -if (ret ==MPATH_PR_ILLEGAL_REQ ) +if (ret ==MPATH_PR_ILLEGAL_REQ ) {unset_pr (mpp); + *nr_keys =0 ; + }condlog (0 ,"%s : pr in read keys service action failed Error=%d" , mpp->alias, ret); - *nr_keys =0 ;return ret; }
@@ -4427,7 +4430,7 @@ retry: clear_reg ? "Clearing" : "Setting", pp->dev, ret); }else if (!clear_reg) {if (update_map_pr (mpp, pp, &nr_keys_needed) !=MPATH_PR_SUCCESS ) -return 0 ; +return nr_keys_needed;if (mpp->prflag !=PR_SET ) {memset (¶m,0 ,sizeof (param)); clear_reg = true;
Signature · 1 line
2.50.1
Benjamin Marzinski
maintainerPATCH 4/4 libmpathpersist: fix code for skipping multipathd path registration
In reply to Benjamin MarzinskiWhen libmpathpersist notifies multipathd that a key has been registered, cli_setprstatus() calls pr_register_active_paths() with a flag to let it know that the paths are likely already registered, and it can skip re-registering them, as long as the number of active paths matches the number of registered keys. This shortcut can fail, causing multipathd to not register needed paths, if either a path becomes usable and another becomes unusable while libmpathpersist is running or if there already were registered keys for I_T Nexus's that don't correspond to path devices.
To make this shortcut work in cases like that, this commit adds a new multipathd command "setprstatus map <map> pathlist <pathlist>", where <pathlist> is a quoted, comma separated list of scsi path devices. libmpathpersist will send out the list of paths it registered the key on. pr_register_active_paths() will skip calling mpath_pr_event_handle() for paths on that list.
In order to deal with the possiblity of a preempt occuring while libmpathpersist was running, the code still needs to check that it has the expected number of keys.
--- libmpathpersist/mpath_persist_int.c | 6 +-- libmpathpersist/mpath_updatepr.c | 48 +++++++++++++++++------ libmpathpersist/mpathpr.h | 4 +- multipathd/callbacks.c | 1 + multipathd/cli.c | 1 + multipathd/cli.h | 2 + multipathd/cli_handlers.c | 39 ++++++++++++++++-- multipathd/main.c | 61 +++++++++++++++++++---------- multipathd/main.h | 3 +- multipathd/multipathd.8.in | 6 +++ 10 files changed, 132 insertions(+), 39 deletions(-)
libmpathpersist/mpath_persist_int.c +3 -3
@@ -1001,12 +1001,12 @@ int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd,case MPATH_PROUT_REG_SA :case MPATH_PROUT_REG_IGN_SA :if (unregistering) -update_prflag (mpp->alias,0 ); +update_prflag (mpp,0 );else -update_prflag (mpp->alias,1 ); +update_prflag (mpp,1 );break ;case MPATH_PROUT_CLEAR_SA : -update_prflag (mpp->alias,0 ); +update_prflag (mpp,0 );if (mpp->prkey_source ==PRKEY_SOURCE_FILE )update_prkey (mpp->alias,0 );break ;
libmpathpersist/mpath_updatepr.c +37 -11
78 lines not on this page · raw message
libmpathpersist/mpathpr.h +3 -1
@@ -1,12 +1,14 @@#ifndef MPATHPR_H_INCLUDED #define MPATHPR_H_INCLUDED +#include "structs.h" +/* * This header file contains symbols that are only used by * libmpathpersist internally. */ -int update_prflag (char *mapname,int set); +int update_prflag (struct multipath *mpp,int set);int update_prkey_flags (char *mapname,uint64_t prkey,uint8_t sa_flags);int get_prflag (char *mapname);int get_prhold (char *mapname);
multipathd/callbacks.c +1 -0
@@ -59,6 +59,7 @@ void init_handler_callbacks(void)set_unlocked_handler_callback (VRB_SHUTDOWN ,HANDLER (cli_shutdown));set_handler_callback (VRB_GETPRSTATUS |Q1_MAP ,HANDLER (cli_getprstatus));set_handler_callback (VRB_SETPRSTATUS |Q1_MAP ,HANDLER (cli_setprstatus)); +set_handler_callback (VRB_SETPRSTATUS |Q1_MAP |Q2_PATHLIST ,HANDLER (cli_setprstatus_list));set_handler_callback (VRB_UNSETPRSTATUS |Q1_MAP ,HANDLER (cli_unsetprstatus));set_handler_callback (VRB_FORCEQ |Q1_DAEMON ,HANDLER (cli_force_no_daemon_q));set_handler_callback (VRB_RESTOREQ |Q1_DAEMON ,HANDLER (cli_restore_no_daemon_q));
multipathd/cli.c +1 -0
@@ -227,6 +227,7 @@ load_keys (void) r +=add_key (keys,"getprhold" ,VRB_GETPRHOLD ,0 ); r +=add_key (keys,"setprhold" ,VRB_SETPRHOLD ,0 ); r +=add_key (keys,"unsetprhold" ,VRB_UNSETPRHOLD ,0 ); + r +=add_key (keys,"pathlist" ,KEY_PATHLIST ,1 );if (r) {free_keys (keys);
multipathd/cli.h +2 -0
@@ -62,6 +62,7 @@ enum {KEY_LOCAL =81 ,KEY_GROUP =82 ,KEY_KEY =83 , + KEY_PATHLIST = 84, };/*
@@ -94,6 +95,7 @@ enum {Q2_LOCAL =KEY_LOCAL <<16 ,Q2_GROUP =KEY_GROUP <<16 ,Q2_KEY =KEY_KEY <<16 , +Q2_PATHLIST =KEY_PATHLIST <<16 ,/* byte 3: qualifier 3 */ Q3_FMT = KEY_FMT << 24,
multipathd/cli_handlers.c +36 -3
@@ -31,6 +31,7 @@#include "foreign.h" #include "strbuf.h" #include "cli_handlers.h" +#include <ctype.h> static struct path * find_path_by_str(const struct vector_s *pathvec, const char *str,
@@ -1276,8 +1277,8 @@ cli_getprstatus (void * v, struct strbuf *reply, void * data)return 0 ; } -static int -cli_setprstatus (void * v,struct strbuf *reply,void * data) +static int do_setprstatus (void * v,struct strbuf *reply,void * data, +const struct vector_s *registered_paths) {struct multipath * mpp;struct vectors * vecs = (struct vectors *)data;
@@ -1291,7 +1292,7 @@ cli_setprstatus(void * v, struct strbuf *reply, void * data)if (mpp->prflag !=PR_SET ) {set_pr (mpp); -pr_register_active_paths (mpp, true); +pr_register_active_paths (mpp, registered_paths);if (mpp->prflag ==PR_SET )condlog (2 ,"%s: prflag set" , param);else
@@ -1302,6 +1303,38 @@ cli_setprstatus(void * v, struct strbuf *reply, void * data)return 0 ; } +static int +cli_setprstatus (void * v,struct strbuf *reply,void * data) +{ +return do_setprstatus (v, reply, data,NULL ); +} + +static int +cli_setprstatus_list (void * v,struct strbuf *reply,void * data) +{ +int r; +struct vector_s registered_paths = { .allocated =0 }; +char *ptr =get_keyparam (v,KEY_PATHLIST ); + +while (isspace (*ptr)) + ptr++; +while (*ptr) { +if (!vector_alloc_slot (®istered_paths)) { + r = -ENOMEM ; + goto out; + } +vector_set_slot (®istered_paths, ptr); +while (*ptr && !isspace (*ptr)) + ptr++; +while (isspace (*ptr)) + *ptr++ ='\0' ; + } + r =do_setprstatus (v, reply, data, ®istered_paths); +out: +vector_reset (®istered_paths); +return r; +} +static int cli_unsetprstatus (void * v,struct strbuf *reply,void * data) {
multipathd/main.c +41 -20
112 lines not on this page · raw message
multipathd/main.h +2 -1
@@ -54,5 +54,6 @@ int resize_map(struct multipath *mpp, unsigned long long size, struct vectors *vecs);void set_pr (struct multipath *mpp);void unset_pr (struct multipath *mpp); -void pr_register_active_paths (struct multipath *mpp,bool check_active_nr); +void pr_register_active_paths (struct multipath *mpp, +const struct vector_s *registered_paths);#endif /* MAIN_H_INCLUDED */
multipathd/multipathd.8.in +6 -0
@@ -348,6 +348,12 @@ Restores configured queue_without_daemon mode. Enable persistent reservation management on $map. . .TP +.B setprstatus map|multipath $map pathlist $pathlist +Enable persistent reservation management on $map, and notify multipathd of +the paths that have been registered, so it doesn't attempt to re-register +them. +. +.TP .B unsetprstatus map|multipath $map Disable persistent reservation management on $map. .
Signature · 1 line
2.50.1
Re: [PATCH 4/4] libmpathpersist: fix code for skipping multipathd path registration
Quoted 42 lines · Benjamin Marzinski
When libmpathpersist notifies multipathd that a key has been registered,
cli_setprstatus()callspr_register_active_paths()with a flag to let it
know that the paths are likely already registered, and it can skip re-registering them, as long as the number of active paths matches the
number of registered keys. This shortcut can fail, causing multipathd to
not register needed paths, if either a path becomes usable and another
becomes unusable while libmpathpersist is running or if there already were registered keys forI_TNexus's that don't correspond to path devices.To make this shortcut work in cases like that, this commit adds a new multipathd command "setprstatus map <map> pathlist <pathlist>", where <pathlist> is a quoted, comma separated list of scsi path devices. libmpathpersist will send out the list of paths it registered the key on.
pr_register_active_paths()will skip callingmpath_pr_event_handle()
for paths on that list.In order to deal with the possiblity of a preempt occuring while libmpathpersist was running, the code still needs to check that it has
the expected number of keys.Fixes f7d6cd17 ("multipathd: Fix race while registering PR key")Signed-off-by Benjamin Marzinski <[email protected]>---
libmpathpersist/mpath_persist_int.c | 6 +-- libmpathpersist/mpath_updatepr.c | 48 +++++++++++++++++------ libmpathpersist/mpathpr.h | 4 +- multipathd/callbacks.c | 1 + multipathd/cli.c | 1 + multipathd/cli.h | 2 + multipathd/cli_handlers.c | 39 ++++++++++++++++-- multipathd/main.c | 61 +++++++++++++++++++-------- --
multipathd/main.h | 3 +- multipathd/multipathd.8.in | 6 +++
Quoted 1 line
10 files changed, 132 insertions(+), 39 deletions(-)
I may be missing something, but this is quite a lot of additional complexity just for the shortcut. Have you considered just not taking the shortcut in the first place?
Martin
Benjamin Marzinski
maintainerRe: [PATCH 4/4] libmpathpersist: fix code for skipping multipathd path registration
Quoted 45 lines · Martin Wilck
Quoted 42 lines · Benjamin Marzinski
When libmpathpersist notifies multipathd that a key has been registered,
cli_setprstatus()callspr_register_active_paths()with a flag to let it
know that the paths are likely already registered, and it can skip re-registering them, as long as the number of active paths matches the
number of registered keys. This shortcut can fail, causing multipathd to
not register needed paths, if either a path becomes usable and another
becomes unusable while libmpathpersist is running or if there already were registered keys forI_TNexus's that don't correspond to path devices.To make this shortcut work in cases like that, this commit adds a new multipathd command "setprstatus map <map> pathlist <pathlist>", where <pathlist> is a quoted, comma separated list of scsi path devices. libmpathpersist will send out the list of paths it registered the key on.
pr_register_active_paths()will skip callingmpath_pr_event_handle()
for paths on that list.In order to deal with the possiblity of a preempt occuring while libmpathpersist was running, the code still needs to check that it has
the expected number of keys.Fixes f7d6cd17 ("multipathd: Fix race while registering PR key")Signed-off-by Benjamin Marzinski <[email protected]>---
libmpathpersist/mpath_persist_int.c | 6 +-- libmpathpersist/mpath_updatepr.c | 48 +++++++++++++++++------ libmpathpersist/mpathpr.h | 4 +- multipathd/callbacks.c | 1 + multipathd/cli.c | 1 + multipathd/cli.h | 2 + multipathd/cli_handlers.c | 39 ++++++++++++++++-- multipathd/main.c | 61 +++++++++++++++++++-------- --
multipathd/main.h | 3 +- multipathd/multipathd.8.in | 6 +++Quoted 1 line
10 files changed, 132 insertions(+), 39 deletions(-)
Quoted 3 lines
I may be missing something, but this is quite a lot of additional complexity just for the shortcut. Have you considered just not taking the shortcut in the first place?
Yep. But that means that whenever you register a multipath device with mpathpersist, multipathd will (almost always pointlessly) re-register all the paths, just to make sure it doesn't hit these super rare corner cases. So this added complexity keeps multipathd from running unnecesary scsi PR commands, and should be quicker. All multipathd does is break the new cli message up into pathnames, and then has pr_register_active_paths() check the paths against the pathanames, and skip them if they match and the number of keys is as big as expected (and it needs to check the number of keys regardless of whether it uses the shortcut).
I thought briefly about pulling all the path registration work into multipathd, but it ends up making multipathd even more complex than this shortcut, while not saving much complexity from libmpathpersist. If we wanted to make multipathd handle all of libmpathpersists work, that would be a different story, but I'm still not sold on the idea of doing that.
That being said, we can drop a chunk of code if we just force multipathd to automatically reregister the paths. So if you think that the reduced work is not worth the added complexity, I'm o.k. with pulling the shortcut out completely.
-Ben
Quoted 1 line
Martin
Re: [PATCH 4/4] libmpathpersist: fix code for skipping multipathd path registration
Quoted 33 lines · Benjamin Marzinski
Quoted 5 lines · Martin Wilck
I may be missing something, but this is quite a lot of additional complexity just for the shortcut. Have you considered just not taking
the shortcut in the first place?Yep. But that means that whenever you register a multipath device with
mpathpersist, multipathd will (almost always pointlessly) re-register all the paths, just to make sure it doesn't hit these super rare corner
cases. So this added complexity keeps multipathd from running unnecesary
scsi PR commands, and should be quicker. All multipathd does is break the new cli message up into pathnames, and then haspr_register_active_paths()check the paths against the pathanames, and
skip them if they match and the number of keys is as big as expected (and it needs to check the number of keys regardless of whether it uses
the shortcut).I thought briefly about pulling all the path registration work into multipathd, but it ends up making multipathd even more complex than this
shortcut, while not saving much complexity from libmpathpersist. If we
wanted to make multipathd handle all of libmpathpersists work, that would be a different story, but I'm still not sold on the idea of doing
that.
Quoted 5 lines
That being said, we can drop a chunk of code if we just force multipathd to automatically reregister the paths. So if you think that
the reduced work is not worth the added complexity, I'm o.k. with pulling the shortcut out completely.
I admit I am somewhat intimidated by the complexity into which the PR code has grown. Therefore I would be glad to avoid extra complexity if possible. But for that very reason, I don't feel competent to judge whether this complexity is "worth" it, IOW how badly performance would be affected by the extra register commands, in particular during high IO load. I suppose it's not so much a matter of "performance", rather of latency between running mpathpersist and the completion of the task in multipathd, which might be critical in certain situations.
This is why I wrote "have you considered". If you, from the vast exprience that you gained in the course of your recent work, think that this extra complexity is worth it, fine with me. I'll go over the patch once more.
Martin
Re: [PATCH 4/4] libmpathpersist: fix code for skipping multipathd path registration
In reply to Benjamin MarzinskiQuoted 125 lines · Benjamin Marzinski
When libmpathpersist notifies multipathd that a key has been registered,
cli_setprstatus()callspr_register_active_paths()with a flag to let it
know that the paths are likely already registered, and it can skip re-registering them, as long as the number of active paths matches the
number of registered keys. This shortcut can fail, causing multipathd to
not register needed paths, if either a path becomes usable and another
becomes unusable while libmpathpersist is running or if there already were registered keys forI_TNexus's that don't correspond to path devices.To make this shortcut work in cases like that, this commit adds a new multipathd command "setprstatus map <map> pathlist <pathlist>", where <pathlist> is a quoted, comma separated list of scsi path devices. libmpathpersist will send out the list of paths it registered the key on.
pr_register_active_paths()will skip callingmpath_pr_event_handle()
for paths on that list.In order to deal with the possiblity of a preempt occuring while libmpathpersist was running, the code still needs to check that it has
the expected number of keys.Fixes f7d6cd17 ("multipathd: Fix race while registering PR key")Signed-off-by Benjamin Marzinski <[email protected]>---
libmpathpersist/mpath_persist_int.c | 6 +-- libmpathpersist/mpath_updatepr.c | 48 +++++++++++++++++------ libmpathpersist/mpathpr.h | 4 +- multipathd/callbacks.c | 1 + multipathd/cli.c | 1 + multipathd/cli.h | 2 + multipathd/cli_handlers.c | 39 ++++++++++++++++-- multipathd/main.c | 61 +++++++++++++++++++-------- --
multipathd/main.h | 3 +- multipathd/multipathd.8.in | 6 +++10 files changed, 132 insertions(+), 39 deletions(-)multipathd/main.c +0
-0@@ -630,28 +630,49 @@ flush_map_nopaths(struct multipath *mpp, struct vectors *vecs) { return true; }
-voidpr_register_active_paths(struct multipath *mpp, bool check_nr_active)
+/*
+ * Ifreg_pathsin non-NULL, it is a vector of paths that libmpathpersist
+ * registered. If the number of registered keys is smaller than the number
+ * of registered paths, then likely a preempt that occurred while
+ * libmpathpersist was registering the key. As long as there are still some
+ * registered keys, treat the preempt as happening first, and make sure to
+ * register keys on all the paths. If the number of registered keys is at
+ * least as large as the number of registered paths, then no preempt happened,
+ * and multipathd does not need to re-register the paths that libmpathpersist
+ * handled
+ */multipathd/main.c +2
-0+void pr_register_active_paths (struct multipath *mpp, + const struct vector_s *reg_paths){
multipathd/main.c +2
-2-unsigned int i, j, nr_keys =0 ; -unsigned int nr_active =0 ; +unsigned int i, j, k, nr_keys =0 ; +unsigned int wanted_nr =VECTOR_SIZE (reg_paths);struct path *pp;
struct pathgroup *pgp;multipathd/main.c +1
-6- -if (check_nr_active) { - nr_active =count_active_paths (mpp); -if (!nr_active) -return ; - } +char *pathname;
vector_foreach_slot(mpp->pg, pgp, i) {vector_foreach_slot(pgp->paths, pp, j) { if (mpp->prflag==PR_UNSET) return;multipathd/main.c +0
-1- if (pp->state == PATH_UP || pp->state ==
PATH_GHOST) {multipathd/main.c +0
-1- nr_keys = mpath_pr_event_handle(pp,
nr_keys,nr_active);multipathd/main.c +0
-1- if (check_nr_active && nr_keys ==
nr_active)multipathd/main.c +1
-1-return ; + if (pp->state != PATH_UP && pp->state !=
PATH_GHOST)multipathd/main.c +3
-0+continue ; +if (wanted_nr && nr_keys) { + vector_foreach_slot(reg_paths,pathname, k) {
multipathd/main.c +1
-0+ if (strcmp(pp->dev,pathname) == 0 ||
multipathd/main.c +1
-0+ strcmp(pp->dev_t,pathname) == 0) {
multipathd/main.c +5
-0+ goto skip; + } + } + } + nr_keys = mpath_pr_event_handle(pp, nr_keys,
wanted_nr);multipathd/main.c +3
-0+if (nr_keys && nr_keys < wanted_nr) { +/* +* Incorrect number of registered keys. Need
multipathd/main.c +3
-0+* to register all devices +*/ + wanted_nr =0 ;
Quoted 2 lines
}
+skip:
This fails on Debian Sid with this error messsage:
main.c:677:3: error: label at end of compound statement is a C23 extension [-Werror,-Wc23-extensions]
677 | }
|
[1] https://github.com/openSUSE/multipath-tools/actions/runs/20031717354/job/57442300023
Martin
Quoted 24 lines · Benjamin Marzinski
I ran into some cases where checking the number of registered keys made
multipathd think all paths had been registered, when they hadn't. The last two patches in this patchset rework that code. The first two are just fixes to other issues I happened to notice while working on this code.Benjamin Marzinski (4):
libmpathpersist: fix register retry status checking multipath-tools man pages: fix multipathd commands keyword ordering
multipathd: remember number of registered keys when ioctl fails
libmpathpersist: fix code for skipping multipathd path registrationlibmpathpersist/mpath_persist_int.c | 20 ++++---- libmpathpersist/mpath_updatepr.c | 48 ++++++++++++++----- libmpathpersist/mpathpr.h | 4 +- multipathd/callbacks.c | 1 + multipathd/cli.c | 1 + multipathd/cli.h | 2 + multipathd/cli_handlers.c | 39 ++++++++++++++-- multipathd/main.c | 72 +++++++++++++++++++-------- --
multipathd/main.h | 3 +- multipathd/multipathd.8.in | 24 ++++++----
Quoted 1 line
10 files changed, 155 insertions(+), 59 deletions(-)
For the series, except 4/4: