Skip to content

Commit

Permalink
fix(cleanup.py): bad live coalesce check regarding FileSR
Browse files Browse the repository at this point in the history
The `VDI.canLiveCoalesce` method can manipulates sizes of different units because of this change:
```
CP-40871: use VHD allocation size in checking canLiveCoalesce
2f863b9
```
As a result, the `canLiveCoalesce` method can return True and cause coalesce attempts
resulting in "Timed out" exceptions.

Only drivers deriving from `FileSR` are impacted.
The size of `self._sizeAllocated` is calculated correctly when `vhdutil.getAllocatedSize`
is called but there is a problematic case where `getVHDInfo` is used instead.
And this function does not convert `info.sizeAllocated` from block size to bytes.
This bug is caused by the call to `FileVDI.load` in cleanup.py.

Signed-off-by: Damien Thenot <damien.thenot@vates.tech>
Co-authored-by: Ronan Abhamon <ronan.abhamon@vates.tech>
  • Loading branch information
Nambrok and Wescoeur committed Nov 26, 2024
1 parent b1eecb5 commit 9e16e8d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/vhdutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def ioretry(cmd, text=True):
errlist=[errno.EIO, errno.EAGAIN])


def convertAllocatedSizeToBytes(size):
# Assume we have standard 2MB allocation blocks
return size * 2 * 1024 * 1024


def getVHDInfo(path, extractUuidFunction, includeParent=True):
"""Get the VHD info. The parent info may optionally be omitted: vhd-util
tries to verify the parent by opening it, which results in error if the VHD
Expand All @@ -115,7 +120,7 @@ def getVHDInfo(path, extractUuidFunction, includeParent=True):
vhdInfo.parentUuid = extractUuidFunction(fields[nextIndex])
nextIndex += 1
vhdInfo.hidden = int(fields[nextIndex].replace("hidden: ", ""))
vhdInfo.sizeAllocated = int(fields[nextIndex+1])
vhdInfo.sizeAllocated = convertAllocatedSizeToBytes(int(fields[nextIndex+1]))
vhdInfo.path = path
return vhdInfo

Expand Down Expand Up @@ -274,8 +279,7 @@ def setSizePhys(path, size, debug=True):
def getAllocatedSize(path):
cmd = [VHD_UTIL, "query", OPT_LOG_ERR, '-a', '-n', path]
ret = ioretry(cmd)
# Assume we have standard 2MB allocation blocks
return int(ret) * 2 * 1024 * 1024
return convertAllocatedSizeToBytes(int(ret))

def killData(path):
"zero out the disk (kill all data inside the VHD file)"
Expand Down

0 comments on commit 9e16e8d

Please sign in to comment.