From: wessels <> Date: Wed, 5 Jan 2000 13:25:42 +0000 (+0000) Subject: This alternate storeDirSelectSwapDir() function is optimized for X-Git-Tag: SQUID_3_0_PRE1~2091 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a5c22d35f42e184c18133e3ed61043cb20a8706;p=thirdparty%2Fsquid.git This alternate storeDirSelectSwapDir() function is optimized for DISKD. It selects the cache_dir with the fewest outstanding messages and then uses free space as the tie-breaker. --- diff --git a/src/store_dir.cc b/src/store_dir.cc index 774c9624cf..28a18c8679 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -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)