multipathd: remove nopath flushing code from flush_map()
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byQuoted 7 lines · Benjamin Marzinski
Instead of
flush_map()handling both user requested flushes and automatic flushes when the last path has been deleted, makeflush_map_nopaths()handle the automatic flushes itself, since a later
patch will change the behavior offlush_map().Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 02/16] multipathd: make flush_map() delete maps like the multipath command
Quoted 25 lines · Benjamin Marzinski
When the multipath command tries to delete a multipath device, it first
disables queueing and then suspends the device to force the IOs to get
flushed. Then it attempts to delete the device and any kpartx partitions. multipathd, on the other hand, simply tries to delete the
device and kpartx partitions, without disabling queueing or suspending.
If there are no paths but there is outstanding IO, multipathd will hang
trying to delete the last kpartx device. This is because it must be the
last opener of the multipath device (multipath won't try to delete the
device if it has any openers besides the kpartx devices) and the kernel
will not allow the last opener of a block device to close until all the
outstanding IO is flushed. This hang can be avoided if multipathd callsdm_suspend_and_flush_map()like the multipath command does, instead ofdm_flush_map().
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 06/16] libmultipath: make dm_remove_partmaps() a static function
Quoted 6 lines · Benjamin Marzinski
dm_remove_partmaps()is only used indevmapper.c, so make it static. It
does need to be declared early, sinceremove_partmaps()and it call eachother.Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 05/16] libmultipath: make _dm_flush_map() return an enum
Quoted 5 lines · Benjamin Marzinski
A future patch will add an additional return code, so make this an enum
instead of just using numbers.Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 03/16] multipathd: disable queueing when removing unknown maps
Quoted 4 lines · Benjamin Marzinski
Make
cli_del_maps()calldm_suspend_and_flush_map()for the unknown multipath devices as well.Signed-off-by Benjamin Marzinski <[email protected]>
dm_flush_maps() is now always called with need_suspend=1. We can simplify it.
Regards
Martin
Benjamin Marzinski
maintainerRe: [PATCH 03/16] multipathd: disable queueing when removing unknown maps
Quoted 8 lines · Martin Wilck
Quoted 4 lines · Benjamin Marzinski
Make
cli_del_maps()calldm_suspend_and_flush_map()for the unknown multipath devices as well.Signed-off-by Benjamin Marzinski <[email protected]>
dm_flush_maps()is now always called with need_suspend=1. We can simplify it.
Yep. I can add that.
-Ben
Quoted 3 lines
Regards
Martin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 04/16] multipathd: simplify cli_del_map()
Quoted 9 lines · Benjamin Marzinski
cli_del_map()does a lot of unnecessary work to match the arguments ofev_remove_map(), of which it is the only caller. Thenev_remove_map()
does more unnecessary work to verify the arguments passed in. removeev_remove_map()and makecli_del_map()get the mpp like the rest of the client handlers do.Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 09/16] multipathd: handle busy devices in cli_del_maps()
Quoted 6 lines · Benjamin Marzinski
Make
cli_del_maps()return-EBUSYlikecli_del_map()if it fails because
a device is in use and it doesn't run into any other type of failures.Signed-off-by Benjamin Marzinski <[email protected]>
It's kind of weird that we use both 1 and negative error codes in our cli handlers to indicate failure. Maybe we should get rid of the catch- all error code 1. Anyway, that's not the fault of your patch, so
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 10/16] libmultipath: print error when find_mp_by_str() fails.
Quoted 7 lines · Benjamin Marzinski
None of the callers of
find_mp_by_str()print any message if they fail
because the map name is invalid. Print one infind_mp_by_str()to save
the effort of adding it to all the callers.Signed-off-by Benjamin Marzinski <[email protected]>
This will be printed to the journal; clients won't see the message unless they check the journal, too. It's ok to add the message, but I don't think it' a condlog(0), which is normally reserved to fatal multipathd errors. I'd make it a 2; after all, it's most likely just a typo by the user.
Martin
Benjamin Marzinski
maintainerRe: [PATCH 10/16] libmultipath: print error when find_mp_by_str() fails.
Quoted 7 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski
None of the callers of
find_mp_by_str()print any message if they fail
because the map name is invalid. Print one infind_mp_by_str()to save
the effort of adding it to all the callers.
Quoted 7 lines
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>This will be printed to the journal; clients won't see the message unless they check the journal, too. It's ok to add the message, but I don't think it' a condlog(0), which is normally reserved to fatal multipathd errors. I'd make it a 2; after all, it's most likely just a typo by the user.
Sure.
-Ben
Quoted 2 lines
Martin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 08/16] multipathd: print extra default reply msg for busy devices
Quoted 7 lines · Benjamin Marzinski
If removing a multipath device fails because the device is in use, return
DM_FLUSH_BUSYfromremove_functions, which causescli_del_map()
to return-EBUSY, which will not print extra information indefault_reply().Signed-off-by Benjamin Marzinski <[email protected]>
This is slightly unclean, because do_foreach_partmaps() works with generic int return codes and not with the DM_FLUSH_xyz enum. Yet:
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 07/16] multipathd: always start failure replies with "fail\n"
Quoted 51 lines · Benjamin Marzinski
When multipathd interactive commands fail for certain reasons, like timing out or incorrect permissions, they do not reply with "fail\n". Currently, multipath and multipathc expect that a reply other than "fail\n" means success. Instead, prefix all failure replies with "fail\n", and adapt multipath and multipathc to return failure for any
reply starting with "fail\n".Signed-off-by Benjamin Marzinski <[email protected]>---
libdmmp/libdmmp.c | 6 +++---
multipath/main.c | 2 +-
multipathd/uxclnt.c | 2 +-
multipathd/uxlsnr.c | 12 +++++-------4 files changed, 10 insertions(+), 12 deletions(-)libdmmp/libdmmp.c +0
-0@@ -321,7 +321,7 @@ invoke: } }if ((*output != NULL) &&
libdmmp/libdmmp.c +1
-1- (strncmp(*output, "timeout", strlen("timeout")) == 0)) + (strncmp(*output, "fail\ntimeout",
strlen("fail\ntimeout")) == 0))
flag_check_tmo= true;
if (flag_check_tmo== true) {libdmmp/libdmmp.c +0
-0@@ -364,8 +364,8 @@ invoke: }
if ((*output != NULL) &&libdmmp/libdmmp.c +2
-2- strncmp(*output, "permission deny", - strlen("permission deny")) == 0) { + strncmp(*output, "fail\npermission deny", + strlen("fail\npermission deny")) == 0) {
_error(ctx, "Permission deny, need to be root"); rc =DMMP_ERR_PERMISSION_DENY;
goto out;multipath/main.c +0
-0@@ -804,7 +804,7 @@ int delegate_to_multipathd(enum mpath_cmds cmd, }
if (reply != NULL && *reply != '\0') {multipath/main.c +1
-1-if (strcmp (reply,"fail\n" )) +if (strncmp (reply,"fail\n" ,5 ))
Quoted 3 lines
r =
DELEGATE_OK;
if (r !=NOT_DELEGATED&&strcmp(reply, "ok\n"))printf("%s", reply);
Perhaps here we should check if the reply length is > 5, and if yes, strip the "fail\n" part. That would make the output consistent with what it used to be.
multipathd/uxclnt.c static int process_req(int fd, char * inbuf, · line 34
Quoted 9 lines
multipathd/uxclnt.c +0
-0@@ -31,7 +31,7 @@ static int process_req(int fd, char * inbuf, unsigned int timeout) return 1; } else { printf("%s", reply);
Same here.
Quoted 36 lines
multipathd/uxclnt.c +1
-1- ret = (strcmp (reply,"fail\n" ) ==0 ); + ret = (strncmp (reply,"fail\n" ,5 ) ==0 ); free(reply); return ret;}
multipathd/uxlsnr.c +0
-0@@ -392,6 +392,11 @@ static void drain_idle_fd(int fd)
voiddefault_reply(struct client *c, int r)
{multipathd/uxlsnr.c +5
-0+if (r ==0 ) { +append_strbuf_str (&c->reply,"ok\n" ); +return ; + } +append_strbuf_str (&c->reply,"fail\n" );switch(r) {
case-EINVAL:
case-ESRCH:multipathd/uxlsnr.c +0
-0@@ -406,13 +411,6 @@ void default_reply(struct client *c, int r)case
-ETIMEDOUT:
append_strbuf_str(&c->reply, "timeout\n"); break;multipathd/uxlsnr.c +0
-5-case 0 : -append_strbuf_str (&c->reply,"ok\n" ); -break ; -default : -/* cli_handler functions return 1 on unspecified error */
multipathd/uxlsnr.c +0
-2-append_strbuf_str (&c->reply,"fail\n" ); -break ;}
}
Benjamin Marzinski
maintainerRe: [PATCH 07/16] multipathd: always start failure replies with "fail\n"
Quoted 61 lines · Martin Wilck
Quoted 51 lines · Benjamin Marzinski
When multipathd interactive commands fail for certain reasons, like timing out or incorrect permissions, they do not reply with "fail\n". Currently, multipath and multipathc expect that a reply other than "fail\n" means success. Instead, prefix all failure replies with "fail\n", and adapt multipath and multipathc to return failure for any
reply starting with "fail\n".Signed-off-by Benjamin Marzinski <[email protected]>---
libdmmp/libdmmp.c | 6 +++---
multipath/main.c | 2 +-
multipathd/uxclnt.c | 2 +-
multipathd/uxlsnr.c | 12 +++++-------4 files changed, 10 insertions(+), 12 deletions(-)libdmmp/libdmmp.c +0
-0@@ -321,7 +321,7 @@ invoke: } }if ((*output != NULL) &&
libdmmp/libdmmp.c +1
-1- (strncmp(*output, "timeout", strlen("timeout")) == 0)) + (strncmp(*output, "fail\ntimeout",
strlen("fail\ntimeout")) == 0))
flag_check_tmo= true;
if (flag_check_tmo== true) {libdmmp/libdmmp.c +0
-0@@ -364,8 +364,8 @@ invoke: }
if ((*output != NULL) &&libdmmp/libdmmp.c +2
-2- strncmp(*output, "permission deny", - strlen("permission deny")) == 0) { + strncmp(*output, "fail\npermission deny", + strlen("fail\npermission deny")) == 0) {
_error(ctx, "Permission deny, need to be root"); rc =DMMP_ERR_PERMISSION_DENY;
goto out;multipath/main.c +0
-0@@ -804,7 +804,7 @@ int delegate_to_multipathd(enum mpath_cmds cmd, }
if (reply != NULL && *reply != '\0') {multipath/main.c +1
-1-if (strcmp (reply,"fail\n" )) +if (strncmp (reply,"fail\n" ,5 ))Quoted 3 lines
r =
DELEGATE_OK;
if (r !=NOT_DELEGATED&&strcmp(reply, "ok\n"))printf("%s", reply);Perhaps here we should check if the reply length is > 5, and if yes, strip the "fail\n" part. That would make the output consistent with what it used to be.
Quoted 11 lines
multipathd/uxclnt.c static int process_req(int fd, char * inbuf, · line 34
Quoted 9 lines
multipathd/uxclnt.c +0
-0@@ -31,7 +31,7 @@ static int process_req(int fd, char * inbuf, unsigned int timeout) return 1; } else { printf("%s", reply);Same here.
Sure.
-Ben
Quoted 37 lines
Quoted 37 lines
multipathd/uxclnt.c +1
-1- ret = (strcmp (reply,"fail\n" ) ==0 ); + ret = (strncmp (reply,"fail\n" ,5 ) ==0 ); free(reply); return ret;}
multipathd/uxlsnr.c +0
-0@@ -392,6 +392,11 @@ static void drain_idle_fd(int fd)
voiddefault_reply(struct client *c, int r)
{multipathd/uxlsnr.c +5
-0+if (r ==0 ) { +append_strbuf_str (&c->reply,"ok\n" ); +return ; + } +append_strbuf_str (&c->reply,"fail\n" );switch(r) {
case-EINVAL:
case-ESRCH:multipathd/uxlsnr.c +0
-0@@ -406,13 +411,6 @@ void default_reply(struct client *c, int r)case
-ETIMEDOUT:
append_strbuf_str(&c->reply, "timeout\n"); break;multipathd/uxlsnr.c +0
-5-case 0 : -append_strbuf_str (&c->reply,"ok\n" ); -break ; -default : -/* cli_handler functions return 1 on unspecified error */
multipathd/uxlsnr.c +0
-2-append_strbuf_str (&c->reply,"fail\n" ); -break ;}
}
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 11/16] multipathd: don't open code find_mp_by_str() in client handers
Quoted 4 lines · Benjamin Marzinski
multiple client handlers simply open coded
find_mp_by_str(). Just use the function instead.Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 12/16] multipathd: make cli_handlers check for paths by dev and devt
Quoted 24 lines · Benjamin Marzinski
Some of the client handlers checked for paths by both dev and devt, but
not all. Also, many of the client handlers don't print anything if they
failed to find a path. Make all the client handlers which work on path
devices use a new function,find_path_by_str(), which will try both methods to find a path, and can print out an error message if none is found.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/cli_handlers.c | 40 ++++++++++++++++++++----------------- --1 file changed, 21 insertions(+), 19 deletions(-)multipathd/cli_handlers.c +0
-0@@ -33,6 +33,20 @@ #include "cli_handlers.h" #include "devmapper.h"
multipathd/cli_handlers.c
Quoted 8 lines
multipathd/cli_handlers.c +8
-0+static struct path * +find_path_by_str (const struct _vector *pathvec,const char *str, + const char *action_str) +{ +struct path *pp; + +if (!(pp =find_path_by_dev (pathvec, str))) + pp =find_path_by_devt (pathvec, str);
I wonder if devt should be tried first. It doesn't make a real difference because no real-world devices will have major:minor names, and the callers in the old code did it the other way around, too; but it would feel more correct to me.
Other than that, LGTM.
Regards
Martin
Benjamin Marzinski
maintainerRe: [PATCH 12/16] multipathd: make cli_handlers check for paths by dev and devt
Quoted 30 lines · Martin Wilck
Quoted 29 lines · Benjamin Marzinski
Some of the client handlers checked for paths by both dev and devt, but
not all. Also, many of the client handlers don't print anything if they
failed to find a path. Make all the client handlers which work on path
devices use a new function,find_path_by_str(), which will try both methods to find a path, and can print out an error message if none is found.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/cli_handlers.c | 40 ++++++++++++++++++++----------------- --1 file changed, 21 insertions(+), 19 deletions(-)multipathd/cli_handlers.c +0
-0@@ -33,6 +33,20 @@ #include "cli_handlers.h" #include "devmapper.h"multipathd/cli_handlers.c +5
-0+static struct path * +find_path_by_str (const struct _vector *pathvec,const char *str, + const char *action_str) +{ +struct path *pp;
Quoted 8 lines
multipathd/cli_handlers.c
Quoted 3 lines
multipathd/cli_handlers.c +3
-0+ +if (!(pp =find_path_by_dev (pathvec, str))) + pp =find_path_by_devt (pathvec, str);I wonder if devt should be tried first. It doesn't make a real difference because no real-world devices will have major:minor names, and the callers in the old code did it the other way around, too; but it would feel more correct to me.
I'm fine with switching the order. Also, I assume you'd like the log level to be set to 2, right?
-Ben
Quoted 4 lines
Other than that, LGTM.
Regards
Martin
Re: [PATCH 12/16] multipathd: make cli_handlers check for paths by dev and devt
Quoted 48 lines · Benjamin Marzinski
Quoted 38 lines · Martin Wilck
Quoted 37 lines · Benjamin Marzinski
Some of the client handlers checked for paths by both dev and devt,
but
not all. Also, many of the client handlers don't print anything if
they
failed to find a path. Make all the client handlers which work on path
devices use a new function,find_path_by_str(), which will try both
methods to find a path, and can print out an error message if none is
found.Signed-off-by Benjamin Marzinski <[email protected]>---
multipathd/cli_handlers.c | 40 ++++++++++++++++++++-------------
----
--1 file changed, 21 insertions(+), 19 deletions(-)multipathd/cli_handlers.c +0
-0@@ -33,6 +33,20 @@ #include "cli_handlers.h" #include "devmapper.h"multipathd/cli_handlers.c +7
-0+static struct path * +find_path_by_str (const struct _vector *pathvec,const char *str, + const char *action_str) +{ +struct path *pp; + +if (!(pp =find_path_by_dev (pathvec, str)))Quoted 8 lines
multipathd/cli_handlers.c
Quoted 1 line
multipathd/cli_handlers.c +1
-0+ pp =find_path_by_devt (pathvec, str);I wonder if devt should be tried first. It doesn't make a real difference because no real-world devices will have major:minor names,
and the callers in the old code did it the other way around, too; but
it would feel more correct to me.
Quoted 2 lines
I'm fine with switching the order. Also, I assume you'd like the log level to be set to 2, right?
Yes.
Regards
Martin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 13/16] multipathd: add cli_handler reply message for missing devs
Quoted 6 lines · Benjamin Marzinski
When the
cli_handlerscannot find the requested map or path, they will
now return-ENODEV, which prints extra information indefault_reply().Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 14/16] libdmmp: handle failures in _process_cmd
Quoted 8 lines · Benjamin Marzinski
currently, most of the callers of
_process_cmd()do not gracefully handle the case where multipathd returns "fail\n".dmmp_flush_mpath()does, but it does extra work to try to figure out after the fact why the
flush command failed. Instead, handle fail replies in_process_cmd()using the appropriate DMMP error codes.Signed-off-by Benjamin Marzinski <[email protected]>
(should Gris Ge have been cc'd on this perhaps? Is he still at Red Hat?)
Benjamin Marzinski
maintainerRe: [PATCH 14/16] libdmmp: handle failures in _process_cmd
Quoted 8 lines · Martin Wilck
Quoted 7 lines · Benjamin Marzinski
currently, most of the callers of
_process_cmd()do not gracefully handle the case where multipathd returns "fail\n".dmmp_flush_mpath()does, but it does extra work to try to figure out after the fact why the
flush command failed. Instead, handle fail replies in_process_cmd()using the appropriate DMMP error codes.
Quoted 6 lines
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>Reviewed-by Martin Wilck <[email protected]>(should Gris Ge have been cc'd on this perhaps? Is he still at Red Hat?)
Yeah. He's still at Red Hat, just working on other things now.
-Ben
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH 15/16] multipath: get rid of unnecessary retries variable
Quoted 4 lines · Benjamin Marzinski
the -R option can just set
conf->remove_retriesdirectly. It has the same effect.Signed-off-by Benjamin Marzinski <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 16/16] multipath: Don't always retry deletgated remove failures
Quoted 6 lines · Benjamin Marzinski
Now that multipathd is running the same code to remove devices as multipath, multipath doesn't need to automatically retry the remove if
it fails.Signed-off-by Benjamin Marzinski <[email protected]>
If we know that multipathd executes the same commands that multipathd does, why don't we just call delegate_to_multipathd() repeatedly until the retries are exhausted?
Martin
Benjamin Marzinski
maintainerRe: [PATCH 16/16] multipath: Don't always retry deletgated remove failures
Quoted 11 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski
Now that multipathd is running the same code to remove devices as multipath, multipath doesn't need to automatically retry the remove if
it fails.Signed-off-by Benjamin Marzinski <[email protected]>If we know that multipathd executes the same commands that multipathd does, why don't we just call
delegate_to_multipathd()repeatedly until the retries are exhausted?
We could. The benefit of the multipath command is a more specific error when the device is in use, and it will work even if multipathd is wedged. On the other hand users can always check the logs for the specifics of which device was in use and we could handle ETIMEDOUT or a reply of "fail\ntimeout" specially. We might want to do that even if the user doesn't ask for retries, since it would be useful for all the delegated commands to failback to doing the work in multipath if multipathd is timing out.
-Ben
Quoted 1 line
Martin
Re: [PATCH 16/16] multipath: Don't always retry deletgated remove failures
Quoted 16 lines · Benjamin Marzinski
Quoted 7 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski
Now that multipathd is running the same code to remove devices as multipath, multipath doesn't need to automatically retry the remove
if
it fails.Quoted 7 lines
Quoted 1 line
Signed-off-by Benjamin Marzinski <[email protected]>If we know that multipathd executes the same commands that multipathd
does, why don't we just calldelegate_to_multipathd()repeatedly until
the retries are exhausted?
Quoted 11 lines
We could. The benefit of the multipath command is a more specific error
when the device is in use, and it will work even if multipathd is wedged. On the other hand users can always check the logs for the specifics of which device was in use and we could handle ETIMEDOUT or a
reply of "fail\ntimeout" specially. We might want to do that even if the
user doesn't ask for retries, since it would be useful for all the delegated commands to failback to doing the work in multipath if multipathd is timing out.
Good point, I agree.
Martin