Bug 477891

Summary: pvresize doesn't move end-of-PV metadata copy
Product: [Fedora] Fedora Reporter: Christopher Head <chead>
Component: lvm2Assignee: Peter Rajnoha <prajnoha>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: agk, bmarzins, bmr, drescherjm, dwysocha, heinzm, jaak, lvm-team, mbroz, prockai
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-04 12:04:54 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 Christopher Head 2008-12-24 23:35:14 UTC
When 2 copies of the metadata are created (e.g. with pvcreate --metadatacopies 2), one copy is placed at the beginning of the PV and the other at the end. pvresize does not move the end-copy of the metadata, which means a subsequent resize of the underlying partition cuts off the second copy. This results in complaints of invalid arguments to lseek on all LVM operations, as they try to seek to examine the second copy of the metadata.

Setting pvmetadatacopies to 1 leaves the only copy of the metadata at the beginning of the partition, which makes shrinking partitions work perfectly.

To fix this, pvresize should move the backup metadata copy to an appropriate new location.

Reproducible: Always

Steps to Reproduce:
1. Create a partition
2. Create a PV on it with 2 metadata copies
3. pvresize the PV down
4. fdisk the partition down
5. Reboot
6. vgscan
Actual Results:  
Lots of complaints from vgscan about lseek: invalid argument.

Expected Results:  
Should work fine, assuming one pvresizes smaller than the new size of the
partition.

Comment 2 Bug Zapper 2009-06-09 10:29:36 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 3 Bug Zapper 2010-04-27 12:37:40 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Peter Rajnoha 2010-05-17 12:43:26 UTC
The solution provided before was not complete. Also, the PV code has changed a little since then. I'll try to revisit the problem and do appropriate changes.

Comment 5 Bug Zapper 2010-07-30 10:34:29 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 14 development cycle.
Changing version to '14'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 6 John M. Drescher 2011-02-09 23:02:42 UTC
(In reply to comment #4)
> The solution provided before was not complete. Also, the PV code has changed a
> little since then. I'll try to revisit the problem and do appropriate changes.

Any progress on this? This bug still exists in version LVM2 2.02.83.

Comment 7 Peter Rajnoha 2011-02-10 09:26:13 UTC
(In reply to comment #6)
> Any progress on this? This bug still exists in version LVM2 2.02.83.

Yes, a new set of patches enabling this were posted on lvm-devel:
  https://www.redhat.com/archives/lvm-devel/2011-January/msg00163.html

...making further clean up and editings based on the review and comments.

Comment 8 Peter Rajnoha 2011-02-25 14:29:29 UTC
The patches are in upstream now. We only allow resizing PVs with two metadata areas that are not part of a VG yet (for resizing PVs in a VG, we need to add more infrastracture for making this safe).

Comment 9 Christopher Head 2011-02-27 21:21:34 UTC
Well, OK, but I hardly think this counts as "fixed", since resizing a PV that isn't part of a VG was never difficult to start with: delete it, resize the underlying device, and recreate it. The interesting case is resizing PVs that *are* part of VGs, because that's something you can't do any other way if there are multiple MDAs.

Comment 10 Alasdair Kergon 2011-02-28 01:26:02 UTC
Agreed - another step is needed to finish this off.

Comment 11 Peter Rajnoha 2011-02-28 17:29:30 UTC
OK, resizing a PV with 2 mdas that is part of a VG is possible now. I've just committed a simple patch removing the restriction we had in the code.

However if either the PV or the VG write fails in the process for any reason, we need to revert to previous state manually using pvcreate and vgcfgrestore (a simple error message/hint is now provided in case such error occurs - for example, the same principle is applied in vgconvert which uses PV write together with VG write).

Providing a solution for PV label write together with VG metadata write with automatic revert is another piece of work since that would be used in more situations, not just the pvresize one...

Comment 12 Peter Rajnoha 2011-08-04 12:04:54 UTC
In rawhide since lvm2 v2.02.85.