1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

vgimportclone: fix vgimportclone with -n to not add number unnecessarily to base VG name

$ vgcreate vgA /dev/sda
  Volume group "vgA" successfully created

$ dd if=/dev/sda of=/dev/sdb bs=1M
$ dd if=/dev/sda of=/dev/sdc bs=1M

(the new VG name is prefix of existing VG name)
$ vgimportclone -n vg /dev/sdb

(the new VG name is suffix of existing VG name)
$ vgimportclone -n gA /dev/sdc

Before this patch:
------------------
(we end up with "vg1" and "gA1" names with the "1" suffix which is not needed)
$ vgs -o vg_name
  VG
  gA1
  vg1
  vgA

With this patch applied:
------------------------
(we end up with "vg" and "gA" names as they're unique already and no extra suffix is added)
$ # vgs -o vg_name
  VG
  gA
  vg
  vgA

Of course, if the name supplied is not unique, the number is added correctly:
$ dd if=/dev/sda of=/dev/sdb bs=1M
$ vgimportclone -n vgA /dev/sdb
$ vgs -o vg_name
  VG
  vgA
  vgA1
This commit is contained in:
Peter Rajnoha 2015-10-12 11:11:34 +02:00
parent 21a8ac0cd3
commit 38df48d108
2 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
Fix vgimportclone with -n to not add number unnecessarily to base VG name.
Cleanup vgimportclone script and remove dependency on awk, grep, cut and tr.
Add vg_missing_pv_count report field to report number of missing PVs in a VG.
Properly identify internal LV holding sanlock locks within lv_role field.

View File

@ -48,7 +48,7 @@ function getvgname {
NAME="${BNAME}"
I=0
while [[ "${VGLIST}" =~ "${NAME}" ]]
while [[ "${VGLIST}" =~ ":${NAME}:" ]]
do
I=$(($I+1))
NAME="${BNAME}$I"
@ -215,10 +215,12 @@ then
fi
#####################################################################
### Get the existing state so we can use it later
### Get the existing state so we can use it later.
### The list of VG names is saved in this format:
### :vgname1:vgname2:...:vgnameN:
#####################################################################
OLDVGS=`"${LVM}" vgs ${LVM_OPTS} -o name --noheadings`
OLDVGS=":`"${LVM}" vgs ${LVM_OPTS} -o name --noheadings --rows --separator :`:"
checkvalue $? "Current VG names could not be collected without errors"
#####################################################################