Eduardo has uploaded a new change for review.
Change subject: getVolumeInfo() new implementation. ......................................................................
getVolumeInfo() new implementation.
BC compatibility preserved but in broken behaviours.
Required to reduce the volume size functions proliferation.
Change-Id: Iedcfd84cd0848fbe3aca9f9af45c44c17722055e Signed-off-by: Eduardo ewarszaw@redhat.com --- M vdsm/storage/blockVolume.py M vdsm/storage/fileVolume.py M vdsm/storage/hsm.py M vdsm/storage/volume.py 4 files changed, 35 insertions(+), 48 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/33/18233/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py index 3ccb9d5..38b7930 100644 --- a/vdsm/storage/blockVolume.py +++ b/vdsm/storage/blockVolume.py @@ -618,17 +618,6 @@
getVolumeTrueSize = getVolumeSize
- def getVolumeMtime(self): - """ - Return the volume mtime in msec epoch - """ - try: - mtime = self.getMetaParam(volume.MTIME) - except se.MetaDataKeyNotFoundError: - mtime = 0 - - return mtime - def _extendSizeRaw(self, newSize): # Since this method relies on lvm.extendLV (lvextend) when the # requested size is equal or smaller than the current size, the diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py index 0217859..5620500 100644 --- a/vdsm/storage/fileVolume.py +++ b/vdsm/storage/fileVolume.py @@ -541,16 +541,6 @@ volPath = self.getVolumePath() return int(int(self.oop.os.stat(volPath).st_blocks) * BLOCK_SIZE / bs)
- def getVolumeMtime(self): - """ - Return the volume mtime in msec epoch - """ - volPath = self.getVolumePath() - try: - return self.getMetaParam(volume.MTIME) - except se.MetaDataKeyNotFoundError: - return self.oop.os.stat(volPath).st_mtime - def _extendSizeRaw(self, newSize): volPath = self.getVolumePath() curSizeBytes = self.oop.os.stat(volPath).st_size diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index 8a6612a..2d9f224 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -3070,10 +3070,25 @@ :rtype: dict """ vars.task.getSharedLock(STORAGE, sdUUID) - info = sdCache.produce( - sdUUID=sdUUID).produceVolume(imgUUID=imgUUID, - volUUID=volUUID).getInfo() - return dict(info=info) + dom = sdCache.produce(sdUUID=sdUUID) + info = dom.produceVolume(imgUUID, volUUID).getInfo() + + # Get the backing-volume size on disk + try: + info['apparentsize'] = str(dom.getVSize(imgUUID, volUUID, bs=1)) + info['truesize'] = str(dom.getVTrueSize(imgUUID, volUUID,bs=1)) + except (OSError, IOError, se.LogicalVolumeDoesNotExistError): + self.log.error("Can't determine volume %s %s %s size", + sdUUID, imgUUID, volUUID, exc_info=True) + info['apparentsize'] = "0" + info['truesize'] = "0" + info['status'] = "INVALID" + + # Both engine and dumpStorageTable don't use this option so + # only keeping it to not break existing scripts that look for the key + info['children'] = [] + + return dict(info=info)
@public def getVolumePath(self, sdUUID, spUUID, imgUUID, volUUID, options=None): diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index a49c4de..81b7e03 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -884,33 +884,26 @@ """ self.log.info("Info request: sdUUID=%s imgUUID=%s volUUID = %s ", self.sdUUID, self.imgUUID, self.volUUID) - image_corrupted = False - info = {} try: meta = self.getMetadata() - info = self.metadata2info(meta) - info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) - del info["size"] - # Get the image actual size on disk - vsize = self.getVolumeSize(bs=1) - avsize = self.getVolumeTrueSize(bs=1) - info['apparentsize'] = str(vsize) - info['truesize'] = str(avsize) - info['mtime'] = self.getVolumeMtime() - info['status'] = "OK" - except se.StorageException as e: - self.log.debug("exception: %s:%s" % (str(e.message), str(e.value))) - info['apparentsize'] = "0" - info['truesize'] = "0" - info['mtime'] = "0" + except se.VolumeMetadataReadError: + self.log.error("Read MD failed for volume %s %s %s", self.sdUUID, + self.imgUUID, self.volUUID, exc_info=True) + info = self.metadata2info({}) info['status'] = "INVALID" + else: + info = self.metadata2info(meta) + info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) # Virtual + del info["size"] # Remove the virtual (by volMD) size [blocks] + if info['mtime'] == "" and self.__class__.__name__ == "FileVolume": + info ['mtime'] = self.oop.os.stat(volPath).st_mtime + # If image was set to illegal, mark the status same + # (because of VDC constraints) + if info['legality'] == ILLEGAL_VOL: + info['status'] = ILLEGAL_VOL + else: + info['status'] = "OK"
- info['children'] = self.getChildrenList() - - # If image was set to illegal, mark the status same - # (because of VDC constraints) - if info.get('legality', None) == ILLEGAL_VOL or image_corrupted: - info['status'] = ILLEGAL_VOL self.log.info("%s/%s/%s info is %s", self.sdUUID, self.imgUUID, self.volUUID, str(info)) return info