master - lvmetad: use the disabled flag in commands
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=04a83148cea3b3c7ec7f6ffccb4d84e2372c3f4a Commit: 04a83148cea3b3c7ec7f6ffccb4d84e2372c3f4a Parent: ff867c2ef6b0717c26f2073f0b79041156a6af58 Author: David Teigland <[email protected]> AuthorDate: Wed Apr 6 15:31:15 2016 -0500 Committer: David Teigland <[email protected]> CommitterDate: Tue Apr 19 09:41:18 2016 -0500
lvmetad: use the disabled flag in commands
Commands already check if the lvmetad token is valid, and if not, they rescan devices to repopulate lvmetad before running. Now, in addition to checking the lvmetad token, they also check if the lvmetad disabled flag is set. If so, they do not use the lvmetad cache and revert to disk scanning.
--- lib/cache/lvmetad.c | 7 +++++++ tools/lvmcmdline.c | 13 ++++++++++++- tools/lvscan.c | 9 ++++++++- tools/pvscan.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- tools/vgimport.c | 7 +++++++ tools/vgscan.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 123 insertions(+), 4 deletions(-)
lib/cache/lvmetad.c +7 -0
@@ -2119,6 +2119,7 @@ void lvmetad_validate_global_cache(struct cmd_context *cmd, int force) {struct dm_list pvc_before;/* pv_cache_list */ struct dm_list pvc_after;/* pv_cache_list */ +const char *reason =NULL ;daemon_reply reply;int global_invalid;
@@ -2183,6 +2184,12 @@ void lvmetad_validate_global_cache(struct cmd_context *cmd, int force)return ; } +if (lvmetad_is_disabled (cmd, &reason)) { +log_warn ("WARNING: Not using lvmetad because %s." , reason); +lvmetad_set_active (cmd,0 ); +return ; + } +/* * Clear the global_invalid flag in lvmetad. * Subsequent local commands that read global state
tools/lvmcmdline.c +12 -1
@@ -1475,6 +1475,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) {struct dm_config_tree *config_string_cft;struct dm_config_tree *config_profile_command_cft, *config_profile_metadata_cft; +const char *reason =NULL ;int ret =0 ;int locking_type;int monitoring;
@@ -1625,7 +1626,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)if (lvmetad_used ()) {lvmetad_set_active (cmd,0 ); -log_verbose ("Disabling use of lvmetad because read-only is set." ); +log_verbose ("Not using lvmetad because read-only is set." ); } }else if (arg_count (cmd, nolocking_ARG)) locking_type =0 ;
@@ -1655,6 +1656,11 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)* - Another local command may have run with a different global filter * which changed the content of lvmetad from what we want (recognized * by different token values.) +* +* lvmetad may have been previously disabled (or disabled during the +* rescan done here) because duplicate devices or lvm1 metadata were seen. +* In this case, disable the *use* of lvmetad by this command, reverting to +* disk scanning. */ if (lvmetad_used () && !(cmd->command->flags &NO_LVMETAD_AUTOSCAN )) {if (cmd->include_foreign_vgs || !lvmetad_token_matches (cmd)) {
@@ -1663,6 +1669,11 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)lvmetad_set_active (cmd,0 ); } } + +if (lvmetad_used () &&lvmetad_is_disabled (cmd, &reason)) { +log_warn ("WARNING: Not using lvmetad because %s." , reason); +lvmetad_set_active (cmd,0 ); + } }/*
tools/lvscan.c +8 -1
@@ -91,6 +91,8 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,int lvscan (struct cmd_context *cmd,int argc,char **argv) { +const char *reason =NULL ; +if (argc && !arg_count (cmd, cache_long_ARG)) {log_error ("No additional command line arguments allowed" );return EINVALID_CMD_LINE ;
@@ -100,12 +102,17 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)log_verbose ("Ignoring lvscan --cache because lvmetad is not in use." );/* Needed because this command has NO_LVMETAD_AUTOSCAN. */ -if (lvmetad_used () && !lvmetad_token_matches (cmd)) { +if (lvmetad_used () && (!lvmetad_token_matches (cmd) ||lvmetad_is_disabled (cmd, &reason))) {if (lvmetad_used () && !lvmetad_pvscan_all_devs (cmd,NULL ,0 )) {log_warn ("WARNING: Not using lvmetad because cache update failed." );lvmetad_set_active (cmd,0 ); } +if (lvmetad_used () &&lvmetad_is_disabled (cmd, &reason)) { +log_warn ("WARNING: Not using lvmetad because %s." , reason); +lvmetad_set_active (cmd,0 ); + } +/* * FIXME: doing lvscan --cache after a full scan is pointless. * Should the cache case just exit here?
tools/pvscan.c +47 -1
68 lines not on this page · raw message
tools/vgimport.c +7 -0
@@ -61,6 +61,8 @@ bad:int vgimport (struct cmd_context *cmd,int argc,char **argv) { +const char *reason =NULL ; +if (!argc && !arg_count (cmd, all_ARG) && !arg_is_set (cmd, select_ARG)) {log_error ("Please supply volume groups or -S for selection or use -a for all." );return EINVALID_CMD_LINE ;
@@ -98,6 +100,11 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)log_warn ("WARNING: Not using lvmetad because cache update failed." );lvmetad_set_active (cmd,0 ); } + +if (lvmetad_used () &&lvmetad_is_disabled (cmd, &reason)) { +log_warn ("WARNING: Not using lvmetad because %s." , reason); +lvmetad_set_active (cmd,0 ); + } } return process_each_vg(cmd, argc, argv, NULL,
tools/vgscan.c +42 -1
61 lines not on this page · raw message