[PATCH 2/4] Add support for detecting lvm vorigin snapshot volumes. (#633038)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 pyanaconda/iw/lvm_dialog_gui.py  |    1 +
 pyanaconda/storage/devices.py    |   28 +++++++++++++++++++++-------
 pyanaconda/storage/devicetree.py |   14 +++++++++-----
 3 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/pyanaconda/iw/lvm_dialog_gui.py b/pyanaconda/iw/lvm_dialog_gui.py
index 8be27dc..090bbba 100644
--- a/pyanaconda/iw/lvm_dialog_gui.py
+++ b/pyanaconda/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/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index ab0d4d6..db17391 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -1809,6 +1809,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):
@@ -2108,6 +2112,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
@@ -2133,13 +2152,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/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 3c75c3e..3c2cfd8 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -1095,17 +1095,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.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux