All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet-tcp: fix incomplete data digest send
@ 2021-11-22 10:08 Varun Prakash
  2021-11-22 10:23 ` Sagi Grimberg
  2021-11-23 16:23 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Varun Prakash @ 2021-11-22 10:08 UTC (permalink / raw)
  To: sagi, hch, kbusch; +Cc: linux-nvme, varun

Current nvmet_try_send_ddgst() code does not check whether
all data digest bytes are transmitted, fix this by returning
-EAGAIN if all data digest bytes are not transmitted.

Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver")
Signed-off-by: Varun Prakash <varun@chelsio.com>
---
 drivers/nvme/target/tcp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 84c387e..2b8bab2 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -700,10 +700,11 @@ static int nvmet_try_send_r2t(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
 static int nvmet_try_send_ddgst(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
 {
 	struct nvmet_tcp_queue *queue = cmd->queue;
+	int left = NVME_TCP_DIGEST_LENGTH - cmd->offset;
 	struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 	struct kvec iov = {
 		.iov_base = (u8 *)&cmd->exp_ddgst + cmd->offset,
-		.iov_len = NVME_TCP_DIGEST_LENGTH - cmd->offset
+		.iov_len = left
 	};
 	int ret;
 
@@ -717,6 +718,10 @@ static int nvmet_try_send_ddgst(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
 		return ret;
 
 	cmd->offset += ret;
+	left -= ret;
+
+	if (left)
+		return -EAGAIN;
 
 	if (queue->nvme_sq.sqhd_disabled) {
 		cmd->queue->snd_cmd = NULL;
-- 
2.0.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvmet-tcp: fix incomplete data digest send
  2021-11-22 10:08 [PATCH] nvmet-tcp: fix incomplete data digest send Varun Prakash
@ 2021-11-22 10:23 ` Sagi Grimberg
  2021-11-23 16:23 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Sagi Grimberg @ 2021-11-22 10:23 UTC (permalink / raw)
  To: Varun Prakash, hch, kbusch; +Cc: linux-nvme

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvmet-tcp: fix incomplete data digest send
  2021-11-22 10:08 [PATCH] nvmet-tcp: fix incomplete data digest send Varun Prakash
  2021-11-22 10:23 ` Sagi Grimberg
@ 2021-11-23 16:23 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-11-23 16:23 UTC (permalink / raw)
  To: Varun Prakash; +Cc: sagi, hch, kbusch, linux-nvme

Thanks,

applied to nvme-5.16.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-23 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 10:08 [PATCH] nvmet-tcp: fix incomplete data digest send Varun Prakash
2021-11-22 10:23 ` Sagi Grimberg
2021-11-23 16:23 ` 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.