--------------------- PatchSet 365 Date: 2002/12/14 00:40:15 Author: rbcollins Branch: unify-io Tag: (none) Log: make creating objects a method Members: src/SwapDir.h:1.1.2.22->1.1.2.23 src/store_io.cc:1.3.10.8->1.3.10.9 src/ufscommon.h:1.1.20.44->1.1.20.45 src/fs/aufs/store_dir_aufs.cc:1.2.12.24->1.2.12.25 src/fs/coss/store_coss.h:1.3.10.20->1.3.10.21 src/fs/coss/store_dir_coss.cc:1.4.10.21->1.4.10.22 src/fs/coss/store_io_coss.cc:1.3.10.13->1.3.10.14 src/fs/diskd/store_dir_diskd.cc:1.2.16.32->1.2.16.33 src/fs/null/store_null.cc:1.1.20.10->1.1.20.11 src/fs/ufs/store_dir_ufs.cc:1.1.20.27->1.1.20.28 Index: squid3/src/SwapDir.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SwapDir.h,v retrieving revision 1.1.2.22 retrieving revision 1.1.2.23 diff -u -r1.1.2.22 -r1.1.2.23 --- squid3/src/SwapDir.h 14 Dec 2002 00:02:03 -0000 1.1.2.22 +++ squid3/src/SwapDir.h 14 Dec 2002 00:40:15 -0000 1.1.2.23 @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.1.2.22 2002/12/14 00:02:03 rbcollins Exp $ + * $Id: SwapDir.h,v 1.1.2.23 2002/12/14 00:40:15 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -75,8 +75,8 @@ virtual void dereference(StoreEntry &); /* Unreference this object */ 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 { - STOBJCREATE *create; STOBJOPEN *open; } obj; virtual void unlink (StoreEntry &); Index: squid3/src/store_io.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store_io.cc,v retrieving revision 1.3.10.8 retrieving revision 1.3.10.9 diff -u -r1.3.10.8 -r1.3.10.9 --- squid3/src/store_io.cc 13 Dec 2002 20:43:40 -0000 1.3.10.8 +++ squid3/src/store_io.cc 14 Dec 2002 00:40:16 -0000 1.3.10.9 @@ -22,6 +22,7 @@ StoreIOState::Pointer storeCreate(StoreEntry * e, STIOCB * file_callback, STIOCB * close_callback, void *callback_data) { + assert (e); ssize_t objsize; sdirno dirn; SwapDir *SD; @@ -46,7 +47,7 @@ SD = INDEXSD(dirn); /* Now that we have a fs to use, call its storeCreate function */ - StoreIOState::Pointer sio = SD->obj.create(SD, e, file_callback, close_callback, callback_data); + StoreIOState::Pointer sio = SD->createStoreIO(*e, file_callback, close_callback, callback_data); if (sio == NULL) store_io_stats.create.create_fail++; else @@ -54,7 +55,6 @@ return sio; } - /* * storeOpen() is purely for reading .. */ Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.44 retrieving revision 1.1.20.45 diff -u -r1.1.20.44 -r1.1.20.45 --- squid3/src/ufscommon.h 14 Dec 2002 00:02:03 -0000 1.1.20.44 +++ squid3/src/ufscommon.h 14 Dec 2002 00:40:16 -0000 1.1.20.45 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.44 2002/12/14 00:02:03 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.45 2002/12/14 00:40:16 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -77,6 +77,8 @@ extern STOBJCREATE commonUFSCreate; extern STOBJOPEN commonUFSOpen; +class UFSStrategy; + class UFSSwapDir : public SwapDir { public: UFSSwapDir(); @@ -91,11 +93,12 @@ virtual int canStore(StoreEntry const &)const = 0; virtual void reference(StoreEntry &); virtual void dereference(StoreEntry &); + virtual StoreIOState::Pointer createStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); void unlinkFile(sfileno f); // move down when unlink is a virtual method //protected: - IOStrategy *IO; + UFSStrategy *IO; char *fullPath(sfileno, char *) const; private: static EVH CleanEvent; 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.24 retrieving revision 1.2.12.25 diff -u -r1.2.12.24 -r1.2.12.25 --- squid3/src/fs/aufs/store_dir_aufs.cc 14 Dec 2002 00:02:03 -0000 1.2.12.24 +++ squid3/src/fs/aufs/store_dir_aufs.cc 14 Dec 2002 00:40:16 -0000 1.2.12.25 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.2.12.24 2002/12/14 00:02:03 rbcollins Exp $ + * $Id: store_dir_aufs.cc,v 1.2.12.25 2002/12/14 00:40:16 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.create = commonUFSCreate; sd->obj.open = commonUFSOpen; sd->log.open = commonUfsDirOpenSwapLog; sd->log.close = commonUfsDirCloseSwapLog; 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.20 retrieving revision 1.3.10.21 diff -u -r1.3.10.20 -r1.3.10.21 --- squid3/src/fs/coss/store_coss.h 14 Dec 2002 00:02:04 -0000 1.3.10.20 +++ squid3/src/fs/coss/store_coss.h 14 Dec 2002 00:40:16 -0000 1.3.10.21 @@ -114,6 +114,7 @@ virtual int canStore(StoreEntry const &)const; virtual int callback(); virtual void sync(); + virtual StoreIOState::Pointer createStoreIO(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.21 retrieving revision 1.4.10.22 diff -u -r1.4.10.21 -r1.4.10.22 --- squid3/src/fs/coss/store_dir_coss.cc 14 Dec 2002 00:02:05 -0000 1.4.10.21 +++ squid3/src/fs/coss/store_dir_coss.cc 14 Dec 2002 00:40:16 -0000 1.4.10.22 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.4.10.21 2002/12/14 00:02:05 rbcollins Exp $ + * $Id: store_dir_coss.cc,v 1.4.10.22 2002/12/14 00:40:16 rbcollins Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -756,7 +756,6 @@ cs->fd = -1; cs->swaplog_fd = -1; - sd->obj.create = storeCossCreate; sd->obj.open = storeCossOpen; sd->log.open = storeCossDirOpenSwapLog; 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.13 retrieving revision 1.3.10.14 diff -u -r1.3.10.13 -r1.3.10.14 --- squid3/src/fs/coss/store_io_coss.cc 14 Dec 2002 00:02:05 -0000 1.3.10.13 +++ squid3/src/fs/coss/store_io_coss.cc 14 Dec 2002 00:40:16 -0000 1.3.10.14 @@ -1,6 +1,6 @@ /* - * $Id: store_io_coss.cc,v 1.3.10.13 2002/12/14 00:02:05 rbcollins Exp $ + * $Id: store_io_coss.cc,v 1.3.10.14 2002/12/14 00:40:16 rbcollins Exp $ * * DEBUG: section 79 Storage Manager COSS Interface * AUTHOR: Eric Stern @@ -154,12 +154,10 @@ } StoreIOState::Pointer -storeCossCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * callback, void *callback_data) +CossSwapDir::createStoreIO(StoreEntry &e, STFNCB * file_callback, STIOCB * callback, void *callback_data) { CossState *cstate; - 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->offset_ = 0; sio->mode = O_WRONLY | O_BINARY; @@ -168,21 +166,21 @@ * If we get handed an object with a size of -1, * the squid code is broken */ - assert(e->mem_obj->object_sz != -1); + assert(e.mem_obj->object_sz != -1); /* * this one is kinda strange - Eric called storeCossAllocate(), then * storeCossOpen(O_RDONLY) .. weird. Anyway, I'm allocating this now. */ - cstate->st_size = objectLen(e) + e->mem_obj->swap_hdr_sz; - sio->swap_dirn = SD->index; - sio->swap_filen = storeCossAllocate(SD, e, COSS_ALLOC_ALLOCATE); + cstate->st_size = objectLen(&e) + e.mem_obj->swap_hdr_sz; + sio->swap_dirn = index; + sio->swap_filen = storeCossAllocate(this, &e, COSS_ALLOC_ALLOCATE); debug(79, 3) ("storeCossCreate: offset %d, size %ld, end %ld\n", sio->swap_filen, (long int) cstate->st_size, (long int) (sio->swap_filen + cstate->st_size)); sio->callback = callback; sio->file_callback = file_callback; sio->callback_data = cbdataReference(callback_data); - sio->e = (StoreEntry *) e; + sio->e = &e; cstate->flags.writing = 0; cstate->flags.reading = 0; @@ -190,9 +188,9 @@ cstate->reqdiskoffset = -1; /* Now add it into the index list */ - storeCossAdd(SD, e); + storeCossAdd(this, &e); - storeCossMemBufLock(SD, sio.getRaw()); + storeCossMemBufLock(this, sio.getRaw()); return sio; } 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.32 retrieving revision 1.2.16.33 diff -u -r1.2.16.32 -r1.2.16.33 --- squid3/src/fs/diskd/store_dir_diskd.cc 14 Dec 2002 00:02:06 -0000 1.2.16.32 +++ squid3/src/fs/diskd/store_dir_diskd.cc 14 Dec 2002 00:40:16 -0000 1.2.16.33 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.2.16.32 2002/12/14 00:02:06 rbcollins Exp $ + * $Id: store_dir_diskd.cc,v 1.2.16.33 2002/12/14 00:40:16 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.create = commonUFSCreate; sd->obj.open = commonUFSOpen; sd->log.open = commonUfsDirOpenSwapLog; sd->log.close = commonUfsDirCloseSwapLog; 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.10 retrieving revision 1.1.20.11 diff -u -r1.1.20.10 -r1.1.20.11 --- squid3/src/fs/null/store_null.cc 14 Dec 2002 00:02:07 -0000 1.1.20.10 +++ squid3/src/fs/null/store_null.cc 14 Dec 2002 00:40:16 -0000 1.1.20.11 @@ -1,6 +1,6 @@ /* - * $Id: store_null.cc,v 1.1.20.10 2002/12/14 00:02:07 rbcollins Exp $ + * $Id: store_null.cc,v 1.1.20.11 2002/12/14 00:40:16 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -47,6 +47,7 @@ public: virtual void init(); virtual int canStore(StoreEntry const &)const; + virtual StoreIOState::Pointer createStoreIO(StoreEntry &, STFNCB *, STIOCB *, void *); }; static int null_initialised = 0; @@ -85,6 +86,13 @@ NULL, 0.0, 1); } +StoreIOState::Pointer +NullSwapDir::createStoreIO(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.27 retrieving revision 1.1.20.28 diff -u -r1.1.20.27 -r1.1.20.28 --- squid3/src/fs/ufs/store_dir_ufs.cc 14 Dec 2002 00:02:07 -0000 1.1.20.27 +++ squid3/src/fs/ufs/store_dir_ufs.cc 14 Dec 2002 00:40:16 -0000 1.1.20.28 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.1.20.27 2002/12/14 00:02:07 rbcollins Exp $ + * $Id: store_dir_ufs.cc,v 1.1.20.28 2002/12/14 00:40:16 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.create = commonUFSCreate; sd->obj.open = commonUFSOpen; sd->log.open = commonUfsDirOpenSwapLog; sd->log.close = commonUfsDirCloseSwapLog; @@ -396,3 +395,9 @@ if (repl->Dereferenced) repl->Dereferenced(repl, &e, &e.repl); } + +StoreIOState::Pointer +UFSSwapDir::createStoreIO(StoreEntry &e, STFNCB * file_callback, STIOCB * callback, void *callback_data) +{ + return IO->create (this, &e, file_callback, callback, callback_data); +}