mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
filters: refresh filters when lvmetad use is toggled
We need to use proper filter chain when we disable lvmetad use explicitly in the code by calling lvmetad_set_active(0) while overriding existing configuration. We need to reinitialize filters in this case so proper filter chain is used. The same applies for the other way round - when we enable lvmetad use explicitly in the code (though this is not yet used).
This commit is contained in:
parent
c2981cf921
commit
a5f01dad22
4
lib/cache/lvmetad.c
vendored
4
lib/cache/lvmetad.c
vendored
@ -98,11 +98,13 @@ int lvmetad_active(void)
|
|||||||
return _lvmetad_connected;
|
return _lvmetad_connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lvmetad_set_active(int active)
|
void lvmetad_set_active(struct cmd_context *cmd, int active)
|
||||||
{
|
{
|
||||||
_lvmetad_use = active;
|
_lvmetad_use = active;
|
||||||
if (!active && lvmetad_active())
|
if (!active && lvmetad_active())
|
||||||
lvmetad_disconnect();
|
lvmetad_disconnect();
|
||||||
|
if (cmd && !refresh_filters(cmd))
|
||||||
|
stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
4
lib/cache/lvmetad.h
vendored
4
lib/cache/lvmetad.h
vendored
@ -37,7 +37,7 @@ void lvmetad_init(struct cmd_context *);
|
|||||||
/*
|
/*
|
||||||
* Override the use of lvmetad for retrieving scan results and metadata.
|
* Override the use of lvmetad for retrieving scan results and metadata.
|
||||||
*/
|
*/
|
||||||
void lvmetad_set_active(int);
|
void lvmetad_set_active(struct cmd_context *, int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure the socket that lvmetad_init will use to connect to the daemon.
|
* Configure the socket that lvmetad_init will use to connect to the daemon.
|
||||||
@ -161,7 +161,7 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
|
|||||||
|
|
||||||
# define lvmetad_init(cmd) do { } while (0)
|
# define lvmetad_init(cmd) do { } while (0)
|
||||||
# define lvmetad_disconnect() do { } while (0)
|
# define lvmetad_disconnect() do { } while (0)
|
||||||
# define lvmetad_set_active(a) do { } while (0)
|
# define lvmetad_set_active(cmd, a) do { } while (0)
|
||||||
# define lvmetad_set_socket(a) do { } while (0)
|
# define lvmetad_set_socket(a) do { } while (0)
|
||||||
# define lvmetad_used() (0)
|
# define lvmetad_used() (0)
|
||||||
# define lvmetad_socket_present() (0)
|
# define lvmetad_socket_present() (0)
|
||||||
|
@ -463,9 +463,9 @@ static int _process_config(struct cmd_context *cmd)
|
|||||||
find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
|
find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
|
||||||
log_warn("WARNING: configuration setting use_lvmetad overridden to 0 due to locking_type 3. "
|
log_warn("WARNING: configuration setting use_lvmetad overridden to 0 due to locking_type 3. "
|
||||||
"Clustered environment not supported by lvmetad yet.");
|
"Clustered environment not supported by lvmetad yet.");
|
||||||
lvmetad_set_active(0);
|
lvmetad_set_active(NULL, 0);
|
||||||
} else
|
} else
|
||||||
lvmetad_set_active(find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL));
|
lvmetad_set_active(NULL, find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL));
|
||||||
|
|
||||||
lvmetad_init(cmd);
|
lvmetad_init(cmd);
|
||||||
|
|
||||||
@ -972,8 +972,10 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
|
|||||||
log_verbose("Failed to create usable device filter.");
|
log_verbose("Failed to create usable device filter.");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
filter_components[0] = cmd->lvmetad_filter;
|
filter_components[0] = cmd->lvmetad_filter;
|
||||||
|
cmd->lvmetad_filter = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* filter component 1 */
|
/* filter component 1 */
|
||||||
if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
|
if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
|
||||||
@ -1036,7 +1038,7 @@ bad:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if lvmetad is used, the cmd->lvmetad_filter is separate */
|
/* if lvmetad is used, the cmd->lvmetad_filter is separate */
|
||||||
if (lvmetad_used() && cmd->lvmetad_filter)
|
if (cmd->lvmetad_filter)
|
||||||
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
|
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1659,7 +1661,7 @@ static void _destroy_filters(struct cmd_context *cmd)
|
|||||||
* is actually a part of cmd->filter and as such, it
|
* is actually a part of cmd->filter and as such, it
|
||||||
* will be destroyed together with cmd->filter.
|
* will be destroyed together with cmd->filter.
|
||||||
*/
|
*/
|
||||||
if (lvmetad_used() && cmd->lvmetad_filter) {
|
if (cmd->lvmetad_filter) {
|
||||||
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
|
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
|
||||||
cmd->lvmetad_filter = NULL;
|
cmd->lvmetad_filter = NULL;
|
||||||
}
|
}
|
||||||
@ -1826,7 +1828,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
|||||||
* is actually a part of cmd->filter and as such, it
|
* is actually a part of cmd->filter and as such, it
|
||||||
* will be destroyed together with cmd->filter.
|
* will be destroyed together with cmd->filter.
|
||||||
*/
|
*/
|
||||||
if (lvmetad_used() && cmd->lvmetad_filter)
|
if (cmd->lvmetad_filter)
|
||||||
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
|
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
|
||||||
if (cmd->filter)
|
if (cmd->filter)
|
||||||
cmd->filter->destroy(cmd->filter);
|
cmd->filter->destroy(cmd->filter);
|
||||||
|
@ -1131,7 +1131,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
* direct activation instead of autoactivation.
|
* direct activation instead of autoactivation.
|
||||||
*/
|
*/
|
||||||
log_warn("lvmetad is not active yet, using direct activation during sysinit");
|
log_warn("lvmetad is not active yet, using direct activation during sysinit");
|
||||||
lvmetad_set_active(0);
|
lvmetad_set_active(cmd, 0);
|
||||||
} else if (lvmetad_active()) {
|
} else if (lvmetad_active()) {
|
||||||
/*
|
/*
|
||||||
* If lvmetad is active already, we want
|
* If lvmetad is active already, we want
|
||||||
|
@ -1342,7 +1342,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
if (arg_count(cmd, readonly_ARG)) {
|
if (arg_count(cmd, readonly_ARG)) {
|
||||||
locking_type = 5;
|
locking_type = 5;
|
||||||
if (lvmetad_used()) {
|
if (lvmetad_used()) {
|
||||||
lvmetad_set_active(0);
|
lvmetad_set_active(cmd, 0);
|
||||||
log_verbose("Disabling use of lvmetad because read-only is set.");
|
log_verbose("Disabling use of lvmetad because read-only is set.");
|
||||||
}
|
}
|
||||||
} else if (arg_count(cmd, nolocking_ARG))
|
} else if (arg_count(cmd, nolocking_ARG))
|
||||||
|
@ -689,7 +689,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
* direct activation instead of autoactivation.
|
* direct activation instead of autoactivation.
|
||||||
*/
|
*/
|
||||||
log_warn("lvmetad is not active yet, using direct activation during sysinit");
|
log_warn("lvmetad is not active yet, using direct activation during sysinit");
|
||||||
lvmetad_set_active(0);
|
lvmetad_set_active(cmd, 0);
|
||||||
} else if (lvmetad_active()) {
|
} else if (lvmetad_active()) {
|
||||||
/*
|
/*
|
||||||
* If lvmetad is active already, we want
|
* If lvmetad is active already, we want
|
||||||
|
@ -37,7 +37,7 @@ static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
|
|||||||
|
|
||||||
int vgck(struct cmd_context *cmd, int argc, char **argv)
|
int vgck(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
lvmetad_set_active(0);
|
lvmetad_set_active(cmd, 0);
|
||||||
return process_each_vg(cmd, argc, argv, 0, NULL,
|
return process_each_vg(cmd, argc, argv, 0, NULL,
|
||||||
&vgck_single);
|
&vgck_single);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user