From Fedora Project Wiki
Line 19: Line 19:
<!-- The actual name of your proposed change page should look something like: Changes/Your_Change_Proposal_Name.  This keeps all change proposals in the same namespace -->
<!-- The actual name of your proposed change page should look something like: Changes/Your_Change_Proposal_Name.  This keeps all change proposals in the same namespace -->


= Change Proposal Name <!-- The name of your change proposal --> =
= Enable fstrim.timer by default <!-- The name of your change proposal --> =


== Summary ==
== Summary ==
<!-- A sentence or two summarizing what this change is and what it will do. This information is used for the overall changeset summary page for each release.  
<!-- A sentence or two summarizing what this change is and what it will do. This information is used for the overall changeset summary page for each release.  
Note that motivation for the change should be in the Motivation section below, and this part should answer the question "What?" rather than "Why?". -->
Note that motivation for the change should be in the Motivation section below, and this part should answer the question "What?" rather than "Why?". -->
Enabling fstrim.timer will cause fstrim.service to execute weekly, which in turn executes `/usr/sbin/fstrim --fstab --verbose --quiet`


== Owner ==
== Owner ==
Line 30: Line 32:
This should link to your home wiki page so we know who you are.  
This should link to your home wiki page so we know who you are.  
-->
-->
* Name: [[User:FASAcountName| Your Name]]
* Name: [[User:chrismurphy| Chris Murphy]]
<!-- Include you email address that you can be reached should people want to contact you about helping with your change, status is requested, or technical issues need to be resolved. If the change proposal is owned by a SIG, please also add a primary contact person. -->
<!-- Include you email address that you can be reached should people want to contact you about helping with your change, status is requested, or technical issues need to be resolved. If the change proposal is owned by a SIG, please also add a primary contact person. -->
* Email: <your email address so we can contact you, invite you to meetings, etc. Please provide your Bugzilla email address if it is different from your email in FAS>
* Email: bugzilla@colorremedies.com
<!--- UNCOMMENT only for Changes with assigned Shepherd (by FESCo)
<!--- UNCOMMENT only for Changes with assigned Shepherd (by FESCo)
* FESCo shepherd: [[User:FASAccountName| Shehperd name]] <email address>
* FESCo shepherd: [[User:FASAccountName| Shehperd name]] <email address>
Line 42: Line 44:


== Current status ==
== Current status ==
* Targeted release: [[Releases/<number> | Fedora <number> ]]  
* Targeted release: [[Releases/32 | Fedora 32 ]]  
* Last updated: <!-- this is an automatic macro — you don't need to change this line -->  {{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY2}}  
* Last updated: <!-- this is an automatic macro — you don't need to change this line -->  {{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY2}}  
<!-- After the change proposal is accepted by FESCo, tracking bug is created in Bugzilla and linked to this page  
<!-- After the change proposal is accepted by FESCo, tracking bug is created in Bugzilla and linked to this page  
Line 56: Line 58:
== Detailed Description ==
== Detailed Description ==


<!-- Expand on the summary, if appropriate.  A couple sentences suffices to explain the goal, but the more details you can provide the better. -->
Some users experience slow downs in certain flash storage devices, which can be alleviated by issuing a periodic fstrim command to the mounted file system. Devices and file systems that don't support fstrim are unaffected.
 
fstrim acts only on mounted filesystems listed in fstab. On supported hardware (SD Card, SSD, NVMe), thin provisioned virtual storage, and file systems (ext4, XFS, Btrfs, f2fs, but excluding FAT16/32), the underlying physical storage device's firmware is informed about unused blocks. This hinting can make wear leveling and block erasure more efficient.
 
Some devices do not support "queued trim" and there may be a brief (seconds) pause as the drive firmware acts upon command issuance. It's expected most users won't notice this. The timer will execute Monday at 00:00 local time. If the system is inactive at this time, it will be run immediately upon becoming active again (upon wake from suspend, during or very soon after boot).


== Benefit to Fedora ==
== Benefit to Fedora ==


<!-- What is the benefit to the distribution?  Will the software we generate be improved? How will the process of creating Fedora releases be improved?
This is an optimization to the storage stack, and may help improve performance and wear leveling for some devices.  
 
      Be sure to include the following areas if relevant:
      If this is a major capability update, what has changed?
          For example: This change introduces Python 5 that runs without the Global Interpreter Lock and is fully multithreaded.
      If this is a new functionality, what capabilities does it bring?
          For example: This change allows package upgrades to be performed automatically and rolled-back at will.
      Does this improve some specific package or set of packages?
          For example: This change modifies a package to use a different language stack that reduces install size by removing dependencies.
      Does this improve specific Spins or Editions?
          For example: This change modifies the default install of Fedora Workstation to be more in line with the base install of Fedora Server.
      Does this make the distribution more efficient?
          For example: This change replaces thousands of individual %post scriptlets in packages with one script that runs at the end.
      Is this an improvement to maintainer processes?
          For example: Gating Fedora packages on automatic QA tests will make rawhide more stable and allow changes to be implemented more smoothly.
      Is this an improvement targeted as specific contributors?
          For example: Ensuring that a minimal set of tools required for contribution to Fedora are installed by default eases the onboarding of new contributors.  


    When a Change has multiple benefits, it's better to list them all.
