master - toollib: add 'parent' field to processing_handle; init report format only if there's no parent
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f752a953022387cc7e5c4da11d118c12e3716ce4 Commit: f752a953022387cc7e5c4da11d118c12e3716ce4 Parent: c099f531fbb1702ea0aed16e5deec0368e7e7250 Author: Peter Rajnoha <[email protected]> AuthorDate: Tue May 31 12:24:05 2016 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Mon Jun 20 11:33:41 2016 +0200
toollib: add 'parent' field to processing_handle; init report format only if there's no parent
If there's parent processing handle, we don't need to create completely new report group and status report - we'll just reuse the one already initialized for the parent.
Currently, the situation where this matter is when doing internal report to do the selection for processing commands where we have parent processing handle for the command itself and processing handle for the selection part (that is selection for non-reporting tools).
--- tools/lvconvert.c | 2 +- tools/lvcreate.c | 2 +- tools/lvrename.c | 2 +- tools/lvresize.c | 2 +- tools/polldaemon.c | 4 ++-- tools/pvchange.c | 2 +- tools/pvcreate.c | 2 +- tools/pvmove.c | 2 +- tools/pvremove.c | 2 +- tools/pvresize.c | 2 +- tools/pvscan.c | 4 ++-- tools/reporter.c | 4 ++-- tools/toollib.c | 22 +++++++++++++--------- tools/toollib.h | 3 ++- tools/vgcfgbackup.c | 2 +- tools/vgcreate.c | 2 +- tools/vgextend.c | 2 +- tools/vgreduce.c | 2 +- tools/vgrename.c | 2 +- 19 files changed, 35 insertions(+), 30 deletions(-)
tools/lvconvert.c +1 -1
@@ -3499,7 +3499,7 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv) .target_attr = ~0, .idls = DM_LIST_HEAD_INIT(lp.idls), }; -struct processing_handle *handle =init_processing_handle (cmd); +struct processing_handle *handle =init_processing_handle (cmd,NULL );if (!handle) {log_error ("Failed to initialize processing handle." );
tools/lvcreate.c +1 -1
@@ -1557,7 +1557,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv) pp.lp = &lp; pp.lcp = &lcp; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/lvrename.c +1 -1
@@ -210,7 +210,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)if (!(lp.lv_name_new =dm_pool_strdup (cmd->mem, lv_name_new)))return ECMD_FAILED ; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/lvresize.c +1 -1
@@ -216,7 +216,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/polldaemon.c +2 -2
@@ -561,7 +561,7 @@ static int _lvmpoll_daemon(struct cmd_context *cmd, struct poll_operation_id *idreturn r ?ECMD_PROCESSED :ECMD_FAILED ; }else {/* process all in-flight operations */ -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }else {
@@ -614,7 +614,7 @@ static int _poll_daemon(struct cmd_context *cmd, struct poll_operation_id *id, }else {if (!parms->interval) parms->interval =find_config_tree_int (cmd, activation_polling_interval_CFG,NULL ); -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." ); ret =ECMD_FAILED ; }else {
tools/pvchange.c +1 -1
@@ -216,7 +216,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) goto out; } -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." ); ret =ECMD_FAILED ; goto out;
tools/pvcreate.c +1 -1
@@ -147,7 +147,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv) return_ECMD_FAILED; cmd->lockd_gl_disable =1 ; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/pvmove.c +1 -1
@@ -877,7 +877,7 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)if (is_abort) cmd->lockd_vg_default_sh =1 ; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/pvremove.c +1 -1
@@ -43,7 +43,7 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv) return_ECMD_FAILED; cmd->lockd_gl_disable =1 ; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/pvresize.c +1 -1
@@ -86,7 +86,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)set_pv_notify (cmd); -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." ); ret =ECMD_FAILED ; goto out;
tools/pvscan.c +2 -2
@@ -273,7 +273,7 @@ static int _pvscan_autoactivate(struct cmd_context *cmd, struct pvscan_aa_paramsif (!lvmetad_used ())log_warn ("WARNING: Autoactivation reading from disk instead of lvmetad." ); -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
@@ -633,7 +633,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)return ECMD_FAILED ; } -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." ); ret =ECMD_FAILED ; goto out;
tools/reporter.c +2 -2
@@ -581,7 +581,7 @@ int report_for_selection(struct cmd_context *cmd, &sh->report_type)) return_0; -if (!(handle =init_processing_handle (cmd))) +if (!(handle =init_processing_handle (cmd, parent_handle))) return_0;/*
@@ -832,7 +832,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args, structint lv_segment_status_needed;int r =ECMD_FAILED ; -if (!(handle =init_processing_handle (cmd))) +if (!(handle =init_processing_handle (cmd,NULL ))) goto_out; if (!(report_handle = report_init(cmd, single_args->options, single_args->keys, &report_type,
tools/toollib.c +13 -9
@@ -1705,7 +1705,7 @@ static int _get_arg_vgnames(struct cmd_context *cmd,return ret_max; } -struct processing_handle *init_processing_handle (struct cmd_context *cmd) +struct processing_handle *init_processing_handle (struct cmd_context *cmd,struct processing_handle *parent_handle) {struct processing_handle *handle;
@@ -1714,6 +1714,8 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd)return NULL ; } + handle->parent = parent_handle; +/* * For any reporting tool, the internal_report_for_select is reset to 0 * automatically because the internal reporting/selection is simply not
@@ -1725,10 +1727,12 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd) handle->internal_report_for_select =arg_is_set (cmd, select_ARG); handle->include_historical_lvs = cmd->include_historical_lvs; -if (!report_format_init (cmd, &handle->report_group_type, &handle->report_group, - &handle->log_rh)) { -dm_pool_free (cmd->mem, handle); -return NULL ; +if (!parent_handle) { +if (!report_format_init (cmd, &handle->report_group_type, &handle->report_group, + &handle->log_rh)) { +dm_pool_free (cmd->mem, handle); +return NULL ; + } }return handle;
@@ -2189,7 +2193,7 @@ int process_each_vg(struct cmd_context *cmd,else _choose_vgs_to_process (cmd, &arg_vgnames, &vgnameids_on_system, &vgnameids_to_process); -if (!handle && !(handle =init_processing_handle (cmd))) { +if (!handle && !(handle =init_processing_handle (cmd,NULL ))) { ret_max =ECMD_FAILED ; goto_out; }
@@ -2286,7 +2290,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,if (arg_lvnames && !dm_list_empty (arg_lvnames)) lvargs_supplied =1 ; -if (!handle && !(handle =init_processing_handle (cmd))) { +if (!handle && !(handle =init_processing_handle (cmd,NULL ))) { ret_max =ECMD_FAILED ; goto_out; }
@@ -2747,7 +2751,7 @@ int process_each_lv(struct cmd_context *cmd, goto_out; } -if (!handle && !(handle =init_processing_handle (cmd))) { +if (!handle && !(handle =init_processing_handle (cmd,NULL ))) { ret_max =ECMD_FAILED ; goto_out; }
@@ -3168,7 +3172,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,int ret_max =ECMD_PROCESSED ;int ret =0 ; -if (!handle && (!(handle =init_processing_handle (cmd)))) { +if (!handle && (!(handle =init_processing_handle (cmd,NULL )))) { ret_max =ECMD_FAILED ; goto_out; }
tools/toollib.h +2 -1
@@ -69,6 +69,7 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm);* a part of that reporting for display (dm_report_object). */ struct processing_handle { +struct processing_handle *parent;int internal_report_for_select;int include_historical_lvs;struct selection_handle *selection_handle;
@@ -144,7 +145,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, int stop_on_error, struct processing_handle *handle, process_single_lv_fn_t process_single_lv); -struct processing_handle *init_processing_handle (struct cmd_context *cmd); +struct processing_handle *init_processing_handle (struct cmd_context *cmd,struct processing_handle *parent_handle);int init_selection_handle (struct cmd_context *cmd,struct processing_handle *handle,report_type_t initial_report_type);void destroy_processing_handle (struct cmd_context *cmd,struct processing_handle *handle);
tools/vgcfgbackup.c +1 -1
@@ -85,7 +85,7 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)char *last_filename =NULL ;struct processing_handle *handle =NULL ; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/vgcreate.c +1 -1
@@ -92,7 +92,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)*/ unlock_vg (cmd, vp_new.vg_name); -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/vgextend.c +1 -1
@@ -169,7 +169,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) return_ECMD_FAILED; cmd->lockd_gl_disable =1 ; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/vgreduce.c +1 -1
@@ -222,7 +222,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) return_ECMD_FAILED; cmd->lockd_gl_disable =1 ; -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }
tools/vgrename.c +1 -1
@@ -237,7 +237,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv) } } -if (!(handle =init_processing_handle (cmd))) { +if (!(handle =init_processing_handle (cmd,NULL ))) {log_error ("Failed to initialize processing handle." );return ECMD_FAILED ; }