Revision: 14430
Author: adrian.chadd
Date: Mon Feb 22 04:48:52 2010
Log: * modify aioRead() to use the passed-in buffer; rather than using a
temporary
buffer
* modify COSS and AUFS to supply the buffer to read rather than copying data
from the completed IO.
http://code.google.com/p/lusca-cache/source/detail?r=14430
Modified:
/playpen/LUSCA_HEAD_zerocopy_storeread/libasyncio/async_io.c
/playpen/LUSCA_HEAD_zerocopy_storeread/libasyncio/async_io.h
/playpen/LUSCA_HEAD_zerocopy_storeread/src/fs/aufs/store_io_aufs.c
/playpen/LUSCA_HEAD_zerocopy_storeread/src/fs/coss/store_io_coss.c
=======================================
--- /playpen/LUSCA_HEAD_zerocopy_storeread/libasyncio/async_io.c Sun Feb 21
22:05:38 2010
+++ /playpen/LUSCA_HEAD_zerocopy_storeread/libasyncio/async_io.c Mon Feb 22
04:48:52 2010
@@ -250,9 +250,6 @@
/* free data if requested to aioWrite() */
if (ctrlp->free_func)
ctrlp->free_func(ctrlp->bufp);
- /* free temporary read buffer */
- if (ctrlp->operation == _AIO_READ)
- xfree(ctrlp->bufp);
}
dlinkDelete(m, &used_list);
memPoolFree(squidaio_ctrl_pool, ctrlp);
@@ -306,7 +303,7 @@
void
-aioRead(int fd, off_t offset, int len, AIOCB * callback, void
*callback_data)
+aioRead(int fd, off_t offset, char *buf, int len, AIOCB * callback, void
*callback_data)
{
squidaio_ctrl_t *ctrlp;
@@ -318,7 +315,7 @@
ctrlp->done_handler_data = callback_data;
ctrlp->operation = _AIO_READ;
ctrlp->len = len;
- ctrlp->bufp = xmalloc(len);
+ ctrlp->bufp = buf;
assert(offset >= 0);
cbdataLock(callback_data);
ctrlp->result.data = ctrlp;
@@ -466,9 +463,6 @@
/* free data if requested to aioWrite() */
if (ctrlp->free_func)
ctrlp->free_func(ctrlp->bufp);
- /* free temporary read buffer */
- if (ctrlp->operation == _AIO_READ)
- xfree(ctrlp->bufp);
memPoolFree(squidaio_ctrl_pool, ctrlp);
}
return retval;
=======================================
--- /playpen/LUSCA_HEAD_zerocopy_storeread/libasyncio/async_io.h Sun Aug 9
21:22:14 2009
+++ /playpen/LUSCA_HEAD_zerocopy_storeread/libasyncio/async_io.h Mon Feb 22
04:48:52 2010
@@ -44,7 +44,7 @@
void aioOpen(const char *, int, mode_t, AIOCB *, void *);
void aioClose(int);
void aioWrite(int, off_t offset, char *, int size, AIOCB *, void *, FREE
*);
-void aioRead(int, off_t offset, int size, AIOCB *, void *);
+void aioRead(int, off_t offset, char *buf, int size, AIOCB *, void *);
void aioStat(char *, struct stat *, AIOCB *, void *);
void aioUnlink(const char *, AIOCB *, void *);
void aioTruncate(const char *, off_t length, AIOCB *, void *);
=======================================
--- /playpen/LUSCA_HEAD_zerocopy_storeread/src/fs/aufs/store_io_aufs.c Fri
Jul 17 17:05:17 2009
+++ /playpen/LUSCA_HEAD_zerocopy_storeread/src/fs/aufs/store_io_aufs.c Mon
Feb 22 04:48:52 2010
@@ -210,7 +210,7 @@
sio->offset = offset;
aiostate->flags.reading = 1;
#if ASYNC_READ
- aioRead(aiostate->fd, (off_t) offset, size, storeAufsReadDone, sio);
+ aioRead(aiostate->fd, (off_t) offset, buf, size, storeAufsReadDone,
sio);
CommStats.syscalls.disk.reads++;
#else
file_read(aiostate->fd, buf, size, (off_t) offset, storeAufsReadDone,
sio);
@@ -363,6 +363,7 @@
void *their_data = sio->read.callback_data;
ssize_t rlen;
int inreaddone = aiostate->flags.inreaddone; /* Protect from callback
loops */
+ assert(buf == aiostate->read_buf);
debug(79, 3) ("storeAufsReadDone: dirno %d, fileno %08X, FD %d,
len %d\n",
sio->swap_dirn, sio->swap_filen, fd, len);
aiostate->flags.inreaddone = 1;
@@ -390,10 +391,6 @@
sio->read.callback = NULL;
sio->read.callback_data = NULL;
if (!aiostate->flags.close_request && cbdataValid(their_data)) {
-#if ASYNC_READ
- if (rlen > 0)
- memcpy(aiostate->read_buf, buf, rlen);
-#endif
callback(their_data, aiostate->read_buf, rlen);
}
cbdataUnlock(their_data);
=======================================
--- /playpen/LUSCA_HEAD_zerocopy_storeread/src/fs/coss/store_io_coss.c Sun
Jul 26 20:14:38 2009
+++ /playpen/LUSCA_HEAD_zerocopy_storeread/src/fs/coss/store_io_coss.c Mon
Feb 22 04:48:52 2010
@@ -1055,7 +1055,7 @@
debug(79, 3) ("COSS Pending Relocate: size %" PRINTF_OFF_T ",
disk_offset %" PRIu64 "\n", (squid_off_t) sio->e->swap_file_sz, (int64_t)
disk_offset);
/* NOTE: the damned buffer isn't passed into aioRead! */
debug(79, 3) ("COSS: aioRead: FD %d, from %d -> %d, offset %"
PRIu64 ", len: %ld\n", cs->fd, pr->original_filen, pr->new_filen, (int64_t)
disk_offset, (long int) pr->len);
- aioRead(cs->fd, (off_t) disk_offset, pr->len,
storeCossCompletePendingReloc, pr);
+ aioRead(cs->fd, (off_t) disk_offset, pr->p, pr->len,
storeCossCompletePendingReloc, pr);
}
CossPendingReloc *
@@ -1090,6 +1090,9 @@
else
errflag = DISK_OK;
+ /* Make sure this buffer is what we submitted! */
+ assert(pr->p == buf);
+
debug(79, 3) ("storeCossCompletePendingReloc: %p\n", pr);
assert(cbdataValid(pr));
if (errflag != 0) {
@@ -1104,15 +1107,11 @@
debug(79, 3) ("COSS Pending Relocate: %d -> %d: completed\n",
pr->original_filen, pr->new_filen);
coss_stats.read.success++;
}
- /* aufs aioRead() doesn't take a buffer, it reads into its own. Grr */
- p = storeCossMemPointerFromDiskOffset(cs,
storeCossFilenoToDiskOffset(pr->new_filen, cs), NULL);
- assert(p != NULL);
- assert(p == pr->p);
- xmemcpy(p, buf, len);
/* Nope, we're not a pending relocate anymore! */
dlinkDelete(&pr->node, &cs->pending_relocs);
+
/* Update the stripe count */
stripe = storeCossFilenoToStripe(cs, pr->original_filen);
assert(stripe >= 0);
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.