#
-# $Id: cf.data.pre,v 1.190 2000/06/26 01:38:37 wessels Exp $
+# $Id: cf.data.pre,v 1.191 2000/06/26 04:57:16 wessels Exp $
#
#
# SQUID Internet Object Cache http://squid.nlanr.net/Squid/
the administrators attention.
DOC_END
+NAME: store_dir_select_algorithm
+TYPE: string
+LOC: Config.store_dir_select_algorithm
+DEFAULT: least-load
+DOC_START
+ Set this to 'round-robin' as an alternative.
+DOC_END
+
EOF
/*
- * $Id: protos.h,v 1.373 2000/06/25 22:41:22 wessels Exp $
+ * $Id: protos.h,v 1.374 2000/06/26 04:57:16 wessels Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
extern char *storeSwapSubSubDir(int, char *);
extern const char *storeSwapPath(int);
extern int storeDirWriteCleanLogs(int reopen);
-extern int storeDirSelectSwapDir(const StoreEntry *);
+extern STDIRSELECT *storeDirSelectSwapDir;
extern int storeVerifySwapDirs(void);
extern void storeCreateSwapDirectories(void);
extern void storeDirCloseSwapLogs(void);
/*
- * $Id: store.cc,v 1.526 2000/06/25 22:28:43 wessels Exp $
+ * $Id: store.cc,v 1.527 2000/06/26 04:57:16 wessels Exp $
*
* DEBUG: section 20 Storage Manager
* AUTHOR: Harvest Derived
StoreEntry *e;
} lock_ctrl_t;
+extern OBJH storeIOStats;
+
/*
* local function prototypes
*/
cachemgrRegister("store_check_cachable_stats",
"storeCheckCachable() Stats",
storeCheckCachableStats, 0, 1);
+ cachemgrRegister("store_io",
+ "Store IO Interface Stats",
+ storeIOStats, 0, 1);
}
void
/*
- * $Id: store_dir.cc,v 1.112 2000/06/25 22:28:43 wessels Exp $
+ * $Id: store_dir.cc,v 1.113 2000/06/26 04:57:17 wessels Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
#include "squid.h"
static int storeDirValidSwapDirSize(int, ssize_t);
+static STDIRSELECT storeDirSelectSwapDirRoundRobin;
+static STDIRSELECT storeDirSelectSwapDirLeastLoad;
+
+/*
+ * This function pointer is set according to 'store_dir_select_algorithm'
+ * in squid.conf.
+ */
+STDIRSELECT *storeDirSelectSwapDir = storeDirSelectSwapDirLeastLoad;
void
storeDirInit(void)
sd = &Config.cacheSwap.swapDirs[i];
sd->init(sd);
}
+ if (0 == strcasecmp(Config.store_dir_select_algorithm, "round-robin")) {
+ storeDirSelectSwapDir = storeDirSelectSwapDirRoundRobin;
+ debug(47, 1) ("Using Round Robin store dir selection\n");
+ } else {
+ storeDirSelectSwapDir = storeDirSelectSwapDirLeastLoad;
+ debug(47, 1) ("Using Least Load store dir selection\n");
+ }
}
void
}
-#if UNUSED /* Squid-2..4.DEVEL3 code */
/*
* This new selection scheme simply does round-robin on all SwapDirs.
* A SwapDir is skipped if it is over the max_size (100%) limit. If
* XXX This function does NOT account for the read_only flag!
*/
static int
-storeDirSelectSwapDir(void)
+storeDirSelectSwapDirRoundRobin(const StoreEntry * unused)
{
static int dirn = 0;
int i;
return dirn;
}
-#if USE_DISKD && EXPERIMENTAL
-/*
- * This fileno selection function returns a fileno on the least
- * busy SwapDir. Ties are broken by selecting the SwapDir with
- * the most free space.
- */
-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;
-}
-#endif
-
-#endif /* Squid-2.4.DEVEL3 code */
-
/*
* Spread load across all of the store directories
*
* ALL swapdirs, regardless of state. Again, this is a hack while
* we sort out the real usefulness of this algorithm.
*/
-int
-storeDirSelectSwapDir(const StoreEntry * e)
+static int
+storeDirSelectSwapDirLeastLoad(const StoreEntry * e)
{
ssize_t objsize;
ssize_t least_size;
#include "squid.h"
+static struct {
+ struct {
+ int calls;
+ int select_fail;
+ int create_fail;
+ int success;
+ } create;
+} store_io_stats;
+
+OBJH storeIOStats;
/*
* submit a request to create a cache object for writing.
size_t objsize;
sdirno dirn;
SwapDir *SD;
+ storeIOState *sio;
+ store_io_stats.create.calls++;
/* This is just done for logging purposes */
objsize = objectLen(e);
if (objsize != -1)
dirn = storeDirSelectSwapDir(e);
if (dirn == -1) {
debug(20, 2) ("storeCreate: no valid swapdirs for this object\n");
+ store_io_stats.create.select_fail++;
return NULL;
}
debug(20, 2) ("storeCreate: Selected dir '%d' for obj size '%d'\n", dirn, objsize);
SD = &Config.cacheSwap.swapDirs[dirn];
/* Now that we have a fs to use, call its storeCreate function */
- return (SD->obj.create(SD, e, file_callback, close_callback, callback_data));
-
- /* Done */
+ sio = SD->obj.create(SD, e, file_callback, close_callback, callback_data);
+ if (NULL == sio)
+ store_io_stats.create.create_fail++;
+ else
+ store_io_stats.create.success++;
+ return sio;
}
{
return sio->offset;
}
+
+/*
+ * Make this non-static so we can register
+ * it from storeInit();
+ */
+void
+storeIOStats(StoreEntry * sentry)
+{
+ storeAppendPrintf(sentry, "Store IO Interface Stats\n");
+ storeAppendPrintf(sentry, "create.calls %d\n", store_io_stats.create.calls);
+ storeAppendPrintf(sentry, "create.select_fail %d\n", store_io_stats.create.select_fail);
+ storeAppendPrintf(sentry, "create.create_fail %d\n", store_io_stats.create.create_fail);
+ storeAppendPrintf(sentry, "create.success %d\n", store_io_stats.create.success);
+}
/*
- * $Id: structs.h,v 1.343 2000/06/26 03:36:06 wessels Exp $
+ * $Id: structs.h,v 1.344 2000/06/26 04:57:17 wessels Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
int high_pf;
int high_memory;
} warnings;
+ char *store_dir_select_algorithm;
};
struct _SquidConfig2 {
/*
- * $Id: typedefs.h,v 1.105 2000/06/25 22:28:43 wessels Exp $
+ * $Id: typedefs.h,v 1.106 2000/06/26 04:57:17 wessels Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
#endif
typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args);
+
+typedef int STDIRSELECT(const StoreEntry *);
+
#endif /* _TYPEDEFS_H_ */