summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2012-05-09 12:30:56 +0000
committerPeter Rajnoha <prajnoha@redhat.com>2012-05-09 12:30:56 +0000
commit501a2c04a4cb009a4c6497cd601801b2fe32fb4e (patch)
treefc8c41ed0a7f63251498948f28c7fa171f64645d
parent9f60083aff1b68298d38b487a6a80c74259ecaae (diff)
downloadlvm2-501a2c04a4cb009a4c6497cd601801b2fe32fb4e.tar.gz
Fix division by zero if PV with zero PE count is used during vgcfgrestore.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/format_text/format-text.c2
-rw-r--r--test/shell/pvcreate-operation.sh8
3 files changed, 10 insertions, 1 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 07e87541f..3a9e41592 100644
--- 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.
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index abd02c8e6..3c89dfabd 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -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) {
diff --git a/test/shell/pvcreate-operation.sh b/test/shell/pvcreate-operation.sh
index e5d7239bb..19d9e8e9f 100644
--- a/test/shell/pvcreate-operation.sh
+++ b/test/shell/pvcreate-operation.sh
@@ -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"