nvmet: use bvec_set_page to initialize bvecs
authorChristoph Hellwig <hch@lst.de>
Fri, 3 Feb 2023 15:06:17 +0000 (16:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 09:11:08 +0000 (11:11 +0200)
[ Upstream commit fc41c97a3a7b08131e6998bc7692f95729f9d359 ]

Use the bvec_set_page helper to initialize bvecs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20230203150634.3199647-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 1f0bbf28940c ("nvmet-tcp: pass iov_len instead of sg->length to bvec_set_page()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/target/io-cmd-file.c
drivers/nvme/target/tcp.c

index 871c4f32f443f5728b2fe3ec66d69925ccef54e2..2d068439b129c52b0d6149ad143dc0c9f8c9db75 100644 (file)
@@ -73,13 +73,6 @@ err:
        return ret;
 }
 
-static void nvmet_file_init_bvec(struct bio_vec *bv, struct scatterlist *sg)
-{
-       bv->bv_page = sg_page(sg);
-       bv->bv_offset = sg->offset;
-       bv->bv_len = sg->length;
-}
-
 static ssize_t nvmet_file_submit_bvec(struct nvmet_req *req, loff_t pos,
                unsigned long nr_segs, size_t count, int ki_flags)
 {
@@ -146,7 +139,8 @@ static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags)
 
        memset(&req->f.iocb, 0, sizeof(struct kiocb));
        for_each_sg(req->sg, sg, req->sg_cnt, i) {
-               nvmet_file_init_bvec(&req->f.bvec[bv_cnt], sg);
+               bvec_set_page(&req->f.bvec[bv_cnt], sg_page(sg), sg->length,
+                             sg->offset);
                len += req->f.bvec[bv_cnt].bv_len;
                total_len += req->f.bvec[bv_cnt].bv_len;
                bv_cnt++;
index cc05c094de221d81abdb51814a5b471e60833a3f..c5759eb503d0048aa635f1db8d1a0ae17c1f7156 100644 (file)
@@ -321,9 +321,8 @@ static void nvmet_tcp_build_pdu_iovec(struct nvmet_tcp_cmd *cmd)
        while (length) {
                u32 iov_len = min_t(u32, length, sg->length - sg_offset);
 
-               iov->bv_page = sg_page(sg);
-               iov->bv_len = sg->length;
-               iov->bv_offset = sg->offset + sg_offset;
+               bvec_set_page(iov, sg_page(sg), sg->length,
+                               sg->offset + sg_offset);
 
                length -= iov_len;
                sg = sg_next(sg);