[PATCH 08/17] nvme-tcp: fixup MSG_SENDPAGE_NOTLAST
Hannes Reinecke
hare at suse.de
Tue Apr 18 23:57:05 PDT 2023
We can only set MSG_SENDPAGE_NOTLAST when sending the command PDU if the
actual data is transferred via sendpage(), too.
If we use sendmsg() to transfer the data we end up with a TX stall on TLS
as it implements different code paths for sendmsg() and sendpage().
So check in nvme_tcp_try_send_pdu() if inline data is present and revert
to sendmsg if the inline data cannot be sent via sendpage().
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
drivers/nvme/host/tcp.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 273c1f2760a4..9ecd7db2cd98 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -995,9 +995,11 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
if (last && !queue->data_digest && !nvme_tcp_queue_more(queue))
flags |= MSG_EOR;
else
- flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST;
+ flags |= MSG_MORE;
if (sendpage_ok(page)) {
+ if (flags & MSG_MORE)
+ flags |= MSG_SENDPAGE_NOTLAST;
ret = kernel_sendpage(queue->sock, page, offset, len,
flags);
} else {
@@ -1049,15 +1051,23 @@ static int nvme_tcp_try_send_cmd_pdu(struct nvme_tcp_request *req)
int ret;
if (inline_data || nvme_tcp_queue_more(queue))
- flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST;
+ flags |= MSG_MORE;
else
flags |= MSG_EOR;
if (queue->hdr_digest && !req->offset)
nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu));
- ret = kernel_sendpage(queue->sock, virt_to_page(pdu),
- offset_in_page(pdu) + req->offset, len, flags);
+ if (!inline_data || sendpage_ok(nvme_tcp_req_cur_page(req))) {
+ if (flags & MSG_MORE)
+ flags |= MSG_SENDPAGE_NOTLAST;
+ ret = kernel_sendpage(queue->sock, virt_to_page(pdu),
+ offset_in_page(pdu) + req->offset, len, flags);
+ } else {
+ ret = sock_no_sendpage(queue->sock, virt_to_page(pdu),
+ offset_in_page(pdu) + req->offset,
+ len, flags);
+ }
if (unlikely(ret <= 0))
return ret;
--
2.35.3
More information about the Linux-nvme
mailing list