5.5. Speeding up discard operations
VDO sets a maximum allowed size of DISCARD (TRIM) blocks for all LVM-VDO devices on the system. The default value is 1, which corresponds to 8 sectors or 4KB maximum. Increasing the DISCARD size can significantly improve the speed of the discard operations. However, there is a tradeoff between improving discard performance and maintaining the speed of other write operations.
The optimal size of the DISCARD sector depends on the storage stack. Both very large and very small DISCARD blocks can potentially degrade the performance. To determine the correct size of the sector, you might need to experiment with different values. Conduct experiments with different values to discover one that delivers satisfactory results.
For example, for an LVM-VDO volume that stores a local file system, it is optimal to use the default value. For an LVM-VDO volume that serves as a SCSI target, a moderately large DISCARD size, works best, for example 256 blocks which corresponds to a 1 MB discard. It is recommended that the maximum DISCARD size does not exceed 2560 blocks, which translates to 5 MB discard. When choosing the size, make sure it is a multiple of 8, because VDO might not handle discards effectively if they do not align with an 8 sector boundary.
Procedure
Deactivate the LVM-VDO volume:
# lvchange -an <vg_name>/<vdo_volume>Set the new maximum size for the DISCARD sector:
# lvchange --vdosettings "vdo_max_discard=<value>"Activate the LVM-VDO volume:
# lvchange -ay <vg_name>/<vdo_volume>
Verification
Verify that the discard value has been changed successfully:
# lvs -o vdo_max_discard <vg_name>/<vdo_volume>