From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: [PATCH] null_blk: Always split BIOs to respect queue limits
Date: Fri, 26 Jan 2024 09:50:32 +0900 [thread overview]
Message-ID: <20240126005032.1985245-1-dlemoal@kernel.org> (raw)
The function null_submit_bio() used for null_blk devices configured
with a BIO-based queue never splits BIOs according to the queue limits
set with the various module and configfs parameters that the user can
specify.
Add a call to bio_split_to_limits() to correctly handle large
BIOs that need splitting. Doing so also fixes issues with zoned devices
as a large BIO may cross over a zone boundary, which breaks null_blk
zone emulation.
While at it, remove all the local variable that are not necessary.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/block/null_blk/main.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 36755f263e8e..514c2592046a 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1528,12 +1528,16 @@ static struct nullb_queue *nullb_to_queue(struct nullb *nullb)
static void null_submit_bio(struct bio *bio)
{
- sector_t sector = bio->bi_iter.bi_sector;
- sector_t nr_sectors = bio_sectors(bio);
- struct nullb *nullb = bio->bi_bdev->bd_disk->private_data;
- struct nullb_queue *nq = nullb_to_queue(nullb);
+ struct nullb_queue *nq =
+ nullb_to_queue(bio->bi_bdev->bd_disk->private_data);
+
+ /* Respect the queue limits */
+ bio = bio_split_to_limits(bio);
+ if (!bio)
+ return;
- null_handle_cmd(alloc_cmd(nq, bio), sector, nr_sectors, bio_op(bio));
+ null_handle_cmd(alloc_cmd(nq, bio), bio->bi_iter.bi_sector,
+ bio_sectors(bio), bio_op(bio));
}
#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION
--
2.43.0
next reply other threads:[~2024-01-26 0:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 0:50 Damien Le Moal [this message]
2024-01-26 7:05 ` [PATCH] null_blk: Always split BIOs to respect queue limits Hannes Reinecke
2024-01-26 7:09 ` Damien Le Moal
2024-01-26 8:37 ` Chaitanya Kulkarni
2024-01-26 14:27 ` 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=20240126005032.1985245-1-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.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