Skip to content

Commit 2101720

Browse files
authored
Merge pull request #1417 from presztak/lvm_pool_space_usage
Remove metadata info from space usage calculation
2 parents 21eee07 + a069761 commit 2101720

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

internal/server/storage/drivers/driver_lvm_utils.go

+3-13
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ func (d *lvm) thinPoolVolumeUsage(volDevPath string) (uint64, uint64, error) {
732732
"--units", "b",
733733
"--nosuffix",
734734
"--separator", ",",
735-
"-o", "lv_size,data_percent,metadata_percent",
735+
"-o", "lv_size,data_percent",
736736
}
737737

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

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

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

765-
metaPerc := float64(0)
766-
767-
// For thin volumes there is no meta data percentage. This is only for the thin pool volume itself.
768-
if parts[2] != "" {
769-
metaPerc, err = strconv.ParseFloat(parts[2], 64)
770-
if err != nil {
771-
return 0, 0, fmt.Errorf("Failed parsing thin pool meta used percentage (%q): %w", parts[2], err)
772-
}
773-
}
774-
775-
usedSize := uint64(float64(total) * ((dataPerc + metaPerc) / 100))
765+
usedSize := uint64(float64(total) * (dataPerc / 100))
776766

777767
return totalSize, usedSize, nil
778768
}

0 commit comments

Comments
 (0)