--------------------- PatchSet 250 Date: 2002/12/05 12:57:32 Author: rbcollins Branch: unify-io Tag: (none) Log: consolidate some members Members: src/IOStrategy.h:1.1.2.3->1.1.2.4 src/ufscommon.cc:1.4.10.3->1.4.10.4 src/ufscommon.h:1.1.20.3->1.1.20.4 src/fs/aufs/store_asyncufs.h:1.2.12.5->1.2.12.6 src/fs/aufs/store_io_aufs.cc:1.3.12.6->1.3.12.7 src/fs/coss/store_coss.h:1.3.10.5->1.3.10.6 src/fs/coss/store_io_coss.cc:1.3.10.5->1.3.10.6 src/fs/diskd/store_diskd.h:1.1.20.7->1.1.20.8 src/fs/diskd/store_io_diskd.cc:1.1.20.8->1.1.20.9 src/fs/null/store_null.cc:1.1.20.4->1.1.20.5 src/fs/ufs/store_io_ufs.cc:1.3.10.9->1.3.10.10 src/fs/ufs/store_ufs.h:1.1.20.7->1.1.20.8 Index: squid3/src/IOStrategy.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/IOStrategy.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/IOStrategy.h 3 Dec 2002 12:25:57 -0000 1.1.2.3 +++ squid3/src/IOStrategy.h 5 Dec 2002 12:57:32 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: IOStrategy.h,v 1.1.2.3 2002/12/03 12:25:57 rbcollins Exp $ + * $Id: IOStrategy.h,v 1.1.2.4 2002/12/05 12:57:32 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,12 +34,15 @@ #ifndef SQUID_IOSTRATEGY_H #define SQUID_IOSTRATEGY_H +#include "StoreIOState.h" + class IOStrategy { public: virtual bool shedLoad() = 0; virtual void deleteSelf() const = 0; virtual void openFailed(){} + virtual StoreIOState::Pointer createState(SwapDir *, StoreEntry *, STIOCB *, void *)const = 0; /* virtual void strategyStats(StoreEntry *sentry) const = 0; */ /* virtual void dumpCacheDirParams(StoreEntry * e, const char *option) const = 0; */ }; Index: squid3/src/ufscommon.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.cc,v retrieving revision 1.4.10.3 retrieving revision 1.4.10.4 diff -u -r1.4.10.3 -r1.4.10.4 --- squid3/src/ufscommon.cc 3 Dec 2002 12:25:57 -0000 1.4.10.3 +++ squid3/src/ufscommon.cc 5 Dec 2002 12:57:32 -0000 1.4.10.4 @@ -1,5 +1,5 @@ /* - * $Id: ufscommon.cc,v 1.4.10.3 2002/12/03 12:25:57 rbcollins Exp $ + * $Id: ufscommon.cc,v 1.4.10.4 2002/12/05 12:57:32 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -1633,6 +1633,6 @@ return 0; } -UFSStoreState::UFSStoreState(){} +UFSStoreState::UFSStoreState() : opening (false){} UFSStoreState::~UFSStoreState(){} Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.3 retrieving revision 1.1.20.4 diff -u -r1.1.20.3 -r1.1.20.4 --- squid3/src/ufscommon.h 5 Dec 2002 12:11:45 -0000 1.1.20.3 +++ squid3/src/ufscommon.h 5 Dec 2002 12:57:32 -0000 1.1.20.4 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.3 2002/12/05 12:11:45 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.4 2002/12/05 12:57:32 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -102,6 +102,10 @@ virtual void deleteSelf() const = 0; UFSStoreState(); ~UFSStoreState(); +// protected: + DiskFile::Pointer theFile; + bool opening; + protected: }; #endif /* SQUID_UFSCOMMON_H */ Index: squid3/src/fs/aufs/store_asyncufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_asyncufs.h,v retrieving revision 1.2.12.5 retrieving revision 1.2.12.6 diff -u -r1.2.12.5 -r1.2.12.6 --- squid3/src/fs/aufs/store_asyncufs.h 4 Dec 2002 12:06:49 -0000 1.2.12.5 +++ squid3/src/fs/aufs/store_asyncufs.h 5 Dec 2002 12:57:32 -0000 1.2.12.6 @@ -144,6 +144,7 @@ public: virtual bool shedLoad(); virtual void deleteSelf() const; + virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; static AufsIO Instance; }; Index: squid3/src/fs/aufs/store_io_aufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_io_aufs.cc,v retrieving revision 1.3.12.6 retrieving revision 1.3.12.7 diff -u -r1.3.12.6 -r1.3.12.7 --- squid3/src/fs/aufs/store_io_aufs.cc 3 Dec 2002 12:25:58 -0000 1.3.12.6 +++ squid3/src/fs/aufs/store_io_aufs.cc 5 Dec 2002 12:57:33 -0000 1.3.12.7 @@ -74,6 +74,13 @@ /* do nothing, we use a single instance */ } +StoreIOState::Pointer +AufsIO::createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const +{ + assert (0); + return NULL; +} + /* open for reading */ StoreIOState::Pointer storeAufsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, Index: squid3/src/fs/coss/store_coss.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/coss/store_coss.h,v retrieving revision 1.3.10.5 retrieving revision 1.3.10.6 diff -u -r1.3.10.5 -r1.3.10.6 --- squid3/src/fs/coss/store_coss.h 4 Dec 2002 12:34:58 -0000 1.3.10.5 +++ squid3/src/fs/coss/store_coss.h 5 Dec 2002 12:57:33 -0000 1.3.10.6 @@ -113,6 +113,7 @@ public: virtual bool shedLoad(); virtual void deleteSelf() const; + virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; static COSSIO Instance; }; #endif Index: squid3/src/fs/coss/store_io_coss.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/coss/store_io_coss.cc,v retrieving revision 1.3.10.5 retrieving revision 1.3.10.6 diff -u -r1.3.10.5 -r1.3.10.6 --- squid3/src/fs/coss/store_io_coss.cc 4 Dec 2002 12:06:51 -0000 1.3.10.5 +++ squid3/src/fs/coss/store_io_coss.cc 5 Dec 2002 12:57:33 -0000 1.3.10.6 @@ -1,6 +1,6 @@ /* - * $Id: store_io_coss.cc,v 1.3.10.5 2002/12/04 12:06:51 rbcollins Exp $ + * $Id: store_io_coss.cc,v 1.3.10.6 2002/12/05 12:57:33 rbcollins Exp $ * * DEBUG: section 79 Storage Manager COSS Interface * AUTHOR: Eric Stern @@ -68,6 +68,12 @@ /* Do nothing, we use a single instance */ } +StoreIOState::Pointer +COSSIO::createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const +{ + assert(0); + return NULL; +} MemPool *CossState::Pool = NULL; Index: squid3/src/fs/diskd/store_diskd.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_diskd.h,v retrieving revision 1.1.20.7 retrieving revision 1.1.20.8 diff -u -r1.1.20.7 -r1.1.20.8 --- squid3/src/fs/diskd/store_diskd.h 5 Dec 2002 12:11:46 -0000 1.1.20.7 +++ squid3/src/fs/diskd/store_diskd.h 5 Dec 2002 12:57:33 -0000 1.1.20.8 @@ -75,7 +75,6 @@ unsigned int writing:1; } flags; char *read_buf; - DiskFile::Pointer theFile; void ioCompletedNotification(); private: CBDATA_CLASS(diskdstate_t); @@ -151,6 +150,7 @@ virtual bool shedLoad(); virtual void deleteSelf() const; virtual void openFailed(); + virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; int away; int magic1; }; Index: squid3/src/fs/diskd/store_io_diskd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_io_diskd.cc,v retrieving revision 1.1.20.8 retrieving revision 1.1.20.9 diff -u -r1.1.20.8 -r1.1.20.9 --- squid3/src/fs/diskd/store_io_diskd.cc 5 Dec 2002 12:11:46 -0000 1.1.20.8 +++ squid3/src/fs/diskd/store_io_diskd.cc 5 Dec 2002 12:57:33 -0000 1.1.20.9 @@ -1,6 +1,6 @@ /* - * $Id: store_io_diskd.cc,v 1.1.20.8 2002/12/05 12:11:46 rbcollins Exp $ + * $Id: store_io_diskd.cc,v 1.1.20.9 2002/12/05 12:57:33 rbcollins Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -78,6 +78,12 @@ diskd_stats.open_fail_queue_len++; } +StoreIOState::Pointer +DiskdIO::createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const +{ + return new diskdstate_t (SD, e, callback, callback_data); +} + /* * SHM manipulation routines */ @@ -279,14 +285,19 @@ void diskdstate_t::ioCompletedNotification() { - debug(79, 3) ("storeDiskdOpenDone: dirno %d, fileno %08x status %d\n", - swap_dirn, swap_filen, theFile->error()); - if (theFile->error()) { - FILE_MODE(mode) == O_RDONLY ? diskd_stats.open.fail++ : diskd_stats.create.fail++; - storeDiskdIOCallback(this, DISK_ERROR); - } else { - FILE_MODE(mode) == O_RDONLY ? diskd_stats.open.success++ : diskd_stats.create.success++; + if (opening) { + opening = false; + debug(79, 3) ("storeDiskdOpenDone: dirno %d, fileno %08x status %d\n", + swap_dirn, swap_filen, theFile->error()); + if (theFile->error()) { + FILE_MODE(mode) == O_RDONLY ? diskd_stats.open.fail++ : diskd_stats.create.fail++; + storeDiskdIOCallback(this, DISK_ERROR); + } else { + FILE_MODE(mode) == O_RDONLY ? diskd_stats.open.success++ : diskd_stats.create.success++; + } + return; } + assert (0); } StoreIOState::Pointer @@ -298,15 +309,16 @@ SD->IO->openFailed(); return NULL; } - StoreIOState::Pointer sio = new diskdstate_t (SD, e, callback, callback_data); - //diskdstate_t *diskdstate = dynamic_cast(sio.getRaw()); + StoreIOState::Pointer sio = SD->IO->createState (SD, e, callback, callback_data); sio->mode |= O_RDONLY; diskdstate_t *diskdstate = dynamic_cast(sio.getRaw()); char *path = commonUfsDirFullPath(SD, e->swap_filen, NULL); DiskFile::Pointer myFile = new DiskdFile (path, (diskdinfo_t *)SD->fsdata, (DiskdIO *)SD->IO); + diskdstate->theFile = myFile; + diskdstate->opening = true; myFile->open (sio->mode, 0644, diskdstate); if (myFile->error()) return NULL; Index: squid3/src/fs/null/store_null.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/null/store_null.cc,v retrieving revision 1.1.20.4 retrieving revision 1.1.20.5 diff -u -r1.1.20.4 -r1.1.20.5 --- squid3/src/fs/null/store_null.cc 3 Dec 2002 02:05:30 -0000 1.1.20.4 +++ squid3/src/fs/null/store_null.cc 5 Dec 2002 12:57:33 -0000 1.1.20.5 @@ -1,6 +1,6 @@ /* - * $Id: store_null.cc,v 1.1.20.4 2002/12/03 02:05:30 rbcollins Exp $ + * $Id: store_null.cc,v 1.1.20.5 2002/12/05 12:57:33 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -47,6 +47,7 @@ public: virtual bool shedLoad(); virtual void deleteSelf() const; + virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; static NullIO Instance; }; @@ -74,6 +75,13 @@ /* Do nothing, we use a single instance */ } +StoreIOState::Pointer +NullIO::createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const +{ + assert (0); + return NULL; +} + static void storeNullDirReconfigure(SwapDir * sd, int index, char *path) { Index: squid3/src/fs/ufs/store_io_ufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/store_io_ufs.cc,v retrieving revision 1.3.10.9 retrieving revision 1.3.10.10 diff -u -r1.3.10.9 -r1.3.10.10 --- squid3/src/fs/ufs/store_io_ufs.cc 5 Dec 2002 12:11:46 -0000 1.3.10.9 +++ squid3/src/fs/ufs/store_io_ufs.cc 5 Dec 2002 12:57:33 -0000 1.3.10.10 @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.3.10.9 2002/12/05 12:11:46 rbcollins Exp $ + * $Id: store_io_ufs.cc,v 1.3.10.10 2002/12/05 12:57:33 rbcollins Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -58,6 +58,12 @@ /* Do nothing, we use a single instance */ } +StoreIOState::Pointer +UfsIO::createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const +{ + return new ufsstate_t (SD, e, callback, callback_data); +} + CBDATA_CLASS_INIT(ufsstate_t); void * @@ -88,7 +94,6 @@ callback = callback_; callback_data = cbdataReference(callback_data_); e = anEntry; - flags.opening = 0; flags.writing = 0; flags.reading = 0; flags.close_request = 0; @@ -134,8 +139,8 @@ void ufsstate_t::ioCompletedNotification() { - if (flags.opening) { - flags.opening = 0; + if (opening) { + opening = false; fd = theFile->getFD(); /* There is no 'opened' callback */ #if 0 @@ -159,7 +164,7 @@ SD->IO->openFailed(); return NULL; } - StoreIOState::Pointer sio = new ufsstate_t(SD,e, callback, callback_data); + StoreIOState::Pointer sio = SD->IO->createState (SD, e, callback, callback_data); sio->mode |= O_RDONLY; @@ -167,7 +172,7 @@ char *path = commonUfsDirFullPath(SD, e->swap_filen, NULL); DiskFile::Pointer myFile = new UFSFile (path); ufs->theFile = myFile; - ufs->flags.opening = 1; + ufs->opening = true; myFile->open (sio->mode, 0644, ufs); if (myFile->error()) Index: squid3/src/fs/ufs/store_ufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/Attic/store_ufs.h,v retrieving revision 1.1.20.7 retrieving revision 1.1.20.8 diff -u -r1.1.20.7 -r1.1.20.8 --- squid3/src/fs/ufs/store_ufs.h 5 Dec 2002 12:11:46 -0000 1.1.20.7 +++ squid3/src/fs/ufs/store_ufs.h 5 Dec 2002 12:57:33 -0000 1.1.20.8 @@ -30,12 +30,10 @@ ~ufsstate_t(); int fd; struct { - unsigned int opening:1; unsigned int close_request:1; unsigned int reading:1; unsigned int writing:1; } flags; - DiskFile::Pointer theFile; void ioCompletedNotification(); private: CBDATA_CLASS(ufsstate_t); @@ -58,6 +56,7 @@ public: virtual bool shedLoad(); virtual void deleteSelf() const; + virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; static UfsIO Instance; };