[PATCH 2/3] nvme-tcp: cleanup nvme_tcp_init_iter
Christoph Hellwig
hch at lst.de
Wed May 27 08:10:21 PDT 2026
Split the two init cases based on code in the zloop driver. This
simplifies the code and makes it easier to follow.
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
drivers/nvme/host/tcp.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 36b3ec50a9fd..9313ab211c67 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -340,32 +340,25 @@ static void nvme_tcp_init_iter(struct nvme_tcp_request *req,
unsigned int dir)
{
struct request *rq = blk_mq_rq_from_pdu(req);
- struct bio_vec *vec;
- unsigned int size;
- int nr_bvec;
- size_t offset;
if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) {
- vec = &rq->special_vec;
- nr_bvec = 1;
- size = blk_rq_payload_bytes(rq);
- offset = 0;
+ iov_iter_bvec(&req->iter, dir, &rq->special_vec, 1,
+ blk_rq_payload_bytes(rq));
+ req->iter.iov_offset = 0;
} else {
struct bio *bio = req->curr_bio;
struct bvec_iter bi;
struct bio_vec bv;
+ int nr_bvec = 0;
- vec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
- nr_bvec = 0;
- bio_for_each_bvec(bv, bio, bi) {
+ bio_for_each_bvec(bv, bio, bi)
nr_bvec++;
- }
- size = bio->bi_iter.bi_size;
- offset = bio->bi_iter.bi_bvec_done;
- }
- iov_iter_bvec(&req->iter, dir, vec, nr_bvec, size);
- req->iter.iov_offset = offset;
+ iov_iter_bvec(&req->iter, dir,
+ __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter), nr_bvec,
+ bio->bi_iter.bi_size);
+ req->iter.iov_offset = bio->bi_iter.bi_bvec_done;
+ }
}
static inline void nvme_tcp_advance_req(struct nvme_tcp_request *req,
--
2.53.0
More information about the Linux-nvme
mailing list