Skip to content

Commit fbab60b

Browse files
fix(device): calculate the part free size
Signed-off-by: wangjiaxing <[email protected]>
1 parent cc23b1a commit fbab60b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/device/device-util.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func findBestPart(diskMetaName string, partSize uint64) (string, uint64, error)
240240
return pList[i].SizeMiB < pList[j].SizeMiB
241241
})
242242
for _, tmp := range pList {
243-
if tmp.SizeMiB > partSize {
243+
if tmp.SizeMiB >= partSize {
244244
return tmp.DiskName, tmp.StartMiB, nil
245245
}
246246
}
@@ -295,7 +295,8 @@ func parsePartFree(row partedOutput) partFree {
295295
endMib := math.Floor(float64(row.endBytes) / 1024 / 1024)
296296
sizeMib := uint64(0)
297297
if endMib > beginMib {
298-
sizeMib = uint64(endMib - beginMib)
298+
// calculate the part free size, needs increase the difference by 1
299+
sizeMib = uint64(math.Floor(float64(row.endBytes-row.beginBytes+1) / 1024 / 1024))
299300
}
300301

301302
return partFree{

0 commit comments

Comments
 (0)