In a way this is overdue on Fedora, as it's been the default behavior on other distributions for a while (at least Ubuntu and openSUSE). At least it has been a well tested optimization.


    Consider these Change pages from previous editions as inspiration:
    https://fedoraproject.org/wiki/Changes/Annobin (low-level and technical, invisible to users)
    https://fedoraproject.org/wiki/Changes/ParallelInstallableDebuginfo (low-level, but visible to advanced users)
    https://fedoraproject.org/wiki/Changes/VirtualBox_Guest_Integration (primarily a UX change)
    https://fedoraproject.org/wiki/Changes/NoMoreAlpha (an improvement to distro processes)
    https://fedoraproject.org/wiki/Changes/perl5.26 (major upgrade to a popular software stack, visible to users of that stack)
-->


== Scope ==
== Scope ==

Revision as of 00:16, 19 December 2019


Enable fstrim.timer by default

Summary

Enabling fstrim.timer will cause fstrim.service to execute weekly, which in turn executes /usr/sbin/fstrim --fstab --verbose --quiet


Owner

Current status

  • Targeted release: Fedora 32
  • Last updated: 2019-12-19
  • Tracker bug: <will be assigned by the Wrangler>
  • Release notes tracker: <will be assigned by the Wrangler>

Detailed Description

Some users experience slow downs in certain flash storage devices, which can be alleviated by issuing a periodic fstrim command to the mounted file system. Devices and file systems that don't support fstrim are unaffected.

fstrim acts only on mounted filesystems listed in fstab. On supported hardware (SD Card, SSD, NVMe), thin provisioned virtual storage, and file systems (ext4, XFS, Btrfs, f2fs, but excluding FAT16/32), the underlying physical storage device's firmware is informed about unused blocks. This hinting can make wear leveling and block erasure more efficient.

Some devices do not support "queued trim" and there may be a brief (seconds) pause as the drive firmware acts upon command issuance. It's expected most users won't notice this. The timer will execute Monday at 00:00 local time. If the system is inactive at this time, it will be run immediately upon becoming active again (upon wake from suspend, during or very soon after boot).

Benefit to Fedora

This is an optimization to the storage stack, and may help improve performance and wear leveling for some devices.

In a way this is overdue on Fedora, as it's been the default behavior on other distributions for a while (at least Ubuntu and openSUSE). At least it has been a well tested optimization.


Scope

  • Proposal owners:

Upon approval, submit a PR for fedora-release, modifying 90-default.preset to enable fstrim.timer

  • Other developers:

strim.timer is provided by util-linux, notify util-linux maintainer

https://bugzilla.redhat.com/show_bug.cgi?id=1785041


  • Release engineering: #9116
  • Policies and guidelines: N/A
  • Trademark approval: N/A

Upgrade/compatibility impact

fstrim.timer will be enabled on upgrade. An upgraded system should exhibit the same behaviors as a clean installed system.

How To Test

The low level function of the fstrim command and fstrim.service is well understood and tested already, all Fedora needs to test is that the timer is enabled following clean installation and upgrades: Preliminaries:

  • Clean install Fedora 32, any edition or spin; or
  • Upgrade from Fedora 30 or Fedora 31, any edition or spin, to Fedora 32

Confirm:

  • sudo systemctl list-timers
  • Confirm fstrim.timer is listed under UNITS, and is next scheduled for Monday 00:00:00
  • Anytime following the NEXT time, sudo systemctl status fstrim.timer

Example, should apply in all cases: Dec 18 13:48:54 fmac.local systemd[1]: fstrim.service: Succeeded.

Full example on a device with an SSD and filesystem supporting trim: ` $ sudo systemctl status fstrim.service ● fstrim.service - Discard unused blocks on filesystems from /etc/fstab

  Loaded: loaded (/usr/lib/systemd/system/fstrim.service; static; vendor preset: disabled)
  Active: inactive (dead) since Wed 2019-12-18 13:48:54 MST; 15min ago
    Docs: man:fstrim(8)
 Process: 3870 ExecStart=/usr/sbin/fstrim --fstab --verbose --quiet (code=exited, status=0/SUCCESS)
Main PID: 3870 (code=exited, status=0/SUCCESS)
     CPU: 1.387s

Dec 18 13:48:48 fmac.local systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab... Dec 18 13:48:54 fmac.local fstrim[3870]: /: 32 GiB (34409328640 bytes) trimmed on /dev/sda4 Dec 18 13:48:54 fmac.local systemd[1]: fstrim.service: Succeeded. Dec 18 13:48:54 fmac.local systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab. Dec 18 13:48:54 fmac.local systemd[1]: fstrim.service: Consumed 1.387s CPU time. ` Regardless of configuration, there should be no errors.

User Experience

Most users will not notice the change. Some will notice improved performance of flash storage devices, and more efficient use of thinly provisioned storage.

This does NOT affect all storage. Only file systems listed in fstab will be affected.

If the user/admin wants fstrim to apply to all storage, they should copy the original fstrim.service unit file, replacing --fstab with --all which will then run fstrim weekly on all mounted file systems. And use this modified unit file as a drop in service unit. See https://www.freedesktop.org/software/systemd/man/systemd.unit.html

Contingency Plan

  • Contingency mechanism: Owner will revert the change
  • Contingency deadline: final freeze
  • Blocks release? No
  • Blocks product? No

Documentation

man fstrim


Release Notes