]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
when write fails because a disk is full, only lower *that* cache_dir
authorwessels <>
Thu, 20 Aug 1998 08:49:10 +0000 (08:49 +0000)
committerwessels <>
Thu, 20 Aug 1998 08:49:10 +0000 (08:49 +0000)
and recompute the maxSize.  'storedir' stats should now be
consistent

src/cache_cf.cc
src/protos.h
src/store_dir.cc
src/store_swapout.cc

index eae709f8ede54809fbac04e4d5022f0450312935..09f3303ab01c1aad6b0ec355e69549fbe4cb705e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -210,11 +210,7 @@ static void
 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();
@@ -222,23 +218,7 @@ configDoConfigure(void)
     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) {
index abac01d533ffae55dc365a2770d57431cfa81bcd..11001d85ae9d108a4537a678f4489d78b6688b8b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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/
@@ -852,6 +852,8 @@ extern int storeDirValidFileno(int fn);
 extern int storeFilenoBelongsHere(int, int, int, int);
 extern OBJH storeDirStats;
 extern int storeDirMapBitsInUse(void);
+extern void storeDirConfigure(void);
+extern void storeDirDiskFull(int fn);
 
 
 /*
index c57f74a627b1f530d1fc610928336007d5d7d23f..8babbbe8ec1ea8366ca3157b25fd35688ffae640 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -789,3 +789,40 @@ storeDirWriteCleanLogs(int reopen)
     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);
+}
index e4d8c6eddf880c4560b4ddbf74d197e365c246a6..3830f4022891d9b000ed1c01ef9dfe557eb5c5c0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -79,13 +79,13 @@ storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data)
        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;