1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

lvmlockd: fix vgimportclone of a shared VG

The new VG from the duplicate PV is imported
as a local VG.
This commit is contained in:
David Teigland 2018-05-25 15:26:30 -05:00
parent a40d447a02
commit 5c5e449dc5
2 changed files with 16 additions and 4 deletions

View File

@ -10,14 +10,13 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
SKIP_WITH_LVMLOCKD=1
SKIP_WITH_LVMPOLLD=1
. lib/inittest
aux prepare_devs 2
vgcreate --metadatasize 128k $vg1 "$dev1"
vgcreate $SHARED --metadatasize 128k $vg1 "$dev1"
lvcreate -l100%FREE -n $lv1 $vg1
# Test plain vgexport vgimport tools
@ -76,7 +75,7 @@ vgremove -ff $vg1 $vg2
# Verify that if we provide the -n|--basevgname,
# the number suffix is not added unnecessarily.
vgcreate --metadatasize 128k A${vg1}B "$dev1"
vgcreate $SHARED --metadatasize 128k A${vg1}B "$dev1"
# vg1B is not the same as Avg1B - we don't need number suffix
dd if="$dev1" of="$dev2" bs=256K count=1

View File

@ -153,6 +153,11 @@ static int _vgimportclone_vg_single(struct cmd_context *cmd, const char *vg_name
if (!(vg->name = dm_pool_strdup(vg->vgmem, vp->new_vgname)))
goto_bad;
/* A duplicate of a shared VG is imported as a new local VG. */
vg->lock_type = NULL;
vg->lock_args = NULL;
vg->system_id = cmd->system_id ? dm_pool_strdup(vg->vgmem, cmd->system_id) : NULL;
dm_list_iterate_items(pvl, &vg->pvs) {
if (!(new_pvl = dm_pool_zalloc(vg->vgmem, sizeof(*new_pvl))))
goto_bad;
@ -174,8 +179,10 @@ static int _vgimportclone_vg_single(struct cmd_context *cmd, const char *vg_name
dm_list_add(&vg->pv_write_list, &new_pvl->list);
}
dm_list_iterate_items(lvl, &vg->lvs)
dm_list_iterate_items(lvl, &vg->lvs) {
memcpy(&lvl->lv->lvid, &vg->id, sizeof(vg->id));
lvl->lv->lock_args = NULL;
}
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
@ -343,6 +350,12 @@ retry_name:
goto out;
}
/*
* Trying to lock the duplicated VG would conflict with the original,
* and it's not needed because the new VG will be imported as a local VG.
*/
cmd->lockd_vg_disable = 1;
ret = process_each_vg(cmd, 0, NULL, vp.old_vgname, NULL, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, 0, handle, _vgimportclone_vg_single);
unlock_vg(cmd, NULL, vp.new_vgname);