]> sourceware.org Git - lvm2.git/commitdiff
Fix division by zero if PV with zero PE count is used during vgcfgrestore.
authorPeter Rajnoha <prajnoha@redhat.com>
Wed, 9 May 2012 12:30:56 +0000 (12:30 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Wed, 9 May 2012 12:30:56 +0000 (12:30 +0000)
WHATS_NEW
lib/format_text/format-text.c
test/shell/pvcreate-operation.sh

index 07e87541f73779f197afc96acf008bd3d58bee4c..3a9e415929e08e942d4cfd574f80b55028b4d62c 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.96 - 
 ================================
+  Fix division by zero if PV with zero PE count is used during vgcfgrestore.
   Add initial support for thin pool lvconvert.
   Fix lvrename for thin volumes (regression in for_each_sub_lv() 2.02.89).
   Fix up-convert when mirror activation is controled by volume_list and tags.
index abd02c8e6953041026a4bbc8eb1640601d671c83..3c89dfabd366ba378c13cab424316943d0740346 100644 (file)
@@ -1713,7 +1713,7 @@ static int _text_pv_setup(const struct format_type *fmt,
                           pv->pe_start + size_reduction;
 
        /* Recalculate number of extents that will fit */
-       if (!pv->pe_count) {
+       if (!pv->pe_count && vg->extent_size) {
                pe_count = (pv->size - pv->pe_start - size_reduction) /
                           vg->extent_size;
                if (pe_count > UINT32_MAX) {
index e5d7239bb609068fc8b4f454c080942bce17671e..19d9e8e9fd19de07c7db184f6cddcb7b0d0be1ba 100644 (file)
@@ -111,6 +111,14 @@ pvcreate --norestorefile --uuid $uuid1 "$dev1"
 vgcfgbackup -f $backupfile
 not pvcreate --uuid $uuid2 --restorefile $backupfile "$dev2"
 
+# vgcfgrestore of a VG containing a PV with zero PEs (bz #820116)
+# (use case: one PV in a VG used solely to keep metadata)
+size_mb=$(($(blockdev --getsz $dev1) / 2048))
+pvcreate --metadatasize $size_mb $dev1
+vgcreate $vg1 $dev1
+vgcfgbackup -f $backupfile
+vgcfgrestore -f $backupfile $vg1
+
 # pvcreate wipes swap signature when forced
 dd if=/dev/zero of="$dev1" bs=1024 count=64
 mkswap "$dev1"
This page took 0.047195 seconds and 5 git commands to generate.