--------------------- PatchSet 239 Date: 2002/12/03 00:47:02 Author: rbcollins Branch: unify-io Tag: (none) Log: make IOStrategies mandatory Members: src/Makefile.am:1.10.10.2->1.10.10.3 src/Store.h:1.3->1.3.16.1 src/SwapDir.cc:1.1.2.2->1.1.2.3 src/SwapDir.h:1.1.2.2->1.1.2.3 src/typedefs.h:1.6.10.2->1.6.10.3 src/fs/aufs/store_asyncufs.h:1.2->1.2.12.1 src/fs/aufs/store_dir_aufs.cc:1.2.12.2->1.2.12.3 src/fs/aufs/store_io_aufs.cc:1.3.12.1->1.3.12.2 src/fs/coss/store_coss.h:1.3->1.3.10.1 src/fs/coss/store_dir_coss.cc:1.4.10.2->1.4.10.3 src/fs/coss/store_io_coss.cc:1.3.10.1->1.3.10.2 src/fs/diskd/store_dir_diskd.cc:1.2.16.2->1.2.16.3 src/fs/diskd/store_diskd.h:1.1->1.1.20.1 src/fs/diskd/store_io_diskd.cc:1.1.20.1->1.1.20.2 src/fs/null/store_null.cc:1.1.20.2->1.1.20.3 src/fs/ufs/store_dir_ufs.cc:1.1.20.2->1.1.20.3 src/fs/ufs/store_io_ufs.cc:1.3.10.1->1.3.10.2 src/fs/ufs/store_ufs.h:1.1->1.1.20.1 Index: squid3/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v retrieving revision 1.10.10.2 retrieving revision 1.10.10.3 diff -u -r1.10.10.2 -r1.10.10.3 --- squid3/src/Makefile.am 2 Dec 2002 23:33:35 -0000 1.10.10.2 +++ squid3/src/Makefile.am 3 Dec 2002 00:47:02 -0000 1.10.10.3 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.10.10.2 2002/12/02 23:33:35 rbcollins Exp $ +# $Id: Makefile.am,v 1.10.10.3 2002/12/03 00:47:02 rbcollins Exp $ # # Uncomment and customize the following to suit your needs: # @@ -262,7 +262,7 @@ @SSLLIB@ \ -lmiscutil \ @XTRA_LIBS@ -squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a +squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a @STORE_OBJS@ unlinkd_SOURCES = unlinkd.cc unlinkd_CXXFLAGS = -DUNLINK_DAEMON Index: squid3/src/Store.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Store.h,v retrieving revision 1.3 retrieving revision 1.3.16.1 diff -u -r1.3 -r1.3.16.1 --- squid3/src/Store.h 15 Oct 2002 09:27:20 -0000 1.3 +++ squid3/src/Store.h 3 Dec 2002 00:47:02 -0000 1.3.16.1 @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.3 2002/10/15 09:27:20 squidadm Exp $ + * $Id: Store.h,v 1.3.16.1 2002/12/03 00:47:02 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -149,6 +149,7 @@ SQUIDCEXTERN void storeSwapFileNumberSet(StoreEntry * e, sfileno filn); SQUIDCEXTERN void storeFsInit(void); SQUIDCEXTERN void storeFsDone(void); +typedef void STSETUP(storefs_entry_t *); SQUIDCEXTERN void storeFsAdd(const char *, STSETUP *); SQUIDCEXTERN void storeReplAdd(const char *, REMOVALPOLICYCREATE *); Index: squid3/src/SwapDir.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SwapDir.cc,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/SwapDir.cc 3 Dec 2002 00:08:45 -0000 1.1.2.2 +++ squid3/src/SwapDir.cc 3 Dec 2002 00:47:02 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.cc,v 1.1.2.2 2002/12/03 00:08:45 rbcollins Exp $ + * $Id: SwapDir.cc,v 1.1.2.3 2002/12/03 00:47:02 rbcollins Exp $ * * DEBUG: section ?? Swap Dir base object * AUTHOR: Robert Collins @@ -40,6 +40,7 @@ SwapDir::Factory (_storefs_entry const &fs) { SwapDir *result = fs.newfunc(); + assert (result->IO); result->type = fs.typestr; return result; } Index: squid3/src/SwapDir.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SwapDir.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/SwapDir.h 2 Dec 2002 23:33:36 -0000 1.1.2.2 +++ squid3/src/SwapDir.h 3 Dec 2002 00:47:02 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.1.2.2 2002/12/02 23:33:36 rbcollins Exp $ + * $Id: SwapDir.h,v 1.1.2.3 2002/12/03 00:47:02 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,13 +34,30 @@ #ifndef SQUID_SWAPDIR_H #define SQUID_SWAPDIR_H +typedef void STINIT(SwapDir *); +typedef void STNEWFS(SwapDir *); +typedef void STDUMP(StoreEntry *, SwapDir *); +typedef void STFREE(SwapDir *); +typedef int STDBLCHECK(SwapDir *, StoreEntry *); +typedef void STSTATFS(SwapDir *, StoreEntry *); +typedef void STMAINTAINFS(SwapDir *); +typedef int STCHECKOBJ(SwapDir *, const StoreEntry *); +typedef void STREFOBJ(SwapDir *, StoreEntry *); +typedef void STUNREFOBJ(SwapDir *, StoreEntry *); +typedef void STDONE(void); +typedef int STCALLBACK(SwapDir *); +typedef void STSYNC(SwapDir *); + +class IOStrategy; + struct SwapDir { public: static SwapDir *Factory (_storefs_entry const &fs); - SwapDir() : max_objsize (-1) { + SwapDir() : IO(NULL), max_objsize (-1){ fs.blksize = 1024; } const char *type; + IOStrategy *IO; int cur_size; int low_size; int max_size; Index: squid3/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/typedefs.h,v retrieving revision 1.6.10.2 retrieving revision 1.6.10.3 diff -u -r1.6.10.2 -r1.6.10.3 --- squid3/src/typedefs.h 3 Dec 2002 00:08:45 -0000 1.6.10.2 +++ squid3/src/typedefs.h 3 Dec 2002 00:47:02 -0000 1.6.10.3 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.6.10.2 2002/12/03 00:08:45 rbcollins Exp $ + * $Id: typedefs.h,v 1.6.10.3 2002/12/03 00:47:02 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -245,20 +245,6 @@ typedef void HLPCMDOPTS(int *argc, char **argv); typedef void IDNSCB(void *, rfc1035_rr *, int); -typedef void STINIT(SwapDir *); -typedef void STNEWFS(SwapDir *); -typedef void STDUMP(StoreEntry *, SwapDir *); -typedef void STFREE(SwapDir *); -typedef int STDBLCHECK(SwapDir *, StoreEntry *); -typedef void STSTATFS(SwapDir *, StoreEntry *); -typedef void STMAINTAINFS(SwapDir *); -typedef int STCHECKOBJ(SwapDir *, const StoreEntry *); -typedef void STREFOBJ(SwapDir *, StoreEntry *); -typedef void STUNREFOBJ(SwapDir *, StoreEntry *); -typedef void STSETUP(storefs_entry_t *); -typedef void STDONE(void); -typedef int STCALLBACK(SwapDir *); -typedef void STSYNC(SwapDir *); typedef storeIOState *STOBJCREATE(SwapDir *, StoreEntry *, STFNCB *, STIOCB *, void *); typedef storeIOState *STOBJOPEN(SwapDir *, StoreEntry *, STFNCB *, STIOCB *, void *); 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 retrieving revision 1.2.12.1 diff -u -r1.2 -r1.2.12.1 --- squid3/src/fs/aufs/store_asyncufs.h 11 Nov 2002 17:31:56 -0000 1.2 +++ squid3/src/fs/aufs/store_asyncufs.h 3 Dec 2002 00:47:03 -0000 1.2.12.1 @@ -128,4 +128,12 @@ extern STOBJWRITE storeAufsWrite; extern STOBJUNLINK storeAufsUnlink; +#include "IOStrategy.h" +class AufsIO : public IOStrategy +{ +public: + virtual bool shedLoad(); + static AufsIO Instance; +}; + #endif 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.2 retrieving revision 1.2.12.3 diff -u -r1.2.12.2 -r1.2.12.3 --- squid3/src/fs/aufs/store_dir_aufs.cc 3 Dec 2002 00:08:45 -0000 1.2.12.2 +++ squid3/src/fs/aufs/store_dir_aufs.cc 3 Dec 2002 00:47:03 -0000 1.2.12.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.2.12.2 2002/12/03 00:08:45 rbcollins Exp $ + * $Id: store_dir_aufs.cc,v 1.2.12.3 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -54,12 +54,6 @@ /* The MAIN externally visible function */ STSETUP storeFsSetup_aufs; -class AufsIO : public IOStrategy -{ -public: - virtual bool shedLoad(); -}; - /* * storeAufsDirCheckObj * @@ -244,7 +238,9 @@ static SwapDir * storeAufsNew(void) { - return new SwapDir; + SwapDir *result = new SwapDir; + result->IO = &AufsIO::Instance; + return result; } void 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.1 retrieving revision 1.3.12.2 diff -u -r1.3.12.1 -r1.3.12.2 --- squid3/src/fs/aufs/store_io_aufs.cc 2 Dec 2002 14:42:16 -0000 1.3.12.1 +++ squid3/src/fs/aufs/store_io_aufs.cc 3 Dec 2002 00:47:03 -0000 1.3.12.2 @@ -47,6 +47,20 @@ return sio; } +AufsIO AufsIO::Instance; +bool +AufsIO::shedLoad() +{ + /* + * we should detect some 'too many files open' condition and return + * NULL here. + */ +#ifdef MAGIC2 + if (aioQueueSize() > MAGIC2) + return true; +#endif + return false; +} /* open for reading */ storeIOState * 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 retrieving revision 1.3.10.1 diff -u -r1.3 -r1.3.10.1 --- squid3/src/fs/coss/store_coss.h 18 Nov 2002 03:12:57 -0000 1.3 +++ squid3/src/fs/coss/store_coss.h 3 Dec 2002 00:47:03 -0000 1.3.10.1 @@ -1,6 +1,8 @@ #ifndef __COSS_H__ #define __COSS_H__ +#include "SwapDir.h" + #ifndef COSS_MEMBUF_SZ #define COSS_MEMBUF_SZ 1048576 #endif @@ -96,4 +98,11 @@ extern void storeCossRemove(SwapDir *, StoreEntry *); extern void storeCossStartMembuf(SwapDir * SD); +#include "IOStrategy.h" +class COSSIO : public IOStrategy +{ +public: + virtual bool shedLoad(); + static COSSIO Instance; +}; #endif 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.2 retrieving revision 1.4.10.3 diff -u -r1.4.10.2 -r1.4.10.3 --- squid3/src/fs/coss/store_dir_coss.cc 3 Dec 2002 00:08:45 -0000 1.4.10.2 +++ squid3/src/fs/coss/store_dir_coss.cc 3 Dec 2002 00:47:03 -0000 1.4.10.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.4.10.2 2002/12/03 00:08:45 rbcollins Exp $ + * $Id: store_dir_coss.cc,v 1.4.10.3 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -894,7 +894,9 @@ static SwapDir * storeCossNew(void) { - return new SwapDir; + SwapDir *result = new SwapDir; + result->IO = &COSSIO::Instance; + return result; } void 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.1 retrieving revision 1.3.10.2 diff -u -r1.3.10.1 -r1.3.10.2 --- squid3/src/fs/coss/store_io_coss.cc 2 Dec 2002 14:42:17 -0000 1.3.10.1 +++ squid3/src/fs/coss/store_io_coss.cc 3 Dec 2002 00:47:03 -0000 1.3.10.2 @@ -1,6 +1,6 @@ /* - * $Id: store_io_coss.cc,v 1.3.10.1 2002/12/02 14:42:17 rbcollins Exp $ + * $Id: store_io_coss.cc,v 1.3.10.2 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 79 Storage Manager COSS Interface * AUTHOR: Eric Stern @@ -57,6 +57,14 @@ /* === PUBLIC =========================================================== */ +COSSIO COSSIO::Instance; + +bool +COSSIO::shedLoad() +{ + return false; +} + /* * This routine sucks. I want to rewrite it when possible, and I also think * that we should check after creatmembuf() to see if the object has a 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.2 retrieving revision 1.2.16.3 diff -u -r1.2.16.2 -r1.2.16.3 --- squid3/src/fs/diskd/store_dir_diskd.cc 3 Dec 2002 00:08:46 -0000 1.2.16.2 +++ squid3/src/fs/diskd/store_dir_diskd.cc 3 Dec 2002 00:47:03 -0000 1.2.16.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.2.16.2 2002/12/03 00:08:46 rbcollins Exp $ + * $Id: store_dir_diskd.cc,v 1.2.16.3 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -508,7 +508,9 @@ static SwapDir * storeDiskdNew(void) { - return new SwapDir; + SwapDir *result = new SwapDir; + result->IO = &DiskdIO::Instance; + return result; } void 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 retrieving revision 1.1.20.1 diff -u -r1.1 -r1.1.20.1 --- squid3/src/fs/diskd/store_diskd.h 14 Oct 2002 00:18:25 -0000 1.1 +++ squid3/src/fs/diskd/store_diskd.h 3 Dec 2002 00:47:03 -0000 1.1.20.1 @@ -108,5 +108,12 @@ #define SHMBUF_BLKSZ SM_PAGE_SIZE extern diskd_stats_t diskd_stats; +#include "IOStrategy.h" +class DiskdIO : public IOStrategy +{ +public: + virtual bool shedLoad(); + static DiskdIO Instance; +}; #endif 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.1 retrieving revision 1.1.20.2 diff -u -r1.1.20.1 -r1.1.20.2 --- squid3/src/fs/diskd/store_io_diskd.cc 2 Dec 2002 14:42:17 -0000 1.1.20.1 +++ squid3/src/fs/diskd/store_io_diskd.cc 3 Dec 2002 00:47:03 -0000 1.1.20.2 @@ -1,6 +1,6 @@ /* - * $Id: store_io_diskd.cc,v 1.1.20.1 2002/12/02 14:42:17 rbcollins Exp $ + * $Id: store_io_diskd.cc,v 1.1.20.2 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -51,6 +51,13 @@ CBDATA_TYPE(storeIOState); /* === PUBLIC =========================================================== */ +DiskdIO DiskdIO::Instance; + +bool +DiskdIO::shedLoad() +{ + return false; +} storeIOState * storeDiskdOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, 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.2 retrieving revision 1.1.20.3 diff -u -r1.1.20.2 -r1.1.20.3 --- squid3/src/fs/null/store_null.cc 3 Dec 2002 00:08:46 -0000 1.1.20.2 +++ squid3/src/fs/null/store_null.cc 3 Dec 2002 00:47:03 -0000 1.1.20.3 @@ -1,6 +1,6 @@ /* - * $Id: store_null.cc,v 1.1.20.2 2002/12/03 00:08:46 rbcollins Exp $ + * $Id: store_null.cc,v 1.1.20.3 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -40,6 +40,14 @@ #endif #endif #include "SwapDir.h" +#include "Store.h" +#include "IOStrategy.h" +class NullIO : public IOStrategy +{ +public: + virtual bool shedLoad(); + static NullIO Instance; +}; static int null_initialised = 0; static void storeNullDirInit(SwapDir * sd); @@ -53,6 +61,13 @@ /* The only externally visible interface */ STSETUP storeFsSetup_null; +extern NullIO NullIO::Instance; +bool +NullIO::shedLoad() +{ + return true; +} + static void storeNullDirReconfigure(SwapDir * sd, int index, char *path) { @@ -68,7 +83,9 @@ static SwapDir * storeNullNew(void) { - return new SwapDir; + SwapDir *result = new SwapDir; + result->IO = &NullIO::Instance; + return result; } static void 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.2 retrieving revision 1.1.20.3 diff -u -r1.1.20.2 -r1.1.20.3 --- squid3/src/fs/ufs/store_dir_ufs.cc 3 Dec 2002 00:08:46 -0000 1.1.20.2 +++ squid3/src/fs/ufs/store_dir_ufs.cc 3 Dec 2002 00:47:03 -0000 1.1.20.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.1.20.2 2002/12/03 00:08:46 rbcollins Exp $ + * $Id: store_dir_ufs.cc,v 1.1.20.3 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -216,7 +216,9 @@ static SwapDir * storeUfsNew(void) { - return new SwapDir; + SwapDir *result = new SwapDir; + result->IO = &UfsIO::Instance; + return result; } void 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.1 retrieving revision 1.3.10.2 diff -u -r1.3.10.1 -r1.3.10.2 --- squid3/src/fs/ufs/store_io_ufs.cc 2 Dec 2002 14:42:18 -0000 1.3.10.1 +++ squid3/src/fs/ufs/store_io_ufs.cc 3 Dec 2002 00:47:03 -0000 1.3.10.2 @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.3.10.1 2002/12/02 14:42:18 rbcollins Exp $ + * $Id: store_io_ufs.cc,v 1.3.10.2 2002/12/03 00:47:03 rbcollins Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -49,6 +49,13 @@ /* === PUBLIC =========================================================== */ +UfsIO UfsIO::Instance; +bool +UfsIO::shedLoad() +{ + return false; +} + storeIOState * storeUfsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * callback, void *callback_data) 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 retrieving revision 1.1.20.1 diff -u -r1.1 -r1.1.20.1 --- squid3/src/fs/ufs/store_ufs.h 14 Oct 2002 00:18:25 -0000 1.1 +++ squid3/src/fs/ufs/store_ufs.h 3 Dec 2002 00:47:03 -0000 1.1.20.1 @@ -30,5 +30,12 @@ extern STOBJREAD storeUfsRead; extern STOBJWRITE storeUfsWrite; extern STOBJUNLINK storeUfsUnlink; +#include "IOStrategy.h" +class UfsIO : public IOStrategy +{ +public: + virtual bool shedLoad(); + static UfsIO Instance; +}; #endif