Commit 49826b36 authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

iscsi: Properly size the receive buffer



Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Change-Id: Id736c8a6d9a2cb8bd23017f61eeeccca8a882c03
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1636


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 0accbe8a
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include "spdk/env.h"
#include "spdk/likely.h"
#include "spdk/trace.h"
#include "spdk/sock.h"
#include "spdk/string.h"
#include "spdk/queue.h"
#include "spdk/net.h"
@@ -1100,6 +1101,7 @@ static int
iscsi_conn_params_update(struct spdk_iscsi_conn *conn)
{
	int rc;
	uint32_t recv_buf_size;

	/* update internal variables */
	rc = spdk_iscsi_copy_param2var(conn);
@@ -1120,6 +1122,27 @@ iscsi_conn_params_update(struct spdk_iscsi_conn *conn)
		}
	}

	/* The socket receive buffer may need to be adjusted based on the new parameters */

	/* Don't allow the recv buffer to be 0 or very large. */
	recv_buf_size = spdk_max(0x1000, spdk_min(0x2000, conn->sess->FirstBurstLength));

	/* Add in extra space for the PDU */
	recv_buf_size += ISCSI_BHS_LEN + ISCSI_AHS_LEN;

	if (conn->header_digest) {
		recv_buf_size += ISCSI_DIGEST_LEN;
	}

	if (conn->data_digest) {
		recv_buf_size += ISCSI_DIGEST_LEN;
	}

	/* Set up to buffer up to 4 commands with immediate data at once */
	if (spdk_sock_set_recvbuf(conn->sock, recv_buf_size * 4) < 0) {
		/* Not fatal. */
	}

	return rc;
}

+2 −0
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ DEFINE_STUB(spdk_iscsi_chap_get_authinfo, int,
	    (struct iscsi_chap_auth *auth, const char *authuser, int ag_tag),
	    0);

DEFINE_STUB(spdk_sock_set_recvbuf, int, (struct spdk_sock *sock, int sz), 0);

int
spdk_scsi_lun_get_id(const struct spdk_scsi_lun *lun)
{