1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

toollib: make it possible to also process internal VGs, add 'include_internal' switch to process_each_vg fn

The lvm fullreport works per VG and as such, the vg, lv, pv, seg and
pvseg subreport is done for each VG. However, if the PV is not part of
any VG yet, we still want to display pv and pvseg subreports for these
"orphan" PVs - so enable this for lvm fullreport's process_each_vg call.
This commit is contained in:
Peter Rajnoha 2016-05-03 11:46:28 +02:00
parent 31aaa3be71
commit 8cfc385491
21 changed files with 29 additions and 25 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.158 -
=================================
Make it possible to iterate over internal 'orphan' VGs in process_each_vg fn.
Make -S|--select option groupable that allows this option to be repeated.
Make -O|--sort option groupable that allows this option to be repeated.
Add --configreport option to select report for which next options are applied.

View File

@ -1564,7 +1564,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
handle->custom_handle = &pp;
ret = process_each_vg(cmd, 0, NULL, lp.vg_name, NULL, READ_FOR_UPDATE, handle,
ret = process_each_vg(cmd, 0, NULL, lp.vg_name, NULL, READ_FOR_UPDATE, 0, handle,
&_lvcreate_single);
_destroy_lvcreate_params(&lp);

View File

@ -217,7 +217,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
handle->custom_handle = &lp;
ret = process_each_vg(cmd, 0, NULL, vg_name, NULL, READ_FOR_UPDATE, handle,
ret = process_each_vg(cmd, 0, NULL, vg_name, NULL, READ_FOR_UPDATE, 0, handle,
_lvrename_single);
destroy_processing_handle(cmd, handle);

View File

@ -223,7 +223,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
handle->custom_handle = &lp;
ret = process_each_vg(cmd, 0, NULL, lp.vg_name, NULL, READ_FOR_UPDATE, handle,
ret = process_each_vg(cmd, 0, NULL, lp.vg_name, NULL, READ_FOR_UPDATE, 0, handle,
&_lvresize_single);
destroy_processing_handle(cmd, handle);

View File

@ -364,7 +364,7 @@ static void _poll_for_all_vgs(struct cmd_context *cmd,
while (1) {
parms->outstanding_count = 0;
process_each_vg(cmd, 0, NULL, NULL, NULL, READ_FOR_UPDATE, handle, _poll_vg);
process_each_vg(cmd, 0, NULL, NULL, NULL, READ_FOR_UPDATE, 0, handle, _poll_vg);
if (!parms->outstanding_count)
break;
if (parms->interval)
@ -508,7 +508,7 @@ static void _lvmpolld_poll_for_all_vgs(struct cmd_context *cmd,
handle->custom_handle = &lpdp;
process_each_vg(cmd, 0, NULL, NULL, NULL, 0, handle, _lvmpolld_init_poll_vg);
process_each_vg(cmd, 0, NULL, NULL, NULL, 0, 0, handle, _lvmpolld_init_poll_vg);
first = dm_list_first(&lpdp.idls);

View File

@ -287,7 +287,7 @@ static int _pvscan_autoactivate(struct cmd_context *cmd, struct pvscan_aa_params
dev_cache_full_scan(cmd->full_filter);
ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, 0, handle, _pvscan_autoactivate_single);
ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, 0, 0, handle, _pvscan_autoactivate_single);
destroy_processing_handle(cmd, handle);

View File

@ -1084,8 +1084,8 @@ static int _do_report(struct cmd_context *cmd, struct processing_handle *handle,
if (args->full_report_vg)
r = _report_all_in_vg(cmd, handle, args->full_report_vg, VGS, lv_info_needed, lv_segment_status_needed);
else
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL, 0,
handle, &_vgs_single);
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL,
0, 0, handle, &_vgs_single);
break;
case LABEL:
r = process_each_label(cmd, args->argc, args->argv,
@ -1101,7 +1101,7 @@ static int _do_report(struct cmd_context *cmd, struct processing_handle *handle,
handle, &_pvs_single);
else
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL,
0, handle, &_pvs_in_vg);
0, 0, handle, &_pvs_in_vg);
}
break;
case SEGS:
@ -1128,7 +1128,7 @@ static int _do_report(struct cmd_context *cmd, struct processing_handle *handle,
&_pvsegs_single);
else
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL,
0, handle, &_pvsegs_in_vg);
0, 0, handle, &_pvsegs_in_vg);
}
break;
case FULL:
@ -1367,7 +1367,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t
if (single_args->report_type == FULL) {
handle->custom_handle = &args;
r = process_each_vg(cmd, argc, argv, NULL, NULL, 0, handle, &_full_report_single);
r = process_each_vg(cmd, argc, argv, NULL, NULL, 0, 1, handle, &_full_report_single);
} else
r = _do_report(cmd, handle, &args, single_args);

