[B/D/E] Prevent fstrim failure so unused blocks can be discarded

Connor Kuehl connor.kuehl at canonical.com
Tue Jan 14 19:04:44 UTC 2020


BugLink: https://bugs.launchpad.net/1856603

[Impact]

Discard requests can fail on a non-compliant nvme device meaning that
prescribed maintenance use of fstrim will be unsuccessful and unused blocks are
no longer properly disposed of.

[Test case]

Run fstrim (from bug report, ran as root: fstrim -v /)

Expected result: "/: 758.3 GiB (814159003648 bytes) trimmed" -- will vary
depending on the blocks that are unused for your system

Unpatched actual result: "fstrim: /: FITRIM ioctl failed: Input/output error"

[Regression Potential]

This patch only increases the size of a memory allocation and does not add any
changes in logic for error handling or normal flow of control. Furthermore, this
allocation size is what was used for discard until this commit reduced the size of
the allocation: 03b5929ebb20 ("nvme: rewrite discard support"). This routine
already handles the case where the memory allocation fails. Because of this, it
is a low risk change.



More information about the kernel-team mailing list