Skip to content

Remove metadata info from space usage calculation #1417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions internal/server/storage/drivers/driver_lvm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ func (d *lvm) thinPoolVolumeUsage(volDevPath string) (uint64, uint64, error) {
"--units", "b",
"--nosuffix",
"--separator", ",",
"-o", "lv_size,data_percent,metadata_percent",
"-o", "lv_size,data_percent",
}

out, err := subprocess.RunCommand("lvs", args...)
Expand All @@ -741,7 +741,7 @@ func (d *lvm) thinPoolVolumeUsage(volDevPath string) (uint64, uint64, error) {
}

parts := util.SplitNTrimSpace(out, ",", -1, true)
if len(parts) < 3 {
if len(parts) < 2 {
return 0, 0, fmt.Errorf("Unexpected output from lvs command")
}

Expand All @@ -762,17 +762,7 @@ func (d *lvm) thinPoolVolumeUsage(volDevPath string) (uint64, uint64, error) {
return 0, 0, fmt.Errorf("Failed parsing thin volume used percentage (%q): %w", parts[1], err)
}

metaPerc := float64(0)

// For thin volumes there is no meta data percentage. This is only for the thin pool volume itself.
if parts[2] != "" {
metaPerc, err = strconv.ParseFloat(parts[2], 64)
if err != nil {
return 0, 0, fmt.Errorf("Failed parsing thin pool meta used percentage (%q): %w", parts[2], err)
}
}

usedSize := uint64(float64(total) * ((dataPerc + metaPerc) / 100))
usedSize := uint64(float64(total) * (dataPerc / 100))

return totalSize, usedSize, nil
}
Expand Down
Loading