few simple cleanups for nvme-tcp host
Sagi Grimberg
maintainercover few simple cleanups for nvme-tcp host
No real bug fix here, but some useful cleanups.
Sagi Grimberg (3):
nvme-tcp: fix wrong setting of request iov_iter
nvme-tcp: get rid of unused helper function
nvme-tcp: pass multipage bvec to request iov_iter
drivers/nvme/host/tcp.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
Signature · 7 lines
2.25.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerPATCH 1/3 nvme-tcp: fix wrong setting of request iov_iter
We might set the iov_iter direction wrong, which is harmless for this use-case, but get it right. Also this makes the code slightly cleaner.
--- drivers/nvme/host/tcp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/nvme/host/tcp.c +2 -5
@@ -982,7 +982,6 @@ static int nvme_tcp_try_send_cmd_pdu(struct nvme_tcp_request *req) req->state =NVME_TCP_SEND_DATA ;if (queue->data_digest)crypto_ahash_init (queue->snd_hash); -nvme_tcp_init_iter (req,WRITE ); }else {nvme_tcp_done_send_req (queue); }
@@ -1015,8 +1014,6 @@ static int nvme_tcp_try_send_data_pdu(struct nvme_tcp_request *req) req->state =NVME_TCP_SEND_DATA ;if (queue->data_digest)crypto_ahash_init (queue->snd_hash); -if (!req->data_sent) -nvme_tcp_init_iter (req,WRITE );return 1 ; } req->offset += ret;
@@ -2262,12 +2259,12 @@ static blk_status_t nvme_tcp_setup_cmd_pdu(struct nvme_ns *ns, req->data_len =blk_rq_nr_phys_segments (rq) ?blk_rq_payload_bytes (rq) :0 ; req->curr_bio = rq->bio; +if (req->curr_bio) +nvme_tcp_init_iter (req,rq_data_dir (rq));if (rq_data_dir (rq) ==WRITE && req->data_len <=nvme_tcp_inline_data_size (queue)) req->pdu_len = req->data_len; -else if (req->curr_bio) -nvme_tcp_init_iter (req,READ ); pdu->hdr.type = nvme_tcp_cmd; pdu->hdr.flags =0 ;
Signature · 7 lines
2.25.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerPATCH 2/3 nvme-tcp: get rid of unused helper function
In reply to Sagi Grimberg--- drivers/nvme/host/tcp.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/nvme/host/tcp.c +0 -5
@@ -205,11 +205,6 @@ static inline size_t nvme_tcp_req_cur_length(struct nvme_tcp_request *req) req->pdu_len - req->pdu_sent); } -static inline size_t nvme_tcp_req_offset (struct nvme_tcp_request *req) -{ -return req->iter.iov_offset; -} -static inline size_t nvme_tcp_pdu_data_left (struct nvme_tcp_request *req) { return rq_data_dir(blk_mq_rq_from_pdu(req)) == WRITE ?
Signature · 7 lines
2.25.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerPATCH 3/3 nvme-tcp: pass multipage bvec to request iov_iter
In reply to Sagi Grimbergiov_iter uses the right helpers so we should be able to pass in a multipage bvec. Right now the iov_iter is initialized with more segments that it needs which doesn't fail because the iov_iter is capped by byte count, but it is better to use a full multipage bvec iter.
--- drivers/nvme/host/tcp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/nvme/host/tcp.c +9 -4
@@ -223,24 +223,29 @@ static void nvme_tcp_init_iter(struct nvme_tcp_request *req,struct request *rq =blk_mq_rq_from_pdu (req);struct bio_vec *vec;unsigned int size; -int nsegs; +int nr_bvec;size_t offset;if (rq->rq_flags &RQF_SPECIAL_PAYLOAD ) { vec = &rq->special_vec; - nsegs =1 ; + nr_bvec =1 ; size =blk_rq_payload_bytes (rq); offset =0 ; }else {struct bio *bio = req->curr_bio; +struct bvec_iter bi; +struct bio_vec bv; vec =__bvec_iter_bvec (bio->bi_io_vec, bio->bi_iter); - nsegs =bio_segments (bio); + nr_bvec =0 ; +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, nsegs, size); +iov_iter_bvec (&req->iter, dir, vec, nr_bvec, size); req->iter.iov_offset = offset; }
Signature · 7 lines
2.25.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Applied to nvme-5.12, thanks.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme