--------------------- PatchSet 1112 Date: 2001/01/06 13:09:52 Author: adri Branch: modio Tag: (none) Log: Lobotomise more UFS code out of the hash fs Members: src/fs/hash/store_dir_hash.c:1.1.2.2->1.1.2.3 src/fs/hash/store_hash.h:1.1.2.2->1.1.2.3 Index: squid/src/fs/hash/store_dir_hash.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/hash/Attic/store_dir_hash.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/src/fs/hash/store_dir_hash.c 5 Jan 2001 14:28:22 -0000 1.1.2.2 +++ squid/src/fs/hash/store_dir_hash.c 6 Jan 2001 13:09:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_hash.c,v 1.1.2.2 2001/01/05 14:28:22 adri Exp $ + * $Id: store_dir_hash.c,v 1.1.2.3 2001/01/06 13:09:52 adri Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -51,11 +51,8 @@ MemPool *hash_state_pool = NULL; static int hash_initialised = 0; -static char *storeHashDirSwapSubDir(SwapDir *, int subdirn); static int storeHashDirCreateDirectory(const char *path, int); -static int storeHashDirVerifyCacheDirs(SwapDir *); static int storeHashDirVerifyDirectory(const char *path); -static void storeHashDirCreateSwapSubDirs(SwapDir *); static char *storeHashDirSwapLogFile(SwapDir *, const char *); static STLOGOPEN storeHashDirOpenSwapLog; static STINIT storeHashDirInit; @@ -145,17 +142,6 @@ /* else it shrunk, and we leave the old one in place */ } -static char * -storeHashDirSwapSubDir(SwapDir * sd, int subdirn) -{ - hashinfo_t *hashinfo = (hashinfo_t *) sd->fsdata; - - LOCAL_ARRAY(char, fullfilename, SQUID_MAXPATHLEN); - assert(0 <= subdirn && subdirn < hashinfo->l1); - snprintf(fullfilename, SQUID_MAXPATHLEN, "%s/%02X", sd->path, subdirn); - return fullfilename; -} - static int storeHashDirCreateDirectory(const char *path, int should_exist) { @@ -193,49 +179,6 @@ return 0; } -/* - * This function is called by storeHashDirInit(). If this returns < 0, - * then Squid exits, complains about swap directories not - * existing, and instructs the admin to run 'squid -z' - */ -static int -storeHashDirVerifyCacheDirs(SwapDir * sd) -{ - hashinfo_t *hashinfo = (hashinfo_t *) sd->fsdata; - int j; - const char *path = sd->path; - - if (storeHashDirVerifyDirectory(path) < 0) - return -1; - for (j = 0; j < hashinfo->l1; j++) { - path = storeHashDirSwapSubDir(sd, j); - if (storeHashDirVerifyDirectory(path) < 0) - return -1; - } - return 0; -} - -static void -storeHashDirCreateSwapSubDirs(SwapDir * sd) -{ - hashinfo_t *hashinfo = (hashinfo_t *) sd->fsdata; - int i, k; - int should_exist; - LOCAL_ARRAY(char, name, MAXPATHLEN); - for (i = 0; i < hashinfo->l1; i++) { - snprintf(name, MAXPATHLEN, "%s/%02X", sd->path, i); - if (storeHashDirCreateDirectory(name, 0)) - should_exist = 0; - else - should_exist = 1; - debug(47, 1) ("Making directories in %s\n", name); - for (k = 0; k < hashinfo->l2; k++) { - snprintf(name, MAXPATHLEN, "%s/%02X/%02X", sd->path, i, k); - storeHashDirCreateDirectory(name, should_exist); - } - } -} - static char * storeHashDirSwapLogFile(SwapDir * sd, const char *ext) { @@ -289,13 +232,7 @@ storeHashDirInit(SwapDir * sd) { static int started_clean_event = 0; - static const char *errmsg = - "\tFailed to verify one of the swap directories, Check cache.log\n" - "\tfor details. Run 'squid -z' to create swap directories\n" - "\tif needed, or if running Squid for the first time."; storeHashDirInitBitmap(sd); - if (storeHashDirVerifyCacheDirs(sd) < 0) - fatal(errmsg); storeHashDirOpenSwapLog(sd); if (!started_clean_event) { eventAdd("storeDirClean", storeHashDirCleanEvent, NULL, 15.0, 1); @@ -319,7 +256,6 @@ { debug(47, 3) ("Creating swap space in %s\n", sd->path); storeHashDirCreateDirectory(sd->path, 0); - storeHashDirCreateSwapSubDirs(sd); } static void @@ -440,8 +376,6 @@ struct statvfs sfs; #endif hashinfo = (hashinfo_t *) SD->fsdata; - storeAppendPrintf(sentry, "First level subdirectories: %d\n", hashinfo->l1); - storeAppendPrintf(sentry, "Second level subdirectories: %d\n", hashinfo->l2); storeAppendPrintf(sentry, "Maximum Size: %d KB\n", SD->max_size); storeAppendPrintf(sentry, "Current Size: %d KB\n", SD->cur_size); storeAppendPrintf(sentry, "Percent Used: %0.2f%%\n", @@ -529,14 +463,11 @@ void storeHashDirDump(StoreEntry * entry, const char *name, SwapDir * s) { - hashinfo_t *hashinfo = (hashinfo_t *) s->fsdata; - storeAppendPrintf(entry, "%s %s %s %d %d %d\n", + storeAppendPrintf(entry, "%s %s %s %d\n", name, "hash", s->path, - s->max_size >> 10, - hashinfo->l1, - hashinfo->l2); + s->max_size >> 10); } /* @@ -556,24 +487,6 @@ } -char * -storeHashDirFullPath(SwapDir * SD, sfileno filn, char *fullpath) -{ - LOCAL_ARRAY(char, fullfilename, SQUID_MAXPATHLEN); - hashinfo_t *hashinfo = (hashinfo_t *) SD->fsdata; - int L1 = hashinfo->l1; - int L2 = hashinfo->l2; - if (!fullpath) - fullpath = fullfilename; - fullpath[0] = '\0'; - snprintf(fullpath, SQUID_MAXPATHLEN, "%s/%02X/%02X/%08X", - SD->path, - ((filn / L2) / L2) % L1, - (filn / L2) % L2, - filn); - return fullpath; -} - /* * storeHashCleanupDoubleCheck * @@ -615,8 +528,6 @@ char *token; int i; int size; - int l1; - int l2; unsigned int read_only = 0; hashinfo_t *hashinfo; @@ -624,14 +535,6 @@ size = i << 10; /* Mbytes to kbytes */ if (size <= 0) fatal("storeHashDirParse: invalid size value"); - i = GetInteger(); - l1 = i; - if (l1 <= 0) - fatal("storeHashDirParse: invalid level 1 directories value"); - i = GetInteger(); - l2 = i; - if (l2 <= 0) - fatal("storeHashDirParse: invalid level 2 directories value"); if ((token = strtok(NULL, w_space))) if (!strcasecmp(token, "read-only")) read_only = 1; @@ -644,8 +547,6 @@ sd->path = xstrdup(path); sd->max_size = size; sd->fsdata = hashinfo; - hashinfo->l1 = l1; - hashinfo->l2 = l2; hashinfo->swaplog_fd = -1; hashinfo->map = NULL; /* Debugging purposes */ hashinfo->suggest = 0; Index: squid/src/fs/hash/store_hash.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/hash/Attic/store_hash.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/src/fs/hash/store_hash.h 5 Jan 2001 14:28:22 -0000 1.1.2.2 +++ squid/src/fs/hash/store_hash.h 6 Jan 2001 13:09:52 -0000 1.1.2.3 @@ -9,8 +9,6 @@ struct _hashinfo_t { int swaplog_fd; - int l1; - int l2; fileMap *map; int suggest; };