]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
This alternate storeDirSelectSwapDir() function is optimized for
authorwessels <>
Wed, 5 Jan 2000 13:25:42 +0000 (13:25 +0000)
committerwessels <>
Wed, 5 Jan 2000 13:25:42 +0000 (13:25 +0000)
DISKD.  It selects the cache_dir with the fewest outstanding messages
and then uses free space as the tie-breaker.

src/store_dir.cc

index 774c9624cf5950028bd762e72bbb8f9d0dc9b7f4..28a18c86793b29ff2837e998012c03f3cf596884 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.100 1999/12/30 17:36:56 wessels Exp $
+ * $Id: store_dir.cc,v 1.101 2000/01/05 06:25:42 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -75,6 +75,32 @@ storeCreateSwapDirectories(void)
     } while (pid > 0 || (pid < 0 && errno == EINTR));
 }
 
+static int
+storeDirSelectSwapDir(void)
+{
+    SwapDir *SD;
+    int min_away = 10000;
+    int min_size = 1<<30;
+    int dirn = 0;
+    int i;
+    for (i = 0; i < Config.cacheSwap.n_configured; i++) {
+       SD = &Config.cacheSwap.swapDirs[i];
+       if (SD->cur_size > SD->max_size)
+           continue;
+       if (SD->u.diskd.away > min_away)
+           continue;
+       if (SD->cur_size > min_size)
+           continue;
+       if (SD->flags.read_only)
+           continue;
+       min_away = SD->u.diskd.away;
+       min_size = SD->cur_size;
+       dirn = i;
+    }
+    return dirn;
+}
+
+#if OLD
 /*
  *Spread load across least 3/4 of the store directories
  */
@@ -165,6 +191,7 @@ storeDirSelectSwapDir(void)
     dirq[0] = -1;
     return dirn;
 }
+#endif
 
 int
 storeDirValidFileno(int fn, int flag)