From 447220e73f6c1a24557e3d4dddf7ca4d68fc9c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiaxing=20Wang=20=28=E6=B1=9F=E6=B9=96=E5=8D=81=E5=B9=B4?= =?UTF-8?q?=29?= Date: Fri, 22 Jul 2022 14:35:33 +0800 Subject: [PATCH] fix(device): calculate the part free size --- pkg/device/device-util.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/device/device-util.go b/pkg/device/device-util.go index 451ae35..66b1e5a 100644 --- a/pkg/device/device-util.go +++ b/pkg/device/device-util.go @@ -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 } } @@ -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{