Federico Simoncelli has uploaded a new change for review.
Change subject: fileVolume: add the BLOCK_SIZE constant
......................................................................
fileVolume: add the BLOCK_SIZE constant
Change-Id: Ia517ec858fb0d7ee45323b7e2a3584c0858222f0
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/fileVolume.py
1 file changed, 11 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/14589/1
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index e463502..37e6990 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -38,6 +38,11 @@
LEASE_FILEEXT = ".lease"
LEASE_FILEOFFSET = 0
+# At the moment this is static and it has been introduced to group all the
+# previous implicit references to the block size in FileVolume. In the future
+# it will depend on the storage domain.
+BLOCK_SIZE = 512
+
def getDomUuidFromVolumePath(volPath):
# Volume path has pattern:
@@ -131,7 +136,7 @@
properly handled and logged in volume.create()
"""
- sizeBytes = int(size) * 512
+ sizeBytes = int(size) * BLOCK_SIZE
if preallocate == volume.SPARSE_VOL:
# Sparse = regular file
@@ -441,14 +446,14 @@
self.setMetaParam(volume.IMAGE, imgUUID)
@classmethod
- def getVSize(cls, sdobj, imgUUID, volUUID, bs=512):
+ def getVSize(cls, sdobj, imgUUID, volUUID, bs=BLOCK_SIZE):
imagePath = image.Image(sdobj._getRepoPath()).getImageDir(
sdobj.sdUUID, imgUUID)
volPath = os.path.join(imagePath, volUUID)
return int(sdobj.oop.os.stat(volPath).st_size / bs)
@classmethod
- def getVTrueSize(cls, sdobj, imgUUID, volUUID, bs=512):
+ def getVTrueSize(cls, sdobj, imgUUID, volUUID, bs=BLOCK_SIZE):
return sdobj.produceVolume(imgUUID, volUUID).getVolumeTrueSize(bs)
@classmethod
@@ -573,20 +578,20 @@
if not self.oop.fileUtils.pathExists(metaVolumePath):
raise se.VolumeDoesNotExist(self.volUUID)
- def getVolumeSize(self, bs=512):
+ 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=512):
+ 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) * 512 / bs)
+ return int(int(self.oop.os.stat(volPath).st_blocks) * BLOCK_SIZE / bs)
def getVolumeMtime(self):
"""
--
To view, visit
http://gerrit.ovirt.org/14589
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia517ec858fb0d7ee45323b7e2a3584c0858222f0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>