diff --git a/internal/util/util.go b/internal/util/util.go index 659b4032080..2f927b5abe9 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -67,9 +67,9 @@ func RoundOffCephFSVolSize(bytes int64) int64 { return 4 * helpers.MiB } - bytes /= helpers.MiB + floatbytes := float64(bytes) / helpers.MiB - bytes = int64(math.Ceil(float64(bytes)/4) * 4) + bytes = int64(math.Ceil(floatbytes/4) * 4) return RoundOffBytes(bytes * helpers.MiB) } diff --git a/internal/util/util_test.go b/internal/util/util_test.go index d8ff374509e..aaacbda0f27 100644 --- a/internal/util/util_test.go +++ b/internal/util/util_test.go @@ -375,6 +375,16 @@ func TestRoundOffCephFSVolSize(t *testing.T) { 1677722, 4194304, // 4 MiB }, + { + "101MB conversion", + 101000000, + 104857600, // 100MiB + }, + { + "500MB conversion", + 500000000, + 503316480, // 480MiB + }, { "1023MiB conversion", 1072693248,