From: Milan Broz <gmazyland@gmail.com>
To: Mikulas Patocka <mpatocka@redhat.com>,
Mike Snitzer <msnitzer@redhat.com>, Ming Lei <minlei@redhat.com>
Cc: dm-devel@redhat.com
Subject: Re: [PATCH] dm: don't overallocate the tags space
Date: Fri, 8 Feb 2019 19:06:45 +0100 [thread overview]
Message-ID: <96b4fcfb-f4fd-60fd-70e3-c9d981205ff2@gmail.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1902081048510.1182@file01.intranet.prod.int.rdu2.redhat.com>
On 08/02/2019 16:52, Mikulas Patocka wrote:
> bio_sectors returns the value in the units of 512-byte sectors (no matter
> what's the real sector size of the device). dm-crypt multiplies
> bio_sectors by on_disk_tag_size to calculate the space allocated for
> integrity tags. If dm-crypt is running with sector size larger than 512,
> it allocates more data than what's needed.
>
> Device mapper trimmed this extra space when passing the bio to
> dm-integrity, so this bug didn't result in any visible misbehavior. This
> bug showed up when device mapper stopped trimming the bio.
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Reported-by: Milan Broz <mbroz@redhat.com>
>
> ---
> drivers/md/dm-crypt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6/drivers/md/dm-crypt.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-crypt.c 2019-02-08 14:12:19.000000000 +0100
> +++ linux-2.6/drivers/md/dm-crypt.c 2019-02-08 14:12:19.000000000 +0100
> @@ -932,7 +932,7 @@ static int dm_crypt_integrity_io_alloc(s
> if (IS_ERR(bip))
> return PTR_ERR(bip);
>
> - tag_len = io->cc->on_disk_tag_size * bio_sectors(bio);
> + tag_len = io->cc->on_disk_tag_size * (bio_sectors(bio) >> io->cc->sector_shift);
>
> bip->bip_iter.bi_size = tag_len;
> bip->bip_iter.bi_sector = io->cc->start + io->sector;
>
Yes, this was the problem (perhaps introduced by me since the first commit implementing
authenticated encryption).
With patch above even the bio_trim() works properly.
Tested-and-Reviewed-by: Milan Broz <gmazyland@gmail.com>
Thanks!
Milan
prev parent reply other threads:[~2019-02-08 18:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 15:52 [PATCH] dm: don't overallocate the tags space Mikulas Patocka
2019-02-08 15:58 ` Bart Van Assche
2019-02-08 16:02 ` Mike Snitzer
2019-02-08 18:06 ` Milan Broz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=96b4fcfb-f4fd-60fd-70e3-c9d981205ff2@gmail.com \
--to=gmazyland@gmail.com \
--cc=dm-devel@redhat.com \
--cc=minlei@redhat.com \
--cc=mpatocka@redhat.com \
--cc=msnitzer@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox