mirror of
git://sourceware.org/git/lvm2.git
synced 2024-10-27 18:55:19 +03:00
select: initialize selection handle for process_each_* fns with initial report type
This is a followup patch for previous patchset that enables selection in process_each_* fns to fix an issue where field prefixes are not automatically used for fields in selection criteria. Use initial report type that matches the intention of each process_each_* functions: - _process_pvs_in_vg - PVS - process_each_vg - VGS - process_each_lv and process_each_lv_in_vg - LVS This is not normally needed for the selection handle init, BUT we would miss the field prefix matching, e.g. lvchange -ay -S 'name=lvol0' The "name" above would not work if we didn't initialize reporting with the LVS type at its start. If we pass proper init type, reporting code can deduce the prefix automatically ("lv_name" in this case). This report type is then changed further based on what selection criteria we have. When doing pure selection, not report output, the final report type is purely based on combination of this initial report type and report types of the fields used in selection criteria.
This commit is contained in:
parent
80cca53611
commit
7f2eebf519
@ -170,7 +170,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
/* FIXME: use process_each_pv for pvchange. */
|
||||
|
||||
if (!(handle = init_processing_handle(cmd)) ||
|
||||
(handle->internal_report_for_select && !init_selection_handle(cmd, handle))) {
|
||||
(handle->internal_report_for_select && !init_selection_handle(cmd, handle, PVS))) {
|
||||
log_error("Failed to initialize processing handle.");
|
||||
r = ECMD_FAILED;
|
||||
goto out;
|
||||
|
@ -1594,7 +1594,8 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd)
|
||||
return handle;
|
||||
}
|
||||
|
||||
int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle)
|
||||
int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle,
|
||||
report_type_t initial_report_type)
|
||||
{
|
||||
struct selection_handle *sh;
|
||||
|
||||
@ -1603,6 +1604,7 @@ int init_selection_handle(struct cmd_context *cmd, struct processing_handle *han
|
||||
return 0;
|
||||
}
|
||||
|
||||
sh->report_type = initial_report_type;
|
||||
if (!(sh->selection_rh = report_init_for_selection(cmd, &sh->report_type,
|
||||
arg_str_value(cmd, select_ARG, NULL)))) {
|
||||
dm_pool_free(cmd->mem, sh);
|
||||
@ -1841,7 +1843,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
goto_out;
|
||||
|
||||
if (handle->internal_report_for_select && !handle->selection_handle &&
|
||||
!init_selection_handle(cmd, handle))
|
||||
!init_selection_handle(cmd, handle, VGS))
|
||||
goto_out;
|
||||
|
||||
ret = _process_vgnameid_list(cmd, flags, &vgnameids_to_process,
|
||||
@ -1887,7 +1889,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
}
|
||||
|
||||
if (handle->internal_report_for_select && !handle->selection_handle &&
|
||||
!init_selection_handle(cmd, handle)) {
|
||||
!init_selection_handle(cmd, handle, LVS)) {
|
||||
ret_max = ECMD_FAILED;
|
||||
goto_out;
|
||||
}
|
||||
@ -2216,7 +2218,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, uint32_t fla
|
||||
goto_out;
|
||||
|
||||
if (handle->internal_report_for_select && !handle->selection_handle &&
|
||||
!init_selection_handle(cmd, handle))
|
||||
!init_selection_handle(cmd, handle, LVS))
|
||||
goto_out;
|
||||
|
||||
/*
|
||||
@ -2455,7 +2457,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
if (handle->internal_report_for_select && !handle->selection_handle &&
|
||||
!init_selection_handle(cmd, handle)) {
|
||||
!init_selection_handle(cmd, handle, PVS)) {
|
||||
ret_max = ECMD_FAILED;
|
||||
goto_out;
|
||||
}
|
||||
|
@ -138,7 +138,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
process_single_lv_fn_t process_single_lv);
|
||||
|
||||
struct processing_handle *init_processing_handle(struct cmd_context *cmd);
|
||||
int init_selection_handle(struct cmd_context *cmd, struct processing_handle *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,
|
||||
int deallocate_handle_root);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user