On Fri, 9 Sep 2022 11:57:49 +0200 Mariusz Tkaczyk <mariusz.tkaczyk@xxxxxxxxxxxxxxx> wrote: > BTW. I'm not sure if discard ensures that data will be all zero. It causes that > drive drops all references but I doesn't mean that data is zeroed. Could you > please check it in documentation? Should we expect zeroes? Indeed, the references are dropped, but the actual data is still on disk. Physically wiping it would be time-consuming. Instead the "zeroing" is achieved via the fact that trying to read back areas for which the drive has no reference, makes the drive return all zeroes instead. The behavior varies per SSD model. Some do not return zeroes after a discard, but some binary garbage instead. In the ATA layer there is the sysfs file "discard_zeroes_data", which tells whether or not to expect zeroes after a discard. That flag does not appear to be always correct, e.g. I have some SSDs which do observably read back zeroes after a discard, but the flag still says "0". Rather than relying on that flag Logan opted for a manual check, reading back the actual disk data to check for zeroes, which I think could employ the optimization safely enough much more often, than simply going per the flag value would allow. -- With respect, Roman