From: Niklas Cassel <cassel@kernel.org>
To: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
Cc: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de,
dlemoal@kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH V3] blk-mq: add blk_rq_nr_bvec() helper
Date: Wed, 3 Dec 2025 07:12:58 +0100 [thread overview]
Message-ID: <aS_U6m9ZzQHFqE23@ryzen> (raw)
In-Reply-To: <20251203035809.30610-1-ckulkarnilinux@gmail.com>
On Tue, Dec 02, 2025 at 07:58:09PM -0800, Chaitanya Kulkarni wrote:
> Add a new helper function blk_rq_nr_bvec() that returns the number of
> bvecs in a request. This count represents the number of iterations
> rq_for_each_bvec() would perform on a request.
>
> Drivers need to pre-allocate bvec arrays before iterating through
> a request's bvecs. Currently, they manually count bvecs using
> rq_for_each_bvec() in a loop, which is repetitive. The new helper
> centralizes this logic.
>
> This pattern exists in loop and zloop drivers, where multi-bio requests
> require copying bvecs into a contiguous array before creating
> an iov_iter for file operations.
>
> Update loop and zloop drivers to use the new helper, eliminating
> duplicate code.
>
> This patch also provides a clear API to avoid any potential misuse of
> blk_nr_phys_segments() for calculating the bvecs since, one bvec can
> have more than one segments and use of blk_nr_phys_segments() can
> lead to extra memory allocation :-
>
> [ 6155.673749] nullb_bio: 128K bio as ONE bvec: sector=0, size=131072
> [ 6155.673846] null_blk: #### null_handle_data_transfer:1375
> [ 6155.673850] null_blk: nr_bvec=1 blk_rq_nr_phys_segments=2
> [ 6155.674263] null_blk: #### null_handle_data_transfer:1375
> [ 6155.674267] null_blk: nr_bvec=1 blk_rq_nr_phys_segments=1
>
> Reviewed-by: Niklas Cassel<cassel@kernel.org>
Missing space before '<'.
Perhaps Jens can fix up when applying if you get no further comments.
Kind regards,
Niklas
next prev parent reply other threads:[~2025-12-03 6:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 3:58 [PATCH V3] blk-mq: add blk_rq_nr_bvec() helper Chaitanya Kulkarni
2025-12-03 6:10 ` Christoph Hellwig
2025-12-03 6:12 ` Niklas Cassel [this message]
2025-12-03 14:53 ` 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=aS_U6m9ZzQHFqE23@ryzen \
--to=cassel@kernel.org \
--cc=axboe@kernel.dk \
--cc=ckulkarnilinux@gmail.com \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--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