From 7795e004d36e779abdf77f8771488595839e4bee Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Mon, 23 Aug 2010 10:21:37 -0700 Subject: [PATCH] Make cache size run-time configurable. --- bluesky/bluesky.h | 3 +++ bluesky/init.c | 5 ++++- bluesky/log.c | 7 ++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bluesky/bluesky.h b/bluesky/bluesky.h index 60a3842..ca3d130 100644 --- a/bluesky/bluesky.h +++ b/bluesky/bluesky.h @@ -33,6 +33,9 @@ typedef struct { /* Should frontends handle requests serially or allow operations to proceed * in parallel? */ int sync_frontends; + + /* Target size of the disk cache at the proxy, in kilobytes. */ + int cache_size; } BlueSkyOptions; extern BlueSkyOptions bluesky_options; diff --git a/bluesky/init.c b/bluesky/init.c index 1db4283..2ac2f23 100644 --- a/bluesky/init.c +++ b/bluesky/init.c @@ -15,7 +15,9 @@ int bluesky_verbose = 0; -BlueSkyOptions bluesky_options; +BlueSkyOptions bluesky_options = { + .cache_size = 1024*1024, // Default cache size is 1 GiB +}; /* Maximum number of threads to use in any particular thread pool, or -1 for no * limit */ @@ -47,6 +49,7 @@ static struct { {"BLUESKY_OPT_WRITETHROUGH", &bluesky_options.writethrough_cache}, {"BLUESKY_OPT_SYNC_INODE_FETCH", &bluesky_options.sync_inode_fetches}, {"BLUESKY_OPT_SYNC_FRONTENDS", &bluesky_options.sync_frontends}, + {"BLUESKY_CACHE_SIZE", &bluesky_options.cache_size}, {NULL, NULL} }; diff --git a/bluesky/log.c b/bluesky/log.c index c8641b7..1fe6176 100644 --- a/bluesky/log.c +++ b/bluesky/log.c @@ -38,10 +38,6 @@ // no absolute guarantees on the size of a log segment. #define LOG_SEGMENT_SIZE (1 << 22) -// Target amount of disk space to use for the journal and cache files, in -// kilobytes. -#define DISK_CACHE_SIZE_TARGET (64 * 1024) - #define HEADER_MAGIC 0x676f4c0a #define FOOTER_MAGIC 0x2e435243 @@ -521,7 +517,8 @@ void bluesky_cachefile_gc(BlueSkyFS *fs) g_print("\n"); gboolean deletion_candidate = FALSE; - if (g_atomic_int_get(&fs->log->disk_used) > DISK_CACHE_SIZE_TARGET + if (g_atomic_int_get(&fs->log->disk_used) + > bluesky_options.cache_size && g_atomic_int_get(&cachefile->refcount) == 0 && g_atomic_int_get(&cachefile->mapcount) == 0) { -- 2.20.1