master - lvm2app: Implement lvm_pv_remove V2
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e33ac7b1ed962abb5ccb3d12a5401c84a188bf92 Commit: e33ac7b1ed962abb5ccb3d12a5401c84a188bf92 Parent: ef3ab801e8604d8f629badc1cac1d9190467033f Author: Tony Asleson <[email protected]> AuthorDate: Tue Apr 2 16:10:18 2013 -0400 Committer: Tony Asleson <[email protected]> CommitterDate: Tue Jul 2 14:24:34 2013 -0500
lvm2app: Implement lvm_pv_remove V2
Code move and changes to support calling code from command line and from library interface.
V2 Change lock_vol call
Signed-off-by Tony Asleson <[email protected]>
--- lib/metadata/metadata.h | 4 ++ lib/metadata/pv_manip.c | 130 +++++++++++++++++++++++++++++++++++++++++++++ liblvm/lvm2app.h | 16 +++++- liblvm/lvm_pv.c | 8 +++ tools/pvremove.c | 133 +++-------------------------------------------- 5 files changed, 163 insertions(+), 128 deletions(-)
lib/metadata/metadata.h +4 -0
@@ -341,6 +341,10 @@ int vg_validate(struct volume_group *vg);int pv_write_orphan (struct cmd_context *cmd,struct physical_volume *pv); +int pvremove_single (struct cmd_context *cmd,const char *pv_name, +void *handle __attribute__((unused)),unsigned force_count, +unsigned prompt); +/* Manipulate PV structures */ int pv_add (struct volume_group *vg,struct physical_volume *pv);int pv_remove (struct volume_group *vg,struct physical_volume *pv);
lib/metadata/pv_manip.c +130 -0
139 lines not on this page · raw message
liblvm/lvm2app.h +14 -2
@@ -553,14 +553,15 @@ struct dm_list *lvm_vg_list_lvs(vg_t vg);* \return * A list of lvm_pv_list structures containing pv handles for all physical * volumes. If no PVs exist or a global lock was unable to be obtained a -* NULL is returned. +* NULL is returned. Do not attempt to remove one of the PVs until after the +* call to lvm_list_pvs_free has been made. */ struct dm_list *lvm_list_pvs (lvm_t libh);/** * Free the resources used by acquiring the pvlist. This should be called as * soon as possible after processing the needed information from the pv list as -* a global locks are held. +* a global lock is held. * * \param pvlist * PV list to be freed
@@ -571,6 +572,17 @@ struct dm_list *lvm_list_pvs(lvm_t libh);int lvm_list_pvs_free (struct dm_list *pvlist);/** +* Remove a physical volume. +* Note: You cannot remove a PV while iterating through the list of PVs as +* locks are held for the PV list. +* \param libh Library handle +* \param pv_name The physical volume name +* \return +* 0 on success, else -1 with library errno and text set. +*/ +int lvm_pv_remove (lvm_t libh,const char *pv_name); + +/** * Return a list of PV handles for a given VG handle. * * \memberof vg_t
liblvm/lvm_pv.c +8 -0
@@ -75,6 +75,14 @@ struct lvm_list_wrapperstruct dm_list vgslist; }; +int lvm_pv_remove (lvm_t libh,const char *pv_name) +{ +struct cmd_context *cmd = (struct cmd_context *)libh; +if (1 !=pvremove_single (cmd, pv_name,NULL ,0 ,0 )) { +return -1 ; + } +return 0 ; +}struct dm_list *lvm_list_pvs (lvm_t libh) {
tools/pvremove.c +7 -126
153 lines not on this page · raw message