--------------------- PatchSet 366 Date: 2002/12/14 00:54:29 Author: rbcollins Branch: unify-io Tag: (none) Log: and make open into openStoreIO Members: src/SwapDir.h:1.1.2.23->1.1.2.24 src/store_io.cc:1.3.10.9->1.3.10.10 src/ufscommon.h:1.1.20.45->1.1.20.46 src/fs/aufs/store_dir_aufs.cc:1.2.12.25->1.2.12.26 src/fs/coss/store_coss.h:1.3.10.21->1.3.10.22 src/fs/coss/store_dir_coss.cc:1.4.10.22->1.4.10.23 src/fs/coss/store_io_coss.cc:1.3.10.14->1.3.10.15 src/fs/diskd/store_dir_diskd.cc:1.2.16.33->1.2.16.34 src/fs/diskd/store_diskd.h:1.1.20.41->1.1.20.42 src/fs/null/store_null.cc:1.1.20.11->1.1.20.12 src/fs/ufs/store_dir_ufs.cc:1.1.20.28->1.1.20.29 src/fs/ufs/store_io_ufs.cc:1.3.10.44->1.3.10.45 Index: squid3/src/SwapDir.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SwapDir.h,v retrieving revision 1.1.2.23 retrieving revision 1.1.2.24 diff -u -r1.1.2.23 -r1.1.2.24 --- squid3/src/SwapDir.h 14 Dec 2002 00:40:15 -0000 1.1.2.23 +++ squid3/src/SwapDir.h 14 Dec 2002 00:54:29 -0000 1.1.2.24 @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.1.2.23 2002/12/14 00:40:15 rbcollins Exp $ + * $Id: SwapDir.h,v 1.1.2.24 2002/12/14 00:54:29 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -36,8 +36,7 @@ #include "StoreIOState.h" -typedef StoreIOState::Pointer STOBJCREATE(SwapDir *, StoreEntry *, STFNCB *, STIOCB *, void *); -typedef StoreIOState::Pointer STOBJOPEN(SwapDir *, StoreEntry *, STFNCB *, STIOCB *, void *); + typedef void STOBJCLOSE(SwapDir *, storeIOState *); class IOStrategy; @@ -76,9 +75,7 @@ virtual int callback(); /* Handle pending callbacks */ virtual void sync(); /* Sync the store prior to shutdown */ virtual StoreIOState::Pointer createStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *) = 0; - struct { - STOBJOPEN *open; - } obj; + virtual StoreIOState::Pointer openStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *) = 0; virtual void unlink (StoreEntry &); struct { STLOGOPEN *open; Index: squid3/src/store_io.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store_io.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/store_io.cc 14 Dec 2002 00:40:16 -0000 1.3.10.9 +++ squid3/src/store_io.cc 14 Dec 2002 00:54:29 -0000 1.3.10.10 @@ -62,8 +62,7 @@ storeOpen(StoreEntry * e, STFNCB * file_callback, STIOCB * callback, void *callback_data) { - SwapDir *SD = INDEXSD(e->swap_dirn); - return SD->obj.open(SD, e, file_callback, callback, callback_data); + return INDEXSD(e->swap_dirn)->openStoreIO(*e, file_callback, callback, callback_data); } void Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.45 retrieving revision 1.1.20.46 diff -u -r1.1.20.45 -r1.1.20.46 --- squid3/src/ufscommon.h 14 Dec 2002 00:40:16 -0000 1.1.20.45 +++ squid3/src/ufscommon.h 14 Dec 2002 00:54:29 -0000 1.1.20.46 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.45 2002/12/14 00:40:16 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.46 2002/12/14 00:54:29 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -74,8 +74,6 @@ int commonUfsDirMapBitAllocate(SwapDir * SD); void commonUfsDirMapBitReset(SwapDir * SD, sfileno filn); #include "SwapDir.h" -extern STOBJCREATE commonUFSCreate; -extern STOBJOPEN commonUFSOpen; class UFSStrategy; @@ -94,6 +92,7 @@ virtual void reference(StoreEntry &); virtual void dereference(StoreEntry &); virtual StoreIOState::Pointer createStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); + virtual StoreIOState::Pointer openStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); void unlinkFile(sfileno f); // move down when unlink is a virtual method Index: squid3/src/fs/aufs/store_dir_aufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_dir_aufs.cc,v retrieving revision 1.2.12.25 retrieving revision 1.2.12.26 diff -u -r1.2.12.25 -r1.2.12.26 --- squid3/src/fs/aufs/store_dir_aufs.cc 14 Dec 2002 00:40:16 -0000 1.2.12.25 +++ squid3/src/fs/aufs/store_dir_aufs.cc 14 Dec 2002 00:54:29 -0000 1.2.12.26 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.2.12.25 2002/12/14 00:40:16 rbcollins Exp $ + * $Id: store_dir_aufs.cc,v 1.2.12.26 2002/12/14 00:54:29 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -188,7 +188,6 @@ aioinfo->map = NULL; /* Debugging purposes */ aioinfo->suggest = 0; aioinfo->io.storeDirUnlinkFile = storeAufsDirIOUnlinkFile; - sd->obj.open = commonUFSOpen; sd->log.open = commonUfsDirOpenSwapLog; sd->log.close = commonUfsDirCloseSwapLog; sd->log.write = commonUfsDirSwapLog; 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.21 retrieving revision 1.3.10.22 diff -u -r1.3.10.21 -r1.3.10.22 --- squid3/src/fs/coss/store_coss.h 14 Dec 2002 00:40:16 -0000 1.3.10.21 +++ squid3/src/fs/coss/store_coss.h 14 Dec 2002 00:54:29 -0000 1.3.10.22 @@ -96,12 +96,6 @@ extern MemPool *coss_membuf_pool; extern MemPool *coss_index_pool; -/* - * Store IO stuff - */ -extern STOBJCREATE storeCossCreate; -extern STOBJOPEN storeCossOpen; - class CossSwapDir : public SwapDir { public: @@ -115,6 +109,7 @@ virtual int callback(); virtual void sync(); virtual StoreIOState::Pointer createStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); + virtual StoreIOState::Pointer openStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); }; extern off_t storeCossAllocate(SwapDir * SD, const StoreEntry * e, int which); Index: squid3/src/fs/coss/store_dir_coss.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/coss/store_dir_coss.cc,v retrieving revision 1.4.10.22 retrieving revision 1.4.10.23 diff -u -r1.4.10.22 -r1.4.10.23 --- squid3/src/fs/coss/store_dir_coss.cc 14 Dec 2002 00:40:16 -0000 1.4.10.22 +++ squid3/src/fs/coss/store_dir_coss.cc 14 Dec 2002 00:54:29 -0000 1.4.10.23 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.4.10.22 2002/12/14 00:40:16 rbcollins Exp $ + * $Id: store_dir_coss.cc,v 1.4.10.23 2002/12/14 00:54:29 rbcollins Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -756,8 +756,6 @@ cs->fd = -1; cs->swaplog_fd = -1; - sd->obj.open = storeCossOpen; - sd->log.open = storeCossDirOpenSwapLog; sd->log.close = storeCossDirCloseSwapLog; sd->log.write = storeCossDirSwapLog; 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.14 retrieving revision 1.3.10.15 diff -u -r1.3.10.14 -r1.3.10.15 --- squid3/src/fs/coss/store_io_coss.cc 14 Dec 2002 00:40:16 -0000 1.3.10.14 +++ squid3/src/fs/coss/store_io_coss.cc 14 Dec 2002 00:54:29 -0000 1.3.10.15 @@ -1,6 +1,6 @@ /* - * $Id: store_io_coss.cc,v 1.3.10.14 2002/12/14 00:40:16 rbcollins Exp $ + * $Id: store_io_coss.cc,v 1.3.10.15 2002/12/14 00:54:29 rbcollins Exp $ * * DEBUG: section 79 Storage Manager COSS Interface * AUTHOR: Eric Stern @@ -195,36 +195,34 @@ } StoreIOState::Pointer -storeCossOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, +CossSwapDir::openStoreIO(StoreEntry & e, STFNCB * file_callback, STIOCB * callback, void *callback_data) { char *p; CossState *cstate; - sfileno f = e->swap_filen; - CossInfo *cs = (CossInfo *) SD->fsdata; + sfileno f = e.swap_filen; + CossInfo *cs = (CossInfo *) fsdata; debug(79, 3) ("storeCossOpen: offset %d\n", f); - CossSwapDir *CSD = dynamic_cast(SD); - assert (CSD); - StoreIOState::Pointer sio = new CossState (CSD); + StoreIOState::Pointer sio = new CossState (this); cstate = dynamic_cast(sio.getRaw()); sio->swap_filen = f; - sio->swap_dirn = SD->index; + sio->swap_dirn = index; sio->offset_ = 0; sio->mode = O_RDONLY | O_BINARY; sio->callback = callback; sio->file_callback = file_callback; sio->callback_data = cbdataReference(callback_data); - cstate->st_size = e->swap_file_sz; - sio->e = e; + cstate->st_size = e.swap_file_sz; + sio->e = &e; cstate->flags.writing = 0; cstate->flags.reading = 0; cstate->readbuffer = NULL; cstate->reqdiskoffset = -1; - p = storeCossMemPointerFromDiskOffset(SD, f, NULL); + p = storeCossMemPointerFromDiskOffset(this, f, NULL); /* make local copy so we don't have to lock membuf */ if (p) { cstate->readbuffer = (char *)xmalloc(cstate->st_size); @@ -242,11 +240,11 @@ */ cstate->reqdiskoffset = sio->swap_filen; sio->swap_filen = -1; - sio->swap_filen = storeCossAllocate(SD, e, COSS_ALLOC_REALLOC); + sio->swap_filen = storeCossAllocate(this, &e, COSS_ALLOC_REALLOC); if (sio->swap_filen == -1) { /* We have to clean up neatly .. */ cs->numcollisions++; - debug(79, 2) ("storeCossOpen: Reallocation of %d/%d failed\n", e->swap_dirn, e->swap_filen); + debug(79, 2) ("storeCossOpen: Reallocation of %d/%d failed\n", e.swap_dirn, e.swap_filen); /* XXX XXX XXX Will squid call storeUnlink for this object? */ return NULL; } @@ -257,13 +255,13 @@ * lock the buffer so it doesn't get swapped out on us * this will get unlocked in storeCossReadDone */ - storeCossMemBufLock(SD, sio.getRaw()); + storeCossMemBufLock(this, sio.getRaw()); /* * Do the index magic to keep the disk and memory LRUs identical */ - storeCossRemove(SD, e); - storeCossAdd(SD, e); + storeCossRemove(this, &e); + storeCossAdd(this, &e); /* * Since we've reallocated a spot for this object, we need to Index: squid3/src/fs/diskd/store_dir_diskd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_dir_diskd.cc,v retrieving revision 1.2.16.33 retrieving revision 1.2.16.34 diff -u -r1.2.16.33 -r1.2.16.34 --- squid3/src/fs/diskd/store_dir_diskd.cc 14 Dec 2002 00:40:16 -0000 1.2.16.33 +++ squid3/src/fs/diskd/store_dir_diskd.cc 14 Dec 2002 00:54:29 -0000 1.2.16.34 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.2.16.33 2002/12/14 00:40:16 rbcollins Exp $ + * $Id: store_dir_diskd.cc,v 1.2.16.34 2002/12/14 00:54:29 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -393,7 +393,6 @@ ufsinfo->map = NULL; /* Debugging purposes */ ufsinfo->suggest = 0; ufsinfo->io.storeDirUnlinkFile = storeDiskdDirIOUnlinkFile; - sd->obj.open = commonUFSOpen; sd->log.open = commonUfsDirOpenSwapLog; sd->log.close = commonUfsDirCloseSwapLog; sd->log.write = commonUfsDirSwapLog; 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.41 retrieving revision 1.1.20.42 diff -u -r1.1.20.41 -r1.1.20.42 --- squid3/src/fs/diskd/store_diskd.h 13 Dec 2002 23:23:32 -0000 1.1.20.41 +++ squid3/src/fs/diskd/store_diskd.h 14 Dec 2002 00:54:29 -0000 1.1.20.42 @@ -129,13 +129,6 @@ extern void storeDiskdHandle(diomsg * M); #include "SwapDir.h" - -/* - * Store IO stuff - */ -extern STOBJCREATE storeDiskdCreate; -extern STOBJOPEN storeDiskdOpen; - class DiskdSwapDir : public UFSSwapDir { public: 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.11 retrieving revision 1.1.20.12 diff -u -r1.1.20.11 -r1.1.20.12 --- squid3/src/fs/null/store_null.cc 14 Dec 2002 00:40:16 -0000 1.1.20.11 +++ squid3/src/fs/null/store_null.cc 14 Dec 2002 00:54:29 -0000 1.1.20.12 @@ -1,6 +1,6 @@ /* - * $Id: store_null.cc,v 1.1.20.11 2002/12/14 00:40:16 rbcollins Exp $ + * $Id: store_null.cc,v 1.1.20.12 2002/12/14 00:54:29 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -48,6 +48,7 @@ virtual void init(); virtual int canStore(StoreEntry const &)const; virtual StoreIOState::Pointer createStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); + virtual StoreIOState::Pointer openStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); }; static int null_initialised = 0; @@ -93,6 +94,13 @@ return NULL; } +StoreIOState::Pointer +NullSwapDir::openStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *) +{ + fatal ("Attempt to get a StoreIO from the NULL store!\n"); + return NULL; +} + static void storeNullDirRebuildComplete(void *unused) { Index: squid3/src/fs/ufs/store_dir_ufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/store_dir_ufs.cc,v retrieving revision 1.1.20.28 retrieving revision 1.1.20.29 diff -u -r1.1.20.28 -r1.1.20.29 --- squid3/src/fs/ufs/store_dir_ufs.cc 14 Dec 2002 00:40:16 -0000 1.1.20.28 +++ squid3/src/fs/ufs/store_dir_ufs.cc 14 Dec 2002 00:54:29 -0000 1.1.20.29 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.1.20.28 2002/12/14 00:40:16 rbcollins Exp $ + * $Id: store_dir_ufs.cc,v 1.1.20.29 2002/12/14 00:54:29 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -169,7 +169,6 @@ ufsinfo->map = NULL; /* Debugging purposes */ ufsinfo->suggest = 0; ufsinfo->io.storeDirUnlinkFile = storeUfsDirIOUnlinkFile; - sd->obj.open = commonUFSOpen; sd->log.open = commonUfsDirOpenSwapLog; sd->log.close = commonUfsDirCloseSwapLog; sd->log.write = commonUfsDirSwapLog; @@ -401,3 +400,9 @@ { return IO->create (this, &e, file_callback, callback, callback_data); } + +StoreIOState::Pointer +UFSSwapDir::openStoreIO(StoreEntry &e, STFNCB * file_callback, STIOCB * callback, void *callback_data) +{ + return IO->open (this, &e, file_callback, callback, callback_data); +} 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.44 retrieving revision 1.3.10.45 diff -u -r1.3.10.44 -r1.3.10.45 --- squid3/src/fs/ufs/store_io_ufs.cc 14 Dec 2002 00:02:08 -0000 1.3.10.44 +++ squid3/src/fs/ufs/store_io_ufs.cc 14 Dec 2002 00:54:29 -0000 1.3.10.45 @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.3.10.44 2002/12/14 00:02:08 rbcollins Exp $ + * $Id: store_io_ufs.cc,v 1.3.10.45 2002/12/14 00:54:29 rbcollins Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -213,23 +213,6 @@ storeUfsIOCallback(this, theFile->error() ? 0 : -1); } -StoreIOState::Pointer -commonUFSOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, - STIOCB * callback, void *callback_data) -{ - UFSStrategy *IO = dynamic_cast (((UfsSwapDir *)SD)->IO); - assert (IO); - return IO->open (SD, e, file_callback, callback, callback_data); -} - -StoreIOState::Pointer -commonUFSCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * callback, void *callback_data) -{ - UFSStrategy *IO = dynamic_cast (((UfsSwapDir *)SD)->IO); - assert (IO); - return IO->create (SD, e, file_callback, callback, callback_data); -} - void ufsstate_t::close() {