dm-integrity: Documentation Improvements

Russell Harmon <[email protected]> Sun, 28 May 2023 21:32:31 -0700
Newsgroups dev.linux.lists.cryptsetup
Message-ID <CA+zrezRkXUtC3AVWBT_-tRH6TrtU2gUD_LSFRSh3t5iUkmerFQ@mail.gmail.com>
I've been trying to more deeply understand the behavior of
dm-integrity, and want to drop some of my learnings here in the hopes
it's useful for others in the future.

I've got a 4k drive, and wanted to see the data+integrity. So after
formatting I started writing a known pattern to the dm device using

    badblocks -b 4096 -o ~/badblocks.integrity_sdc -t 464367618 -w -v
-s -c 128 /dev/mapper/integrity_sdc

I then inspected the drive using `xxd /dev/sdc1`. The following comes
from several different tries with this combo, while varying the
different format options.

When you format the drive with `integritysetup format`, it's got
several options. In my case I used:

    integritysetup format /dev/sdc1 --sector-size 4096
--integrity-no-journal --journal-size=1 --interleave-sectors=8192
--no-wipe --verbose

Note there's a bug, you cannot set --journal-size=0, if you do it just
becomes the default size.

Based on this, my findings are:

* On a 4k drive, setting --sector-size 4096 fails to fully utilize the
sectors reserved for integrity. In order to fully utilize the sectors,
you've got to have 4M of data per integrity sector (assuming 4-byte
tags).
* --interleave-sectors is *always* denoted in 512-byte sectors,
regardless of what you set --sector-size to
* The output of `integritysetup dump /dev/sdc1` has a
`log2_interleave_sectors 13` field. The way to interpret that is as
2^13, or 8192 in my case, which matches the value I passed to
--interleave-sectors. Again, this is in *512 byte* sectors, regardless
of what `sector_size` says.

I intend to utilize these settings when configuring a RAID array.
Please make mention if it seems like this is a bad idea.