summaryrefslogtreecommitdiff
path: root/tools/toollib.h
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-02-16 14:15:24 -0600
committerDavid Teigland <teigland@redhat.com>2016-02-25 09:14:09 -0600
commit71671778ab0b2ae4f9f014b37372939b00e90e1d (patch)
tree403db711dc2ad5d6a1eb6b08f2db4574c4654887 /tools/toollib.h
parentff2267012aea37e08ed1fc2a511f8a0d3f0d145b (diff)
downloadlvm2-71671778ab0b2ae4f9f014b37372939b00e90e1d.tar.gz
toollib: add two phase pv processing code
This is common code for handling PV create/remove that can be shared by pvcreate/vgcreate/vgextend/pvremove. This does not change any commands to use the new code. - Pull out the hidden equivalent of process_each_pv into an actual top level process_each_pv. - Pull the prompts to the top level, and do not run any prompts while locks are held. The orphan lock is reacquired after any prompts are done, and the devices being created are checked for any change made while the lock was not held. Previously, pvcreate_vol() was the shared function for creating a PV for pvcreate, vgcreate, vgextend. Now, it will be toollib function pvcreate_each_device(). pvcreate_vol() was called effectively as a helper, from within vgcreate and vgextend code paths. pvcreate_each_device() will be called at the same level as other process_each functions. One of the main problems with pvcreate_vol() is that it included a hidden equivalent of process_each_pv for each device being created: pvcreate_vol() -> _pvcreate_check() -> find_pv_by_name() -> get_pvs() -> get_pvs_internal() -> _get_pvs() -> get_vgids() -> /* equivalent to process_each_pv */ dm_list_iterate_items(vgids) vg = vg_read_internal() dm_list_iterate_items(&vg->pvs) pvcreate_each_device() reorganizes the code so that each-VG-each-PV loop is done once, and uses the standard process_each_pv function at the top level of the function.
Diffstat (limited to 'tools/toollib.h')
-rw-r--r--tools/toollib.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/toollib.h b/tools/toollib.h
index fc502b9cd..0ef9e9269 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -101,8 +101,8 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
struct processing_handle *handle,
process_single_vg_fn_t process_single_vg);
-int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
- const char *vg_name, uint32_t read_flags,
+int process_each_pv(struct cmd_context *cmd, int argc, char **argv, const char *vg_name,
+ int all_is_set, uint32_t read_flags,
struct processing_handle *handle,
process_single_pv_fn_t process_single_pv);
@@ -152,6 +152,10 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
unsigned *dev_dir_found);
+void pvcreate_each_params_set_defaults(struct pvcreate_each_params *pp);
+int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each_params *pp);
+int pvcreate_each_device(struct cmd_context *cmd, struct processing_handle *handle, struct pvcreate_each_params *pp);
+
/*
* Builds a list of pv's from the names in argv. Used in
* lvcreate/extend.