master - vgsplit: Make vgsplit work on mirrors with leg and log on same PV
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9ac858fe6b56318cee821e86e4a5edede75d5134 Commit: 9ac858fe6b56318cee821e86e4a5edede75d5134 Parent: 0ee9d59b48b7b5eb844f6857977641e7a95f7ccb Author: Jonathan Brassow <[email protected]> AuthorDate: Fri Apr 25 14:53:34 2014 -0500 Committer: Jonathan Brassow <[email protected]> CommitterDate: Fri Apr 25 14:53:34 2014 -0500
vgsplit: Make vgsplit work on mirrors with leg and log on same PV
Given a named mirror LV, vgsplit will look for the PVs that compose it and move them to a new VG. It does this by first looking at the log and then the legs. If the log is on the same device as one of the mirror images, a problem occurs. This is because the PV is moved to the new VG as the log is processed and thus cannot be found in the current VG when the image is processed. The solution is to check and see if the PV we are looking for has already been moved to the new VG. If so, it is not an error.
--- lib/metadata/metadata.c | 23 +++++++++++++--- test/shell/vgsplit-operation.sh | 55 +++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 6 deletions(-)
lib/metadata/metadata.c +19 -4
@@ -360,14 +360,23 @@ out:return r; } -int move_pv (struct volume_group *vg_from,struct volume_group *vg_to, -const char *pv_name) +int _move_pv (struct volume_group *vg_from,struct volume_group *vg_to, +const char *pv_name,int enforce_pv_from_source) {struct physical_volume *pv;struct pv_list *pvl;/* FIXME: handle tags */ if (!(pvl =find_pv_in_vg (vg_from, pv_name))) { +if (!enforce_pv_from_source && + (pvl =find_pv_in_vg (vg_to, pv_name))) +/* +* PV has already been moved. This can happen if an +* LV is being moved that has multiple sub-LVs on the +* same PV. +*/ +return 1 ; +log_error ("Physical volume %s not in volume group %s" , pv_name, vg_from->name);return 0 ;
@@ -391,6 +400,12 @@ int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,return 1 ; } +int move_pv (struct volume_group *vg_from,struct volume_group *vg_to, +const char *pv_name) +{ +return _move_pv (vg_from, vg_to, pv_name,1 ); +} +int move_pvs_used_by_lv (struct volume_group *vg_from,struct volume_group *vg_to,const char *lv_name)
@@ -418,8 +433,8 @@ int move_pvs_used_by_lv(struct volume_group *vg_from, return_0;for (s =0 ; s < lvseg->area_count; s++) {if (seg_type (lvseg, s) ==AREA_PV ) { -if (!move_pv (vg_from, vg_to, -pv_dev_name (seg_pv (lvseg, s)))) +if (!_move_pv (vg_from, vg_to, +pv_dev_name (seg_pv (lvseg, s)),0 )) return_0; }else if (seg_type (lvseg, s) ==AREA_LV ) { lv =seg_lv (lvseg, s);
test/shell/vgsplit-operation.sh +53 -2
79 lines not on this page · raw message