From: Caleb Sander Mateos <csander@purestorage.com>
To: Jens Axboe <axboe@kernel.dk>, Damien Le Moal <dlemoal@kernel.org>,
Christoph Hellwig <hch@lst.de>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Caleb Sander Mateos <csander@purestorage.com>
Subject: [PATCH 2/2] zloop: use blk_rq_nr_phys_segments() instead of iterating bvecs
Date: Sat, 8 Nov 2025 16:01:01 -0700 [thread overview]
Message-ID: <20251108230101.4187106-3-csander@purestorage.com> (raw)
In-Reply-To: <20251108230101.4187106-1-csander@purestorage.com>
The number of bvecs can be obtained directly from struct request's
nr_phys_segments field via blk_rq_nr_phys_segments(), so use that
instead of iterating over the bvecs an extra time.
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
drivers/block/zloop.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 92be9f0af00a..7883e56ed12a 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -368,11 +368,11 @@ static void zloop_rw(struct zloop_cmd *cmd)
struct req_iterator rq_iter;
struct zloop_zone *zone;
struct iov_iter iter;
struct bio_vec tmp;
sector_t zone_end;
- int nr_bvec = 0;
+ unsigned short nr_bvec = blk_rq_nr_phys_segments(rq);
int ret;
atomic_set(&cmd->ref, 2);
cmd->sector = sector;
cmd->nr_sectors = nr_sectors;
@@ -435,13 +435,10 @@ static void zloop_rw(struct zloop_cmd *cmd)
zone->wp += nr_sectors;
if (zone->wp == zone_end)
zone->cond = BLK_ZONE_COND_FULL;
}
- rq_for_each_bvec(tmp, rq, rq_iter)
- nr_bvec++;
-
if (rq->bio != rq->biotail) {
struct bio_vec *bvec;
cmd->bvec = kmalloc_array(nr_bvec, sizeof(*cmd->bvec), GFP_NOIO);
if (!cmd->bvec) {
--
2.45.2
next prev parent reply other threads:[~2025-11-08 23:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-08 23:00 [PATCH 0/2] use blk_rq_nr_phys_segments() instead of iterating bvecs Caleb Sander Mateos
2025-11-08 23:01 ` [PATCH 1/2] loop: " Caleb Sander Mateos
2025-11-09 12:19 ` Ming Lei
2025-11-09 19:05 ` Chaitanya Kulkarni
2025-11-10 16:47 ` Caleb Sander Mateos
2025-11-10 21:34 ` Chaitanya Kulkarni
2025-11-11 1:22 ` Ming Lei
2025-11-08 23:01 ` Caleb Sander Mateos [this message]
2025-11-11 9:07 ` [PATCH 2/2] zloop: " Christoph Hellwig
2025-11-11 18:19 ` Chaitanya Kulkarni
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=20251108230101.4187106-3-csander@purestorage.com \
--to=csander@purestorage.com \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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