Change in vdsm[master]: VolumeMetadata: move getVolumeSize
alitke at redhat.com
alitke at redhat.com
Fri Jun 5 20:57:12 UTC 2015
Adam Litke has uploaded a new change for review.
Change subject: VolumeMetadata: move getVolumeSize
......................................................................
VolumeMetadata: move getVolumeSize
Change-Id: Ie122d4c96ad81d31c0e783e8651a99328722f8ed
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M vdsm/storage/blockVolume.py
M vdsm/storage/fileVolume.py
M vdsm/storage/volume.py
3 files changed, 34 insertions(+), 27 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/98/41998/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index c22af74..82f74bc 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -30,6 +30,7 @@
import volume
import image
import sd
+import blockSD
import misc
from misc import logskip
from misc import deprecated
@@ -157,6 +158,18 @@
Return the underlying device (for sharing)
"""
return lvm.lvPath(self.sdUUID, self.volUUID)
+
+ def getVolumeSize(self, bs=BLOCK_SIZE):
+ """
+ Return the volume size in blocks
+ """
+ # Just call the SD Manifest method getVSize() - apparently it does what
+ # we need. We consider incurred overhead of producing the object
+ # to be a small price for code de-duplication.
+ manifest = blockSD.BlockStorageDomainManifest(self.sdUUID)
+ return int(manifest.getVSize(self.imgUUID, self.volUUID) / bs)
+
+ getVolumeTrueSize = getVolumeSize
def setMetadata(self, meta, metaId=None):
"""
@@ -669,18 +682,6 @@
* dom.logBlkSize * sd.LEASE_BLOCKS)
sanlock.init_resource(sdUUID, volUUID, [(leasePath, leaseOffset)])
-
- def getVolumeSize(self, bs=BLOCK_SIZE):
- """
- Return the volume size in blocks
- """
- # Just call the SD method getVSize() - apparently it does what
- # we need. We consider incurred overhead of producing the SD object
- # to be a small price for code de-duplication.
- sdobj = sdCache.produce(sdUUID=self.sdUUID)
- return int(sdobj.getVSize(self.imgUUID, self.volUUID) / bs)
-
- getVolumeTrueSize = getVolumeSize
def _extendSizeRaw(self, newSize):
# Since this method relies on lvm.extendLV (lvextend) when the
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index 5be21ee..7956ad4 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -131,6 +131,21 @@
"""
return self.getVolumePath()
+ def getVolumeSize(self, bs=BLOCK_SIZE):
+ """
+ Return the volume size in blocks
+ """
+ volPath = self.getVolumePath()
+ return int(int(self.oop.os.stat(volPath).st_size) / bs)
+
+ def getVolumeTrueSize(self, bs=BLOCK_SIZE):
+ """
+ Return the size of the storage allocated for this volume
+ on underlying storage
+ """
+ volPath = self.getVolumePath()
+ return int(int(self.oop.os.stat(volPath).st_blocks) * BLOCK_SIZE / bs)
+
def setMetadata(self, meta, metaId=None):
"""
Set the meta data hash as the new meta data of the Volume
@@ -576,21 +591,6 @@
metaVolumePath = self._getMetaVolumePath()
if not self.oop.fileUtils.pathExists(metaVolumePath):
raise se.VolumeDoesNotExist(self.volUUID)
-
- def getVolumeSize(self, bs=BLOCK_SIZE):
- """
- Return the volume size in blocks
- """
- volPath = self.getVolumePath()
- return int(int(self.oop.os.stat(volPath).st_size) / bs)
-
- def getVolumeTrueSize(self, bs=BLOCK_SIZE):
- """
- Return the size of the storage allocated for this volume
- on underlying storage
- """
- volPath = self.getVolumePath()
- return int(int(self.oop.os.stat(volPath).st_blocks) * BLOCK_SIZE / bs)
def _extendSizeRaw(self, newSize):
volPath = self.getVolumePath()
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 21e779d..97afb56 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -872,6 +872,12 @@
def getSize(self):
return self.md.getSize()
+ def getVolumeSize(self, bs=BLOCK_SIZE):
+ return self.md.getVolumeSize(bs)
+
+ def getVolumeTrueSize(self, bs=BLOCK_SIZE):
+ return self.md.getVolumeTrueSize(bs)
+
def setSize(self, size):
self.md.setSize(size)
--
To view, visit https://gerrit.ovirt.org/41998
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie122d4c96ad81d31c0e783e8651a99328722f8ed
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>
More information about the vdsm-patches
mailing list