On Thu, Aug 27, 2020 at 11:57:03AM -0400, Josef Bacik wrote: > > > > This sort of brings up a good point, the whole point of DISCARD support in > log-writes was to expose problems where we may have been discarding real > data we cared about, hence adding the forced zero'ing stuff for devices that > didn't support discard. But that made the incorrect assumption that a drive > with actual discard support would actually return 0's for discarded data. > That assumption was based on hardware that did actually do that, but now we > live in the brave new world of significantly shittier drives. Does dm-thinp > reliably unmap the ranges we discard, and thus give us this zero'ing > behavior? Because we might as well just use that for everything so > log-writes doesn't have to resort to pwrite()'ing zeros everywhere. Thanks, So the right fix is to replace issuing REQ_OP_DISCARD bios with REQ_OP_WRITE_ZEROES (plus the check for that). That'll give you the effective zeroing part if the device supports it, and you can still fall back to manual zeroing (and blk-lib.c actually has helpers for that as well).