Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/zfs: Enable trim by default #69672

Merged
merged 1 commit into from Sep 28, 2019
Merged

nixos/zfs: Enable trim by default #69672

merged 1 commit into from Sep 28, 2019

Conversation

Baughn
Copy link
Contributor

@Baughn Baughn commented Sep 27, 2019

Motivation for this change

Trimming SSDs once per week should be safe in all cases, barring firmware or ZFS bugs. It's the default everywhere else.

Not trimming an SSD will wear it out much faster than necessary.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @

@Baughn Baughn changed the title zfs: Enable trim by default nixos/zfs: Enable trim by default Sep 27, 2019
@Baughn
Copy link
Contributor Author

Baughn commented Sep 27, 2019

@Mic92

@Mic92
Copy link
Member

Mic92 commented Sep 27, 2019

Assuming that more and more people will have SSDs/NVMEs this days this seems like a fair assumption. What do you think? @fpletz

@Mic92
Copy link
Member

Mic92 commented Sep 27, 2019

We also have services.fstrim.enable, which could be enabled by default.

@Baughn
Copy link
Contributor Author

Baughn commented Sep 28, 2019

I've been using ZFS trim since it was released, with the only data corruption being on 0.8.0 when combined with encryption. That one was resolved...

Enabling fstrim by default would mean relying on every other filesystem to work, however.

@fpletz
Copy link
Member

fpletz commented Sep 28, 2019

I feel a bit uneasy enabling this by default since it incurs a performance impact which is unnecessary for spinning disks. According to the related ZFS PR #8419, it will only do trim if the underlying block device supports discard though. If that works as intended 👍 from me. I wonder why ZoL disabled it by default then.

Regarding services.fstrim, how does this interact with ZFS since it has its own trimming feature? And how do other filesystems on spinning disks behave if you do a trim?

@Mic92
Copy link
Member

Mic92 commented Sep 28, 2019

services.fstrim is orthogonal to zfs, it's just for the same thing for other filesystems (I think ubuntu also has such a timer-activated service running). Also note that services.zfs.trim.enable is a systemd-timer-based weekly trim that is different from the autotrim property that is builtin into zfs.
From the zfs manpage:

Be aware that automatic trimming of recently freed data blocks can put significant stress on the underlying storage devices. This will vary depending of how well the specific device handles these commands. For lower end devices it is often possible to achieve most of the benefits of automatic trimming by running an on-demand (manual) TRIM periodically using the zpool trim command.

which is probably why zfsonlinux does not enable autotrim by default.

@Mic92 Mic92 merged commit 5a73cd4 into NixOS:master Sep 28, 2019
@fpletz
Copy link
Member

fpletz commented Sep 28, 2019

Okay, thanks! 👍

@Baughn
Copy link
Contributor Author

Baughn commented Sep 28, 2019

Not to let "lower end devices" fool anyone: The fastest devices on the market are NVMe, and all the ones I've found guidance for say to use periodic trim, not continuous.

@delroth
Copy link
Contributor

delroth commented Oct 6, 2019

I think this PR might have enabled zpool-trim on all systems regardless of whether they use ZFS. I just received a monitoring alert from all my NixOS machines saying that zpool-trim.service had failed execution :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants