@@ -751,7 +751,7 @@ def getAllLeaves(self):
751
751
return leaves
752
752
753
753
def updateBlockInfo (self ) -> Optional [str ]:
754
- val = base64 .b64encode (self ._queryVHDBlocks ()).decode ()
754
+ val = base64 .b64encode (self ._queryCowBlocks ()).decode ()
755
755
self .setConfig (VDI .DB_VDI_BLOCKS , val )
756
756
return val
757
757
@@ -1087,7 +1087,7 @@ def _setSizeVirt(self, size) -> None:
1087
1087
jFile = os .path .join (self .sr .path , self .uuid )
1088
1088
self .cowutil .setSizeVirt (self .path , size , jFile )
1089
1089
1090
- def _queryVHDBlocks (self ) -> bytes :
1090
+ def _queryCowBlocks (self ) -> bytes :
1091
1091
return self .cowutil .getBlockBitmap (self .path )
1092
1092
1093
1093
def _getCoalescedSizeData (self ):
@@ -1200,7 +1200,7 @@ def getAllocatedSize(self) -> int:
1200
1200
1201
1201
1202
1202
class LVMVDI (VDI ):
1203
- """Object representing a VDI in an LVHD SR"""
1203
+ """Object representing a VDI in an LVM SR"""
1204
1204
1205
1205
JRN_ZERO = "zero" # journal entry type for zeroing out end of parent
1206
1206
@@ -1222,13 +1222,14 @@ def load(self, info=None) -> None:
1222
1222
self .hidden = info .hidden
1223
1223
self .parentUuid = info .parentUuid
1224
1224
self .path = os .path .join (self .sr .path , self .fileName )
1225
+ self .lvmcowutil = LvmCowUtil (self .cowutil )
1225
1226
1226
1227
@staticmethod
1227
1228
def extractUuid (path ):
1228
1229
return LvmCowUtil .extractUuid (path )
1229
1230
1230
1231
def inflate (self , size ):
1231
- """inflate the LV containing the VHD to 'size'"""
1232
+ """inflate the LV containing the COW image to 'size'"""
1232
1233
if not VdiType .isCowImage (self .vdi_type ):
1233
1234
return
1234
1235
self ._activate ()
@@ -1314,8 +1315,8 @@ def getSizePhys(self) -> int:
1314
1315
return self ._sizePhys
1315
1316
1316
1317
def _loadInfoSizePhys (self ):
1317
- """Get the physical utilization of the VHD file. We do it individually
1318
- (and not using the VHD batch scanner) as an optimization: this info is
1318
+ """Get the physical utilization of the COW image file. We do it individually
1319
+ (and not using the COW batch scanner) as an optimization: this info is
1319
1320
relatively expensive and we need it only for VDI's involved in
1320
1321
coalescing."""
1321
1322
if not VdiType .isCowImage (self .vdi_type ):
@@ -1334,7 +1335,7 @@ def getAllocatedSize(self) -> int:
1334
1335
1335
1336
def _loadInfoSizeAllocated (self ):
1336
1337
"""
1337
- Get the allocated size of the VHD volume.
1338
+ Get the allocated size of the COW volume.
1338
1339
"""
1339
1340
if not VdiType .isCowImage (self .vdi_type ):
1340
1341
return
@@ -1386,7 +1387,7 @@ def validate(self, fast=False) -> None:
1386
1387
1387
1388
@override
1388
1389
def _doCoalesce (self ) -> None :
1389
- """LVHD parents must first be activated, inflated, and made writable"""
1390
+ """LVMVDI parents must first be activated, inflated, and made writable"""
1390
1391
try :
1391
1392
self ._activateChain ()
1392
1393
self .sr .lvmCache .setReadonly (self .parent .fileName , False )
@@ -1415,10 +1416,10 @@ def _setParent(self, parent) -> None:
1415
1416
parent .children .append (self )
1416
1417
try :
1417
1418
self .setConfig (self .DB_VDI_PARENT , self .parentUuid )
1418
- Util .log ("Updated the vhd -parent field for child %s with %s" % \
1419
+ Util .log ("Updated the VDI -parent field for child %s with %s" % \
1419
1420
(self .uuid , self .parentUuid ))
1420
1421
except :
1421
- Util .log ("Failed to update the vhd -parent with %s for child %s" % \
1422
+ Util .log ("Failed to update the VDI -parent with %s for child %s" % \
1422
1423
(self .parentUuid , self .uuid ))
1423
1424
1424
1425
def _activate (self ):
@@ -1474,7 +1475,7 @@ def _increaseSizeVirt(self, size, atomic=True) -> None:
1474
1475
def _setSizeVirt (self , size ) -> None :
1475
1476
"""WARNING: do not call this method directly unless all VDIs in the
1476
1477
subtree are guaranteed to be unplugged (and remain so for the duration
1477
- of the operation): this operation is only safe for offline VHDs """
1478
+ of the operation): this operation is only safe for offline COW images. """
1478
1479
self ._activate ()
1479
1480
jFile = self .lvmcowutil .createResizeJournal (self .sr .lvmCache , self .uuid )
1480
1481
try :
@@ -1483,9 +1484,9 @@ def _setSizeVirt(self, size) -> None:
1483
1484
self .lvmcowutil .destroyResizeJournal (self .sr .lvmCache , self .uuid )
1484
1485
1485
1486
@override
1486
- def _queryVHDBlocks (self ) -> bytes :
1487
+ def _queryCowBlocks (self ) -> bytes :
1487
1488
self ._activate ()
1488
- return VDI ._queryVHDBlocks (self )
1489
+ return VDI ._queryCowBlocks (self )
1489
1490
1490
1491
@override
1491
1492
def _calcExtraSpaceForCoalescing (self ) -> int :
@@ -1782,7 +1783,7 @@ def _setSizeVirt(self, size) -> None:
1782
1783
jfile , self .cowutil .getResizeJournalSize (), persistent = False , volume_name = jfile
1783
1784
)
1784
1785
try :
1785
- self .inflate (LinstorVhdUtil .compute_volume_size (size , self .vdi_type ))
1786
+ self .inflate (linstorcowutil .compute_volume_size (size , self .vdi_type ))
1786
1787
self .sr ._vhdutil .set_size_virt (size , jfile )
1787
1788
finally :
1788
1789
try :
@@ -1792,7 +1793,7 @@ def _setSizeVirt(self, size) -> None:
1792
1793
pass
1793
1794
1794
1795
@override
1795
- def _queryVHDBlocks (self ) -> bytes :
1796
+ def _queryCowBlocks (self ) -> bytes :
1796
1797
return self .sr ._vhdutil .get_block_bitmap (self .uuid )
1797
1798
1798
1799
def _inflateParentForCoalesce (self ):
@@ -3083,14 +3084,21 @@ def _calcExtraSpaceNeeded(self, child, parent) -> int:
3083
3084
def _handleInterruptedCoalesceLeaf (self ) -> None :
3084
3085
entries = self .journaler .getAll (VDI .JRN_LEAF )
3085
3086
for uuid , parentUuid in entries .items ():
3086
- childLV = LV_PREFIX [VdiType .VHD ] + uuid
3087
- tmpChildLV = LV_PREFIX [VdiType .VHD ] + \
3088
- self .TMP_RENAME_PREFIX + uuid
3089
- parentLV1 = LV_PREFIX [VdiType .VHD ] + parentUuid
3090
- parentLV2 = LV_PREFIX [VdiType .RAW ] + parentUuid
3091
- parentPresent = (self .lvmCache .checkLV (parentLV1 ) or \
3092
- self .lvmCache .checkLV (parentLV2 ))
3093
- if parentPresent or self .lvmCache .checkLV (tmpChildLV ):
3087
+ undo = False
3088
+ for prefix in LV_PREFIX .values ():
3089
+ parentLV = prefix + parentUuid
3090
+ undo = self .lvmCache .checkLV (parentLV ):
3091
+ if undo :
3092
+ break
3093
+
3094
+ if not undo :
3095
+ for prefix in LV_PREFIX .values ():
3096
+ tmpChildLV = prefix + uuid
3097
+ undo = self .lvmCache .checkLV (tmpChildLV )
3098
+ if undo :
3099
+ break
3100
+
3101
+ if undo :
3094
3102
self ._undoInterruptedCoalesceLeaf (uuid , parentUuid )
3095
3103
else :
3096
3104
self ._finishInterruptedCoalesceLeaf (uuid , parentUuid )
@@ -3199,8 +3207,7 @@ def _updateSlavesOnUndoLeafCoalesce(self, parent, child) -> None:
3199
3207
child )
3200
3208
return
3201
3209
3202
- tmpName = LV_PREFIX [VdiType .VHD ] + \
3203
- self .TMP_RENAME_PREFIX + child .uuid
3210
+ tmpName = child .vdi_type + self .TMP_RENAME_PREFIX + child .uuid
3204
3211
args = {"vgName" : self .vgName ,
3205
3212
"action1" : "deactivateNoRefcount" ,
3206
3213
"lvName1" : tmpName ,
0 commit comments