multipathd: Make sure to disable queueing if recovery has failed.
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]
Quoted 49 lines · Benjamin Marzinski
If a multipath device has
no_path_retryset to a number and has lost all
paths, gone into recovery mode, and timed out, it will disablequeue_if_no_paths. After that, if one of those failed paths is removed,
when the device is reloaded,queue_if_no_pathswill be re-enabled. Whenset_no_path_retry()is then called to update the queueing state, it will
not disablequeue_if_no_paths, since the device is still in the recovery
state, so it believes no work needs to be done. The device will remain
in the recovery state, withretry_ticksat 0, and queueing enabled, even though there are no usable paths.To fix this, in
set_no_path_retry(), ifno_path_retryis set to a number
and the device is queueing but it is in recovery mode and out of retries with no usable paths, manually disablequeue_if_no_path.Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/structs_vec.c | 23 ++++++++++++++++++++++-1 file changed, 22 insertions(+), 1 deletion(-)libmultipath/structs_vec.c +3
-1@@ -627,8 +627,18 @@ void set_no_path_retry(struct multipath *mpp) !mpp->in_recovery) dm_queue_if_no_path(mpp->alias, 1); leave_recovery_mode(mpp); - }else if (pathcount (mpp,PATH_PENDING ) ==0 ) + }else if (pathcount (mpp,PATH_PENDING ) ==0 ) { +/* +* If in_recovery is set,
enter_recovery_modedoeslibmultipath/structs_vec.c +1
-0+* nothing. If the device is already in recovery
libmultipath/structs_vec.c +1
-0+* mode and has already timed out, manually call
libmultipath/structs_vec.c +1
-0+* dm_queue_if_no_path to stop it from queueing.
libmultipath/structs_vec.c +3
-0+*/ +if ((!mpp->features || is_queueing) && + mpp->in_recovery && mpp->retry_tick ==0)
libmultipath/structs_vec.c
Quoted 1 line
libmultipath/structs_vec.c +1
-0+dm_queue_if_no_path (mpp->alias,0 );
I don't understand why you put this statement in the pathcount(mpp, PATH_PENDING) == 0 clause. In 7278108 ("libmultipath: don't enter recovery mode with pending paths"), you argued correctly that recovery mode should not be *entered* with pending paths, but here we are in recovery mode already.
Also, what do you think about the following? This way, we'd avoid enabling queueing temporarily when we reload the map.
libmultipath/dmparser.c +12 -2
@@ -60,9 +60,19 @@ int assemble_map(struct multipath *mp, char **params) nr_priority_groups =VECTOR_SIZE (mp->pg); initial_pg_nr = (nr_priority_groups ? mp->bestpg :0 ); -if (mp->no_path_retry !=NO_PATH_RETRY_UNDEF && - mp->no_path_retry !=NO_PATH_RETRY_FAIL ) { +switch (mp->no_path_retry) { +case NO_PATH_RETRY_UNDEF : +case NO_PATH_RETRY_FAIL : +break ; +default : +/* don't enable queueing if no_path_retry has timed out */ +if (mp->in_recovery && mp->retry_tick ==0 && +count_active_paths (mp) ==0 ) +break ; +/* fallthrough */ +case NO_PATH_RETRY_QUEUE :add_feature (&mp->features, no_path_retry); +break ; }if (mp->retain_hwhandler ==RETAIN_HWHANDLER_ON &&get_linux_version_code () <KERNEL_VERSION (4 ,3 ,0 ))
Regards
Martin
Benjamin Marzinski
maintainerQuoted 49 lines · Martin Wilck
Quoted 48 lines · Benjamin Marzinski
If a multipath device has
no_path_retryset to a number and has lost all
paths, gone into recovery mode, and timed out, it will disablequeue_if_no_paths. After that, if one of those failed paths is removed,
when the device is reloaded,queue_if_no_pathswill be re-enabled. Whenset_no_path_retry()is then called to update the queueing state, it will
not disablequeue_if_no_paths, since the device is still in the recovery
state, so it believes no work needs to be done. The device will remain
in the recovery state, withretry_ticksat 0, and queueing enabled, even though there are no usable paths.To fix this, in
set_no_path_retry(), ifno_path_retryis set to a number
and the device is queueing but it is in recovery mode and out of retries with no usable paths, manually disablequeue_if_no_path.Signed-off-by Benjamin Marzinski <[email protected]>---
libmultipath/structs_vec.c | 23 ++++++++++++++++++++++-1 file changed, 22 insertions(+), 1 deletion(-)libmultipath/structs_vec.c +3
-1@@ -627,8 +627,18 @@ void set_no_path_retry(struct multipath *mpp) !mpp->in_recovery) dm_queue_if_no_path(mpp->alias, 1); leave_recovery_mode(mpp); - }else if (pathcount (mpp,PATH_PENDING ) ==0 ) + }else if (pathcount (mpp,PATH_PENDING ) ==0 ) { +/* +* If in_recovery is set,
enter_recovery_modedoeslibmultipath/structs_vec.c +1
-0+* nothing. If the device is already in recovery
libmultipath/structs_vec.c +1
-0+* mode and has already timed out, manually call
libmultipath/structs_vec.c +1
-0+* dm_queue_if_no_path to stop it from queueing.
libmultipath/structs_vec.c +3
-0+*/ +if ((!mpp->features || is_queueing) && + mpp->in_recovery && mpp->retry_tick ==
Quoted 8 lines
libmultipath/structs_vec.c
Quoted 2 lines
0)
libmultipath/structs_vec.c +1
-0+dm_queue_if_no_path (mpp->alias,0 );I don't understand why you put this statement in the
pathcount(mpp, PATH_PENDING)== 0 clause. In 7278108 ("libmultipath: don't enter recovery mode with pending paths"), you argued correctly that recovery mode should not be *entered* with pending paths, but here we are in recovery mode already.
I see your point. But I think the only way this could happen is if you added a new path to a multipath device that was already in recovery mode. If the path checker didn't finish quickly enough during path addition, the path will be in PATH_PENDING after the reload. The fact that you are adding the path makes it seem more likely that the path is working. In this case, it seems a little wrong to have a multipath device that starts queueing on the reload, and then disables queueing, only to reenable it again a second later when the pending path is rechecked and is found to be up. I think it's reasonable to wait for the PENDING state to get resolved before you take any actions here. But I don't really have strong feelings about this, so if you do, I'm fine with changing it.
Quoted 19 lines
Also, what do you think about the following? This way, we'd avoid enabling queueing temporarily when we reload the map.
libmultipath/dmparser.c +6
-2@@ -60,9 +60,19 @@ int assemble_map(struct multipath *mp, char **params) nr_priority_groups =VECTOR_SIZE (mp->pg); initial_pg_nr = (nr_priority_groups ? mp->bestpg :0 ); -if (mp->no_path_retry !=NO_PATH_RETRY_UNDEF && - mp->no_path_retry !=NO_PATH_RETRY_FAIL ) { +switch (mp->no_path_retry) { +case NO_PATH_RETRY_UNDEF : +case NO_PATH_RETRY_FAIL : +break ; +default : +/* don't enable queueing if no_path_retry has timed out */
libmultipath/dmparser.c int assemble_map(struct multipath *mp, char **params) · line 78
Quoted 10 lines
libmultipath/dmparser.c +6
-0+if (mp->in_recovery && mp->retry_tick ==0 && +count_active_paths (mp) ==0 ) +break ; +/* fallthrough */ +case NO_PATH_RETRY_QUEUE :add_feature (&mp->features, no_path_retry); +break ; }if (mp->retain_hwhandler ==RETAIN_HWHANDLER_ON &&get_linux_version_code () <KERNEL_VERSION (4 ,3 ,0 ))
This looks good.
-Ben
Quoted 4 lines
Regards
Martin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 5/5] multipathd: force setting dm state when disabling/restoring queueing
Quoted 8 lines · Benjamin Marzinski
Currently, the interactive commands to disable and restore queueing call
set_no_path_retry()without first re-reading the device table. This means that the value ofmpp->featuresmight not be current, which means
thatset_no_path_retry()might not tell device-mapper to change thequeue_if_no_pathstate when it should have.
Quoted 7 lines
Instead of making these commands do extra work to re-read the device table, simply make them always tell dm to update the
queue_if_no_pathstate, regardless of the current state. There is no harm in telling dm
to set the state to its current value.Signed-off-by Benjamin Marzinski <[email protected]>
I am still not convinced, as this goes against the spirit of keeping the no_path_retry setting consistently in a single place. Why don't we rather make sure that our "features" string correctly matches the kernel settings (ignoring possible attempts to bypass multipathd)?
The code snippet I sent in reply to your 1/5 patch should achieve this for map reloading. Queueing can only changed by (re)loading, or by sending dm messages. Thus AFAICS it should be sufficient to add calls to add_feature("queue_if_no_path") and remove_feature("queue_if_no_path") to dm_queue_if_no_path(). Am I overlooking something?
Wrt "there is no harm in telling dm to set the state to its current value", the kernel doesn't seem to check whether the new and current value are the same. It always takes a spinlock and set some flags in the dm device. So the ioctl is not a zero-cost operation.
Apart from these general doubts, I have some more remarks below.
Before 6071176 ("libmultipath: drop mpp->nr_active field"), which introduced the call to set_no_path_retry() from cli_restore_queueing(), we also reset mpp->retry_tick, which your new code does not. (That was actually part of the motivation to use set_no_path_retry() rather than direct calls to dm_queue_if_no_path(), IIRC).
The term "restorequeuing" suggests that it's somehow reset to a previously saved value, which is not the case. We should mention in the man page that "restorequeuing" actually just enables queueing (for maps that are configured to queue). Perhaps we should also add "enablequeueing" as an alias for "restorequeueing".
Quoted 37 lines
---
multipathd/cli_handlers.c | 25 +++++++++----------------1 file changed, 9 insertions(+), 16 deletions(-)multipathd/cli_handlers.c +0
-0@@ -934,16 +934,9 @@ cli_restore_queueing(void *v, struct strbuf *reply, void *data) select_no_path_retry(conf, mpp); pthread_cleanup_pop(1);multipathd/cli_handlers.c +0
-2-/* -* Don't call set_no_path_retry() for the NO_PATH_RETRY_FAIL case.
multipathd/cli_handlers.c +0
-1-* That would disable queueing when "restorequeueing" is called,
multipathd/cli_handlers.c +0
-1-* and the code never behaved that way. Users might not expect it.
multipathd/cli_handlers.c +0
-1-* In almost all cases, queueing will be disabled anyway when we
multipathd/cli_handlers.c +3
-5-* are here. -*/ -if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF && - mpp->no_path_retry != NO_PATH_RETRY_FAIL) -set_no_path_retry (mpp); +if (mpp->no_path_retry ==NO_PATH_RETRY_QUEUE || + (mpp->no_path_retry > 0 && count_active_paths(mpp) > 0)) +dm_queue_if_no_path (mpp->alias,1 );
return 0;
}multipathd/cli_handlers.c +0
-0@@ -962,10 +955,10 @@ cli_restore_all_queueing(void *v, struct strbuf *reply, void *data) pthread_cleanup_push(put_multipath_config, conf); select_no_path_retry(conf, mpp);
multipathd/cli_handlers.c cli_restore_all_queueing(void *v, struct strbuf · line 963
Quoted 10 lines
multipathd/cli_handlers.c +4
-4pthread_cleanup_pop(1); -/* See comment in cli_restore_queueing() */ -if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF && - mpp->no_path_retry != NO_PATH_RETRY_FAIL) -set_no_path_retry (mpp); + +if (mpp->no_path_retry ==NO_PATH_RETRY_QUEUE || + (mpp->no_path_retry > 0 &&count_active_paths (mpp) >0 )) +dm_queue_if_no_path (mpp->alias,1 );
What about the case when there are no active paths, no pending paths, mpp->in_recovery and mpp->retry_tick > 0?
Regards,
Martin
Benjamin Marzinski
maintainerRe: [PATCH v2 5/5] multipathd: force setting dm state when disabling/restoring queueing
Quoted 29 lines · Martin Wilck
Quoted 8 lines · Benjamin Marzinski
Currently, the interactive commands to disable and restore queueing call
set_no_path_retry()without first re-reading the device table. This means that the value ofmpp->featuresmight not be current, which means
thatset_no_path_retry()might not tell device-mapper to change thequeue_if_no_pathstate when it should have.Quoted 7 lines
Instead of making these commands do extra work to re-read the device table, simply make them always tell dm to update the
queue_if_no_pathstate, regardless of the current state. There is no harm in telling dm
to set the state to its current value.Signed-off-by Benjamin Marzinski <[email protected]>I am still not convinced, as this goes against the spirit of keeping the
no_path_retrysetting consistently in a single place. Why don't we rather make sure that our "features" string correctly matches the kernel settings (ignoring possible attempts to bypass multipathd)?The code snippet I sent in reply to your 1/5 patch should achieve this for map reloading. Queueing can only changed by (re)loading, or by sending dm messages. Thus AFAICS it should be sufficient to add calls to
add_feature("queue_if_no_path")andremove_feature("queue_if_no_path")todm_queue_if_no_path(). Am I overlooking something?
Quoted 4 lines
Wrt "there is no harm in telling dm to set the state to its current value", the kernel doesn't seem to check whether the new and current value are the same. It always takes a spinlock and set some flags in the dm device. So the ioctl is not a zero-cost operation.
fair enough. I can replace this with a patch to keep mpp->features in sync with what multipathd has done to the device.
Quoted 8 lines
Apart from these general doubts, I have some more remarks below.
Before 6071176 ("libmultipath: drop
mpp->nr_activefield"), which introduced the call toset_no_path_retry()fromcli_restore_queueing(), we also resetmpp->retry_tick, which your new code does not. (That was actually part of the motivation to useset_no_path_retry()rather than direct calls todm_queue_if_no_path(), IIRC).
Quoted 5 lines
The term "restorequeuing" suggests that it's somehow reset to a previously saved value, which is not the case. We should mention in the man page that "restorequeuing" actually just enables queueing (for maps that are configured to queue). Perhaps we should also add "enablequeueing" as an alias for "restorequeueing".
I don't like the name "enablequeueing". "disablequeueing" turns queueing off regardless of the device's setting. "enablequeueing" sound like it could turn queueing on regardless of the device's setting. If you'd like, we could add code to restore queueing to stop queueing if we shouldn't be, but I'm not sure how that could happen, so it seems unnecessary, unless there's some way that this could happen that I'm not thinking about. I'm fine with updating the man page to mention that "restorequeueing" will just reset no_path_retry to the configured setting and reenable queueing if necessary.
Quoted 42 lines
Quoted 42 lines
---
multipathd/cli_handlers.c | 25 +++++++++----------------1 file changed, 9 insertions(+), 16 deletions(-)multipathd/cli_handlers.c +0
-0@@ -934,16 +934,9 @@ cli_restore_queueing(void *v, struct strbuf *reply, void *data) select_no_path_retry(conf, mpp); pthread_cleanup_pop(1);multipathd/cli_handlers.c +0
-2-/* -* Don't call set_no_path_retry() for the NO_PATH_RETRY_FAIL case.
multipathd/cli_handlers.c +0
-1-* That would disable queueing when "restorequeueing" is called,
multipathd/cli_handlers.c +0
-1-* and the code never behaved that way. Users might not expect it.
multipathd/cli_handlers.c +0
-1-* In almost all cases, queueing will be disabled anyway when we
multipathd/cli_handlers.c +3
-5-* are here. -*/ -if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF && - mpp->no_path_retry != NO_PATH_RETRY_FAIL) -set_no_path_retry (mpp); +if (mpp->no_path_retry ==NO_PATH_RETRY_QUEUE || + (mpp->no_path_retry > 0 && count_active_paths(mpp) > 0)) +dm_queue_if_no_path (mpp->alias,1 );
return 0;
}multipathd/cli_handlers.c +0
-4@@ -962,10 +955,10 @@ cli_restore_all_queueing(void *v, struct strbuf *reply, void *data) pthread_cleanup_push(put_multipath_config, conf); select_no_path_retry(conf, mpp); pthread_cleanup_pop(1); -/* See comment in cli_restore_queueing() */ -if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF && - mpp->no_path_retry != NO_PATH_RETRY_FAIL) -set_no_path_retry (mpp);
Quoted 8 lines
multipathd/cli_handlers.c cli_restore_all_queueing(void *v, struct strbuf · line 963
Quoted 5 lines
multipathd/cli_handlers.c +4
-0+ +if (mpp->no_path_retry ==NO_PATH_RETRY_QUEUE || + (mpp->no_path_retry > 0 &&count_active_paths (mpp) >0 )) +dm_queue_if_no_path (mpp->alias,1 );What about the case when there are no active paths, no pending paths,
mpp->in_recoveryandmpp->retry_tick> 0?
I guess I always sort of assumed the the restore queueing commands would get called after the disablequeueing commands. In that case, retry_tick can't be greater than 0. But if the plan is to keep mpp->features in sync, and we go back to calling set_no_path_retry() here, we still won't enable queueing it the state you mention. I would argue that there's not much point in doing so. We don't have paths, and we already were failing back IO, so anything that was sending IO will already have seen failures. There doesn't seem much point in turning it back on now. Besides how would we even get into this state? I suppose something outside of multipathd could have turned off queueing.
I was planning on just going back to set_no_path_retry() if we keep mpp->features in sync, unless you object.
-Ben
Quoted 3 lines
Regards,
Martin
Re: [PATCH v2 5/5] multipathd: force setting dm state when disabling/restoring queueing
Quoted 9 lines · Benjamin Marzinski
Quoted 7 lines · Martin Wilck
The term "restorequeuing" suggests that it's somehow reset to a previously saved value, which is not the case. We should mention in the
man page that "restorequeuing" actually just enables queueing (for maps
that are configured to queue). Perhaps we should also add "enablequeueing" as an alias for "restorequeueing".
Quoted 13 lines
I don't like the name "enablequeueing". "disablequeueing" turns queueing
off regardless of the device's setting. "enablequeueing" sound like it
could turn queueing on regardless of the device's setting. If you'd like,
we could add code to restore queueing to stop queueing if we shouldn't
be, but I'm not sure how that could happen, so it seems unnecessary, unless there's some way that this could happen that I'm not thinking about. I'm fine with updating the man page to mention that "restorequeueing" will just resetno_path_retryto the configured setting and reenable queueing if necessary.
Ok, forget about "enablequeueing", then. Let's just make sure the man page accurately describes what "restorequeuing" does.
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
(quoted diff) +0
-0@@ -962,10 +955,10 @@ cli_restore_all_queueing(void *v, structstrbuf
*reply, void *data)pthread_cleanup_push(put_multipath_config, conf);
select_no_path_retry(conf, mpp);pthread_cleanup_pop(1);(quoted diff) +1
-4- /* See comment in cli_restore_queueing() */ - if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF && - mpp->no_path_retry != NO_PATH_RETRY_FAIL) - set_no_path_retry(mpp); +Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+ if (mpp->no_path_retry == NO_PATH_RETRY_QUEUE || + (mpp->no_path_retry > 0 &&
count_active_paths(mpp)> 0))(quoted diff) +1
-0+ dm_queue_if_no_path(mpp->alias, 1);What about the case when there are no active paths, no pending paths,
mpp->in_recoveryandmpp->retry_tick> 0?
Quoted 12 lines
I guess I always sort of assumed the the restore queueing commands would
get called after the disablequeueing commands. In that case,retry_tick
can't be greater than 0. But if the plan is to keepmpp->featuresin sync, and we go back to callingset_no_path_retry()here, we still won't
enable queueing it the state you mention. I would argue that there's not much point in doing so. We don't have paths, and we already were failing back IO, so anything that was sending IO will already have seen
failures. There doesn't seem much point in turning it back on now.
That makes some sense, yet IMO a user would expect that "restorequeueing" does just that, whether or not it's reasonable to do so. If it does not, we need to document it, I think.
I wonder if we can / should somehow enforce that "restorequeueing" can only be called on a map on which "disablequeueing" had been called previously.
Quoted 5 lines
Besides how would we even get into this state? I suppose something outside of multipathd could have turned off queueing.
I was planning on just going back to
set_no_path_retry()if we keepmpp->featuresin sync, unless you object.
No objections.
Regards,
Martin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH v2 3/5] multipathd: remove reset option from update_multipath
Quoted 5 lines · Benjamin Marzinski
Since all callers now set the reset argument, it's unnecessary to keep
it as an argument.Signed-off-by Benjamin Marzinski <[email protected]>
(as noted before, this breaks the dmevent test, but that can be easily fixed in the test itself).
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 2/5] multipathd: don't modify the multipath device on show commands
Quoted 6 lines · Benjamin Marzinski
The commands to show a multipath device are supposed to return its current state without updating it. Even when reset is 0,
update_multipath()still can update the device. Call,__setup_multipath()instead to just fetch the current state.Signed-off-by Benjamin Marzinski <[email protected]>
__setup_multipath() can still call remove_map_and_stop_waiter(), do we want to avoid that, too, maybe?
Martin
Benjamin Marzinski
maintainerRe: [PATCH v2 2/5] multipathd: don't modify the multipath device on show commands
Quoted 10 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski
The commands to show a multipath device are supposed to return its current state without updating it. Even when reset is 0,
update_multipath()still can update the device. Call,__setup_multipath()instead to just fetch the current state.Signed-off-by Benjamin Marzinski <[email protected]>
__setup_multipath()can still callremove_map_and_stop_waiter(), do we want to avoid that, too, maybe?
If there really is no multipath device anymore, I don't see a benefit in keeping it around in multipathd until the next path check, do you?
-Ben
Quoted 2 lines
Martin
Re: [PATCH v2 2/5] multipathd: don't modify the multipath device on show commands
Quoted 10 lines · Benjamin Marzinski
Quoted 9 lines · Martin Wilck
Quoted 7 lines · Benjamin Marzinski
The commands to show a multipath device are supposed to return its
current state without updating it. Even when reset is 0,update_multipath()still can update the device. Call,__setup_multipath()instead to just fetch the current state.Signed-off-by Benjamin Marzinski <[email protected]>
Quoted 7 lines
Quoted 3 lines
__setup_multipath()can still callremove_map_and_stop_waiter(), do we
want to avoid that, too, maybe?If there really is no multipath device anymore, I don't see a benefit in
keeping it around in multipathd until the next path check, do you?
No, but that wasn't my point. I thought the rationale was that a "show" command shouldn't change the internal state of multipathd in any way. That would imply not calling remove_map_and_stop_waiter(). But I agree it's really a corner case. I just wanted to make sure that this was no oversight.
Martin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Martin Wilck
Reviewed-byRe: [PATCH v2 4/5] multipathd: cleanup __setup_multipath
Quoted 6 lines · Benjamin Marzinski
split
__setup_multipath()into two functions:refresh_multipath(), that
updates the table and status, andsetup_multipath(), which works as before, but now callsrefresh_multipath().Signed-off-by Benjamin Marzinski <[email protected]>
If this set goes through a v3, please merge this patch with 2/5.
Martin
Benjamin Marzinski
maintainerRe: [PATCH v2 4/5] multipathd: cleanup __setup_multipath
Quoted 11 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski
split
__setup_multipath()into two functions:refresh_multipath(), that
updates the table and status, andsetup_multipath(), which works as before, but now callsrefresh_multipath().Signed-off-by Benjamin Marzinski <[email protected]>Reviewed-by Martin Wilck <[email protected]>If this set goes through a v3, please merge this patch with 2/5.
Sure
-Ben
Quoted 2 lines
Martin