From owner-svn-src-projects@FreeBSD.ORG Tue Oct 6 07:24:23 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB018106568F; Tue, 6 Oct 2009 07:24:23 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B0A118FC15; Tue, 6 Oct 2009 07:24:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n967ONH0039036; Tue, 6 Oct 2009 07:24:23 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n967ONHI039033; Tue, 6 Oct 2009 07:24:23 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200910060724.n967ONHI039033@svn.freebsd.org> From: Lawrence Stewart Date: Tue, 6 Oct 2009 07:24:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197801 - in projects/tcp_ffcaia2008_8.x/sys: kern sys X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Oct 2009 07:24:23 -0000 Author: lstewart Date: Tue Oct 6 07:24:23 2009 New Revision: 197801 URL: http://svn.freebsd.org/changeset/base/197801 Log: Cannibalise an unused field in the ALE to store a count of the bytes written to the ALE by the consumer. This extends the alq_get/alq_post interface to allow a consumer to request an allocation from the ALQ that may be larger than is actually needed. Nothing changes in the default use case. The new use case made possible by this change is as follows: - Consumer requests X bytes from the ALQ using alq_getn(). - Consumer only generates Y bytes of data (where Y < X) and writes them to the ALQ buffer location pointed to by ale->ae_data. - [New step] Consumer overwrites ale->ae_bytesused with the value of Y to inform alq_post() of the actual number of bytes written. - Consumer calls alq_post() to complete the write. Sponsored by: FreeBSD Foundation Modified: projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c projects/tcp_ffcaia2008_8.x/sys/sys/alq.h Modified: projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c Tue Oct 6 06:35:52 2009 (r197800) +++ projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c Tue Oct 6 07:24:23 2009 (r197801) @@ -668,15 +668,7 @@ alq_getn(struct alq *alq, int len, int f * available in our buffer starting at aq_writehead. */ alq->aq_getpost.ae_data = alq->aq_entbuf + alq->aq_writehead; - alq->aq_writehead += len; - alq->aq_freebytes -= len; - - /* Wrap aq_writehead if we've filled to the end of the buffer. */ - if (alq->aq_writehead == alq->aq_buflen) - alq->aq_writehead = 0; - - KASSERT((alq->aq_writehead >= 0 && alq->aq_writehead < alq->aq_buflen), - ("%s: aq_writehead < 0 || aq_writehead >= aq_buflen", __func__)); + alq->aq_getpost.ae_bytesused = len; return (&alq->aq_getpost); } @@ -693,6 +685,16 @@ alq_post(struct alq *alq, struct ale *al } else activate = 0; + alq->aq_writehead += ale->ae_bytesused; + alq->aq_freebytes -= ale->ae_bytesused; + + /* Wrap aq_writehead if we've filled to the end of the buffer. */ + if (alq->aq_writehead == alq->aq_buflen) + alq->aq_writehead = 0; + + KASSERT((alq->aq_writehead >= 0 && alq->aq_writehead < alq->aq_buflen), + ("%s: aq_writehead < 0 || aq_writehead >= aq_buflen", __func__)); + ALQ_UNLOCK(alq); if (activate) { Modified: projects/tcp_ffcaia2008_8.x/sys/sys/alq.h ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/sys/alq.h Tue Oct 6 06:35:52 2009 (r197800) +++ projects/tcp_ffcaia2008_8.x/sys/sys/alq.h Tue Oct 6 07:24:23 2009 (r197801) @@ -42,7 +42,7 @@ extern struct thread *ald_thread; * Async. Logging Entry */ struct ale { - struct ale *ae_next; /* Unused, compat. */ + intptr_t ae_bytesused; /* # bytes written to ALE. */ char *ae_data; /* Write ptr. */ int ae_flags; /* Unused, compat. */ };