--------------------- PatchSet 576 Date: 2000/09/16 21:49:46 Author: hno Branch: hno-devel Tag: (none) Log: Added #ifdefs for not making certain operations async Members: src/fs/aufs/store_asyncufs.h:1.1.6.3.2.5->1.1.6.3.2.6 src/fs/aufs/store_io_aufs.c:1.1.6.6.2.5->1.1.6.6.2.6 Index: squid/src/fs/aufs/store_asyncufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_asyncufs.h,v retrieving revision 1.1.6.3.2.5 retrieving revision 1.1.6.3.2.6 diff -u -r1.1.6.3.2.5 -r1.1.6.3.2.6 --- squid/src/fs/aufs/store_asyncufs.h 16 Sep 2000 20:48:01 -0000 1.1.6.3.2.5 +++ squid/src/fs/aufs/store_asyncufs.h 16 Sep 2000 21:49:46 -0000 1.1.6.3.2.6 @@ -18,6 +18,13 @@ /* Queue limit where swapins are deferred (open/create fails) */ #define MAGIC2 (NUMTHREADS*Config.cacheSwap.n_configured*20) +/* Which operations to run async */ +#define ASYNC_OPEN 1 +#define ASYNC_CLOSE 0 +#define ASYNC_WRITE 0 +#define ASYNC_READ 1 +/* #define ASYNC_UNLINK 1 */ /* not yet conditional */ + struct _aio_result_t { int aio_return; int aio_errno; Index: squid/src/fs/aufs/store_io_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_io_aufs.c,v retrieving revision 1.1.6.6.2.5 retrieving revision 1.1.6.6.2.6 diff -u -r1.1.6.6.2.5 -r1.1.6.6.2.6 --- squid/src/fs/aufs/store_io_aufs.c 16 Sep 2000 20:48:01 -0000 1.1.6.6.2.5 +++ squid/src/fs/aufs/store_io_aufs.c 16 Sep 2000 21:49:46 -0000 1.1.6.6.2.6 @@ -6,8 +6,16 @@ #include "squid.h" #include "store_asyncufs.h" +#if ASYNC_READ static AIOCB storeAufsReadDone; +#else +static DRCB storeAufsReadDone; +#endif +#if ASYNC_WRITE static AIOCB storeAufsWriteDone; +#else +static DWCB storeAufsWriteDone; +#endif static void storeAufsIOCallback(storeIOState * sio, int errflag); static AIOCB storeAufsOpenDone; static int storeAufsSomethingPending(storeIOState *); @@ -39,6 +47,9 @@ sfileno f = e->swap_filen; char *path = storeAufsDirFullPath(SD, f, NULL); storeIOState *sio; +#if !ASYNC_OPEN + int fd; +#endif debug(78, 3) ("storeAufsOpen: fileno %08X\n", f); /* * we should detect some 'too many files open' condition and return @@ -48,6 +59,13 @@ if (aioQueueSize() > MAGIC2) return NULL; #endif +#if !ASYNC_OPEN + fd = file_open(path, O_RDONLY); + if (fd < 0) { + debug(78, 3) ("storeAufsOpen: got failude (%d)\n", errno); + return NULL; + } +#endif sio = memAllocate(MEM_STORE_IO); cbdataAdd(sio, storeAufsIOFreeEntry, MEM_STORE_IO); sio->fsstate = memPoolAlloc(aio_state_pool); @@ -60,8 +78,12 @@ sio->callback_data = callback_data; sio->e = e; cbdataLock(callback_data); - aioOpen(path, O_RDONLY, 0644, storeAufsOpenDone, sio); Opening_FD++; +#if ASYNC_OPEN + aioOpen(path, O_RDONLY, 0644, storeAufsOpenDone, sio); +#else + storeAufsOpenDone(fd, sio, fd, 0); +#endif store_open_disk_fd++; return sio; } @@ -74,6 +96,9 @@ storeIOState *sio; sfileno filn; sdirno dirn; +#if !ASYNC_CREATE + int fd; +#endif /* Allocate a number */ dirn = SD->index; @@ -89,6 +114,13 @@ if (aioQueueSize() > MAGIC2) return NULL; #endif +#if !ASYNC_OPEN + fd = file_open(path, O_WRONLY | O_CREAT | O_TRUNC); + if (fd < 0) { + debug(78, 3) ("storeAufsCreate: got failude (%d)\n", errno); + return NULL; + } +#endif sio = memAllocate(MEM_STORE_IO); cbdataAdd(sio, storeAufsIOFreeEntry, MEM_STORE_IO); sio->fsstate = memPoolAlloc(aio_state_pool); @@ -101,8 +133,12 @@ sio->callback_data = callback_data; sio->e = (StoreEntry *) e; cbdataLock(callback_data); - aioOpen(path, O_WRONLY | O_CREAT | O_TRUNC, 0644, storeAufsOpenDone, sio); Opening_FD++; +#if ASYNC_CREATE + aioOpen(path, O_WRONLY | O_CREAT | O_TRUNC, 0644, storeAufsOpenDone, sio); +#else + storeAufsOpenDone(fd, sio, fd, 0); +#endif store_open_disk_fd++; /* now insert into the replacement policy */ @@ -158,7 +194,11 @@ sio->swap_dirn, sio->swap_filen, aiostate->fd); sio->offset = offset; aiostate->flags.reading = 1; +#if ASYNC_READ aioRead(aiostate->fd, offset, buf, size, storeAufsReadDone, sio); +#else + file_read(aiostate->fd, offset, buf, size, storeAufsReadDone, sio); +#endif } @@ -197,9 +237,16 @@ * XXX it might be nice if aioWrite() gave is immediate * feedback here about EWOULDBLOCK instead of in the * callback function + * XXX Should never give EWOULDBLOCK under normal operations + * if it does then the MAGIC1/2 tuning is wrong. */ +#if ASYNC_WRITE aioWrite(aiostate->fd, offset, buf, size, storeAufsWriteDone, sio, free_func); +#else + file_write(aiostate->fd, offset, buf, size, storeAufsWriteDone, sio, + free_func); +#endif } /* Unlink */ @@ -267,8 +314,20 @@ debug(78, 3) ("storeAufsOpenDone: exiting\n"); } +/* + * XXX TODO + * if errflag == EWOULDBLOCK, then we'll need to re-queue the + * chunk at the beginning of the write_pending list and try + * again later. + * XXX Should not normally happen. + */ +#if ASYNC_READ static void storeAufsReadDone(int fd, void *my_data, int len, int errflag) +#else +static void +storeAufsReadDone(int fd, int errflag, size_t len, void *my_data) +#endif { storeIOState *sio = my_data; aiostate_t *aiostate = (aiostate_t *) sio->fsstate; @@ -306,9 +365,15 @@ * if errflag == EWOULDBLOCK, then we'll need to re-queue the * chunk at the beginning of the write_pending list and try * again later. + * XXX Should not normally happen. */ +#if ASYNC_WRITE static void storeAufsWriteDone(int fd, void *my_data, int len, int errflag) +#else +static void +storeAufsWriteDone(int fd, int errflag, size_t len, void *my_data) +#endif { static int loop_detect = 0; storeIOState *sio = my_data;