--------------------- PatchSet 3182 Date: 2001/10/16 11:39:15 Author: adri Branch: coss Tag: (none) Log: More random fixes to the COSS code, including: * argument type fixes in the async io code * add some xmemcpy debug code in store_io_coss.c, since I'm seeing very strange stack-smashing memcpy's that I don't quite yet understand * lots of type fixes in the store_io_coss.c code Members: src/fs/coss/async_io.c:1.3->1.3.22.1 src/fs/coss/async_io.h:1.2->1.2.32.1 src/fs/coss/store_io_coss.c:1.8.12.1->1.8.12.2 Index: squid/src/fs/coss/async_io.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/coss/async_io.c,v retrieving revision 1.3 retrieving revision 1.3.22.1 diff -u -r1.3 -r1.3.22.1 --- squid/src/fs/coss/async_io.c 24 Aug 2001 15:43:58 -0000 1.3 +++ squid/src/fs/coss/async_io.c 16 Oct 2001 11:39:15 -0000 1.3.22.1 @@ -54,7 +54,7 @@ /* Exported routines */ void -a_file_read(async_queue_t * q, int fd, void *buf, int req_len, off_t offset, +a_file_read(async_queue_t * q, int fd, void *buf, size_t req_len, off_t offset, DRCB * callback, void *data) { int slot; @@ -101,7 +101,7 @@ void -a_file_write(async_queue_t * q, int fd, off_t offset, void *buf, int len, +a_file_write(async_queue_t * q, int fd, off_t offset, void *buf, size_t len, DWCB * callback, void *data, FREE * freefunc) { int slot; Index: squid/src/fs/coss/async_io.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/coss/async_io.h,v retrieving revision 1.2 retrieving revision 1.2.32.1 diff -u -r1.2 -r1.2.32.1 --- squid/src/fs/coss/async_io.h 16 Aug 2001 07:39:04 -0000 1.2 +++ squid/src/fs/coss/async_io.h 16 Oct 2001 11:39:15 -0000 1.2.32.1 @@ -47,10 +47,10 @@ /* Functions */ -extern void a_file_read(async_queue_t * q, int fd, void *buf, int req_len, +extern void a_file_read(async_queue_t * q, int fd, void *buf, size_t req_len, off_t offset, DRCB * callback, void *data); extern void a_file_write(async_queue_t * q, int fd, off_t offset, void *buf, - int len, DWCB * callback, void *data, FREE * freefunc); + size_t len, DWCB * callback, void *data, FREE * freefunc); extern int a_file_callback(async_queue_t * q); extern void a_file_setupqueue(async_queue_t * q); extern void a_file_syncqueue(async_queue_t * q); Index: squid/src/fs/coss/store_io_coss.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/coss/store_io_coss.c,v retrieving revision 1.8.12.1 retrieving revision 1.8.12.2 diff -u -r1.8.12.1 -r1.8.12.2 --- squid/src/fs/coss/store_io_coss.c 16 Oct 2001 00:51:36 -0000 1.8.12.1 +++ squid/src/fs/coss/store_io_coss.c 16 Oct 2001 11:39:15 -0000 1.8.12.2 @@ -33,6 +33,7 @@ * */ + #include "squid.h" #include #include "async_io.h" @@ -45,7 +46,6 @@ static void storeCossMemBufLock(SwapDir * SD, storeIOState * e); static void storeCossMemBufUnlock(SwapDir * SD, storeIOState * e); static void storeCossWriteMemBuf(SwapDir * SD, CossMemBuf * t); -static void storeCossWriteMemBufDone(int fd, int errflag, size_t len, void *my_data); static CossMemBuf *storeCossCreateMemBuf(SwapDir * SD, size64_t start, sfileno curfn, int *collision); static CBDUNL storeCossIOFreeEntry; @@ -53,6 +53,11 @@ CBDATA_TYPE(storeIOState); CBDATA_TYPE(CossMemBuf); +#if 0 +#undef xmemcpy +#define xmemcpy(dst,src,len) { debug(81,1) ("Line %d: memcpy(%08X, %08X, %d)\n", __LINE__,dst,src,len); memcpy(dst,src,len); } while(0); +#endif + /* === PUBLIC =========================================================== */ /* @@ -102,7 +107,7 @@ cs->current_offset = 0; /* wrap back to beginning */ debug(81, 2) ("storeCossAllocate: wrap to 0\n"); - newmb = storeCossCreateMemBuf(SD, 0, checkf, &coll); + newmb = storeCossCreateMemBuf(SD, (size64_t)0, checkf, &coll); cs->current_membuf = newmb; /* Check if we have overflowed the MemBuf */ @@ -189,7 +194,7 @@ storeIOState *sio; char *p; CossState *cstate; - sfileno f = e->swap_filen; + off64_t f = e->swap_filen; CossInfo *cs = (CossInfo *) SD->fsdata; debug(81, 3) ("storeCossOpen: offset %d\n", f); @@ -307,7 +312,7 @@ storeCossReadDone(cs->fd, cstate->readbuffer, sio->st_size, - 0, + (size64_t)0, sio); } } @@ -325,6 +330,14 @@ */ assert(sio->e->mem_obj->object_sz != -1); + /* + * If someone for some reason supplies an offset, make sure they're + * streaming the data over + */ + if (offset > -1) { + assert(offset == sio->offset); + } + debug(81, 3) ("storeCossWrite: offset %d, len %d\n", sio->offset, size); diskoffset = COSS_BLK_TO_OFS((int64_t)sio->swap_filen) + sio->offset; dest = storeCossMemPointerFromDiskOffset(SD, diskoffset, &membuf); @@ -347,7 +360,7 @@ void *their_data = sio->read.callback_data; SwapDir *SD = INDEXSD(sio->swap_dirn); CossState *cstate = (CossState *) sio->fsstate; - size_t rlen; + ssize_t rlen; debug(81, 3) ("storeCossReadDone: fileno %d, FD %d, len %d\n", sio->swap_filen, fd, len); @@ -461,7 +474,7 @@ CossInfo *cs = (CossInfo *) SD->fsdata; CossMemBuf *t; dlink_node *m; - int end; + off64_t end; /* First, flush pending IO ops */ a_file_syncqueue(&cs->aq); @@ -475,7 +488,7 @@ sleep(5); /* XXX EEEWWW! */ lseek(cs->fd, t->diskstart, SEEK_SET); end = (t == cs->current_membuf) ? cs->current_offset : t->diskend; - write(cs->fd, t->buffer, end - t->diskstart); + write(cs->fd, t->buffer, (size_t)(end - t->diskstart)); } } @@ -488,7 +501,7 @@ t->flags.writing = 1; /* Remember that diskstart/diskend are block offsets! */ a_file_write(&cs->aq, cs->fd, t->diskstart, &t->buffer, - t->diskend - t->diskstart, storeCossWriteMemBufDone, t, NULL); + (size_t)(t->diskend - t->diskstart), storeCossWriteMemBufDone, t, NULL); } @@ -498,7 +511,7 @@ CossMemBuf *t = my_data; CossInfo *cs = (CossInfo *) t->SD->fsdata; - debug(81, 3) ("storeCossWriteMemBufDone: buf %08X, len %d\n", t, len); + debug(81, 3) ("storeCossWriteMemBufDone: fd %d, buf %08X, len %d\n", fd, t, len); if (errflag) debug(81, 0) ("storeCossMemBufWriteDone: got failure (%d)\n", errflag);