@@ -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 ,
@@ -1343,7 +1349,10 @@ def create(self, sr_uuid, vdi_uuid, size):
13431349 if self .exists :
13441350 raise xs_errors .XenError ('VDIExists' )
13451351
1346- size = vhdutil .validate_and_round_vhd_size (int (size ))
1352+ size = vhdutil .validate_and_round_vhd_size (
1353+ int (size ),
1354+ vhdutil .DEFAULT_VHD_BLOCK_SIZE
1355+ )
13471356
13481357 util .SMlog ("LVHDVDI.create: type = %s, %s (size=%s)" % \
13491358 (self .vdi_type , self .path , size ))
@@ -1356,7 +1365,10 @@ def create(self, sr_uuid, vdi_uuid, size):
13561365 lvSize = util .roundup (lvutil .LVM_SIZE_INCREMENT ,
13571366 vhdutil .calcOverheadEmpty (lvhdutil .MSIZE ))
13581367 elif self .sr .provision == "thick" :
1359- lvSize = lvhdutil .calcSizeVHDLV (int (size ))
1368+ lvSize = lvhdutil .calcSizeVHDLV (
1369+ int (size ),
1370+ vhdutil .DEFAULT_VHD_BLOCK_SIZE
1371+ )
13601372
13611373 self .sr ._ensureSpaceAvailable (lvSize )
13621374
@@ -1459,7 +1471,10 @@ def attach(self, sr_uuid, vdi_uuid):
14591471 needInflate = False
14601472 else :
14611473 self ._loadThis ()
1462- if self .utilisation >= lvhdutil .calcSizeVHDLV (self .size ):
1474+ if (
1475+ self .utilisation >=
1476+ lvhdutil .calcSizeVHDLV (self .size , self .block_size )
1477+ ):
14631478 needInflate = False
14641479
14651480 if needInflate :
@@ -1479,7 +1494,7 @@ def detach(self, sr_uuid, vdi_uuid):
14791494 util .SMlog ("LVHDVDI.detach for %s" % self .uuid )
14801495 self ._loadThis ()
14811496 already_deflated = (self .utilisation < \
1482- lvhdutil .calcSizeVHDLV (self .size ))
1497+ lvhdutil .calcSizeVHDLV (self .size , self . block_size ))
14831498 needDeflate = True
14841499 if self .vdi_type == vhdutil .VDI_TYPE_RAW or already_deflated :
14851500 needDeflate = False
@@ -1520,7 +1535,7 @@ def resize(self, sr_uuid, vdi_uuid, size):
15201535 '(current size: %d, new size: %d)' % (self .size , size ))
15211536 raise xs_errors .XenError ('VDISize' , opterr = 'shrinking not allowed' )
15221537
1523- size = vhdutil .validate_and_round_vhd_size (int (size ))
1538+ size = vhdutil .validate_and_round_vhd_size (int (size ), self . block_size )
15241539
15251540 if size == self .size :
15261541 return VDI .VDI .get_params (self )
@@ -1530,7 +1545,7 @@ def resize(self, sr_uuid, vdi_uuid, size):
15301545 lvSizeNew = util .roundup (lvutil .LVM_SIZE_INCREMENT , size )
15311546 else :
15321547 lvSizeOld = self .utilisation
1533- lvSizeNew = lvhdutil .calcSizeVHDLV (size )
1548+ lvSizeNew = lvhdutil .calcSizeVHDLV (size , self . block_size )
15341549 if self .sr .provision == "thin" :
15351550 # VDI is currently deflated, so keep it deflated
15361551 lvSizeNew = lvSizeOld
@@ -1696,7 +1711,7 @@ def _snapshot(self, snapType, cloneOp=False, cbtlog=None, cbt_consistency=None):
16961711 self .issnap = self .session .xenapi .VDI .get_is_a_snapshot ( \
16971712 self .sr .srcmd .params ['vdi_ref' ])
16981713
1699- fullpr = lvhdutil .calcSizeVHDLV (self .size )
1714+ fullpr = lvhdutil .calcSizeVHDLV (self .size , self . block_size )
17001715 thinpr = util .roundup (lvutil .LVM_SIZE_INCREMENT , \
17011716 vhdutil .calcOverheadEmpty (lvhdutil .MSIZE ))
17021717 lvSizeOrig = thinpr
0 commit comments