pvresize should defrag pv if necessary to reduce its size

Bug #177350 reported by Eric Anopolsky
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
lvm2 (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

The problem:
I have an LVM2 physical volume with a lot of free physical extents. But, when I try to shrink that physical volume with pvresize, it tells me that it can't. The reason is that there are allocated physical extents beyond the end of what would be the new physical volume.

The solution:
if( physicalExtentsBeyondEndOfRequestedPhysicalVolumeSize() ) {
    compactPhysicalExtentsToTheBeginningOfThePhysicalVolume();
}
shrinkPhysicalVolume();

This bug depends on bug #1. If that bug is fixed, I won't need to shrink LVM2 PVs.

Revision history for this message
Paolo Sammicheli (xdatap1) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering if this is still an issue for you. Can you try with the latest Ubuntu release? Thanks in advance.

Changed in lvm2 (Ubuntu):
status: New → Incomplete
assignee: nobody → Paolo Sammicheli (xdatap1)
Revision history for this message
Paolo Sammicheli (xdatap1) wrote :

We are closing this bug report because it lacks the information we need to investigate the problem, as described in the previous comments. Please reopen it if you can give us the missing information, and don't hesitate to submit bug reports in the future. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to "New". Thanks again!

Changed in lvm2 (Ubuntu):
status: Incomplete → Invalid
assignee: Paolo Sammicheli (xdatap1) → nobody
Revision history for this message
Taylor Raack (track16) wrote :

I'm reopening this, because I'm having the exact same problem as Paulo. I'm trying with Lucid 2.6.32-24-generic and LVM2 2.02.54-1ubuntu4. Is anyone willing to take a quick look at this and determine if it's something which can be fixed?

Changed in lvm2 (Ubuntu):
status: Invalid → New
Revision history for this message
Soren Hansen (soren) wrote :

You should be able to use pvmove to move the offending physical extents within the pv. IIRC, the magic incantation is:

   pvmove -v /dev/whatever_your_pv_is_called

Revision history for this message
Taylor Raack (track16) wrote :

Soren, I just tried this out and sadly am having no luck. I run 'pvmove -v /dev/sdf1' (sdf1 is my pv) and the result I get is:

Finding volume group "mermaid"
  No extents available for allocation

But clearly I have extents on the pv, as reported by pvdisplay:
--- Physical volume ---
  PV Name /dev/sdf1
  VG Name mermaid
  PV Size 931.51 GiB / not usable 3.19 MiB
  Allocatable yes
  PE Size 4.00 MiB
  Total PE 238466
  Free PE 97497
  Allocated PE 140969
  PV UUID wGWKzs-Z1XJ-DFrd-jalf-0HOE-UM1x-V1GNZt

So, that doesn't seem to work. Does anything else come to mind?

Revision history for this message
Taylor Raack (track16) wrote :

I should have also mentioned that my vg only has one pv in it. Perhaps this is compounding the problem - there is no other pv in the group to which I can move extents. But really all I want to do is coalesce the extents on the existing pv so that I can physically shrink it.

Revision history for this message
Soren Hansen (soren) wrote : Re: [Bug 177350] Re: pvresize can't shrink PVs

And pvmove won't let you do that?
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Revision history for this message
Phillip Susi (psusi) wrote : Re: pvresize can't shrink PVs

By default pvmove allocates extents on pvs OTHER than the one they are coming from. If you want to move extents around on the same PV, IIRC, you have to pass --alloc anywhere, and explicitly specify destination extents.

At any rate, this isn't really a bug. It is by design that you can not reduce a pv below its last allocated extent. If extent fragmentation is a problem, lvm currently does not support auto defragmentation. So this is really a feature request.

Changed in lvm2 (Ubuntu):
importance: Undecided → Wishlist
status: New → Triaged
summary: - pvresize can't shrink PVs
+ pvresize should defrag pv if necessary to reduce its size
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.