From 0d3ad999290d5321c40f58b6624e6304826b757e Mon Sep 17 00:00:00 2001 From: Alexey Marchuk Date: Thu, 11 Feb 2021 09:02:55 +0300 Subject: [PATCH] sock/posix: Don't return if zcopy is disabled When socket is being created and zcopy is disabled by the config, we can return from posix_sock_alloc function before we try to set quick_ack Signed-off-by: Alexey Marchuk Change-Id: I6670b8337e70ec12b18a5e6753674fbef9e95648 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6382 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- module/sock/posix/posix.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index f23039af2..497919b50 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -2,7 +2,7 @@ * BSD LICENSE * * Copyright (c) Intel Corporation. All rights reserved. - * Copyright (c) 2020 Mellanox Technologies LTD. All rights reserved. + * Copyright (c) 2020, 2021 Mellanox Technologies LTD. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -327,14 +327,12 @@ posix_sock_alloc(int fd, bool enable_zero_copy) #if defined(SPDK_ZEROCOPY) flag = 1; - if (!enable_zero_copy || !g_spdk_posix_sock_impl_opts.enable_zerocopy_send) { - return sock; - } - - /* Try to turn on zero copy sends */ - rc = setsockopt(sock->fd, SOL_SOCKET, SO_ZEROCOPY, &flag, sizeof(flag)); - if (rc == 0) { - sock->zcopy = true; + if (enable_zero_copy && g_spdk_posix_sock_impl_opts.enable_zerocopy_send) { + /* Try to turn on zero copy sends */ + rc = setsockopt(sock->fd, SOL_SOCKET, SO_ZEROCOPY, &flag, sizeof(flag)); + if (rc == 0) { + sock->zcopy = true; + } } #endif