[dm-devel] [PATCH v2] dm-integrity: if we have discard support, use it when recalculating

Melvin Vermeeren vermeeren at vermwa.re
Fri Apr 30 19:39:46 UTC 2021


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 at redhat.com>
> 
> 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 at redhat.com>

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?
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.

Thanks,

-- 
Melvin Vermeeren
Systems engineer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20210430/3f52dcda/attachment.sig>


More information about the dm-devel mailing list