aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-02-26 20:08:37 +0000
committerDavid Howells <dhowells@redhat.com>2010-02-26 20:08:37 +0000
commitebaf857743f5afcc998086ae4f333ca3f5b5c2a1 (patch)
tree53162e1ff15e4a61fdbbb99895b63075a669277c
parent641e49724780cb1de46d9d431bd4152890f78a3a (diff)
downloadcachefilesd-ebaf857743f5afcc998086ae4f333ca3f5b5c2a1.tar.gz
Provide an option to suppress cachefilesd culling
Provide an option to suppress cachefilesd culling. This prevents the daemon from using up resources scanning the cache. The downside is that it never attempts to shrink the cache to make space when the cache ends up exceeding its limits due to other processes using up resources on the same filesystem as the cache. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--cachefilesd.c62
-rw-r--r--cachefilesd.conf.58
2 files changed, 45 insertions, 25 deletions
diff --git a/cachefilesd.c b/cachefilesd.c
index 7f6dde3..3973e2a 100644
--- a/cachefilesd.c
+++ b/cachefilesd.c
@@ -105,7 +105,7 @@ static const char *pidfile = "/var/run/cachefilesd.pid";
static char *cacheroot, *graveyardpath;
static int xdebug, xnolog, xopenedlog;
-static int stop, reap, cull; //, statecheck;
+static int stop, reap, cull, nocull; //, statecheck;
static int graveyardfd;
static unsigned long long brun, bcull, bstop, frun, fcull, fstop;
@@ -389,6 +389,12 @@ int main(int argc, char *argv[])
if (*cp == '#')
continue;
+ /* allow culling to be disabled */
+ if (memcmp(cp, "nocull", 6) == 0 &&
+ (!cp[6] || isspace(cp[6]))) {
+ nocull = 1;
+ }
+
/* note the cull table size command */
if (memcmp(cp, "culltable", 9) == 0 && isspace(cp[9])) {
unsigned long cts;
@@ -445,13 +451,15 @@ int main(int argc, char *argv[])
oserror("Unable to close %s", configfile);
/* allocate the cull tables */
- cullbuild = calloc(culltable_size, sizeof(cullbuild[0]));
- if (!cullbuild)
- oserror("calloc");
-
- cullready = calloc(culltable_size, sizeof(cullready[0]));
- if (!cullready)
- oserror("calloc");
+ if (!nocull) {
+ cullbuild = calloc(culltable_size, sizeof(cullbuild[0]));
+ if (!cullbuild)
+ oserror("calloc");
+
+ cullready = calloc(culltable_size, sizeof(cullready[0]));
+ if (!cullready)
+ oserror("calloc");
+ }
/* leave stdin, stdout, stderr and cachefd open only */
if (nullfd != 0)
@@ -595,27 +603,31 @@ static void cachefilesd(void)
read_cache_state();
}
- if (jumpstart_scan) {
- jumpstart_scan = 0;
- if (!stop && !scan) {
- notice("Refilling cull table");
- root.usage++;
- scan = &root;
+ if (nocull) {
+ cull = 0;
+ } else {
+ if (jumpstart_scan) {
+ jumpstart_scan = 0;
+ if (!stop && !scan) {
+ notice("Refilling cull table");
+ root.usage++;
+ scan = &root;
+ }
}
- }
- if (cull) {
- if (oldest_ready >= 0)
- cull_objects();
- else if (oldest_build < 0)
- jumpstart_scan = 1;
- }
+ if (cull) {
+ if (oldest_ready >= 0)
+ cull_objects();
+ else if (oldest_build < 0)
+ jumpstart_scan = 1;
+ }
- if (scan)
- build_cull_table();
+ if (scan)
+ build_cull_table();
- if (!scan && oldest_ready < 0 && oldest_build >= 0)
- decant_cull_table();
+ if (!scan && oldest_ready < 0 && oldest_build >= 0)
+ decant_cull_table();
+ }
if (reap)
reap_graveyard();
diff --git a/cachefilesd.conf.5 b/cachefilesd.conf.5
index 4535b13..28d4a30 100644
--- a/cachefilesd.conf.5
+++ b/cachefilesd.conf.5
@@ -69,6 +69,12 @@ indicates a table of 4096 entries and 13 indicates 8192 entries. The
permissible values are between 12 and 20, the latter indicating 1048576
entries. The default is 12.
.TP
+.B nocull
+Disable culling. Culling and building up the cull table take up a certain
+amount of a systems resources, which may be undesirable. Supplying this option
+disables all culling activity. The cache will keep building up to the limits
+set and won't be shrunk, except by the removal of out-dated cache files.
+.TP
.B debug <mask>
This command specifies a numeric bitmask to control debugging in the kernel
module. The default is zero (all off). The following values can be OR'd into
@@ -161,6 +167,8 @@ The userspace daemon scans the cache to build up a table of cullable objects.
These are then culled in least recently used order. A new scan of the cache is
started as soon as space is made in the table. Objects will be skipped if
their atimes have changed or if the kernel module says it is still using them.
+.P
+Culling can be disabled with the \fBnocull\fP option.
.SH SEE ALSO
\fBcachefilesd\fR(8), \fBdf\fR(1), /usr/share/doc/cachefilesd-*/README
.SH AUTHORS