/*
- * $Id: cache_cf.cc,v 1.298 1998/08/17 23:27:58 wessels Exp $
+ * $Id: cache_cf.cc,v 1.299 1998/08/20 02:49:10 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
configDoConfigure(void)
{
LOCAL_ARRAY(char, buf, BUFSIZ);
- int i;
- SwapDir *SD;
- fileMap *fm;
const refresh_t *R;
- int n;
memset(&Config2, '\0', sizeof(SquidConfig2));
/* init memory as early as possible */
memConfigure();
if (Config.cacheSwap.swapDirs == NULL)
fatal("No cache_dir's specified in config file");
/* calculate Config.Swap.maxSize */
- Config.Swap.maxSize = 0;
- for (i = 0; i < Config.cacheSwap.n_configured; i++) {
- SD = &Config.cacheSwap.swapDirs[i];;
- Config.Swap.maxSize += SD->max_size;
- n = 2 * SD->max_size / Config.Store.avgObjectSize;
- if (NULL == SD->map) {
- /* first time */
- SD->map = file_map_create(n);
- } else if (n > SD->map->max_n_files) {
- /* it grew, need to expand */
- fm = file_map_create(n);
- filemapCopy(SD->map, fm);
- filemapFreeMemory(SD->map);
- SD->map = fm;
- }
- /* else it shrunk, and we leave the old one in place */
- }
+ storeDirConfigure();
if (Config.Swap.maxSize < (Config.Mem.maxSize >> 10))
fatal("cache_swap is lower than cache_mem");
if (Config.Announce.period > 0) {
/*
- * $Id: protos.h,v 1.251 1998/08/19 06:05:54 wessels Exp $
+ * $Id: protos.h,v 1.252 1998/08/20 02:49:11 wessels Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
extern int storeFilenoBelongsHere(int, int, int, int);
extern OBJH storeDirStats;
extern int storeDirMapBitsInUse(void);
+extern void storeDirConfigure(void);
+extern void storeDirDiskFull(int fn);
/*
/*
- * $Id: store_dir.cc,v 1.74 1998/07/22 20:37:59 wessels Exp $
+ * $Id: store_dir.cc,v 1.75 1998/08/20 02:49:12 wessels Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
return n;
}
#undef CLEAN_BUF_SZ
+
+void
+storeDirConfigure(void)
+{
+ SwapDir *SD;
+ int n;
+ int i;
+ fileMap *fm;
+ Config.Swap.maxSize = 0;
+ for (i = 0; i < Config.cacheSwap.n_configured; i++) {
+ SD = &Config.cacheSwap.swapDirs[i];;
+ Config.Swap.maxSize += SD->max_size;
+ n = 2 * SD->max_size / Config.Store.avgObjectSize;
+ if (NULL == SD->map) {
+ /* first time */
+ SD->map = file_map_create(n);
+ } else if (n > SD->map->max_n_files) {
+ /* it grew, need to expand */
+ fm = file_map_create(n);
+ filemapCopy(SD->map, fm);
+ filemapFreeMemory(SD->map);
+ SD->map = fm;
+ }
+ /* else it shrunk, and we leave the old one in place */
+ }
+}
+
+void
+storeDirDiskFull(int fn)
+{
+ int dirn = fn >> SWAP_DIR_SHIFT;
+ SwapDir *SD = &Config.cacheSwap.swapDirs[dirn];
+ assert(0 <= dirn && dirn < Config.cacheSwap.n_configured);
+ SD->max_size = SD->cur_size;
+ debug(20, 1)("WARNING: Shrinking cache_dir #%d to %d KB\n",
+ dirn, SD->cur_size);
+}
/*
- * $Id: store_swapout.cc,v 1.23 1998/08/19 04:32:14 wessels Exp $
+ * $Id: store_swapout.cc,v 1.24 1998/08/20 02:49:13 wessels Exp $
*
* DEBUG: section 20 Storage Manager Swapout Functions
* AUTHOR: Duane Wessels
if (e->swap_file_number > -1) {
storeUnlinkFileno(e->swap_file_number);
storeDirMapBitReset(e->swap_file_number);
+ if (flag == DISK_NO_SPACE_LEFT) {
+ storeDirDiskFull(e->swap_file_number);
+ storeDirConfigure();
+ storeConfigure();
+ }
e->swap_file_number = -1;
}
- if (flag == DISK_NO_SPACE_LEFT) {
- /* reduce the swap_size limit to the current size. */
- Config.Swap.maxSize = store_swap_size;
- storeConfigure();
- }
storeReleaseRequest(e);
storeSwapOutFileClose(e);
return;