There are two changes in this PR: - I've added `pvFree` to lvmpv format. I need this for LVM cache support in blivet-gui. - Thanks to pvFree we know if the PV is empty, so we can the solve problem with removing empty PVs from VG. We run `pvmove` automatically before `vgreduce` and `pvmove` returns 5 for empty PVs so we think it failed (and 5 is not unique return code for this situation).
From: Vojtech Trefny vtrefny@redhat.com
Signed-off-by: Vojtech Trefny vtrefny@redhat.com --- blivet/formats/lvmpv.py | 2 +- blivet/populator.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py index ee3e29e..3f7446f 100644 --- a/blivet/formats/lvmpv.py +++ b/blivet/formats/lvmpv.py @@ -79,6 +79,7 @@ def __init__(self, **kwargs): self.vgName = kwargs.get("vgName") self.vgUuid = kwargs.get("vgUuid") self.peStart = kwargs.get("peStart", lvm.LVM_PE_START) + self.pvFree = kwargs.get("pvFree", Size(0)) self.dataAlignment = kwargs.get("dataAlignment", Size(0))
self.inconsistentVG = False @@ -143,4 +144,3 @@ def status(self): os.path.isdir("/dev/%s" % self.vgName))
register_device_format(LVMPhysicalVolume) - diff --git a/blivet/populator.py b/blivet/populator.py index 733c593..a334928 100644 --- a/blivet/populator.py +++ b/blivet/populator.py @@ -1424,6 +1424,10 @@ def handleUdevDeviceFormat(self, info, device): kwargs["peStart"] = Size(pv_info.pe_start) else: log.warning("PV %s has no pe_start", name) + if pv_info.pv_free: + kwargs["pvFree"] = Size(pv_info.pv_free) + else: + log.warning("PV %s has no pv_free", name) elif format_type == "vfat": # efi magic if isinstance(device, PartitionDevice) and device.bootable:
From: Vojtech Trefny vtrefny@redhat.com
Running pvmove on empty pv results in non-zero exit code (causing libblockdev to think pvmove failed).
Signed-off-by: Vojtech Trefny vtrefny@redhat.com --- blivet/devices/lvm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py index 39d245c..d283b7d 100644 --- a/blivet/devices/lvm.py +++ b/blivet/devices/lvm.py @@ -265,7 +265,9 @@ def _remove(self, member): if lv.exists: lv.setup()
- blockdev.lvm.pvmove(member.path) + # do not run pvmove on empty pvs + if (member.size - member.format.peStart - member.format.pvFree) >= self.peSize: + blockdev.lvm.pvmove(member.path) blockdev.lvm.vgreduce(self.name, member.path)
for (lv, status) in zip(self.lvs, status):
Looks good to me.
Added label: ACK.
+1 for me
Removed label: ACK.
Just realize this just doesn't work. The `pvFree` is updated only when running `populate()` and we can't update it for non-existing LVs.
Closed.
anaconda-patches@lists.fedorahosted.org