@@ -721,7 +721,10 @@ def scan(self, uuid):
721721 util .roundup (lvutil .LVM_SIZE_INCREMENT ,
722722 vhdutil .calcOverheadEmpty (lvhdutil .MSIZE ))
723723 else :
724- utilisation = lvhdutil .calcSizeVHDLV (int (size ))
724+ utilisation = lvhdutil .calcSizeVHDLV (
725+ int (size ),
726+ vhdutil .getBlockSize (lvPath )
727+ )
725728
726729 vdi_ref = self .session .xenapi .VDI .db_introduce (
727730 vdi_uuid ,
@@ -989,7 +992,10 @@ def _undoCloneOp(self, lvs, origUuid, baseUuid, clonUuid):
989992
990993 # inflate the parent to fully-allocated size
991994 if base .vdiType == vhdutil .VDI_TYPE_VHD :
992- fullSize = lvhdutil .calcSizeVHDLV (vhdInfo .sizeVirt )
995+ fullSize = lvhdutil .calcSizeVHDLV (
996+ vhdInfo .sizeVirt ,
997+ vhdutil .getBlockSize (basePath )
998+ )
993999 lvhdutil .inflate (self .journaler , self .uuid , baseUuid , fullSize )
9941000
9951001 # rename back
@@ -1178,7 +1184,7 @@ def _undoAllVHDJournals(self):
11781184 util .SMlog ("Found VHD journal %s, reverting %s" % (uuid , vdi .path ))
11791185 self .lvActivator .activate (uuid , vdi .lvname , False )
11801186 self .lvmCache .activateNoRefcount (jlvName )
1181- fullSize = lvhdutil .calcSizeVHDLV (vdi .size )
1187+ fullSize = lvhdutil .calcSizeVHDLV (vdi .size , vdi . block_size )
11821188 lvhdutil .inflate (self .journaler , self .uuid , vdi .uuid , fullSize )
11831189 try :
11841190 jFile = os .path .join (self .path , jlvName )
@@ -1189,7 +1195,7 @@ def _undoAllVHDJournals(self):
11891195 util .SMlog ("VHD revert failed but VHD ok: removing journal" )
11901196 # Attempt to reclaim unused space
11911197 vhdInfo = vhdutil .getVHDInfo (vdi .path , lvhdutil .extractUuid , False )
1192- NewSize = lvhdutil .calcSizeVHDLV (vhdInfo .sizeVirt )
1198+ NewSize = lvhdutil .calcSizeVHDLV (vhdInfo .sizeVirt , vdi . block_size )
11931199 if NewSize < fullSize :
11941200 lvhdutil .deflate (self .lvmCache , vdi .lvname , int (NewSize ))
11951201 lvhdutil .lvRefreshOnAllSlaves (self .session , self .uuid ,
@@ -1444,7 +1450,10 @@ def attach(self, sr_uuid, vdi_uuid):
14441450 needInflate = False
14451451 else :
14461452 self ._loadThis ()
1447- if self .utilisation >= lvhdutil .calcSizeVHDLV (self .size ):
1453+ if (
1454+ self .utilisation >=
1455+ lvhdutil .calcSizeVHDLV (self .size , self .block_size )
1456+ ):
14481457 needInflate = False
14491458
14501459 if needInflate :
@@ -1464,7 +1473,7 @@ def detach(self, sr_uuid, vdi_uuid):
14641473 util .SMlog ("LVHDVDI.detach for %s" % self .uuid )
14651474 self ._loadThis ()
14661475 already_deflated = (self .utilisation < \
1467- lvhdutil .calcSizeVHDLV (self .size ))
1476+ lvhdutil .calcSizeVHDLV (self .size , self . block_size ))
14681477 needDeflate = True
14691478 if self .vdi_type == vhdutil .VDI_TYPE_RAW or already_deflated :
14701479 needDeflate = False
@@ -1505,7 +1514,7 @@ def resize(self, sr_uuid, vdi_uuid, size):
15051514 '(current size: %d, new size: %d)' % (self .size , size ))
15061515 raise xs_errors .XenError ('VDISize' , opterr = 'shrinking not allowed' )
15071516
1508- size = vhdutil .validate_and_round_vhd_size (int (size ))
1517+ size = vhdutil .validate_and_round_vhd_size (int (size ), self . block_size )
15091518
15101519 if size == self .size :
15111520 return VDI .VDI .get_params (self )
@@ -1515,7 +1524,7 @@ def resize(self, sr_uuid, vdi_uuid, size):
15151524 lvSizeNew = util .roundup (lvutil .LVM_SIZE_INCREMENT , size )
15161525 else :
15171526 lvSizeOld = self .utilisation
1518- lvSizeNew = lvhdutil .calcSizeVHDLV (size )
1527+ lvSizeNew = lvhdutil .calcSizeVHDLV (size , self . block_size )
15191528 if self .sr .provision == "thin" :
15201529 # VDI is currently deflated, so keep it deflated
15211530 lvSizeNew = lvSizeOld
@@ -1681,7 +1690,7 @@ def _snapshot(self, snapType, cloneOp=False, cbtlog=None, cbt_consistency=None):
16811690 self .issnap = self .session .xenapi .VDI .get_is_a_snapshot ( \
16821691 self .sr .srcmd .params ['vdi_ref' ])
16831692
1684- fullpr = lvhdutil .calcSizeVHDLV (self .size )
1693+ fullpr = lvhdutil .calcSizeVHDLV (self .size , self . block_size )
16851694 thinpr = util .roundup (lvutil .LVM_SIZE_INCREMENT , \
16861695 vhdutil .calcOverheadEmpty (lvhdutil .MSIZE ))
16871696 lvSizeOrig = thinpr
0 commit comments