Discard involves iterating through all the clusters in a range and unmapping the reference in the L2 table. In the current implementation we write-through metadata updates which means we (a) write a lot; and (b) often rewrite the same L2 blocks many times. Together this means the discard is slow; slow enough to trigger timeouts in the Linux AHCI driver.
We should switch to write-back from write-through, with an appropriate hook for flush to synchronise with the writing thread before running flush.
Note this probably affects the current offline TRIM implementation as well as online TRIM
Discard involves iterating through all the clusters in a range and unmapping the reference in the L2 table. In the current implementation we write-through metadata updates which means we (a) write a lot; and (b) often rewrite the same L2 blocks many times. Together this means the
discardis slow; slow enough to trigger timeouts in the Linux AHCI driver.We should switch to write-back from write-through, with an appropriate hook for
flushto synchronise with the writing thread before running flush.Note this probably affects the current offline TRIM implementation as well as online TRIM