Eduardo has uploaded a new change for review.
Change subject: Do not fail when getVSize is called on an inctive LV.
......................................................................
Do not fail when getVSize is called on an inctive LV.
Change-Id: I0a8b6da4d57cdf810769586c1959989d7a545d0c
Bug-uri:
https://bugzilla.redhat.com/show_bug.cgi?id=878955
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/blockVolume.py
1 file changed, 11 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/9739/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 98c471b..bf71fb2 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -61,7 +61,7 @@
rmanager = rm.ResourceManager.getInstance()
-def _getDeviceSize(devPath):
+def _tellEnd(devPath):
with open(devPath, "rb") as f:
f.seek(0, 2)
return f.tell()
@@ -91,15 +91,17 @@
@classmethod
def getVSize(cls, sdobj, imgUUID, volUUID, bs=512):
try:
- return _getDeviceSize(lvm.lvPath(sdobj.sdUUID, volUUID)) / bs
- except Exception, e:
- # The volume might not be active, skip logging.
- if not (isinstance(e, IOError) and e.errno == os.errno.ENOENT):
- cls.log.warn("Could not get size for vol %s/%s using "
- "optimized methods", sdobj.sdUUID, volUUID, exc_info=True)
+ size = _tellEnd(lvm.lvPath(sdobj.sdUUID, volUUID)) / bs
+ except IOError as e:
+ if e.errno == os.errno.ENOENT:
+ # Inactive volume has no /dev entry. Fallback to lvm way.
+ size = int(int(lvm.getLV(sdobj.sdUUID, volUUID).size) / bs)
+ else:
+ cls.log.warn("Could not get size for vol %s/%s",
+ sdobj.sdUUID, volUUID, exc_info=True)
+ raise
- # Fallback to the traditional way.
- return int(int(lvm.getLV(sdobj.sdUUID, volUUID).size) / bs)
+ return size
getVTrueSize = getVSize
--
To view, visit
http://gerrit.ovirt.org/9739
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a8b6da4d57cdf810769586c1959989d7a545d0c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>