FITRIM/discard: Difference between revisions

From xfs.org
J3gum (talk | contribs)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== Purpose ==
== Purpose ==


FITRIM is a mounted filesystem feature to discard (or "[http://en.wikipedia.org/wiki/TRIM trim]") blocks which are not in use by the filesystem. This is useful for solid-state drives (SSDs) and thinly-provisioned storage.
FITRIM is a mounted filesystem feature to discard (or "[https://en.wikipedia.org/wiki/TRIM trim]") blocks which are not in use by the filesystem. This is useful for solid-state drives (SSDs) and thinly-provisioned storage.


== Requirements ==
== Requirements ==
Line 32: Line 32:
=== Batch Mode ===
=== Batch Mode ===


This mode requires user intervention.  This intervention is in the form of the command <code>fstrim</code>.  It has been included in [http://en.wikipedia.org/wiki/Util-linux util-linux-ng] [http://www.bobsseo.com since] about Nov 26, 2010.
This mode requires user intervention.  This intervention is in the form of the command <code>fstrim</code>.  It has been included in [https://en.wikipedia.org/wiki/Util-linux util-linux-ng] since about Nov 26, 2010.


Usage example:
Usage example:
Line 41: Line 41:


== References ==
== References ==
# FITRIM description - Lukas Czerner <lczerner at redhat.com> http://patchwork.xfs.org/patch/1490/
# FITRIM description - Lukas Czerner <lczerner at redhat.com> 2010-12-10 15:53:27 Message ID <1291996407-26251-1-git-send-email-lczerner@redhat.com> http://patchwork.xfs.org/patch/1490/
# Block requirements - Dave Chinner <david at fromorbit.com> http://oss.sgi.com/pipermail/xfs/2011-October/053379.html
# Block requirements - Dave Chinner <david at fromorbit.com> 2011-10-10 21:05:52 http://oss.sgi.com/pipermail/xfs/2011-October/014867.html
# util-linux-ng addition - Karel Zak <kzak@xxxxxxxxxx> http://www.spinics.net/lists/util-linux-ng/msg03646.
# util-linux-ng addition - Karel Zak <kzak@xxxxxxxxxx> 2010-11-26 15:17:39 http://www.spinics.net/lists/util-linux-ng/msg03646.html
# Online TRIM/discard performance impact - http://oss.sgi.com/pipermail/xfs/2011-November/053841.html
# Online TRIM/discard performance impact - Christoph Hellwig <hch at infradead.org> 2011-11-07 04:21:21 http://oss.sgi.com/pipermail/xfs/2011-November/015329.html

Latest revision as of 16:25, 31 August 2012

Purpose[edit | edit source]

FITRIM is a mounted filesystem feature to discard (or "trim") blocks which are not in use by the filesystem. This is useful for solid-state drives (SSDs) and thinly-provisioned storage.

Requirements[edit | edit source]

  1. The block device underneath the filesystem must support the FITRIM operation.
  2. The kernel must include TRIM support and XFS must include FITRIM support (this has been true for Linux since v2.6.38, Jan 18 2011)
  3. Realtime discard mode requires a more recent v3.0 kernel

This can be verified by viewing /sys/block/<dev>/queue/discard_max_bytes -- If the value is zero then your device doesn't support discard operations.

Modes of Operation[edit | edit source]

  • Realtime discard -- As files are removed, the filesystem issues discard requests automatically
  • Batch Mode -- A user procedure that trims all or portions of the filesystem

Realtime discard[edit | edit source]

This mode issues discard requests automatically as files are removed from the filesystem. No other command or process is required.

There can be a severe performance penalty for enabling realtime discard. (4)

Realtime discard is selected by adding the filesystem option discard while mounting.

This can be done by the following examples:

  1. placing discard in your /etc/fstab for the filesystem: /dev/sda1 /mountpoint xfs defaults,discard 0 1
  2. mount options: mount -o discard /dev/sda1 /mountpoint

Batch Mode[edit | edit source]

This mode requires user intervention. This intervention is in the form of the command fstrim. It has been included in util-linux-ng since about Nov 26, 2010.

Usage example: fstrim /mountpoint



References[edit | edit source]

  1. FITRIM description - Lukas Czerner <lczerner at redhat.com> 2010-12-10 15:53:27 Message ID <1291996407-26251-1-git-send-email-lczerner@redhat.com> http://patchwork.xfs.org/patch/1490/
  2. Block requirements - Dave Chinner <david at fromorbit.com> 2011-10-10 21:05:52 http://oss.sgi.com/pipermail/xfs/2011-October/014867.html
  3. util-linux-ng addition - Karel Zak <kzak@xxxxxxxxxx> 2010-11-26 15:17:39 http://www.spinics.net/lists/util-linux-ng/msg03646.html
  4. Online TRIM/discard performance impact - Christoph Hellwig <hch at infradead.org> 2011-11-07 04:21:21 http://oss.sgi.com/pipermail/xfs/2011-November/015329.html