From: Bart Van Assche <bvanassche@acm.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Damien Le Moal <dlemoal@kernel.org>, Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Yu Kuai <yukuai1@huaweicloud.com>,
Ming Lei <ming.lei@redhat.com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH 1/2] block: Make __submit_bio_noacct() preserve the bio submission order
Date: Tue, 10 Jun 2025 10:23:26 -0700 [thread overview]
Message-ID: <83e74dd7-55bb-4e39-b7c6-e2fb952db90b@acm.org> (raw)
In-Reply-To: <20250609035515.GA26025@lst.de>
On 6/8/25 8:55 PM, Christoph Hellwig wrote:
> The problem here is that blk_crypto_fallback_split_bio_if_needed does
> sneaky splits behind the back of the main splitting code.
>
> The fix is to include the limit imposed by it in __bio_split_to_limits
> as well if the crypto fallback is used.
(+Eric)
Hmm ... my understanding is that when the inline encryption fallback
code is used that the bio must be split before
blk_crypto_fallback_encrypt_bio() encrypts the bio. Making
__bio_split_to_limits() take the inline encryption limit into account
would require to encrypt the data much later. How to perform encryption
later for bio-based drivers? Would moving the blk_crypto_bio_prep() call
from submit_bio() to just before __bio_split_to_limits() perhaps require
modifying all bio-based drivers that do not call
__bio_split_to_limits()?
> If you have time to fix this that would be great. Otherwise I can
> give it a spin, but it's public holiday and travel season here, so
> my availability is a bit limited.
This is not the solution that you are looking for but this seems to
work:
diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c
index 7c33e9573e5e..f4fefecdcc5e 100644
--- a/block/blk-crypto-fallback.c
+++ b/block/blk-crypto-fallback.c
@@ -213,6 +213,7 @@ blk_crypto_fallback_alloc_cipher_req(struct
blk_crypto_keyslot *slot,
static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr)
{
struct bio *bio = *bio_ptr;
+ const struct queue_limits *lim = bdev_limits(bio->bi_bdev);
unsigned int i = 0;
unsigned int num_sectors = 0;
struct bio_vec bv;
@@ -223,6 +224,7 @@ static bool
blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr)
if (++i == BIO_MAX_VECS)
break;
}
+ num_sectors = min(num_sectors, get_max_io_size(bio, lim));
if (num_sectors < bio_sectors(bio)) {
struct bio *split_bio;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index fb6253c07387..e308325a333c 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -192,8 +192,7 @@ static inline unsigned int
blk_boundary_sectors(const struct queue_limits *lim,
* requests that are submitted to a block device if the start of a bio
is not
* aligned to a physical block boundary.
*/
-static inline unsigned get_max_io_size(struct bio *bio,
- const struct queue_limits *lim)
+unsigned get_max_io_size(struct bio *bio, const struct queue_limits *lim)
{
unsigned pbs = lim->physical_block_size >> SECTOR_SHIFT;
unsigned lbs = lim->logical_block_size >> SECTOR_SHIFT;
diff --git a/block/blk.h b/block/blk.h
index 37ec459fe656..5f97db919cdf 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -425,6 +425,8 @@ static inline unsigned get_max_segment_size(const
struct queue_limits *lim,
(unsigned long)lim->max_segment_size - 1) + 1);
}
+unsigned get_max_io_size(struct bio *bio, const struct queue_limits *lim);
+
int ll_back_merge_fn(struct request *req, struct bio *bio,
unsigned int nr_segs);
bool blk_attempt_req_merge(struct request_queue *q, struct request *rq,
Thanks,
Bart.
next prev parent reply other threads:[~2025-06-10 17:23 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 20:29 [PATCH 0/2] Two bug fixes for zoned block devices Bart Van Assche
2025-05-14 20:29 ` [PATCH 1/2] block: Make __submit_bio_noacct() preserve the bio submission order Bart Van Assche
2025-05-15 7:19 ` Niklas Cassel
2025-05-15 15:58 ` Bart Van Assche
2025-05-16 4:47 ` Christoph Hellwig
2025-05-19 22:12 ` Bart Van Assche
2025-05-20 13:56 ` Christoph Hellwig
2025-05-20 18:09 ` Bart Van Assche
2025-05-21 5:53 ` Christoph Hellwig
2025-05-21 21:18 ` Bart Van Assche
2025-05-22 5:12 ` Damien Le Moal
2025-05-22 17:08 ` Bart Van Assche
2025-05-23 6:02 ` Damien Le Moal
2025-05-23 16:30 ` Bart Van Assche
2025-05-24 8:48 ` Damien Le Moal
2025-05-24 14:05 ` Bart Van Assche
2025-05-24 15:36 ` Damien Le Moal
2025-05-26 5:24 ` Christoph Hellwig
2025-05-27 16:19 ` Bart Van Assche
2025-05-31 0:25 ` Bart Van Assche
2025-06-08 22:07 ` Bart Van Assche
2025-06-08 22:47 ` Damien Le Moal
2025-06-09 3:58 ` Christoph Hellwig
2025-06-09 20:48 ` Bart Van Assche
2025-06-10 5:04 ` Christoph Hellwig
2025-06-09 3:55 ` Christoph Hellwig
2025-06-10 17:23 ` Bart Van Assche [this message]
2025-06-10 23:18 ` Keith Busch
2025-06-11 0:46 ` Damien Le Moal
2025-06-11 1:00 ` Keith Busch
2025-06-11 1:02 ` Damien Le Moal
2025-06-11 1:08 ` Keith Busch
2025-06-11 1:34 ` Keith Busch
2025-06-11 3:40 ` Christoph Hellwig
2025-06-11 4:21 ` Eric Biggers
2025-06-11 16:15 ` Bart Van Assche
2025-06-11 18:15 ` Eric Biggers
2025-06-11 19:43 ` Bart Van Assche
2025-06-18 22:27 ` Bart Van Assche
2025-05-23 4:21 ` Christoph Hellwig
2025-05-14 20:29 ` [PATCH 2/2] block: Fix a deadlock related freezing zoned storage devices Bart Van Assche
2025-05-16 4:51 ` Christoph Hellwig
2025-05-19 22:22 ` Bart Van Assche
2025-05-20 13:57 ` Christoph Hellwig
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=83e74dd7-55bb-4e39-b7c6-e2fb952db90b@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=ebiggers@google.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=shinichiro.kawasaki@wdc.com \
--cc=yukuai1@huaweicloud.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