LVM reporting different usage percentage than container

We use lxd with lvm thinpools, and are generally happy with that. At least performance is way better than zfs. However an issue have occured. We had a container that was running full with log files, but after deleting them the lvs command still show 89% of usage. The container show 25%:

/dev/lxd/containers_phct--132 1009G  235G  733G  25% /
containers_phct--132  lxd Vwi-aotz-k    1.00t LXDThinPool   89.98 % 

I was wondering if this has something to do with TRIM/Discard, but i cannot run fstrim on the container due to permissions.

I thin ran fstrim on /proc/{pid of process running in container}/root/ but that did not resolve the issue either.

What is going on here?

Ok update from here. Tried to run fstrim from the mountspace where the volume is mounted. It worked.
Is this really the way to do it, or is there something that i am missing here?

LVM provides block volumes, which LXD then uses to add a filesystem on top and uses that as the rootfs mount point for the container.

When the filesystem allocates spaces from the block device the utilisation from LVM’s perspective increases. However when a file is removed from a filesystem it is unusual for a filesystem to return that back to the block device as unallocated (as there is a performance cost associated with that and the blocks are likely to only be allocated again when the filesystem uses more space in the future).

As such the normal scenario with LVM is that usage will increase with filesystem usage, but not decrease when files are removed. When new files are created the filesystem will reuse blocks it has already been allocated, so LVM utilisation won’t increase again until new blocks need to be allocated.

As you have found running fstrim instructs the filesystem to release blocks it is not currently using and so this space appears as unused space to LVM again.