]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvme-tcp: cleanup nvme_tcp_init_iter
authorChristoph Hellwig <hch@lst.de>
Wed, 27 May 2026 15:10:21 +0000 (17:10 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 28 May 2026 13:59:11 +0000 (07:59 -0600)
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@lst.de>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Link: https://patch.msgid.link/20260527151043.2349900-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/tcp.c

index 36b3ec50a9fdf76de4d7bbcd09ad1ddbb714335d..9313ab211c67d5b29c0463018ae1de058d784f08 100644 (file)
@@ -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,