Bug 1860720 - RFE: kickstart option to control discard configuration
Summary: RFE: kickstart option to control discard configuration
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Fedora
Classification: Fedora
Component: anaconda
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Anaconda Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1851166
TreeView+ depends on / blocked
 
Reported: 2020-07-26 21:34 UTC by Chris Murphy
Modified: 2020-10-04 11:27 UTC (History)
12 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-08-20 04:30:11 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Chris Murphy 2020-07-26 21:34:07 UTC
Background:
So far upstream fs developers have been reluctant to make 'discard' mount option the default or autodetected. When discards happen to fast, many consumer SSDs become busy with garbage collection, either hanging on the operation or resulting in performance stalls. When discards don't happen at all, some consumer SSDs can get stuck doing on-demand erase block erasures, and become slow.

Btrfs offers a new implementation, discard=async. The goal is to provide discard hinting, but at a slower rate that doesn't cause conflicts with metadata and data writes.

Use case:
Discard mount option is likely only applicable to host computers with SSD drives.

Contra use case:
Virtual machine (guests) might not want this option set, because it will result in fallocated backing files becoming sparse files. Other setups, using LVM (thick or thin) might want this option set.

Enhancement request:
Provide a means to explicitly set or unset the proper option by kickstart command, probably per mount point, with persistent enablement happening in /etc/fstab (or systemd native unit file, as appropriate).

--discards=default - use file system default. This would be the Anaconda default if not explicitly used for a given mount point.

--discards=on - use mount option discard on xfs, ext4, use discard=async on btrfs

--discards=off - use mount option nodiscard on xfs, ext4, btrfs

Comment 1 Chris Murphy 2020-07-26 21:37:41 UTC
Arguably --discards=default doesn't need to exist, but I'm not sure of the style/semantics. If it's not needed, great.

Comment 2 Chris Murphy 2020-07-26 21:46:57 UTC
Another possibility is some kind of condition check that chooses on/off. This would mean the installer can just figure it out. e.g.

--discard=auto  If the condition check sees both SSD and not a virtual machine guest, then discard=on. Otherwise, discard=default (or possibly discard=off).

Comment 3 Brian Lane 2020-07-27 17:09:04 UTC
I think the '--fsoptions FSOPTS' argument for part should work fine for this: https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#part-or-partition 

I'd really like to try to avoid piling on more options unless they are absolutely needed.

Comment 4 Chris Murphy 2020-08-04 13:10:55 UTC
Understood. Is it possible in kickstart to test for some condition, so that the option is used only for those conditions? i.e. only if the file system is btrfs, not if it's in a VM, not if the target is rotational (or other test that discards are supported). I think those three are everything.

Comment 5 Brian Lane 2020-08-04 15:47:45 UTC
(In reply to Chris Murphy from comment #4)
> Understood. Is it possible in kickstart to test for some condition, so that
> the option is used only for those conditions? i.e. only if the file system
> is btrfs, not if it's in a VM, not if the target is rotational (or other
> test that discards are supported). I think those three are everything.

No, and that's not something that we'll be adding :) The way people usually handle that is via %pre scripts and %include but even then that's a bit of a hack.

Comment 6 Vladimír Slávik 2020-08-06 18:03:45 UTC
As written in comment 0, this would really span anaconda, pykickstart, and python-blivet.

Taking only a subset of the RFE, Brian says that from pykickstart point of view, there is already a way to provide the raw fstab options string. The kickstart would look something like this:
> part (...) --fsoptions "discard=async"

But with conditional enablement, the scope expands: The right place to decide if the option would be set is the blivet library which handles actual storage manipulation. And of course anaconda would have to glue that with the rest of the works.

Comment 7 Chris Murphy 2020-08-06 18:16:58 UTC
I wonder if it's possible, and more appropriate, to do this by udev rule injecting the mount option? It would be much less discoverable to the user, but I'm not convinced it's a significant negative *if* the condition checking is reliable, and the applied policy is correct.

We have similar problems elsewhere, e.g. "rotational" detection is not reliable. USB sticks report they're rotational, as do virtioblk (/dev/vda) devices.

Comment 8 Martin Kletzander 2020-08-07 07:11:54 UTC
I would argue for not making this behave differently based on whether the host is a VM or not.  Not only can it make some future reproducers difficult, but the hypervisor itself should be intelligent enough to only enable the discards to go through when it wants to (e.g. thin provisioning), but not for fully allocated disks.

Comment 9 Chris Murphy 2020-08-07 17:19:26 UTC
(In reply to Martin Kletzander from comment #8)
> the hypervisor itself should be intelligent enough to only
> enable the discards to go through when it wants to

It's a persuasive argument.

Also, for reference:
https://www.redhat.com/archives/libvir-list/2020-August/msg00341.html

Comment 10 Chris Murphy 2020-08-20 04:30:11 UTC
Consolidating btrfs issues for design and planning logics. This issue is now found here:

#6 enable discard=async by default 
https://pagure.io/fedora-btrfs/project/issue/6


Note You need to log in before you can comment on or make changes to this bug.