Skip to content

Commit

Permalink
fix(device): calculate the part free size
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghushinian committed Jul 22, 2022
1 parent cc23b1a commit 447220e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/device/device-util.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func findBestPart(diskMetaName string, partSize uint64) (string, uint64, error)
return pList[i].SizeMiB < pList[j].SizeMiB
})
for _, tmp := range pList {
if tmp.SizeMiB > partSize {
if tmp.SizeMiB >= partSize {
return tmp.DiskName, tmp.StartMiB, nil
}
}
Expand Down Expand Up @@ -295,7 +295,8 @@ func parsePartFree(row partedOutput) partFree {
endMib := math.Floor(float64(row.endBytes) / 1024 / 1024)
sizeMib := uint64(0)
if endMib > beginMib {
sizeMib = uint64(endMib - beginMib)
// calculate the part free size, needs increase the difference by 1
sizeMib = uint64(math.Floor(float64(row.endBytes-row.beginBytes+1) / 1024 / 1024))
}

return partFree{
Expand Down

0 comments on commit 447220e

Please sign in to comment.