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

  1. Deactivate the LVM-VDO volume:

    # lvchange -an <vg_name>/<vdo_volume>
  2. Set the new maximum size for the DISCARD sector:

    # lvchange --vdosettings "vdo_max_discard=<value>"
  3. 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>
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部