--------------------- PatchSet 344 Date: 2002/12/13 09:32:57 Author: rbcollins Branch: unify-io Tag: (none) Log: move newfs to a method, and the ufs code to it's final home Members: src/SwapDir.cc:1.1.2.4->1.1.2.5 src/SwapDir.h:1.1.2.8->1.1.2.9 src/store_dir.cc:1.4.10.3->1.4.10.4 src/ufscommon.cc:1.4.10.8->1.4.10.9 src/ufscommon.h:1.1.20.31->1.1.20.32 src/fs/aufs/store_dir_aufs.cc:1.2.12.10->1.2.12.11 src/fs/coss/store_coss.h:1.3.10.10->1.3.10.11 src/fs/coss/store_dir_coss.cc:1.4.10.7->1.4.10.8 src/fs/diskd/store_dir_diskd.cc:1.2.16.17->1.2.16.18 src/fs/ufs/store_dir_ufs.cc:1.1.20.9->1.1.20.10 Index: squid3/src/SwapDir.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SwapDir.cc,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid3/src/SwapDir.cc 3 Dec 2002 02:05:28 -0000 1.1.2.4 +++ squid3/src/SwapDir.cc 13 Dec 2002 09:32:57 -0000 1.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.cc,v 1.1.2.4 2002/12/03 02:05:28 rbcollins Exp $ + * $Id: SwapDir.cc,v 1.1.2.5 2002/12/13 09:32:57 rbcollins Exp $ * * DEBUG: section ?? Swap Dir base object * AUTHOR: Robert Collins @@ -49,3 +49,6 @@ SwapDir::~SwapDir() { IO->deleteSelf(); } + +void +SwapDir::newFileSystem(){} Index: squid3/src/SwapDir.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SwapDir.h,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid3/src/SwapDir.h 13 Dec 2002 08:22:57 -0000 1.1.2.8 +++ squid3/src/SwapDir.h 13 Dec 2002 09:32:58 -0000 1.1.2.9 @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.1.2.8 2002/12/13 08:22:57 rbcollins Exp $ + * $Id: SwapDir.h,v 1.1.2.9 2002/12/13 09:32:58 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,7 +34,6 @@ #ifndef SQUID_SWAPDIR_H #define SQUID_SWAPDIR_H -typedef void STNEWFS(SwapDir *); typedef void STDUMP(StoreEntry *, SwapDir *); typedef void STFREE(SwapDir *); typedef int STDBLCHECK(SwapDir *, StoreEntry *); @@ -78,7 +77,7 @@ unsigned int read_only:1; } flags; virtual void init() = 0; /* Initialise the fs */ - STNEWFS *newfs; /* Create a new fs */ + virtual void newFileSystem(); /* Create a new fs */ STDUMP *dump; /* Dump fs config snippet */ STFREE *freefs; /* Free the fs data */ STDBLCHECK *dblcheck; /* Double check the obj integrity */ Index: squid3/src/store_dir.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store_dir.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/store_dir.cc 13 Dec 2002 08:22:57 -0000 1.4.10.3 +++ squid3/src/store_dir.cc 13 Dec 2002 09:32:58 -0000 1.4.10.4 @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.4.10.3 2002/12/13 08:22:57 rbcollins Exp $ + * $Id: store_dir.cc,v 1.4.10.4 2002/12/13 09:32:58 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -76,15 +76,12 @@ storeCreateSwapDirectories(void) { int i; - SwapDir *sd; pid_t pid; int status; for (i = 0; i < Config.cacheSwap.n_configured; i++) { if (fork()) continue; - sd = INDEXSD(i); - if (NULL != sd->newfs) - sd->newfs(sd); + INDEXSD(i)->newFileSystem(); exit(0); } do { Index: squid3/src/ufscommon.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.cc,v retrieving revision 1.4.10.8 retrieving revision 1.4.10.9 diff -u -r1.4.10.8 -r1.4.10.9 --- squid3/src/ufscommon.cc 13 Dec 2002 08:50:39 -0000 1.4.10.8 +++ squid3/src/ufscommon.cc 13 Dec 2002 09:32:58 -0000 1.4.10.9 @@ -1,5 +1,5 @@ /* - * $Id: ufscommon.cc,v 1.4.10.8 2002/12/13 08:50:39 rbcollins Exp $ + * $Id: ufscommon.cc,v 1.4.10.9 2002/12/13 09:32:58 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -69,9 +69,7 @@ #endif static int commonUfsFilenoBelongsHere(int fn, int F0, int F1, int F2); static char *commonUfsDirSwapSubDir(SwapDir *, int subdirn); -static int commonUfsDirCreateDirectory(const char *path, int); static int commonUfsDirVerifyDirectory(const char *path); -static void commonUfsDirCreateSwapSubDirs(SwapDir *); static int commonUfsDirMapBitTest(SwapDir * SD, sfileno filn); static char *commonUfsDirSwapLogFile(SwapDir *, const char *); static EVH commonUfsDirRebuildFromDirectory; @@ -100,7 +98,6 @@ static STLOGCLEANDONE commonUfsDirWriteCleanDone; static STLOGCLOSE commonUfsDirCloseSwapLog; static STLOGWRITE commonUfsDirSwapLog; -static STNEWFS commonUfsDirNewfs; static STCHECKOBJ commonUfsDirCheckObj; #endif static QS rev_int_sort; @@ -203,7 +200,7 @@ } int -commonUfsDirCreateDirectory(const char *path, int should_exist) +UFSSwapDir::createDirectory(const char *path, int should_exist) { int created = 0; struct stat st; @@ -265,22 +262,22 @@ } void -commonUfsDirCreateSwapSubDirs(SwapDir * sd) +UFSSwapDir::createSwapSubDirs() { - squidufsinfo_t *ioinfo = (squidufsinfo_t *) sd->fsdata; + squidufsinfo_t *ioinfo = (squidufsinfo_t *) fsdata; int i, k; int should_exist; LOCAL_ARRAY(char, name, MAXPATHLEN); for (i = 0; i < ioinfo->l1; i++) { - snprintf(name, MAXPATHLEN, "%s/%02X", sd->path, i); - if (commonUfsDirCreateDirectory(name, 0)) + snprintf(name, MAXPATHLEN, "%s/%02X", path, i); + if (createDirectory(name, 0)) should_exist = 0; else should_exist = 1; debug(47, 1) ("Making directories in %s\n", name); for (k = 0; k < ioinfo->l2; k++) { - snprintf(name, MAXPATHLEN, "%s/%02X/%02X", sd->path, i, k); - commonUfsDirCreateDirectory(name, should_exist); + snprintf(name, MAXPATHLEN, "%s/%02X/%02X", path, i, k); + createDirectory(name, should_exist); } } } @@ -1103,14 +1100,6 @@ (FREE *) storeSwapLogDataFree); } -void -commonUfsDirNewfs(SwapDir * sd) -{ - debug(47, 3) ("Creating swap space in %s\n", sd->path); - commonUfsDirCreateDirectory(sd->path, 0); - commonUfsDirCreateSwapSubDirs(sd); -} - static int rev_int_sort(const void *A, const void *B) { Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.31 retrieving revision 1.1.20.32 diff -u -r1.1.20.31 -r1.1.20.32 --- squid3/src/ufscommon.h 13 Dec 2002 08:50:39 -0000 1.1.20.31 +++ squid3/src/ufscommon.h 13 Dec 2002 09:32:59 -0000 1.1.20.32 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.31 2002/12/13 08:50:39 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.32 2002/12/13 09:32:59 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -84,11 +84,14 @@ class UFSSwapDir : public SwapDir { public: virtual void init(); + virtual void newFileSystem(); private: static EVH CleanEvent; void initBitmap(); bool verifyCacheDirs(); void rebuild(); + int createDirectory(const char *path, int); + void createSwapSubDirs(); }; #include "RefCount.h" 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.10 retrieving revision 1.2.12.11 diff -u -r1.2.12.10 -r1.2.12.11 --- squid3/src/fs/aufs/store_dir_aufs.cc 13 Dec 2002 08:22:57 -0000 1.2.12.10 +++ squid3/src/fs/aufs/store_dir_aufs.cc 13 Dec 2002 09:32:59 -0000 1.2.12.11 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.2.12.10 2002/12/13 08:22:57 rbcollins Exp $ + * $Id: store_dir_aufs.cc,v 1.2.12.11 2002/12/13 09:32:59 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -190,7 +190,6 @@ aioinfo->map = NULL; /* Debugging purposes */ aioinfo->suggest = 0; aioinfo->io.storeDirUnlinkFile = storeAufsDirIOUnlinkFile; - sd->newfs = commonUfsDirNewfs; sd->dump = storeAufsDirDump; sd->freefs = commonUfsDirFree; sd->dblcheck = commonUfsCleanupDoubleCheck; 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.10 retrieving revision 1.3.10.11 diff -u -r1.3.10.10 -r1.3.10.11 --- squid3/src/fs/coss/store_coss.h 13 Dec 2002 08:22:58 -0000 1.3.10.10 +++ squid3/src/fs/coss/store_coss.h 13 Dec 2002 09:32:59 -0000 1.3.10.11 @@ -103,7 +103,9 @@ class CossSwapDir : public SwapDir { +public: virtual void init(); + virtual void newFileSystem(); }; 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.7 retrieving revision 1.4.10.8 diff -u -r1.4.10.7 -r1.4.10.8 --- squid3/src/fs/coss/store_dir_coss.cc 13 Dec 2002 08:22:58 -0000 1.4.10.7 +++ squid3/src/fs/coss/store_dir_coss.cc 13 Dec 2002 09:33:00 -0000 1.4.10.8 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.4.10.7 2002/12/13 08:22:58 rbcollins Exp $ + * $Id: store_dir_coss.cc,v 1.4.10.8 2002/12/13 09:33:00 rbcollins Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -82,7 +82,6 @@ static STLOGCLEANDONE storeCossDirWriteCleanDone; static STLOGCLOSE storeCossDirCloseSwapLog; static STLOGWRITE storeCossDirSwapLog; -static STNEWFS storeCossDirNewfs; static STCHECKOBJ storeCossDirCheckObj; static STFREE storeCossDirShutdown; static STFSPARSE storeCossDirParse; @@ -650,10 +649,11 @@ (FREE *) storeSwapLogDataFree); } -static void -storeCossDirNewfs(SwapDir * sd) +void +CossSwapDir::newFileSystem() { - debug(47, 3) ("Creating swap space in %s\n", sd->path); + debug(47, 3) ("Creating swap space in %s\n", path); + debug (47,0)("COSS autocreation is not implemented. Please create the file manually\n"); } /* we are shutting down, flush all membufs to disk */ @@ -762,7 +762,6 @@ cs->fd = -1; cs->swaplog_fd = -1; - sd->newfs = storeCossDirNewfs; sd->dump = storeCossDirDump; sd->freefs = storeCossDirShutdown; sd->dblcheck = NULL; 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.17 retrieving revision 1.2.16.18 diff -u -r1.2.16.17 -r1.2.16.18 --- squid3/src/fs/diskd/store_dir_diskd.cc 13 Dec 2002 08:22:58 -0000 1.2.16.17 +++ squid3/src/fs/diskd/store_dir_diskd.cc 13 Dec 2002 09:33:00 -0000 1.2.16.18 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.2.16.17 2002/12/13 08:22:58 rbcollins Exp $ + * $Id: store_dir_diskd.cc,v 1.2.16.18 2002/12/13 09:33:00 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -397,7 +397,6 @@ ufsinfo->map = NULL; /* Debugging purposes */ ufsinfo->suggest = 0; ufsinfo->io.storeDirUnlinkFile = storeDiskdDirIOUnlinkFile; - sd->newfs = commonUfsDirNewfs; sd->dump = storeDiskdDirDump; sd->freefs = commonUfsDirFree; sd->dblcheck = commonUfsCleanupDoubleCheck; 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.9 retrieving revision 1.1.20.10 diff -u -r1.1.20.9 -r1.1.20.10 --- squid3/src/fs/ufs/store_dir_ufs.cc 13 Dec 2002 08:50:39 -0000 1.1.20.9 +++ squid3/src/fs/ufs/store_dir_ufs.cc 13 Dec 2002 09:33:00 -0000 1.1.20.10 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.1.20.9 2002/12/13 08:50:39 rbcollins Exp $ + * $Id: store_dir_ufs.cc,v 1.1.20.10 2002/12/13 09:33:00 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -171,7 +171,6 @@ ufsinfo->map = NULL; /* Debugging purposes */ ufsinfo->suggest = 0; ufsinfo->io.storeDirUnlinkFile = storeUfsDirIOUnlinkFile; - sd->newfs = commonUfsDirNewfs; sd->dump = storeUfsDirDump; sd->freefs = commonUfsDirFree; sd->dblcheck = commonUfsCleanupDoubleCheck; @@ -222,6 +221,14 @@ (void) storeDirGetBlkSize(path, &fs.blksize); } +void +UFSSwapDir::newFileSystem() +{ + debug(47, 3) ("Creating swap space in %s\n", path); + createDirectory(path, 0); + createSwapSubDirs(); +} + static void storeUfsDirDone(void) {