On Fri, 30 Apr 2021, Melvin Vermeeren wrote: > Hi again, > > On Wednesday, 28 April 2021 23:00:23 CEST Mikulas Patocka wrote: > > Here I'm sending version 2 of the patch - it increases version number of > > the target, so that userspace can test if this feature is present. > > > > From: Mikulas Patocka <mpatocka@xxxxxxxxxx> > > > > If we have discard support, we don't have to recalculate hash - we can > > just fill the metadata with the discard pattern. > > > > Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx> > > I had a look at this patch. If I understand correctly, this logic only applies > to dm-integrity recalculation, so for example from userspace with: > $ integritysetup --integrity-recalculate --allow-discards open <dev> <name> > > In such a case, it will fill all tag values with discard filler instead of > reading from the drive and computing the tags. If that is true I think this is > not desired behaviour, consider the following: > > * SSD with existing data /dev/sda1. > * Device for dm-integrity metadata /dev/vg/is_sda1_meta. > * $ integritysetup --data-device /dev/sda1 --no-wipe /dev/vg/is_sda1_meta > * $ integritysetup --data-device /dev/sda1 --integrity-recalculate \ > --allow-discards open /dev/vg/is_sda1_meta is_sda1 > > In current production version, this causes a full read of the SSD to > recalculate integrity tags, which is as expected and works very nicely. With > this patch, wouldn't it result in all integrity tags being set to the discard > filler? Does this patch assume a device is fully discarded when recalculating? It doesn't matter if the device is discarded or not. If the metadata constains the discard filler, dm-integrity won't check the checksum - so the data can contain anything. > Perhaps I am reading it wrong, I am not familiar with the dm kernel modules. > > > Also, a bit unrelated to any of the above. When doing a format operation > (without --no-wipe) on a device supporting discard, would it not be possible > to format via discards instead of the current data write operations? That > would significantly improve speed for SSDs and also reduce wear on the drive. You don't have to discard the device when initializing it. The device after discard may contain random pattern (some SSDs really do) - so when the metadata contains the discard filler, the data may contain anything. > Thanks, Mikulas -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel