From: Damien Le Moal <dlemoal@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
Hans Holmberg <Hans.Holmberg@wdc.com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/4] block: rework bio splitting
Date: Tue, 27 Aug 2024 07:37:37 +0900 [thread overview]
Message-ID: <9a25857d-21ca-46c8-82bb-bb642d9328bf@kernel.org> (raw)
In-Reply-To: <e59de073-c608-4206-8f98-9f46b1750931@kernel.org>
On 8/27/24 07:26, Damien Le Moal wrote:
> On 8/27/24 02:37, Christoph Hellwig wrote:
>> The current setup with bio_may_exceed_limit and __bio_split_to_limits
>> is a bit of a mess.
>>
>> Change it so that __bio_split_to_limits does all the work and is just
>> a variant of bio_split_to_limits that returns nr_segs. This is done
>> by inlining it and instead have the various bio_split_* helpers directly
>> submit the potentially split bios.
>>
>> To support btrfs, the rw version has a lower level helper split out
>> that just returns the offset to split. This turns out to nicely clean
>> up the btrfs flow as well.
>>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> ---
>> block/blk-merge.c | 146 +++++++++++++++++---------------------------
>> block/blk-mq.c | 11 ++--
>> block/blk.h | 63 +++++++++++++------
>> fs/btrfs/bio.c | 30 +++++----
>> include/linux/bio.h | 4 +-
>> 5 files changed, 125 insertions(+), 129 deletions(-)
>>
>> diff --git a/block/blk-merge.c b/block/blk-merge.c
>> index de5281bcadc538..c7222c4685e060 100644
>> --- a/block/blk-merge.c
>> +++ b/block/blk-merge.c
>> @@ -105,9 +105,33 @@ static unsigned int bio_allowed_max_sectors(const struct queue_limits *lim)
>> return round_down(UINT_MAX, lim->logical_block_size) >> SECTOR_SHIFT;
>> }
>>
>> -static struct bio *bio_split_discard(struct bio *bio,
>> - const struct queue_limits *lim,
>> - unsigned *nsegs, struct bio_set *bs)
>> +static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
>
> Why not "unsigned int" for split_sectors ? That would avoid the need for the
> first "if" of the function. Note that bio_split() also takes an int for the
> sector count and also checks for < 0 count with a BUG_ON(). We can clean that up
> too. BIOs sector count is unsigned int...
>
>> +{
>> + if (unlikely(split_sectors < 0)) {
>> + bio->bi_status = errno_to_blk_status(split_sectors);
>> + bio_endio(bio);
>> + return NULL;
>> + }
>> +
>> + if (split_sectors) {
>
> May be the simple case should come first ? E.g.:
>
> if (!split_sectors)
> return bio;
>
> But shouldn't this check be:
>
> if (split_sectors >= bio_sectors(bio))
> return bio;
Please ignore this one. The passed sector count is a limit, which can be 0, so
checking "if (!split_sectors)" is correct.
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2024-08-26 22:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 17:37 fix unintentional splitting of zone append bios Christoph Hellwig
2024-08-26 17:37 ` [PATCH 1/4] block: rework bio splitting Christoph Hellwig
2024-08-26 20:29 ` David Sterba
2024-08-26 22:26 ` Damien Le Moal
2024-08-26 22:37 ` Damien Le Moal [this message]
2024-08-27 3:20 ` Christoph Hellwig
2024-08-27 4:08 ` Damien Le Moal
2024-08-26 17:37 ` [PATCH 2/4] block: constify the lim argument to queue_limits_max_zone_append_sectors Christoph Hellwig
2024-08-26 22:27 ` Damien Le Moal
2024-08-26 17:37 ` [PATCH 3/4] block: properly handle REQ_OP_ZONE_APPEND in __bio_split_to_limits Christoph Hellwig
2024-08-26 22:32 ` Damien Le Moal
2024-08-26 17:37 ` [PATCH 4/4] block: don't use bio_split_rw on misc operations Christoph Hellwig
2024-08-26 22:34 ` Damien Le Moal
2024-08-27 11:23 ` fix unintentional splitting of zone append bios Hans Holmberg
2024-08-27 11:43 ` Niklas Cassel
2024-08-27 12:18 ` Christoph Hellwig
2024-08-29 10:33 ` Jens Axboe
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=9a25857d-21ca-46c8-82bb-bb642d9328bf@kernel.org \
--to=dlemoal@kernel.org \
--cc=Hans.Holmberg@wdc.com \
--cc=axboe@kernel.dk \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.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