From: Keith Busch <kbusch@kernel.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Keith Busch <kbusch@meta.com>,
dm-devel@lists.linux.dev, linux-block@vger.kernel.org,
snitzer@kernel.org
Subject: Re: [RESEND PATCHv3 1/2] dm-crypt: allow unaligned bio_vecs for direct io
Date: Wed, 18 Mar 2026 11:40:17 -0600 [thread overview]
Message-ID: <abrjgdttXBHCFh34@kbusch-mbp> (raw)
In-Reply-To: <7cc4892a-5a2f-09b7-1f32-320acac4c797@redhat.com>
On Wed, Mar 18, 2026 at 05:19:39PM +0100, Mikulas Patocka wrote:
> On Mon, 16 Mar 2026, Keith Busch wrote:
> > + if (!unaligned_allowed) {
> > + cc->io_alignment = cc->sector_size - 1;
> > + } else {
> > + set_bit(CRYPT_DISCONTIGUOUS_SEGS, &cc->cipher_flags);
> > + cc->io_alignment = 3;
> > + }
> > return 0;
> > }
>
> Why is "3" there? Should there be the dma_alignment of the underlying
> block device instead?
It doesn't matter what the underlying block device reports because
dm-crypt bounces the incoming plain text buffers to something aligned to
the backing device for the cypher text.
Why 3? This can theoretically do 0, but you can't express that as a
block limit; block layer will assume you didn't set anything and use a
511 default, which is exactly what I don't want. So why not 1 instead of
3? Three is the smallest non-zero cra_alignmask currently reported, and
its inefficient to do byte aligned direct io anyway.
> > --- a/drivers/md/dm-table.c
> > +++ b/drivers/md/dm-table.c
> > @@ -1767,6 +1767,7 @@ int dm_calculate_queue_limits(struct dm_table *t,
> > bool zoned = false;
> >
> > dm_set_stacking_limits(limits);
> > + limits->dma_alignment = 0;
> >
> > t->integrity_supported = true;
> > for (unsigned int i = 0; i < t->num_targets; i++) {
>
> dm-integrity doesn't set dma_alignment if it is using 512-byte sector size
> (assuming that there is default 511). This should be fixed in dm-integrity
> before making this change.
>
> Other device mapper targets should also be reviewed to make sure that this
> change doens't break them.
The previous call to dm_set_stacking_limits() sets it to 511, which sets
an unnecessary minimum. Setting it to 0 here means that the stacked
device will inhereit whatever the mapper overrides it to, or go back to
511 if it decides not to override it.
next prev parent reply other threads:[~2026-03-18 17:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 15:02 [RESEND PATCHv3 1/2] dm-crypt: allow unaligned bio_vecs for direct io Keith Busch
2026-03-16 15:09 ` [RESEND PATCHv3 2/2] dm-crypt: dynamic scatterlist for many segments Keith Busch
2026-03-18 16:34 ` Mikulas Patocka
2026-03-18 17:01 ` Keith Busch
2026-03-18 17:40 ` Mikulas Patocka
2026-03-18 17:53 ` Keith Busch
2026-03-18 18:16 ` Mikulas Patocka
2026-03-18 18:32 ` Keith Busch
2026-03-18 18:41 ` Mikulas Patocka
2026-03-16 15:09 ` [RESEND PATCHv3 0/2] dm-crypt: support relaxed memory alignment Keith Busch
2026-03-18 16:19 ` [RESEND PATCHv3 1/2] dm-crypt: allow unaligned bio_vecs for direct io Mikulas Patocka
2026-03-18 17:40 ` Keith Busch [this message]
2026-03-18 18:06 ` Mikulas Patocka
2026-03-18 18:35 ` Keith Busch
2026-03-25 18:34 ` Keith Busch
-- strict thread matches above, loose matches on Subject: below --
2026-01-14 15:49 [RESEND PATCHv3 0/2] dm-crypt: support relaxed memory alignment Keith Busch
2026-01-14 15:49 ` [RESEND PATCHv3 1/2] dm-crypt: allow unaligned bio_vecs for direct io Keith Busch
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=abrjgdttXBHCFh34@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=kbusch@meta.com \
--cc=linux-block@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
/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