From owner-svn-src-all@FreeBSD.ORG Tue Apr 1 22:03:05 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 53E7CCBA; Tue, 1 Apr 2014 22:03:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 33EE31C8; Tue, 1 Apr 2014 22:03:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s31M34mW007385; Tue, 1 Apr 2014 22:03:04 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s31M34Gr007384; Tue, 1 Apr 2014 22:03:04 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201404012203.s31M34Gr007384@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 1 Apr 2014 22:03:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264025 - head/sys/dev/iscsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Apr 2014 22:03:05 -0000 Author: trasz Date: Tue Apr 1 22:03:03 2014 New Revision: 264025 URL: http://svnweb.freebsd.org/changeset/base/264025 Log: Get rid of the "autoscaling", instead just set socket buffer sizes in the usual way. The only thing the old code did was making things less predictable. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/iscsi/icl.c Modified: head/sys/dev/iscsi/icl.c ============================================================================== --- head/sys/dev/iscsi/icl.c Tue Apr 1 21:54:20 2014 (r264024) +++ head/sys/dev/iscsi/icl.c Tue Apr 1 22:03:03 2014 (r264025) @@ -68,6 +68,14 @@ TUNABLE_INT("kern.icl.partial_receive_le SYSCTL_INT(_kern_icl, OID_AUTO, partial_receive_len, CTLFLAG_RW, &partial_receive_len, 1 * 1024, "Minimum read size for partially received " "data segment"); +static int sendspace = 1048576; +TUNABLE_INT("kern.icl.sendspace", &sendspace); +SYSCTL_INT(_kern_icl, OID_AUTO, sendspace, CTLFLAG_RW, + &sendspace, 1048576, "Default send socket buffer size"); +static int recvspace = 1048576; +TUNABLE_INT("kern.icl.recvspace", &recvspace); +SYSCTL_INT(_kern_icl, OID_AUTO, recvspace, CTLFLAG_RW, + &recvspace, 1048576, "Default receive socket buffer size"); static uma_zone_t icl_conn_zone; static uma_zone_t icl_pdu_zone; @@ -1008,7 +1016,7 @@ icl_conn_free(struct icl_conn *ic) static int icl_conn_start(struct icl_conn *ic) { - size_t bufsize; + size_t minspace; struct sockopt opt; int error, one = 1; @@ -1029,18 +1037,28 @@ icl_conn_start(struct icl_conn *ic) ICL_CONN_UNLOCK(ic); /* - * Use max available sockbuf size for sending. Do it manually - * instead of sbreserve(9) to work around resource limits. + * For sendspace, this is required because the current code cannot + * send a PDU in pieces; thus, the minimum buffer size is equal + * to the maximum PDU size. "+4" is to account for possible padding. * - * XXX: This kind of sucks. On one hand, we don't currently support - * sending a part of data segment; we always do it in one piece, - * so we have to make sure it can fit in the socket buffer. - * Once I've implemented partial send, we'll get rid of this - * and use autoscaling. + * What we should actually do here is to use autoscaling, but set + * some minimal buffer size to "minspace". I don't know a way to do + * that, though. */ - bufsize = (sizeof(struct iscsi_bhs) + - ic->ic_max_data_segment_length) * 8; - error = soreserve(ic->ic_socket, bufsize, bufsize); + minspace = sizeof(struct iscsi_bhs) + ic->ic_max_data_segment_length + + ISCSI_HEADER_DIGEST_SIZE + ISCSI_DATA_DIGEST_SIZE + 4; + if (sendspace < minspace) { + ICL_WARN("kern.icl.sendspace too low; must be at least %jd", + minspace); + sendspace = minspace; + } + if (recvspace < minspace) { + ICL_WARN("kern.icl.recvspace too low; must be at least %jd", + minspace); + recvspace = minspace; + } + + error = soreserve(ic->ic_socket, sendspace, recvspace); if (error != 0) { ICL_WARN("soreserve failed with error %d", error); icl_conn_close(ic);