mirror of
git://sourceware.org/git/lvm2.git
synced 2025-08-02 04:22:02 +03:00
dev-cache: ignore persistent cache if configuration changed
Commitf6473baffc
introduced a new cmd->initialized variable to keep info about which parts of the cmd_context have been initialized. A part of this patch was also a change in refresh_filters fn which checks for cmd->initialized.filters variable and it does the filter refresh *only* if the filter has already been initialized before otherwise it's a NOOP (before, the refresh_filters also initialized filters as a side effect in case it had not been initialized before which was not quite correct). However, the commitf6473baffc
did not handle the case in which configuration changes either via --config argument or when configuration file changed and its timestamp was higher than the timestamp of the persistent cache file - the /etc/lvm/cache/.cache. This patch fixes this issue and it causes the init_filters fn in lvm_run_command fn to be called with proper value of "load_persistent_cache" switch even if the configuration changes, hence causing the persistent cache file to be ignored in this case.
This commit is contained in:
@ -1478,6 +1478,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
||||
char *arg_new, *arg;
|
||||
int i;
|
||||
int skip_hyphens;
|
||||
int refresh_done = 0;
|
||||
|
||||
init_error_message_produced(0);
|
||||
|
||||
@ -1554,6 +1555,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_error("Updated config file invalid. Aborting.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
refresh_done = 1;
|
||||
}
|
||||
|
||||
if (!_prepare_profiles(cmd))
|
||||
@ -1562,7 +1564,11 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
||||
if (!cmd->initialized.connections && !_cmd_no_meta_proc(cmd) && !init_connections(cmd))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
if (!cmd->initialized.filters && !_cmd_no_meta_proc(cmd) && !init_filters(cmd, 1))
|
||||
/* Note: Load persistent cache only if we haven't refreshed toolcontext!
|
||||
* If toolcontext has been refreshed, it means config has changed
|
||||
* and we can't rely on persistent cache anymore.
|
||||
*/
|
||||
if (!cmd->initialized.filters && !_cmd_no_meta_proc(cmd) && !init_filters(cmd, !refresh_done))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
if (arg_count(cmd, readonly_ARG))
|
||||
|
Reference in New Issue
Block a user