@@ -716,7 +716,10 @@ def scan(self, uuid):
716716 util .roundup (lvutil .LVM_SIZE_INCREMENT ,
717717 vhdutil .calcOverheadEmpty (lvhdutil .MSIZE ))
718718 else :
719- utilisation = lvhdutil .calcSizeVHDLV (int (size ))
719+ utilisation = lvhdutil .calcSizeVHDLV (
720+ int (size ),
721+ vhdutil .getBlockSize (lvPath )
722+ )
720723
721724 vdi_ref = self .session .xenapi .VDI .db_introduce (
722725 vdi_uuid ,
@@ -984,7 +987,10 @@ def _undoCloneOp(self, lvs, origUuid, baseUuid, clonUuid):
984987
985988 # inflate the parent to fully-allocated size
986989 if base .vdiType == vhdutil .VDI_TYPE_VHD :
987- fullSize = lvhdutil .calcSizeVHDLV (vhdInfo .sizeVirt )
990+ fullSize = lvhdutil .calcSizeVHDLV (
991+ vhdInfo .sizeVirt ,
992+ vhdutil .getBlockSize (basePath )
993+ )
988994 lvhdutil .inflate (self .journaler , self .uuid , baseUuid , fullSize )
989995
990996 # rename back
@@ -1173,7 +1179,7 @@ def _undoAllVHDJournals(self):
11731179 util .SMlog ("Found VHD journal %s, reverting %s" % (uuid , vdi .path ))
11741180 self .lvActivator .activate (uuid , vdi .lvname , False )
11751181 self .lvmCache .activateNoRefcount (jlvName )
1176- fullSize = lvhdutil .calcSizeVHDLV (vdi .size )
1182+ fullSize = lvhdutil .calcSizeVHDLV (vdi .size , vdi . block_size )
11771183 lvhdutil .inflate (self .journaler , self .uuid , vdi .uuid , fullSize )
11781184 try :
11791185 jFile = os .path .join (self .path , jlvName )
@@ -1184,7 +1190,7 @@ def _undoAllVHDJournals(self):
11841190 util .SMlog ("VHD revert failed but VHD ok: removing journal" )
11851191 # Attempt to reclaim unused space
11861192 vhdInfo = vhdutil .getVHDInfo (vdi .path , lvhdutil .extractUuid , False )
1187- NewSize = lvhdutil .calcSizeVHDLV (vhdInfo .sizeVirt )
1193+ NewSize = lvhdutil .calcSizeVHDLV (vhdInfo .sizeVirt , vdi . block_size )
11881194 if NewSize < fullSize :
11891195 lvhdutil .deflate (self .lvmCache , vdi .lvname , int (NewSize ))
11901196 lvhdutil .lvRefreshOnAllSlaves (self .session , self .uuid ,
@@ -1459,7 +1465,10 @@ def attach(self, sr_uuid, vdi_uuid):
14591465 needInflate = False
14601466 else :
14611467 self ._loadThis ()
1462- if self .utilisation >= lvhdutil .calcSizeVHDLV (self .size ):
1468+ if (
1469+ self .utilisation >=
1470+ lvhdutil .calcSizeVHDLV (self .size , self .block_size )
1471+ ):
14631472 needInflate = False
14641473
14651474 if needInflate :
@@ -1479,7 +1488,7 @@ def detach(self, sr_uuid, vdi_uuid):
14791488 util .SMlog ("LVHDVDI.detach for %s" % self .uuid )
14801489 self ._loadThis ()
14811490 already_deflated = (self .utilisation < \
1482- lvhdutil .calcSizeVHDLV (self .size ))
1491+ lvhdutil .calcSizeVHDLV (self .size , self . block_size ))
14831492 needDeflate = True
14841493 if self .vdi_type == vhdutil .VDI_TYPE_RAW or already_deflated :
14851494 needDeflate = False
@@ -1520,7 +1529,7 @@ def resize(self, sr_uuid, vdi_uuid, size):
15201529 '(current size: %d, new size: %d)' % (self .size , size ))
15211530 raise xs_errors .XenError ('VDISize' , opterr = 'shrinking not allowed' )
15221531
1523- size = vhdutil .validate_and_round_vhd_size (int (size ))
1532+ size = vhdutil .validate_and_round_vhd_size (int (size ), self . block_size )
15241533
15251534 if size == self .size :
15261535 return VDI .VDI .get_params (self )
@@ -1530,7 +1539,7 @@ def resize(self, sr_uuid, vdi_uuid, size):
15301539 lvSizeNew = util .roundup (lvutil .LVM_SIZE_INCREMENT , size )
15311540 else :
15321541 lvSizeOld = self .utilisation
1533- lvSizeNew = lvhdutil .calcSizeVHDLV (size )
1542+ lvSizeNew = lvhdutil .calcSizeVHDLV (size , self . block_size )
15341543 if self .sr .provision == "thin" :
15351544 # VDI is currently deflated, so keep it deflated
15361545 lvSizeNew = lvSizeOld
@@ -1696,7 +1705,7 @@ def _snapshot(self, snapType, cloneOp=False, cbtlog=None, cbt_consistency=None):
16961705 self .issnap = self .session .xenapi .VDI .get_is_a_snapshot ( \
16971706 self .sr .srcmd .params ['vdi_ref' ])
16981707
1699- fullpr = lvhdutil .calcSizeVHDLV (self .size )
1708+ fullpr = lvhdutil .calcSizeVHDLV (self .size , self . block_size )
17001709 thinpr = util .roundup (lvutil .LVM_SIZE_INCREMENT , \
17011710 vhdutil .calcOverheadEmpty (lvhdutil .MSIZE ))
17021711 lvSizeOrig = thinpr
0 commit comments