[master 3/3] Add cache support to the LVMLogicalVolumeDevice class
vpodzime
installerbot-noreply at redhat.com
Thu Jun 18 20:07:01 UTC 2015
From: Vratislav Podzimek <vpodzime at redhat.com>
This way LVMLogicalVolumeDevice can report whether they are cached, provide
information related to their cache and attach cache pool to themselves so that
they become cached.
---
blivet/devices/lvm.py | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index ab70d01..64ac559 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -532,6 +532,7 @@ def __init__(self, name, parents=None, size=None, uuid=None, segType=None,
self._metaDataSize = Size(0)
self._internal_lvs = []
+ self._cache = None
def _check_parents(self):
"""Check that this device has parents as expected"""
@@ -622,8 +623,12 @@ def maxSize(self):
@property
def vgSpaceUsed(self):
""" Space occupied by this LV, not including snapshots. """
+ if self.cached:
+ cache_size = self.cache.size
+ else:
+ cache_size = Size(0)
return (self.vg.align(self.size, roundup=True) * self.copies
- + self.logSize + self.metaDataSize)
+ + self.logSize + self.metaDataSize + cache_size)
@property
def vg(self):
@@ -854,6 +859,28 @@ def removeInternalLV(self, int_lv):
self.name)
raise ValueError(msg)
+ @property
+ def cached(self):
+ return bool(self.cache)
+
+ @property
+ def cache(self):
+ if self.exists and not self._cache:
+ # check if we have a cache pool internal LV
+ pool = None
+ for lv in self._internal_lvs:
+ if isinstance(lv, LVMCachePoolLogicalVolumeDevice):
+ pool = lv
+
+ self._cache = LVMCache(self, size=pool.size, exists=True)
+
+ return self._cache
+
+ def attach_cache(self, cache_pool_lv):
+ blockdev.lvm.cache_attach(self.vg.name, self.lvname, cache_pool_lv.lvname)
+ self._cache = LVMCache(self, size=cache_pool_lv.size, exists=True)
+
+
@add_metaclass(abc.ABCMeta)
class LVMInternalLogicalVolumeDevice(LVMLogicalVolumeDevice):
"""Abstract base class for internal LVs
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/113058f9f04d5a14f76e57308533653778f37809
More information about the anaconda-patches
mailing list