We don't show them, don't offer to edit or delete them. All we do is account for the space they occupy in the volume group. This patch also consolidates the calculation of snapshot space usage in LVMVolumeGroupDevice into a property, snapshotSpace, and refactors LVMVolumeGroup.freeSpace accordingly. --- iw/lvm_dialog_gui.py | 1 + storage/devices.py | 28 +++++++++++++++++++++------- storage/devicetree.py | 14 +++++++++----- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py index aca28d4..0192b04 100644 --- a/iw/lvm_dialog_gui.py +++ b/iw/lvm_dialog_gui.py @@ -46,6 +46,7 @@ class VolumeGroupEditor: pvs = [copy.deepcopy(pv) for pv in self.pvs] vg = LVMVolumeGroupDevice('tmp-%s' % self.vg.name, parents=pvs, peSize=self.peSize) + vg.voriginSnapshots = self.vg.voriginSnapshots.copy() for lv in self.lvs.values(): _l = LVMLogicalVolumeDevice(lv['name'], vg, format=lv['format'], size=lv['size'], exists=lv['exists'], diff --git a/storage/devices.py b/storage/devices.py index 401a73a..0776f22 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -1814,6 +1814,10 @@ class LVMVolumeGroupDevice(DMDevice): if not self.exists: self.pvCount = len(self.parents) + # Some snapshots don't have a proper LV as an origin (--vorigin). + # They still occupy space in the VG. + self.voriginSnapshots = {} + #self.probe() def __str__(self): @@ -2113,6 +2117,21 @@ class LVMVolumeGroupDevice(DMDevice): return modified @property + def snapshotSpace(self): + """ Total space used by snapshots in this volume group. """ + used = 0 + for lv in self.lvs: + log.debug("lv %s uses %dMB for snapshots" % (lv.lvname, + lv.snapshotSpace)) + used += self.align(lv.snapshotSpace, roundup=True) + + for (vname, vsize) in self.voriginSnapshots.items(): + log.debug("snapshot %s with vorigin uses %dMB" % (vname, vsize)) + used += self.align(vsize, roundup=True) + + return used + + @property def size(self): """ The size of this VG """ # TODO: just ask lvm if isModified returns False @@ -2138,13 +2157,8 @@ class LVMVolumeGroupDevice(DMDevice): # TODO: just ask lvm if isModified returns False # total the sizes of any LVs - used = 0 - size = self.size - log.debug("%s size is %dMB" % (self.name, size)) - for lv in self.lvs: - log.debug("lv %s uses %dMB" % (lv.name, lv.vgSpaceUsed)) - used += self.align(lv.vgSpaceUsed, roundup=True) - + log.debug("%s size is %dMB" % (self.name, self.size)) + used = sum(lv.size for lv in self.lvs) + self.snapshotSpace free = self.size - used log.debug("vg %s has %dMB free" % (self.name, free)) return free diff --git a/storage/devicetree.py b/storage/devicetree.py index 9824589..1f0c391 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -1518,17 +1518,21 @@ class DeviceTree(object): origin = self.getDeviceByName("%s-%s" % (vg_name, origin_name)) if not origin: - log.warning("snapshot lv '%s' origin lv '%s-%s' " - "not found" % (name, - vg_name, origin_name)) + if origin_name.endswith("_vorigin]"): + log.info("snapshot volume '%s' has vorigin" % name) + vg_device.voriginSnapshots[lv_name] = lv_sizes[index] + else: + log.warning("snapshot lv '%s' origin lv '%s-%s' " + "not found" % (name, + vg_name, origin_name)) continue log.debug("adding %dMB to %s snapshot total" % (lv_sizes[index], origin.name)) origin.snapshotSpace += lv_sizes[index] continue - elif lv_attr[index][0] in 'Iil': - # skip mirror images and log volumes + elif lv_attr[index][0] in 'Iilv': + # skip mirror images, log volumes, and vorigins continue log_size = 0 -- 1.7.2.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list