* [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host
@ 2021-01-14 21:15 Sagi Grimberg
2021-01-14 21:15 ` [PATCH 1/3] nvme-tcp: fix wrong setting of request iov_iter Sagi Grimberg
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sagi Grimberg @ 2021-01-14 21:15 UTC (permalink / raw
To: Christoph Hellwig, Keith Busch, linux-nvme
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(-)
--
2.25.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] nvme-tcp: fix wrong setting of request iov_iter
2021-01-14 21:15 [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Sagi Grimberg
@ 2021-01-14 21:15 ` Sagi Grimberg
2021-01-14 21:15 ` [PATCH 2/3] nvme-tcp: get rid of unused helper function Sagi Grimberg
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2021-01-14 21:15 UTC (permalink / raw
To: Christoph Hellwig, Keith Busch, linux-nvme
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.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
drivers/nvme/host/tcp.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 216619926563..acf41f50a9dd 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -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;
--
2.25.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] nvme-tcp: get rid of unused helper function
2021-01-14 21:15 [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Sagi Grimberg
2021-01-14 21:15 ` [PATCH 1/3] nvme-tcp: fix wrong setting of request iov_iter Sagi Grimberg
@ 2021-01-14 21:15 ` Sagi Grimberg
2021-01-14 21:15 ` [PATCH 3/3] nvme-tcp: pass multipage bvec to request iov_iter Sagi Grimberg
2021-01-18 18:09 ` [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Christoph Hellwig
3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2021-01-14 21:15 UTC (permalink / raw
To: Christoph Hellwig, Keith Busch, linux-nvme
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
drivers/nvme/host/tcp.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index acf41f50a9dd..0a738ba34aca 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -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 ?
--
2.25.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] nvme-tcp: pass multipage bvec to request iov_iter
2021-01-14 21:15 [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Sagi Grimberg
2021-01-14 21:15 ` [PATCH 1/3] nvme-tcp: fix wrong setting of request iov_iter Sagi Grimberg
2021-01-14 21:15 ` [PATCH 2/3] nvme-tcp: get rid of unused helper function Sagi Grimberg
@ 2021-01-14 21:15 ` Sagi Grimberg
2021-01-18 18:09 ` [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Christoph Hellwig
3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2021-01-14 21:15 UTC (permalink / raw
To: Christoph Hellwig, Keith Busch, linux-nvme
iov_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.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
drivers/nvme/host/tcp.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 0a738ba34aca..4f8936751aa3 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -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;
}
--
2.25.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host
2021-01-14 21:15 [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Sagi Grimberg
` (2 preceding siblings ...)
2021-01-14 21:15 ` [PATCH 3/3] nvme-tcp: pass multipage bvec to request iov_iter Sagi Grimberg
@ 2021-01-18 18:09 ` Christoph Hellwig
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-01-18 18:09 UTC (permalink / raw
To: Sagi Grimberg; +Cc: Keith Busch, Christoph Hellwig, linux-nvme
Applied to nvme-5.12, thanks.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-18 18:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-14 21:15 [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Sagi Grimberg
2021-01-14 21:15 ` [PATCH 1/3] nvme-tcp: fix wrong setting of request iov_iter Sagi Grimberg
2021-01-14 21:15 ` [PATCH 2/3] nvme-tcp: get rid of unused helper function Sagi Grimberg
2021-01-14 21:15 ` [PATCH 3/3] nvme-tcp: pass multipage bvec to request iov_iter Sagi Grimberg
2021-01-18 18:09 ` [PATCH 0/3 RESEND] few simple cleanups for nvme-tcp host Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.