mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
toollib: add vg name list arg to process_each_vg
This commit is contained in:
parent
bf8d00985a
commit
55683a659f
@ -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, READ_FOR_UPDATE, handle,
|
||||
ret = process_each_vg(cmd, 0, NULL, lp.vg_name, NULL, READ_FOR_UPDATE, handle,
|
||||
&_lvcreate_single);
|
||||
|
||||
_destroy_lvcreate_params(&lp);
|
||||
|
@ -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, READ_FOR_UPDATE, handle,
|
||||
ret = process_each_vg(cmd, 0, NULL, vg_name, NULL, READ_FOR_UPDATE, handle,
|
||||
_lvrename_single);
|
||||
|
||||
destroy_processing_handle(cmd, handle);
|
||||
|
@ -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, READ_FOR_UPDATE, handle,
|
||||
ret = process_each_vg(cmd, 0, NULL, lp.vg_name, NULL, READ_FOR_UPDATE, handle,
|
||||
&_lvresize_single);
|
||||
|
||||
destroy_processing_handle(cmd, handle);
|
||||
|
@ -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, READ_FOR_UPDATE, handle, _poll_vg);
|
||||
process_each_vg(cmd, 0, NULL, NULL, NULL, READ_FOR_UPDATE, 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, 0, handle, _lvmpolld_init_poll_vg);
|
||||
process_each_vg(cmd, 0, NULL, NULL, NULL, 0, handle, _lvmpolld_init_poll_vg);
|
||||
|
||||
first = dm_list_first(&lpdp.idls);
|
||||
|
||||
|
@ -837,7 +837,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
|
||||
&_lvs_single);
|
||||
break;
|
||||
case VGS:
|
||||
r = process_each_vg(cmd, args->argc, args->argv, NULL, 0,
|
||||
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL, 0,
|
||||
handle, &_vgs_single);
|
||||
break;
|
||||
case LABEL:
|
||||
@ -850,7 +850,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
|
||||
arg_is_set(cmd, all_ARG), 0,
|
||||
handle, &_pvs_single);
|
||||
else
|
||||
r = process_each_vg(cmd, args->argc, args->argv, NULL,
|
||||
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL,
|
||||
0, handle, &_pvs_in_vg);
|
||||
break;
|
||||
case SEGS:
|
||||
@ -870,7 +870,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
|
||||
lv_info_needed && lv_segment_status_needed ? &_pvsegs_with_lv_info_and_status_single :
|
||||
&_pvsegs_single);
|
||||
else
|
||||
r = process_each_vg(cmd, args->argc, args->argv, NULL,
|
||||
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL,
|
||||
0, handle, &_pvsegs_in_vg);
|
||||
break;
|
||||
default:
|
||||
|
@ -1645,6 +1645,7 @@ int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_na
|
||||
static int _get_arg_vgnames(struct cmd_context *cmd,
|
||||
int argc, char **argv,
|
||||
const char *one_vgname,
|
||||
struct dm_list *use_vgnames,
|
||||
struct dm_list *arg_vgnames,
|
||||
struct dm_list *arg_tags)
|
||||
{
|
||||
@ -1661,6 +1662,11 @@ static int _get_arg_vgnames(struct cmd_context *cmd,
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
if (use_vgnames && !dm_list_empty(use_vgnames)) {
|
||||
dm_list_splice(arg_vgnames, use_vgnames);
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
for (; opt < argc; opt++) {
|
||||
vg_name = argv[opt];
|
||||
|
||||
@ -2073,11 +2079,14 @@ static void _choose_vgs_to_process(struct cmd_context *cmd,
|
||||
|
||||
/*
|
||||
* Call process_single_vg() for each VG selected by the command line arguments.
|
||||
* If one_vgname is set, process only that VG and ignore argc/argv (which should be 0/NULL)..
|
||||
* If one_vgname is set, process only that VG and ignore argc/argv (which should be 0/NULL).
|
||||
* If one_vgname is not set, get VG names to process from argc/argv.
|
||||
*/
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
const char *one_vgname, uint32_t read_flags,
|
||||
int process_each_vg(struct cmd_context *cmd,
|
||||
int argc, char **argv,
|
||||
const char *one_vgname,
|
||||
struct dm_list *use_vgnames,
|
||||
uint32_t read_flags,
|
||||
struct processing_handle *handle,
|
||||
process_single_vg_fn_t process_single_vg)
|
||||
{
|
||||
@ -2104,7 +2113,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
/*
|
||||
* Find any VGs or tags explicitly provided on the command line.
|
||||
*/
|
||||
if ((ret = _get_arg_vgnames(cmd, argc, argv, one_vgname, &arg_vgnames, &arg_tags)) != ECMD_PROCESSED) {
|
||||
if ((ret = _get_arg_vgnames(cmd, argc, argv, one_vgname, use_vgnames, &arg_vgnames, &arg_tags)) != ECMD_PROCESSED) {
|
||||
ret_max = ret;
|
||||
goto_out;
|
||||
}
|
||||
|
@ -97,8 +97,11 @@ typedef int (*process_single_pvseg_fn_t) (struct cmd_context * cmd,
|
||||
struct pv_segment * pvseg,
|
||||
struct processing_handle *handle);
|
||||
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
const char *one_vgname, uint32_t flags,
|
||||
int process_each_vg(struct cmd_context *cmd,
|
||||
int argc, char **argv,
|
||||
const char *one_vgname,
|
||||
struct dm_list *use_vgnames,
|
||||
uint32_t flags,
|
||||
struct processing_handle *handle,
|
||||
process_single_vg_fn_t process_single_vg);
|
||||
|
||||
|
@ -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, READ_ALLOW_INCONSISTENT,
|
||||
ret = process_each_vg(cmd, argc, argv, NULL, NULL, READ_ALLOW_INCONSISTENT,
|
||||
handle, &vg_backup_single);
|
||||
|
||||
dm_free(last_filename);
|
||||
|
@ -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, flags, NULL, &vgchange_single);
|
||||
ret = process_each_vg(cmd, argc, argv, NULL, NULL, flags, NULL, &vgchange_single);
|
||||
|
||||
/* Wait for lock-start ops that were initiated in vgchange_lockstart. */
|
||||
|
||||
|
@ -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, 0, NULL,
|
||||
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, NULL,
|
||||
&vgck_single);
|
||||
}
|
||||
|
@ -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, READ_FOR_UPDATE, NULL,
|
||||
return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, NULL,
|
||||
&vgconvert_single);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
**********/
|
||||
|
||||
return process_each_vg(cmd, argc, argv, NULL, 0, NULL,
|
||||
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, NULL,
|
||||
vgdisplay_single);
|
||||
|
||||
/******** FIXME Need to count number processed
|
||||
|
@ -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, READ_FOR_UPDATE, NULL,
|
||||
return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, NULL,
|
||||
&vgexport_single);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
handle->custom_handle = &vp;
|
||||
|
||||
ret = process_each_vg(cmd, 0, NULL, vg_name,
|
||||
ret = process_each_vg(cmd, 0, NULL, vg_name, NULL,
|
||||
READ_FOR_UPDATE, handle,
|
||||
restoremissing ? &_vgextend_restoremissing : &_vgextend_single);
|
||||
|
||||
|
@ -107,7 +107,7 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
return process_each_vg(cmd, argc, argv, NULL,
|
||||
return process_each_vg(cmd, argc, argv, NULL, NULL,
|
||||
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
|
||||
NULL,
|
||||
&vgimport_single);
|
||||
|
@ -109,7 +109,7 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
|
||||
cmd->lockd_gl_disable = 1;
|
||||
|
||||
cmd->handles_missing_pvs = 1;
|
||||
ret = process_each_vg(cmd, argc, argv, NULL,
|
||||
ret = process_each_vg(cmd, argc, argv, NULL, NULL,
|
||||
READ_FOR_UPDATE,
|
||||
NULL, &vgremove_single);
|
||||
|
||||
|
@ -244,7 +244,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
handle->custom_handle = &vp;
|
||||
|
||||
ret = process_each_vg(cmd, 0, NULL, vg_name_old,
|
||||
ret = process_each_vg(cmd, 0, NULL, vg_name_old, NULL,
|
||||
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
|
||||
handle, _vgrename_single);
|
||||
|
||||
|
@ -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, 0, NULL,
|
||||
maxret = process_each_vg(cmd, argc, argv, NULL, NULL, 0, NULL,
|
||||
&vgscan_single);
|
||||
|
||||
if (arg_count(cmd, mknodes_ARG)) {
|
||||
|
Loading…
Reference in New Issue
Block a user