From bc8e7836a2f9655dbdd2cd978e8779e6a7fe26ed Mon Sep 17 00:00:00 2001 From: David Lehman Date: Mon, 21 Apr 2014 12:04:57 -0500 Subject: [PATCH 12/18] Drop special accounting for snapshot space usage in VG. Snapshots are now represented by devices, so the space accounting is handled the same as for other LVs. --- blivet/devices.py | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/blivet/devices.py b/blivet/devices.py index b42144a..4ce6969 100644 --- a/blivet/devices.py +++ b/blivet/devices.py @@ -2381,10 +2381,6 @@ class LVMVolumeGroupDevice(ContainerDevice): 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 = {} - # >0 is fixed self.size_policy = self.size @@ -2595,18 +2591,6 @@ class LVMVolumeGroupDevice(ContainerDevice): return modified @property - def snapshotSpace(self): - """ Total space used by snapshots in this volume group. """ - used = 0 - for lv in self.lvs: - used += self.align(lv.snapshotSpace, roundup=True) - - for (_vname, vsize) in self.voriginSnapshots.items(): - used += self.align(vsize, roundup=True) - - return used - - @property def reservedSpace(self): """ Reserved space in this VG """ reserved = Size(0) @@ -2649,7 +2633,7 @@ class LVMVolumeGroupDevice(ContainerDevice): # total the sizes of any LVs log.debug("%s size is %s", self.name, self.size) - used = sum(lv.vgSpaceUsed for lv in self.lvs) + self.snapshotSpace + used = sum(lv.vgSpaceUsed for lv in self.lvs) if not self.exists and raid_disks: # (only) we allocate (5 * num_disks) extra extents for LV metadata # on RAID (see the devicefactory.LVMFactory._get_total_space method) @@ -2739,7 +2723,7 @@ class LVMLogicalVolumeDevice(DMDevice): _packages = ["lvm2"] def __init__(self, name, parents=None, size=None, uuid=None, - copies=1, logSize=0, snapshotSpace=0, segType=None, + copies=1, logSize=0, segType=None, fmt=None, exists=False, sysfsPath='', grow=None, maxsize=None, percent=None, singlePV=False): @@ -2765,8 +2749,6 @@ class LVMLogicalVolumeDevice(DMDevice): :type copies: int :keyword logSize: size of log volume (for mirrored lvs) :type logSize: :class:`~.size.Size` - :keyword snapshotSpace: sum of sizes of snapshots of this lv - :type snapshotSpace: :class:`~.size.Size` :keyword singlePV: if true, maps this lv to a single pv :type singlePV: bool :keyword segType: segment type (eg: "linear", "raid1") @@ -2804,7 +2786,6 @@ class LVMLogicalVolumeDevice(DMDevice): 'size': self.size}) self.uuid = uuid - self.snapshotSpace = snapshotSpace self.copies = copies self.logSize = logSize self.metaDataSize = 0 @@ -2841,11 +2822,10 @@ class LVMLogicalVolumeDevice(DMDevice): s += (" VG device = %(vgdev)r\n" " segment type = %(type)s percent = %(percent)s\n" " mirror copies = %(copies)d" - " snapshot total = %(snapshots)s\n" " VG space used = %(vgspace)s" % {"vgdev": self.vg, "percent": self.req_percent, "copies": self.copies, "type": self.segType, - "snapshots": self.snapshotSpace, "vgspace": self.vgSpaceUsed }) + "vgspace": self.vgSpaceUsed }) return s @property @@ -2853,7 +2833,6 @@ class LVMLogicalVolumeDevice(DMDevice): d = super(LVMLogicalVolumeDevice, self).dict if self.exists: d.update({"copies": self.copies, - "snapshots": self.snapshotSpace, "vgspace": self.vgSpaceUsed}) else: d.update({"percent": self.req_percent}) -- 1.9.0