diff options
author | Joe Thornber <ejt@redhat.com> | 2018-06-01 13:04:12 +0100 |
---|---|---|
committer | Joe Thornber <ejt@redhat.com> | 2018-06-01 13:04:12 +0100 |
commit | dbba1e9b93bac348c0df556b160676234cc8a8c4 (patch) | |
tree | b1db4389e0288231ad36d7a6de607bcc38f38c3a /tools/vgimportclone.c | |
parent | 89fdc0b5889d24fe785e7fa4c2be13659d1ed0b2 (diff) | |
parent | cb379c86c4b468858b781695934d5ad5957108d2 (diff) | |
download | lvm2-dbba1e9b93bac348c0df556b160676234cc8a8c4.tar.gz |
Merge branch 'master' into 2018-05-11-fork-libdm
Diffstat (limited to 'tools/vgimportclone.c')
-rw-r--r-- | tools/vgimportclone.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c index d1509bffc..742191235 100644 --- a/tools/vgimportclone.c +++ b/tools/vgimportclone.c @@ -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); |