From 449cab95696a07f86ddd8bbe8b9dab9d5c091d9f Mon Sep 17 00:00:00 2001 From: Richael Zhuang Date: Thu, 31 Mar 2022 15:06:01 +0800 Subject: [PATCH] posix: update sendmsg_idx only if zerocopy is enabled Sendmsg_idx is used in _sock_check_zcopy to check whether idx in MSG_ERRQUEUE and req's idx match. There is no need to update it if zerocopy is disabled. Change-Id: I24bb367e0bff006782d9052470857f6e4db90681 Signed-off-by: Richael Zhuang Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12104 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- module/sock/posix/posix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index 11b48ed2d..7203ae14e 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -744,12 +744,14 @@ _sock_flush(struct spdk_sock *sock) return rc; } - /* Handling overflow case, because we use psock->sendmsg_idx - 1 for the - * req->internal.offset, so sendmsg_idx should not be zero */ - if (spdk_unlikely(psock->sendmsg_idx == UINT32_MAX)) { - psock->sendmsg_idx = 1; - } else { - psock->sendmsg_idx++; + if (psock->zcopy) { + /* Handling overflow case, because we use psock->sendmsg_idx - 1 for the + * req->internal.offset, so sendmsg_idx should not be zero */ + if (spdk_unlikely(psock->sendmsg_idx == UINT32_MAX)) { + psock->sendmsg_idx = 1; + } else { + psock->sendmsg_idx++; + } } /* Consume the requests that were actually written */