1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

persistent filter: Skip import before rescan

The persistent filter should not be imported by any command that doesn't
use it so take addtional note of REQUIRES_FULL_LABEL_SCAN (for vgrename)
and introduce IGNORE_PERSISTENT_FILTER for vgscan and pvscan.
This commit is contained in:
Alasdair G Kergon 2017-11-13 19:45:16 +00:00
parent fe69a8d215
commit 598fcccf45
5 changed files with 25 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
Avoid importing persistent filter in vgscan/pvscan/vgrename.
Fix memleak of string buffer when vgcfgbackup runs in secure mode.
Do not print error when clvmd cannot find running clvmd.
Prevent start of new merge of snapshot if origin is already being merged.

View File

@ -140,6 +140,7 @@ static inline int configtype_arg(struct cmd_context *cmd __attribute__((unused))
#define ENABLE_DUPLICATE_DEVS 0x00000400
#define DISALLOW_TAG_ARGS 0x00000800
#define GET_VGNAME_FROM_OPTIONS 0x00001000
#define IGNORE_PERSISTENT_FILTER 0x00002000
/* create foo_CMD enums for command def ID's in command-lines.in */

View File

@ -149,7 +149,7 @@ xx(pvs,
xx(pvscan,
"List all physical volumes",
PERMITTED_READ_ONLY | LOCKD_VG_SH | NO_LVMETAD_AUTOSCAN)
PERMITTED_READ_ONLY | LOCKD_VG_SH | NO_LVMETAD_AUTOSCAN | IGNORE_PERSISTENT_FILTER)
xx(segtypes,
"List available segment types",
@ -233,7 +233,7 @@ xx(vgs,
xx(vgscan,
"Search for all volume groups",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | NO_LVMETAD_AUTOSCAN)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | NO_LVMETAD_AUTOSCAN | IGNORE_PERSISTENT_FILTER)
xx(vgsplit,
"Move physical volumes into a new or existing volume group",

View File

@ -2706,6 +2706,21 @@ static int _cmd_no_meta_proc(struct cmd_context *cmd)
return cmd->cname->flags & NO_METADATA_PROCESSING;
}
static int _cmd_no_lvmetad_autoscan(struct cmd_context *cmd)
{
return cmd->cname->flags & NO_LVMETAD_AUTOSCAN;
}
static int _cmd_requires_full_label_scan(struct cmd_context *cmd)
{
return cmd->cname->flags & REQUIRES_FULL_LABEL_SCAN;
}
static int _cmd_ignores_persistent_filter(struct cmd_context *cmd)
{
return cmd->cname->flags & IGNORE_PERSISTENT_FILTER;
}
int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
{
struct dm_config_tree *config_string_cft, *config_profile_command_cft, *config_profile_metadata_cft;
@ -2831,8 +2846,10 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
/* 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.
* Similarly ignore the persistent cache if the command is going to discard it regardless.
*/
if (!cmd->initialized.filters && !_cmd_no_meta_proc(cmd) && !init_filters(cmd, !refresh_done))
if (!cmd->initialized.filters && !_cmd_no_meta_proc(cmd) &&
!init_filters(cmd, !(refresh_done || _cmd_requires_full_label_scan(cmd) || _cmd_ignores_persistent_filter(cmd))))
return_ECMD_FAILED;
if (arg_is_set(cmd, readonly_ARG))
@ -2945,7 +2962,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
* In this case, disable the *use* of lvmetad by this command, reverting to
* disk scanning.
*/
if (lvmetad_used() && !(cmd->cname->flags & NO_LVMETAD_AUTOSCAN)) {
if (lvmetad_used() && !_cmd_no_lvmetad_autoscan(cmd)) {
if (cmd->include_foreign_vgs || !lvmetad_token_matches(cmd)) {
if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, cmd->include_foreign_vgs ? 1 : 0)) {
log_warn("WARNING: Not using lvmetad because cache update failed.");

View File

@ -137,6 +137,8 @@ struct arg_value_group_list {
#define DISALLOW_TAG_ARGS 0x00000800
/* Command may need to find VG name in an option value. */
#define GET_VGNAME_FROM_OPTIONS 0x00001000
/* Command must not load the contents saved by the persistent filter */
#define IGNORE_PERSISTENT_FILTER 0x00002000
void usage(const char *name);