Skip to content

Commit 102110e

Browse files
Varun PrakashChristoph Hellwig
authored andcommitted
nvmet-tcp: fix incomplete data digest send
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: 872d26a ("nvmet-tcp: add NVMe over TCP target driver") Signed-off-by: Varun Prakash <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent af21250 commit 102110e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/nvme/target/tcp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,11 @@ static int nvmet_try_send_r2t(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
711711
static int nvmet_try_send_ddgst(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
712712
{
713713
struct nvmet_tcp_queue *queue = cmd->queue;
714+
int left = NVME_TCP_DIGEST_LENGTH - cmd->offset;
714715
struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
715716
struct kvec iov = {
716717
.iov_base = (u8 *)&cmd->exp_ddgst + cmd->offset,
717-
.iov_len = NVME_TCP_DIGEST_LENGTH - cmd->offset
718+
.iov_len = left
718719
};
719720
int ret;
720721

@@ -728,6 +729,10 @@ static int nvmet_try_send_ddgst(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
728729
return ret;
729730

730731
cmd->offset += ret;
732+
left -= ret;
733+
734+
if (left)
735+
return -EAGAIN;
731736

732737
if (queue->nvme_sq.sqhd_disabled) {
733738
cmd->queue->snd_cmd = NULL;

0 commit comments

Comments
 (0)