We should consider discard=asyncby default on all baremetal installations; and coordinate with upstream about making it a default there too.
How to implement:
We can do this in kickstart using --fsoption discard=async which will enable it during installation and add it to /etc/fstab.
Overly verbose background and extras in this now closed RFE: kickstart option to control discard configuration
Should we use discard=async for NVMe SSD's as well? Or periodic TRIM is preferable for NVMe devices?
The discard mount option (both sync and async) will discard metadata blocks, and it happens fairly soon after blocks are freed. Those blocks might be needed by 'usebackuproot' if there's a crash or powerfailure. It's trivially reproducible (locally) to discover that those backuproots are all zeros if either discard mount option is enabled.
I'm inclined to say we should stick with just fstrim.timer as the primary way discards get issued. Once a week is surely often enough for the vast majority of workloads. And leave it up to case by case basis for enabling the discard mount option.
If it's possible to issue discards only to data blocks, that would be better.
Neither the discard section nor the usebackuproot section in man 5 btrfs mention this. I wonder if it is intentional. Perhaps it would be worth the effort to file a request for btrfs developers to either implement data-only discard option, or to make sure that backuproot metadata are not discarded immediately (but later, compared to all other blocks). It might even be a bug.
man 5 btrfs
Upstream definitely knows about it. I may have overstated the value of usebackuproot because it shouldn't ever be needed, it's really a work around for buggy firmware to try to get back to a (hopefully) known good root in case write ordering got messed up by the firmware.
While most drives do honor write ordering properly, and can use discard safely, I think the overwhelming majority of users are adequately and well served by the default weekly fstrim. And that the incremental improvement of discard applies to few cases in Fedora compared to the risk for those who have buggy drives and untimely crash/power fail. I am really on the fence, and not opposed to discard by default but I'm inclined to be more conservative and let upstream lead on when discard should become the default. And right now it isn't.
Perhaps this is best dealt with documentation of mount options that aren't enabled by default but are recommended for specific use cases?
Metadata Update from @ngompa:
- Issue set to the milestone: Future Release (was: Fedora 34)
to comment on this ticket.