Skip to content

LXD overreports LVM thin-pool storage usage in /1.0/storage-pools/<pool>/resources and lxc storage info #18150

@Maharacha

Description

@Maharacha

Please confirm

  • I have searched existing issues to check if an issue already exists for the bug I encountered.

Distribution

Ubuntu server

Distribution version

22.04.5

Output of snap list --all lxd core20 core22 core24 snapd

Name    Version         Rev    Tracking       Publisher   Notes
core20  20260105        2717   latest/stable  canonical✓  base,disabled
core20  20260211        2769   latest/stable  canonical✓  base
core22  20260128        2339   latest/stable  canonical✓  base,disabled
core22  20260225        2411   latest/stable  canonical✓  base
core24  20260317        1587   latest/stable  canonical✓  base
lxd     5.21.4-8a3cf61  36579  5.21/stable    canonical✓  disabled,held
lxd     5.21.4-9eb1368  36971  5.21/stable    canonical✓  held
snapd   2.73            25935  latest/stable  canonical✓  snapd,disabled
snapd   2.74.1          26382  latest/stable  canonical✓  snapd

System info

kernel_version: 6.8.0-90-generic
lxc version: 5.21.4 LTS
lxd version: 5.21.4 LTS
storage backend: lvm

Instance log

n/a

Expected behavior

lxc storage info <pool> show correct space used.
/1.0/storage-pools/<pool>/resources endpoint show correct space used.

Actual behavior

In thinPoolVolumeUsage() LXD reads lv_size,data_percent,metadata_percent and computes:

usedSize = totalSize * ((dataPerc + metaPerc) / 100)

This is incorrect because metadata_percent is relative to the thin-pool metadata LV, not to the thin-pool data LV / total pool size. Adding the percentages and applying them to totalSize overcounts usage, often by a very large amount.

Example:

  • thin pool size: 7681263796224 bytes
  • data_percent: 41.09
  • metadata_percent: 28.30
  • LXD reports used: 5330028948199 bytes (4.85 TiB)

But actual data allocation is about 3156231293868 bytes (2.87 TiB), and metadata usage is only ~33 MiB because the metadata LV itself is 112 MiB.

This affects:

  • GET /1.0/storage-pools//resources
  • lxc storage info <pool>

Steps to reproduce

Run lxc storage info <pool>.
Compare what is actually used.
Compare with lvs <VG>.

Information to attach

  • Any relevant kernel output (dmesg)
  • Instance configuration (lxc config show <instance> --expanded)
  • Main daemon log (at /var/log/lxd/lxd.log or /var/snap/lxd/common/lxd/logs/lxd.log)
  • If a lxc command fails, output of the command with --debug
  • Output of the daemon with --debug (or use lxc monitor while reproducing the issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions