diff --git a/tools/lvconvert.c b/tools/lvconvert.c index a4e702342..a711c31ff 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -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."); diff --git a/tools/lvcreate.c b/tools/lvcreate.c index b1bf1af3d..fb28dc538 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -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; } diff --git a/tools/lvrename.c b/tools/lvrename.c index e9dd061e5..4dfcda23e 100644 --- a/tools/lvrename.c +++ b/tools/lvrename.c @@ -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; } diff --git a/tools/lvresize.c b/tools/lvresize.c index 7a8617898..05e386f32 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -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; } diff --git a/tools/polldaemon.c b/tools/polldaemon.c index f8aa49c13..e12a69419 100644 --- a/tools/polldaemon.c +++ b/tools/polldaemon.c @@ -561,7 +561,7 @@ static int _lvmpoll_daemon(struct cmd_context *cmd, struct poll_operation_id *id return 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 { diff --git a/tools/pvchange.c b/tools/pvchange.c index e100b80c5..ed99e7ce2 100644 --- a/tools/pvchange.c +++ b/tools/pvchange.c @@ -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; diff --git a/tools/pvcreate.c b/tools/pvcreate.c index 77f5969db..ae133fa74 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -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; } diff --git a/tools/pvmove.c b/tools/pvmove.c index b5df45a1e..f5f5654ed 100644 --- a/tools/pvmove.c +++ b/tools/pvmove.c @@ -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; } diff --git a/tools/pvremove.c b/tools/pvremove.c index dd9a4e84c..e262eb007 100644 --- a/tools/pvremove.c +++ b/tools/pvremove.c @@ -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; } diff --git a/tools/pvresize.c b/tools/pvresize.c index 9931cc684..ddff52005 100644 --- a/tools/pvresize.c +++ b/tools/pvresize.c @@ -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; diff --git a/tools/pvscan.c b/tools/pvscan.c index 9b5037496..db678d1b7 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -273,7 +273,7 @@ static int _pvscan_autoactivate(struct cmd_context *cmd, struct pvscan_aa_params if (!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; diff --git a/tools/reporter.c b/tools/reporter.c index d8aac681c..7bd5d3602 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -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, struct int 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, diff --git a/tools/toollib.c b/tools/toollib.c index e09146790..3b2ad6a20 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -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; } diff --git a/tools/toollib.h b/tools/toollib.h index 622badcc7..8cd9087e6 100644 --- a/tools/toollib.h +++ b/tools/toollib.h @@ -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); diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c index 554317edf..c47c1ef72 100644 --- a/tools/vgcfgbackup.c +++ b/tools/vgcfgbackup.c @@ -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; } diff --git a/tools/vgcreate.c b/tools/vgcreate.c index 38115831d..974d7e785 100644 --- a/tools/vgcreate.c +++ b/tools/vgcreate.c @@ -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; } diff --git a/tools/vgextend.c b/tools/vgextend.c index 24b51cf02..8f44672a0 100644 --- a/tools/vgextend.c +++ b/tools/vgextend.c @@ -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; } diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 3176a0e77..ae86a6740 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -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; } diff --git a/tools/vgrename.c b/tools/vgrename.c index ee6a91f99..3dceeab6b 100644 --- a/tools/vgrename.c +++ b/tools/vgrename.c @@ -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; }