public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
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 2/2] dm-crypt: dynamic scatterlist for many segments
Date: Wed, 18 Mar 2026 12:32:53 -0600	[thread overview]
Message-ID: <abrv1Zk_L8yoovW4@kbusch-mbp> (raw)
In-Reply-To: <d8cc89c8-be4c-3d62-5855-2c6021d77b56@redhat.com>

On Wed, Mar 18, 2026 at 07:16:15PM +0100, Mikulas Patocka wrote:
> On Wed, 18 Mar 2026, Keith Busch wrote:
> > On Wed, Mar 18, 2026 at 06:40:52PM +0100, Mikulas Patocka wrote:
> > > On Wed, 18 Mar 2026, Keith Busch wrote:
> > > 
> > > > But even then, the only thing I know of that really wants this has an
> > > > offset that straddles two pages per block, so I never need more than 2
> > > > segments, and the inline scatterlist has four. There's just currently no
> > > > way for the block layer to report a max-segments-per-block limit, so I'm
> > > > including this patch to be consistent with the reportable limits.
> > > 
> > > Can userspace use preadv/pwritev with many small iovecs on a file opened 
> > > for direct I/O?
> > 
> > Yes, I have several patches that were accepted last year to block and
> > iomap that align direct-io memory requirements to the backing device's
> > dma constraints. You can do dword aligned and sized vectored IO to a
> > block device today if the block limits say its okay.
> 
> So, we must support worst-case scenario - "cc->sector_size / 4" segments. 
> 
> sector_size can be up to 4096, so there may be up to 1024 segments. Each 
> segment consumes sizeof(struct scatterlist) bytes - that's 32 bytes. So, 
> we allocate up to 32768 bytes.
> 
> kmalloc with size greater than 32768 is unreliable - so we are just on 
> this limit.

Direct-io hits the BIO_VEC_MAX limit (256) first, so 8k for the
scatterlist (not great, but less terrible). You can have some 4-byte
segments in the user request, but the average segement size would have
to be larger. The important part is that any segment can start at any
memory address dword alignment offset.

  reply	other threads:[~2026-03-18 18:32 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 [this message]
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
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 2/2] dm-crypt: dynamic scatterlist for many segments 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=abrv1Zk_L8yoovW4@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