[master 1/1] Do not try to get LVM cache's size from stats for inactive LV

vpodzime installerbot-noreply at redhat.com
Thu Nov 12 11:54:06 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

If the cached LV is not active, we cannot determine the size of its cache from
the stats because these are only available for activated LVs. However, if the LV
and cache exist, we examined them on devicetree population and got the
information about the size at that point. Thus we can used the stored value if
the LV is no longer active.

Also, keep the logic of when we should be able to get stats in one place.
---
 blivet/devices/lvm.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index fc92683..350e423 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -1786,8 +1786,10 @@ def __init__(self, cached_lv, size=None, md_size=None, exists=False, fast_pvs=No
 
     @property
     def size(self):
-        if self.exists:
-            return self.stats.size
+        # self.stats is always dynamically fetched so store and reuse the value here
+        stats = self.stats
+        if stats:
+            return stats.size
         else:
             return self._size
 
@@ -1808,9 +1810,11 @@ def exists(self):
 
     @property
     def stats(self):
-        if not self._exists:
+        # to get the stats we need the cached LV to exist and be activated
+        if self._exists and self._cached_lv.status:
+            return LVMCacheStats(blockdev.lvm.cache_stats(self._cached_lv.vg.name, self._cached_lv.lvname))
+        else:
             return None
-        return LVMCacheStats(blockdev.lvm.cache_stats(self._cached_lv.vg.name, self._cached_lv.lvname))
 
     @property
     def mode(self):


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/b4baf5e7c9c7a7afe28ff6183aea8c0b4fa7702e


More information about the anaconda-patches mailing list