master - lvmetad: add disabled state
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a4ef8fa25e4a8e14bef132393070006819b30935 Commit: a4ef8fa25e4a8e14bef132393070006819b30935 Parent: e41ee70accbc604e3a7daea0ab10f9405e95a531 Author: David Teigland <[email protected]> AuthorDate: Thu Jan 28 16:54:36 2016 -0600 Committer: David Teigland <[email protected]> CommitterDate: Tue Apr 19 09:41:18 2016 -0500
lvmetad: add disabled state
A global flag in lvmetad indicates it has been disabled. Other flags indicate the reason it was disabled. These flags can be queried using get_global_info.
The lvmetactl debugging utility can set and clear the disabled flag in lvmetad. Nothing else sets the disabled flag yet.
Commands will check these flags after connecting to lvmetad. If the disabled flag is set, the command will not use the lvmetad cache, but revert to disk scanning.
To test this feature:
$ lvmetactl get_global_info response = "OK" global_invalid = 0 global_disable = 0 disable_reason = "none" token = "filter:3041577944"
$ vgs (should report VGs from lvmetad)
$ lvmetactl set_global_disable 1
$ lvmetactl get_global_info response = "OK" global_invalid = 0 global_disable = 1 disable_reason = "DIRECT" token = "filter:3041577944"
$ vgs WARNING: Not using lvmetad because the disable flag was set directly. (should report VGs without contacting lvmetad)
$ lvmetactl set_global_disable 0
$ vgs (should report VGs from lvmetad) --- daemons/lvmetad/lvmetactl.c | 23 ++++++++++-- daemons/lvmetad/lvmetad-core.c | 74 +++++++++++++++++++++++++++++++++++++++- lib/cache/lvmetad.c | 49 ++++++++++++++++++++++++++ lib/cache/lvmetad.h | 3 ++ 4 files changed, 144 insertions(+), 5 deletions(-)
daemons/lvmetad/lvmetactl.c +19 -4
@@ -37,11 +37,12 @@ int main(int argc, char **argv)printf ("lvmetactl dump\n" );printf ("lvmetactl pv_list\n" );printf ("lvmetactl vg_list\n" ); +printf ("lvmetactl get_global_info\n" );printf ("lvmetactl vg_lookup_name <name>\n" );printf ("lvmetactl vg_lookup_uuid <uuid>\n" );printf ("lvmetactl pv_lookup_uuid <uuid>\n" );printf ("lvmetactl set_global_invalid 0|1\n" ); -printf ("lvmetactl get_global_invalid\n" ); +printf ("lvmetactl set_global_disable 0|1\n" );printf ("lvmetactl set_vg_version <uuid> <name> <version>\n" );printf ("lvmetactl vg_lock_type <uuid>\n" );return -1 ;
@@ -69,6 +70,12 @@ int main(int argc, char **argv) NULL);printf ("%s\n" , reply.buffer.mem); + }else if (!strcmp (cmd,"get_global_info" )) { + reply =daemon_send_simple (h,"get_global_info" , +"token = %s" ,"skip" , +NULL ); +printf ("%s\n" , reply.buffer.mem); + }else if (!strcmp (cmd,"set_global_invalid" )) {if (argc <3 ) {printf ("set_global_invalid 0|1\n" );
@@ -82,11 +89,19 @@ int main(int argc, char **argv) NULL);print_reply (reply); - }else if (!strcmp (cmd,"get_global_invalid" )) { - reply =daemon_send_simple (h,"get_global_info" , + }else if (!strcmp (cmd,"set_global_disable" )) { +if (argc <3 ) { +printf ("set_global_disable 0|1\n" ); +return -1 ; + } + val =atoi (argv[2 ]); + + reply =daemon_send_simple (h,"set_global_info" , +"global_disable = " FMTd64, (int64_t ) val, +"disable_reason = %s" ,"DIRECT" ,"token = %s" ,"skip" ,NULL ); -printf ("%s\n" , reply.buffer.mem); +print_reply (reply); }else if (!strcmp (cmd,"set_vg_version" )) {if (argc <5 ) {
daemons/lvmetad/lvmetad-core.c +73 -1
103 lines not on this page · raw message
lib/cache/lvmetad.c +49 -0
52 lines not on this page · raw message
lib/cache/lvmetad.h +3 -0
@@ -172,6 +172,8 @@ int lvmetad_token_matches(struct cmd_context *cmd);int lvmetad_vg_is_foreign (struct cmd_context *cmd,const char *vgname,const char *vgid); +int lvmetad_is_disabled (struct cmd_context *cmd,const char **reason); +# else /* LVMETAD_SUPPORT */ # define lvmetad_init (cmd) do { } while (0)
@@ -202,6 +204,7 @@ int lvmetad_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const cha# define lvmetad_validate_global_cache (cmd, force) do { } while (0)# define lvmetad_vg_is_foreign (cmd, vgname, vgid) (0)# define lvmetad_token_matches (cmd) (1) +# define lvmetad_is_disabled (cmd, reason) (0)# endif /* LVMETAD_SUPPORT */