Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 824813

Summary: vgcfgrestore fails with division by zero if metadata-only PV with no physical extents present in VG
Product: Red Hat Enterprise Linux 5 Reporter: Milan Broz <mbroz>
Component: lvm2-clusterAssignee: Alasdair Kergon <agk>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: low Docs Contact:
Priority: low    
Version: 5.8CC: agk, ccaulfie, cmarthal, dwysocha, heinzm, jbrassow, mbroz, msnitzer, nperic, prajnoha, prockai, pvrabec, thornber, zkabelac
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-cluster-2.02.88-8.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 820237 Environment:
Last Closed: 2013-01-08 07:04:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 820237    
Bug Blocks:    

Description Milan Broz 2012-05-24 10:38:17 UTC
+++ This bug was initially created as a clone of Bug #820237 +++
Clone for lvm2-cluster build

Description of problem:
If there is PV with zero PE count in the VG, vgcfgrestore on the VG fails saying "Floating point exception", which is caused by division by zero.

Background:
We are using LVM heavily for storage of block device backups. Because the PVs are usually very busy and metadata manipulation requires direct access to the metadata sector (may take considerable time to complete), we have created a metadata-only PV on a separate drive. 

Version-Release number of selected component (if applicable):
  LVM version:     2.02.87(2)-RHEL6 (2011-10-12)
  Library version: 1.02.66-RHEL6 (2011-10-12)
  Driver version:  4.22.6

How reproducible:
Always

Steps to Reproduce:
create /dev/<metadata_device> with size 200M
create /dev/<data_device> of any size
pvcreate --metadatasize 128m /dev/<metadata_device>
pvcreate --metadatasize 128m /dev/<data_device>
vgcreate -s 128m myVG /dev/<metadata_device> /dev/<data_device>
vgcfgbackup myVG
vgcfgrestore myVG
  
Actual results:
Last command fails with "Floating point exception" error. 

Expected results:
vgcfgrestore should successfully write VG metadata

Additional info:
This issue may be worked around by omitting the zero-length PV from the backup file. See file contents below.
We have solved this for our case using the above workaround and making the metadata PV bigger and setting allocable to N afterwards.

Backup file contents:
# Generated by LVM2 version 2.02.87(2)-RHEL6 (2011-10-12): Wed May  9 10:13:28 2012

contents = "Text Format Volume Group"
version = 1

description = "vgcfgbackup -f myvg.vg myvg"

creation_host = "localhost.localdomain"	# Linux localhost.localdomain 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64
creation_time = 1336551208	# Wed May  9 10:13:28 2012

myvg {
	id = "ouGQeP-8bPl-udT8-lm8a-Nd3A-WprB-pOGXfj"
	seqno = 1
	status = ["RESIZEABLE", "READ", "WRITE"]
	flags = []
	extent_size = 262144		# 128 Megabytes
	max_lv = 0
	max_pv = 0
	metadata_copies = 0

	physical_volumes {

		pv0 {
			id = "hbMvQA-zTeD-CKPc-WE8o-umlm-Z6GJ-iyALRr"
			device = "/dev/vg_test/pv1"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 20971520	# 10 Gigabytes
			pe_start = 264192
			pe_count = 78	# 9.75 Gigabytes
		}

		pv1 {
			id = "K1BwfU-2LuG-8aeW-IXHR-RLf7-d36V-DMERDr"
			device = "/dev/vg_test/pv_metadata"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 409600	# 200 Megabytes
			pe_start = 264192
			pe_count = 0	# 0 Kilobytes
		}
	}

}


Backup file for workaround:
# Generated by LVM2 version 2.02.87(2)-RHEL6 (2011-10-12): Wed May  9 10:13:28 2012

contents = "Text Format Volume Group"
version = 1

description = "vgcfgbackup -f myvg.vg myvg"

creation_host = "localhost.localdomain"	# Linux localhost.localdomain 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64
creation_time = 1336551208	# Wed May  9 10:13:28 2012

myvg {
	id = "ouGQeP-8bPl-udT8-lm8a-Nd3A-WprB-pOGXfj"
	seqno = 1
	status = ["RESIZEABLE", "READ", "WRITE"]
	flags = []
	extent_size = 262144		# 128 Megabytes
	max_lv = 0
	max_pv = 0
	metadata_copies = 0

	physical_volumes {

		pv0 {
			id = "hbMvQA-zTeD-CKPc-WE8o-umlm-Z6GJ-iyALRr"
			device = "/dev/vg_test/pv1"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 20971520	# 10 Gigabytes
			pe_start = 264192
			pe_count = 78	# 9.75 Gigabytes
		}
	}

}

Comment 1 RHEL Program Management 2012-05-24 10:49:18 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux release.  Product Management has
requested further review of this request by Red Hat Engineering, for
potential inclusion in a Red Hat Enterprise Linux release for currently
deployed products.  This request is not yet committed for inclusion in
a release.

Comment 2 Milan Broz 2012-05-24 15:51:42 UTC
Fixed in
lvm2-cluster-2.02.88-8.el5

Comment 4 Nenad Peric 2012-06-06 09:35:36 UTC
Tested with:

lvm2-cluster-2.02.88-8.el5
cmirror-1.1.39-15.el5
device-mapper-multipath-0.4.7-49.el5
device-mapper-1.02.67-2.el5
device-mapper-event-1.02.67-2.el5


The creation of a suggested VG and PVs, and executing backup/restore procedure produced no errors, as expected.

Comment 6 errata-xmlrpc 2013-01-08 07:04:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0024.html