From: wessels <> Date: Sat, 26 Apr 1997 02:15:31 +0000 (+0000) Subject: fixing SwapDirs[dirn].cur_size X-Git-Tag: SQUID_3_0_PRE1~5052 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76fefb7763485362d746bd885f29433704befc50;p=thirdparty%2Fsquid.git fixing SwapDirs[dirn].cur_size --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 7ac64ecc54..d80fe40eb4 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,5 +1,5 @@ /* - * $Id: cache_cf.cc,v 1.177 1997/03/29 04:45:13 wessels Exp $ + * $Id: cache_cf.cc,v 1.178 1997/04/25 20:15:31 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -245,7 +245,6 @@ static void parseMcastGroupLine _PARAMS((void)); static void parseMemLine _PARAMS((void)); static void parseMgrLine _PARAMS((void)); static void parseKilobytes _PARAMS((int *)); -static void parseSwapLine _PARAMS((void)); static void parseRefreshPattern _PARAMS((int icase)); static void parseVisibleHostnameLine _PARAMS((void)); static void parseWAISRelayLine _PARAMS((void)); @@ -420,14 +419,6 @@ parseMemLine(void) Config.Mem.maxSize = i << 20; } -static void -parseSwapLine(void) -{ - char *token; - int i; - GetInteger(i); - Config.Swap.maxSize = i << 10; -} static void parseRefreshPattern(int icase) @@ -867,7 +858,8 @@ parseCacheDir(void) self_destruct(); dir = token; GetInteger(i); - size = i; + size = i << 10; /* Mbytes to kbytes */ + Config.Swap.maxSize += size; GetInteger(i); l1 = i; GetInteger(i); @@ -985,9 +977,6 @@ parseConfigFile(const char *file_name) else if (!strcmp(token, "cache_mem")) parseMemLine(); - else if (!strcmp(token, "cache_swap")) - parseSwapLine(); - else if (!strcmp(token, "cache_mgr")) parseMgrLine(); diff --git a/src/stat.cc b/src/stat.cc index 93cbe2a6dc..d5d7949801 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.130 1997/03/29 04:45:21 wessels Exp $ + * $Id: stat.cc,v 1.131 1997/04/25 20:15:33 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -757,7 +757,7 @@ info_get(const cacheinfo * obj, StoreEntry * sentry) storeAppendPrintf(sentry, "{Cache information for %s:}\n", appname); storeAppendPrintf(sentry, "{\tStorage Swap size:\t%d MB}\n", - storeGetSwapSize() >> 10); + store_swap_size >> 10); storeAppendPrintf(sentry, "{\tStorage Mem size:\t%d KB}\n", store_mem_size >> 10); storeAppendPrintf(sentry, "{\tStorage LRU Expiration Age:\t%6.2f days}\n", diff --git a/src/store.cc b/src/store.cc index ef8b143518..93b4b76392 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.218 1997/04/25 06:38:22 wessels Exp $ + * $Id: store.cc,v 1.219 1997/04/25 20:15:34 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -320,7 +320,7 @@ static int store_pages_low = 0; /* current file name, swap file, use number as a filename */ static int swapfileno = 0; -static int store_swap_size = 0; /* kilobytes !! */ +int store_swap_size = 0; /* kilobytes !! */ static int store_swap_high = 0; static int store_swap_low = 0; static int storelog_fd = -1; @@ -1248,7 +1248,7 @@ storeSwapOutHandle(int fd, int flag, StoreEntry * e) debug(20, 6, "storeSwapOutHandle: store_swap_size = %dk\n", store_swap_size); mem->swap_offset += mem->e_swap_buf_len; /* round up */ - store_swap_size += ((mem->e_swap_buf_len + 1023) >> 10); + storeDirUpdateSwapSize(e->swap_file_number, mem->e_swap_buf_len); if (mem->swap_offset >= e->object_len) { /* swapping complete */ e->swap_status = SWAP_OK; @@ -1412,6 +1412,7 @@ storeDoRebuildFromDisk(void *data) storeDirCloseTmpSwapLog(d->dirn); RB->rebuild_dir = d->next; safe_free(d); + eventAdd("storeRebuild", storeDoRebuildFromDisk, RB, 0); return; } if ((++RB->linecount & 0x3FFF) == 0) @@ -1473,7 +1474,7 @@ storeDoRebuildFromDisk(void *data) continue; } /* update store_swap_size */ - store_swap_size += (int) ((size + 1023) >> 10); + storeDirUpdateSwapSize(sfileno, size); RB->objcount++; e = storeAddDiskRestore(url, sfileno, @@ -1488,7 +1489,7 @@ storeDoRebuildFromDisk(void *data) TRUE); } RB->rebuild_dir = d->next; - for (D = &RB->rebuild_dir; (*D)->next; D = &(*D)->next); + for (D = &RB->rebuild_dir; *D; D = &(*D)->next); *D = d; d->next = NULL; eventAdd("storeRebuild", storeDoRebuildFromDisk, RB, 0); @@ -1660,13 +1661,6 @@ storeStartRebuildFromDisk(void) } } -/* return current swap size in kilo-bytes */ -int -storeGetSwapSize(void) -{ - return store_swap_size; -} - static int storeCheckSwapable(StoreEntry * e) { @@ -2169,9 +2163,9 @@ storeRelease(StoreEntry * e) if (e->swap_status == SWAP_OK && (e->swap_file_number > -1)) { (void) safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1); + storeDirUpdateSwapSize(e->swap_file_number, -(e->object_len)); storeDirMapBitReset(e->swap_file_number); e->swap_file_number = -1; - store_swap_size -= (e->object_len + 1023) >> 10; HTTPCacheInfo->proto_purgeobject(HTTPCacheInfo, urlParseProtocol(e->url), e->object_len); diff --git a/src/store_dir.cc b/src/store_dir.cc index 6b6f35796d..8c0bfb829d 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -76,12 +76,6 @@ storeAddSwapDisk(const char *path, int size, int l1, int l2, int read_only) tmp->l2 = l2; tmp->read_only = read_only; tmp->map = file_map_create(MAX_FILES_PER_DIR); - debug(20,0,"storeAddSwapDisk: #%d: %s\n", ncache_dirs, path); - debug(20,0,"storeAddSwapDisk: l1=%d\n", tmp->l1); - debug(20,0,"storeAddSwapDisk: l2=%d\n", tmp->l2); - debug(20,0,"storeAddSwapDisk: sz=%d\n", tmp->max_size); - debug(20,0,"storeAddSwapDisk: ro=%d\n", tmp->read_only); - debug(20,0,"storeAddSwapDisk: mp=%d\n", tmp->map); return ++ncache_dirs; } @@ -153,6 +147,8 @@ storeMostFreeSwapDir(void) int i; for (i = 0; i < ncache_dirs; i++) { this_free = SwapDirs[i].max_size - SwapDirs[i].cur_size; +debug(20,0,"storeMostFreeSwapDir: most free = #%d with %d\n", dirn, most_free); +debug(20,0,"storeMostFreeSwapDir: #%d has %d free\n", i, this_free); if (this_free <= most_free) continue; if (SwapDirs[i].read_only) @@ -160,6 +156,8 @@ storeMostFreeSwapDir(void) most_free = this_free; dirn = i; } +debug(20,0,"storeMostFreeSwapDir: most free = #%d with %d\n", dirn, most_free); +debug(20,0,"storeMostFreeSwapDir: returning %d\n", dirn); return dirn; } @@ -352,3 +350,12 @@ storeDirCloseTmpSwapLog(int dirn) } SD->swaplog_fd = fd; } + +void +storeDirUpdateSwapSize(int fn, size_t size) +{ + int dirn = (fn >> SWAP_DIR_SHIFT) % ncache_dirs; + int k = ((size + 1023) >> 10); + SwapDirs[dirn].cur_size += k; + store_swap_size += k; +}