From: John Garry <john.g.garry@oracle.com>
To: Yu Kuai <yukuai1@huaweicloud.com>, Christoph Hellwig <hch@lst.de>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, "yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH 2/2] block: remove the bi_inline_vecs variable sized array from struct bio
Date: Tue, 9 Sep 2025 09:55:22 +0100 [thread overview]
Message-ID: <8e5b16eb-a5f9-4fdb-8422-34be7c24b93b@oracle.com> (raw)
In-Reply-To: <8257e4d7-cf2e-6913-06fd-f11c2f94f38a@huaweicloud.com>
On 09/09/2025 09:40, Yu Kuai wrote:
>
> 在 2025/09/09 16:16, John Garry 写道:
>>> diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
>>> index 4fc80c6d5b31..73918e55bf04 100644
>>> --- a/drivers/md/bcache/movinggc.c
>>> +++ b/drivers/md/bcache/movinggc.c
>>> @@ -145,9 +145,9 @@ static void read_moving(struct cache_set *c)
>>> continue;
>>> }
>>> - io = kzalloc(struct_size(io, bio.bio.bi_inline_vecs,
>>> - DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)),
>>> - GFP_KERNEL);
>>> + io = kzalloc(sizeof(*io) + sizeof(struct bio_vec) *
>>> + DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS),
>>> + GFP_KERNEL);
>>
>> this seems a common pattern, so maybe another helper (which could be
>> used by bio_kmalloc)? I am not advocating it, but just putting the
>> idea out there... too many helpers makes it messy IMHO
>
> Not sure how to do this, do you mean a marco to pass in the base
> structure type, nr_vecs and the gfp_mask?
something like the following (which I think is messy and an imprecise
API, so again I am not advocating it):
struct bio *bio_kmalloc(unsigned short nr_vecs, gfp_t gfp_mask)
{
return kmalloc(sizeof(struct bio) + nr_vecs * sizeof(struct bio_vec),
gfp_mask);
}
struct bio *bio_kmalloc_inline(unsigned short nr_vecs, gfp_t gfp_mask)
{
if (nr_vecs > BIO_MAX_INLINE_VECS)
return NULL;
return bio_kmalloc(nr_vecs, gfp_mask);
}
next prev parent reply other threads:[~2025-09-09 8:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 10:56 remove the bi_inline_vecs field struct bio Christoph Hellwig
2025-09-08 10:56 ` [PATCH 1/2] block: add a bio_init_inline helper Christoph Hellwig
2025-09-09 8:34 ` Yu Kuai
2025-09-09 8:43 ` John Garry
2025-09-11 6:10 ` Christoph Hellwig
2025-09-08 10:56 ` [PATCH 2/2] block: remove the bi_inline_vecs variable sized array from struct bio Christoph Hellwig
2025-09-09 8:16 ` John Garry
2025-09-09 8:40 ` Yu Kuai
2025-09-09 8:55 ` John Garry [this message]
2025-09-09 9:10 ` Yu Kuai
2025-09-11 6:12 ` Christoph Hellwig
2025-09-11 6:07 ` Christoph Hellwig
2025-09-09 13:32 ` remove the bi_inline_vecs field " 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=8e5b16eb-a5f9-4fdb-8422-34be7c24b93b@oracle.com \
--to=john.g.garry@oracle.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.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