3.11. Managing thin-provisioned LVM-VDO volumes
It is possible to configure a thin-provisioned LVM-VDO volume to prepare for future expansion of the physical space, to address a condition where the physical space usage of the LVM-VDO volume is approaching 100%. Instead of using -l 100%FREE in the lvcreate operation, for example, use 95%FREE to ensure that there is some reserved space for recovery later on if needed. You can use the same method to resolve the following issues:
- The volume runs out of space.
- The file system enters read-only mode.
- ENOSPC reported by the volume.
The best way to address high physical space usage on an LVM-VDO volume is to delete unused files, and discard the blocks used by these unused files either by using online discard or the fstrim program. The physical space of an LVM-VDO volume can only be grown to 8192 slabs that is 16 TB for an LVM-VDO volume with the default slab size of 2 GB, or 256 TB for an LVM-VDO volume with the maximal slab size of 32 GB.
In all of the following steps, replace myvg and myvdo with the volume group and LVM-VDO name respectively.
Prerequisites
- Install the VDO software. For more information, see Installing VDO.
- An LVM volume group with free storage capacity exists on your system.
-
A thin-provisioned LVM-VDO volume using the
lvcreate --type vdo --name myvdo myvg -l <percentage_of_free_space_in_vg> --virtualsize <virtual_size_of_vdo>command. For more information, see Creating and mounting an LVM-VDO volume.
Procedure
Determine the optimal logical size for a thin-provisioned LVM-VDO volume:
# vdostats myvg-vpool0-vpoolDevice 1K-blocks Used Available Use% Space saving% myvg-vpool0-vpool 104856576 29664088 75192488 28% 69%To calculate the space savings ratio, use the following formula:
Savings ratio = 1 / (1 - Space saving%)In this example,
-
there is approximately a
3.22:1space savings ratio on a data set of about 80 GB. - Multiplying the data set size by the ratio would yield a potential logical size of 256 GB if more data with the same space savings were written to the LVM-VDO volume.
- Adjusting this number downward to 200 GB yields a logical size with a safe margin of free physical space, given the same space savings ratio.
-
there is approximately a
Monitor the free physical space in an LVM-VDO volume:
# vdostats myvg-vpool0-vpoolThis command can be executed periodically to provide monitoring of the used and free physical space of the LVM-VDO volume.
Optional: View the warnings on physical space usage on an LVM-VDO volume by using the available
/usr/share/doc/vdo/examples/monitor/monitor_check_vdostats_physicalSpace.plscript:# /usr/share/doc/vdo/examples/monitor/monitor_check_vdostats_physicalSpace.pl myvg-vpool0-vpoolWhen creating an LVM-VDO volume, the
dmeventdmonitoring service monitors the usage of physical space in an LVM-VDO volume. This is enabled by default when an LVM-VDO volume is created or started.Use the
journalctlcommand to view the output ofdmeventdin the logs while monitoring an LVM-VDO volume:lvm[8331]: Monitoring VDO pool myvg-vpool0-vpool. ... lvm[8331]: WARNING: VDO pool myvg-vpool0-vpool is now 84.63% full. lvm[8331]: WARNING: VDO pool myvg-vpool0-vpool is now 91.01% full. lvm[8331]: WARNING: VDO pool myvg-vpool0-vpool is now 97.34% full.Remediate LVM-VDO volumes that are almost out of available physical space. When it is possible to add a physical space to an LVM-VDO volume, but the volume space is full before it can be grown, it may be necessary to temporarily stop I/O to the volume.
To temporarily stop I/O to the volume, execute the following steps, where LVM-VDO volume
myvdocontains a file system mounted on the</users/homeDir>path:Freeze the file system:
# xfs_freeze -f </users/homeDir># vgextend myvg /dev/vdc2# lvextend -L <new_size> myvg/vpool0# xfs_freeze -u </users/homeDir>Unmount the file system:
# umount </users/homeDir># vgextend myvg /dev/vdc2# lvextend -L <new_size> myvg/vpool0# mount -o discard /dev/myvg/myvdo </users/homeDir>注意Unmounting or freezing a file system with cached data will incur a write of the cached data, which might fill the physical space of the LVM-VDO volume. Consider the maximum amount of cached file system data when setting a monitoring threshold for free physical space on an LVM-VDO volume.
Blocks that are no longer used by a file system can be cleaned up by using the
fstrimutility. Executingfstrimagainst a mounted file system on top of a VDO volume can result in increased free physical space for that volume. Thefstrimutility will send discards to the LVM-VDO volume, which are then used to remove references to the previously used blocks. If any of those blocks are single-referenced, the physical space will be available to use.Check VDO stats to see what the current amount of free space is:
# vdostats --human-readable myvg-vpool0-vpoolDevice Size Used Available Use% Space saving% myvg-vpool0-vpool 100.0G 95.0G 5.0G 95% 73%Discard unused blocks:
# fstrim </users/homeDir>View the free physical space of the LVM-VDO volume:
# vdostats --human-readable myvg-vpool0-vpoolDevice Size Used Available Use% Space saving% myvg-vpool0-vpool 100.0G 30.0G 70.0G 30% 43%In this example, after executing
fstrimon the file system, the discards were able to return 65 G of physical space to use in the LVM-VDO volume.注意Discarding volumes with lower levels of deduplication and compression will have a possibility of reclaiming physical space than discarding volumes with higher levels of deduplication and compression. A volume that has high levels of deduplication and compression can potentially require a more extensive cleanup to reclaim physical space than just simply discarding already unused blocks.