master - toolcontext: add switches to create_toolcontext for connections and filters init
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f6473baffc2d0b486b2aa941cf2681683026b3a5 Commit: f6473baffc2d0b486b2aa941cf2681683026b3a5 Parent: 3e343ba5ef02d8ae3e87eadc80cf69fc34c65622 Author: Peter Rajnoha <[email protected]> AuthorDate: Thu Jul 30 10:34:10 2015 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Thu Jul 30 13:54:09 2015 +0200
toolcontext: add switches to create_toolcontext for connections and filters init
Make it possible to decide whether we want to initialize connections and filters together with toolcontext creation.
Add "filters" and "connections" fields to struct cmd_context_initialized_parts and set these in cmd_context.initialized instance accordingly.
(For now, all create_toolcontext calls do initialize connections and filters, we'll change that in subsequent patch appropriately.)
--- daemons/clvmd/lvm-functions.c | 2 +- daemons/lvmetad/testclient.c | 2 +- lib/commands/toolcontext.c | 54 ++++++++++++++++++++++++++++------------ lib/commands/toolcontext.h | 8 +++++- liblvm/lvm_base.c | 2 +- tools/lvm2cmdline.h | 2 +- tools/lvmcmdlib.c | 2 +- tools/lvmcmdline.c | 7 +++-- 8 files changed, 54 insertions(+), 25 deletions(-)
daemons/clvmd/lvm-functions.c +1 -1
@@ -899,7 +899,7 @@ int init_clvm(struct dm_hash_table *excl_uuid)if (!get_initial_state (excl_uuid))log_error ("Cannot load initial lock states." ); -if (!(cmd =create_toolcontext (1 ,NULL ,0 ,1 ))) { +if (!(cmd =create_toolcontext (1 ,NULL ,0 ,1 ,1 ,1 ))) {log_error ("Failed to allocate command context" );return 0 ; }
daemons/lvmetad/testclient.c +1 -1
@@ -124,7 +124,7 @@ int main(int argc, char **argv) {if (argc >1 ) {int i; -struct cmd_context *cmd =create_toolcontext (0 ,NULL ,0 ,0 ); +struct cmd_context *cmd =create_toolcontext (0 ,NULL ,0 ,0 ,1 ,1 );for (i =1 ; i < argc; ++i) {const char *uuid =NULL ;scan (h, argv[i]);
lib/commands/toolcontext.c +38 -16
155 lines not on this page · raw message
lib/commands/toolcontext.h +7 -1
@@ -62,6 +62,8 @@ struct config_tree_list {struct cmd_context_initialized_parts {unsigned config:1 ;/* used to reinitialize config if previous init was not successful */ +unsigned filters:1 ; +unsigned connections:1 ; };/* FIXME Split into tool & library contexts */
@@ -171,13 +173,17 @@ struct cmd_context {struct cmd_context *create_toolcontext (unsigned is_long_lived,const char *system_dir,unsigned set_buffering, -unsigned threaded); +unsigned threaded, +unsigned set_connections, +unsigned set_filters);void destroy_toolcontext (struct cmd_context *cmd);int refresh_toolcontext (struct cmd_context *cmd);int refresh_filters (struct cmd_context *cmd);int process_profilable_config (struct cmd_context *cmd);int config_files_changed (struct cmd_context *cmd);int init_lvmcache_orphans (struct cmd_context *cmd); +int init_filters (struct cmd_context *cmd,unsigned load_persistent_cache); +int init_connections (struct cmd_context *cmd);struct format_type *get_format_by_name (struct cmd_context *cmd,const char *format);
liblvm/lvm_base.c +1 -1
@@ -45,7 +45,7 @@ static lvm_t _lvm_init(const char *system_dir)/* create context */ /* FIXME: split create_toolcontext */ /* FIXME: make all globals configurable */ - cmd =create_toolcontext (0 , system_dir,0 ,0 ); + cmd =create_toolcontext (0 , system_dir,0 ,0 ,1 ,1 );if (!cmd)return NULL ;
tools/lvm2cmdline.h +1 -1
@@ -31,7 +31,7 @@ int lvm2_main(int argc, char **argv);void *cmdlib_lvm2_init (unsigned static_compile);void lvm_fin (struct cmd_context *cmd); -struct cmd_context *init_lvm (void ); +struct cmd_context *init_lvm (unsigned set_connections,unsigned set_filters);void lvm_register_commands (void );int lvm_split (char *str,int *argc,char **argv,int max);int lvm_run_command (struct cmd_context *cmd,int argc,char **argv);
tools/lvmcmdlib.c +1 -1
@@ -33,7 +33,7 @@ void *cmdlib_lvm2_init(unsigned static_compile)lvm_register_commands ();init_is_static (static_compile); -if (!(cmd =init_lvm ())) +if (!(cmd =init_lvm (1 ,1 )))return NULL ;return (void *) cmd;
tools/lvmcmdline.c +4 -3
@@ -1873,7 +1873,7 @@ static int _close_stray_fds(const char *command)return 1 ; } -struct cmd_context *init_lvm (void ) +struct cmd_context *init_lvm (unsigned set_connections,unsigned set_filters) {struct cmd_context *cmd;
@@ -1887,7 +1887,8 @@ struct cmd_context *init_lvm(void)*/ dm_set_name_mangling_mode (DM_STRING_MANGLING_NONE ); -if (!(cmd =create_toolcontext (0 ,NULL ,1 ,0 ))) { +if (!(cmd =create_toolcontext (0 ,NULL ,1 ,0 , + set_connections, set_filters))) {udev_fin_library_context (); return_NULL; }
@@ -2055,7 +2056,7 @@ int lvm2_main(int argc, char **argv)if (!alias && argc >1 && !strcmp (argv[1 ],"version" ))return lvm_return_code (version (NULL , argc, argv)); -if (!(cmd =init_lvm ())) +if (!(cmd =init_lvm (1 ,1 )))return -1 ; cmd->argv = argv;