View File

@ -1875,7 +1875,8 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t read_flags,
skip = 0;
notfound = 0;
if (vg_uuid && !id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid)))
if (vg_uuid && !is_orphan_vg(vg_name) &&
!id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid)))
stack;
log_very_verbose("Processing VG %s %s", vg_name, vg_uuid ? uuid : "");
@ -2091,6 +2092,7 @@ int process_each_vg(struct cmd_context *cmd,
const char *one_vgname,
struct dm_list *use_vgnames,
uint32_t read_flags,
int include_internal,
struct processing_handle *handle,
process_single_vg_fn_t process_single_vg)
{
@ -2158,7 +2160,7 @@ int process_each_vg(struct cmd_context *cmd,
*/
log_debug("Get list of VGs on system");
if (!get_vgnameids(cmd, &vgnameids_on_system, NULL, 0)) {
if (!get_vgnameids(cmd, &vgnameids_on_system, NULL, include_internal)) {
ret_max = ECMD_FAILED;
goto_out;
}

View File

@ -106,6 +106,7 @@ int process_each_vg(struct cmd_context *cmd,
const char *one_vgname,
struct dm_list *use_vgnames,
uint32_t flags,
int include_internal,
struct processing_handle *handle,
process_single_vg_fn_t process_single_vg);

View File

@ -94,7 +94,7 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
init_pvmove(1);
ret = process_each_vg(cmd, argc, argv, NULL, NULL, READ_ALLOW_INCONSISTENT,
ret = process_each_vg(cmd, argc, argv, NULL, NULL, READ_ALLOW_INCONSISTENT, 0,
handle, &vg_backup_single);
dm_free(last_filename);

View File

@ -1216,7 +1216,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, lockstart_ARG) || arg_is_set(cmd, lockstop_ARG))
flags |= READ_ALLOW_EXPORTED;
ret = process_each_vg(cmd, argc, argv, NULL, NULL, flags, NULL, &vgchange_single);
ret = process_each_vg(cmd, argc, argv, NULL, NULL, flags, 0, NULL, &vgchange_single);
/* Wait for lock-start ops that were initiated in vgchange_lockstart. */

View File

@ -38,6 +38,6 @@ static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
int vgck(struct cmd_context *cmd, int argc, char **argv)
{
lvmetad_make_unused(cmd);
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, NULL,
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL,
&vgck_single);
}

View File

@ -181,6 +181,6 @@ int vgconvert(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, NULL,
return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, 0, NULL,
&vgconvert_single);
}

View File

@ -89,7 +89,7 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
}
**********/
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, NULL,
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL,
vgdisplay_single);
/******** FIXME Need to count number processed

View File

@ -80,6 +80,6 @@ int vgexport(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, NULL,
return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, 0, NULL,
&vgexport_single);
}

View File

@ -198,7 +198,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
handle->custom_handle = &vp;
ret = process_each_vg(cmd, 0, NULL, vg_name, NULL,
READ_FOR_UPDATE, handle,
READ_FOR_UPDATE, 0, handle,
restoremissing ? &_vgextend_restoremissing : &_vgextend_single);
destroy_processing_handle(cmd, handle);

View File

@ -109,6 +109,6 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
return process_each_vg(cmd, argc, argv, NULL, NULL,
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
NULL,
0, NULL,
&vgimport_single);
}

View File

@ -247,7 +247,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
process_each_vg(cmd, 0, NULL, vg_name, NULL,
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
handle, &_vgreduce_repair_single);
0, handle, &_vgreduce_repair_single);
if (vp.already_consistent) {
log_print_unless_silent("Volume group \"%s\" is already consistent", vg_name);

View File

@ -110,7 +110,7 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
cmd->handles_missing_pvs = 1;
ret = process_each_vg(cmd, argc, argv, NULL, NULL,
READ_FOR_UPDATE,
READ_FOR_UPDATE, 0,
NULL, &vgremove_single);
return ret;

View File

@ -246,7 +246,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
ret = process_each_vg(cmd, 0, NULL, vg_name_old, NULL,
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
handle, _vgrename_single);
0, handle, _vgrename_single);
/* Needed if process_each_vg returns error before calling _single. */
if (vp.unlock_new_name)

View File

@ -117,7 +117,7 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
else
log_print_unless_silent("Reading volume groups from cache.");
maxret = process_each_vg(cmd, argc, argv, NULL, NULL, 0, NULL,
maxret = process_each_vg(cmd, argc, argv, NULL, NULL, 0, NULL, 0,
&vgscan_single);
if (arg_count(cmd, mknodes_ARG)) {