Bug 209927

Summary: Creating a LVM snapshot destroys volume group metadata
Product: Red Hat Enterprise Linux 4 Reporter: Tomas Edwardsson <tommi>
Component: lvm2Assignee: Alasdair Kergon <agk>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: medium    
Version: 4.4CC: agk, dwysocha, heinzm, mbroz
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2008-0776 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-07-24 20:07:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomas Edwardsson 2006-10-08 12:56:08 UTC
Description of problem:
When create a LVM snapshot of a volume group with metadata version 1 on RHEL4
the volume group becomes unusable. Nothing short of a vgcfgrestore fixes the
problem.

Version-Release number of selected component (if applicable):
lvm2-2.02.06-6.0.RHEL4
kernel-smp-2.6.9-42.0.2.EL



Steps to Reproduce:
1.lvcreate  -L 32G -s -n snap /dev/vg01/lvol1 (on a metadata ver 1 vg/lv)

Comment 1 Petr Rockai 2006-11-09 15:40:39 UTC
Reproduced, will see what can be done about it.

Comment 3 Suzanne Logcher 2007-09-17 20:04:27 UTC
This request was previously evaluated by Red Hat Product Management
for inclusion in the current Red Hat Enterprise Linux release, but
Red Hat was unable to resolve it in time.  This request will be
reviewed for a future Red Hat Enterprise Linux release.

Comment 4 Petr Rockai 2008-04-21 15:40:05 UTC
Since LVM1 metadata can be converted to LVM2 easily *and* this is about 
creating new snapshots on LVM1 volume groups, I would propose a simple measure 
of disallowing such action. The tools somehow manage to corrupt the LVM1 
metadata in nontrivial way, and I suppose it is not worth the debugging 
trouble. LVM1 metadata is definitely deprecated and the only viable usecase is 
maintaining a system compatible with RHEL3, which together with necessity to 
create new snapshots is niche at best.

The patch for such a solution should be straightforward. I'm adding that to my 
TODO and will propose such a patch shortly.

Comment 5 Alasdair Kergon 2008-04-21 18:14:43 UTC
I've just tried this:

    Invalid LV in extent map (PV /var/tmp/test2, PE 1, LV 1, LE 0)
    Couldn't fill logical volume maps.

Let's at least understand why it goes wrong to make sure there's nothing more
fundamental we need to fix.

Comment 6 Alasdair Kergon 2008-04-22 11:31:49 UTC
Indeed there is an underlying bug here: the internal variable vg->lv_count is
not maintained consistently throughout the code, leading to this bug.

Comment 7 Alasdair Kergon 2008-04-22 11:50:33 UTC
One line fix in 2.02.36, to remember to include snapshots when writing the
number of LVs in the VG into the on-disk metadata.

Comment 9 Alasdair Kergon 2008-04-22 13:09:16 UTC
Also fixed related problem of lvremove also getting the number of LVs wrong.

Comment 12 Alasdair Kergon 2008-06-19 23:03:50 UTC
To clarify - this is a bug affecting the manipulation of metadata stored on-disk
in the old format used by LVM1.  It should not affect data stored within any LVs.  

Metadata stored on-disk using the default LVM2 format is unaffected.

Comment 13 Alasdair Kergon 2008-06-19 23:08:01 UTC
To see which format you are using, run:
  vgs -o +vg_fmt

Comment 14 Corey Marthaler 2008-06-27 21:29:54 UTC
Fix verified in lvm2-2.02.37-3.el4.

[root@taft-03 ~]# vgs -o +vg_fmt
  VG         #PV #LV #SN Attr   VSize   VFree   Fmt
  VolGroup00   1   2   0 wz--n-  68.12G  32.00M lvm2
  taft         3   0   0 wz--n- 406.98G 406.98G lvm1
[root@taft-03 ~]# lvcreate -L 1G -n origin taft
  Logical volume "origin" created
[root@taft-03 ~]# lvcreate -s taft/origin -L 100M -n snap
  Logical volume "snap" created
[root@taft-03 ~]# lvs -a -o +devices
  LV       VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert Devices
  LogVol00 VolGroup00 -wi-ao  58.34G                                      
/dev/sda2(0)
  LogVol01 VolGroup00 -wi-ao   9.75G                                      
/dev/sda2(1867)
  origin   taft       own-a-   1.00G                                      
/dev/sdb1(0)
  snap     taft       swn-a- 100.00M origin   0.01                        
/dev/sdc1(0)


Comment 16 errata-xmlrpc 2008-07-24 20:07:13 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2008-0776.html