16.01.2021 18:19, Adam Borowski пишет: > On Sat, Jan 16, 2021 at 10:39:51AM +0300, Andrei Borzenkov wrote: >> 15.01.2021 06:54, Zygo Blaxell пишет: >>> On the other hand, I'm in favor of deprecating the whole discard option >>> and going with fstrim instead. discard in its current form tends to >>> increase write wear rather than decrease it, especially on metadata-heavy >>> workloads. discard is roughly equivalent to running fstrim thousands >>> of times a day, which is clearly bad for many (most? all?) SSDs. >> >> My (probably naive) understanding so far was that trim on SSD marks >> areas as "unused" which means SSD need to copy less residual data from >> erase block when reusing it. Assuming TRIM unit is (significantly) >> smaller than erase block. >> >> I would appreciate if you elaborate how trim results in more write on SSD? > > The areas are not only marked as unused, but also zeroed. To keep the > zeroing semantic, every discard must be persisted, thus requiring a write > to the SSD's metadata (not btrfs metadata) area. >
There is no requirement that TRIM did it. If device sets RZAT SUPPORTED bit, it should return zeroes for trimmed range, but there is no need to physically zero anything - simply return zeroes for areas marked as unallocated. Discard must be persisted in allocation table, but then every write must be persisted in allocation table anyway. Moreover, to actually zero on TRIM either trim request must be issued for the full erase block or device must perform garbage collection. Do you have any links that show that discards increase write load on physical media? I am really curious.