Skip to content

Commit 98fd5c7

Browse files
sagigrimbergkeithbusch
authored andcommitted
nvmet-tcp: set MSG_MORE only if we actually have more to send
When we send PDU data, we want to optimize the tcp stack operation if we have more data to send. So when we set MSG_MORE when: - We have more fragments coming in the batch, or - We have a more data to send in this PDU - We don't have a data digest trailer - We optimize with the SUCCESS flag and omit the NVMe completion (used if sq_head pointer update is disabled) This addresses a regression in QD=1 with SUCCESS flag optimization as we unconditionally set MSG_MORE when we didn't actually have more data to send. Fixes: 7058329 ("nvmet-tcp: implement C2HData SUCCESS optimization") Reported-by: Mark Wunderlich <[email protected]> Tested-by: Mark Wunderlich <[email protected]> Signed-off-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 9134ae2 commit 98fd5c7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/nvme/target/tcp.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,23 @@ static int nvmet_try_send_data_pdu(struct nvmet_tcp_cmd *cmd)
515515
return 1;
516516
}
517517

518-
static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd)
518+
static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
519519
{
520520
struct nvmet_tcp_queue *queue = cmd->queue;
521521
int ret;
522522

523523
while (cmd->cur_sg) {
524524
struct page *page = sg_page(cmd->cur_sg);
525525
u32 left = cmd->cur_sg->length - cmd->offset;
526+
int flags = MSG_DONTWAIT;
527+
528+
if ((!last_in_batch && cmd->queue->send_list_len) ||
529+
cmd->wbytes_done + left < cmd->req.transfer_len ||
530+
queue->data_digest || !queue->nvme_sq.sqhd_disabled)
531+
flags |= MSG_MORE;
526532

527533
ret = kernel_sendpage(cmd->queue->sock, page, cmd->offset,
528-
left, MSG_DONTWAIT | MSG_MORE);
534+
left, flags);
529535
if (ret <= 0)
530536
return ret;
531537

@@ -660,7 +666,7 @@ static int nvmet_tcp_try_send_one(struct nvmet_tcp_queue *queue,
660666
}
661667

662668
if (cmd->state == NVMET_TCP_SEND_DATA) {
663-
ret = nvmet_try_send_data(cmd);
669+
ret = nvmet_try_send_data(cmd, last_in_batch);
664670
if (ret <= 0)
665671
goto done_send;
666672
}

0 commit comments

Comments
 (0)