git: kernel - Remove duplicate TRIM, only trim with the 'trim' mount opt

Matthew Dillon dillon at
Mon Oct 1 21:25:05 PDT 2018

commit 50a1f598541d76ff7f4a575a7efdd3a6dc7fc169
Author: Matthew Dillon <dillon at>
Date:   Mon Oct 1 21:12:28 2018 -0700

    kernel - Remove duplicate TRIM, only trim with the 'trim' mount opt
    * ffs_blkfree_cg() was improperly issuing a synchronous
      VOP_FREEBLKS() on the underlying device.  This issues a
      BUF_CMD_FREEBLKS stategy op to the underlying device,
      which is executed unconditionally.  This basically runs
      an unconditional TRIM whether the 'trim' mount flag is
      specified or not.
      Remove the VOP_FREEBLKS() call.
    * For softupdates operation, ffs_blkfree() handles the
      'trim' mount flag by issuing a BUF_CMD_FREEBLKS and
      sequencing the call to ffs_blkfree_cg() when it completes.
      When 'trim' was enabled, *two* TRIM operations were being
      executed on the underlying device, and prior to our fix,
      if 'trim' was not enabled, *one* TRIM operation would
      still be executed instead of zero.
    * In many situations... possibly even most situations,
      trim operations seriously reduce performance due to
      being serialized by AHCI or by the target device.  It
      is not as useful as people often think it should be
      on normal filesystems.
    * The removal of the unconditional TRIM significantly improves
      UFS performance, meaning primarily installkernel's
      since DragonFly doesn't use UFS for its main filesystem by
      default any more.
    * The 'trim' mount option for UFS will still work as advertised
      when coupled with softupdates.

Summary of changes:
 sys/bus/pci/pcivar.h    | 5 -----
 sys/vfs/ufs/ffs_alloc.c | 8 +++++++-
 2 files changed, 7 insertions(+), 6 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list