svn commit: r197801 - in projects/tcp_ffcaia2008_8.x/sys: kern sys
Lawrence Stewart
lstewart at FreeBSD.org
Tue Oct 6 07:24:23 UTC 2009
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. */
};
More information about the svn-src-projects
mailing list