All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-cachefs@redhat.com
Cc: linux-nfs@vger.kernel.org, neilb@suse.de, steved@redhat.com,
	dhowells@redhat.com, linux-fsdevel@vger.kernel.org,
	jlayton@poochiereds.net, jsnow@redhat.com
Subject: [PATCH 1/2] cachefilesd can spin when disk space is short.
Date: Mon, 25 Jan 2016 16:49:30 +0000	[thread overview]
Message-ID: <20160125164930.9670.46763.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20160125164111.9466.79976.stgit@warthog.procyon.org.uk>

From: NeilBrown <neilb@suse.de>

When cachefilesd finds that it needs to cull, but that culling doesn't
achieve anything, it sets an alarm to wake it in 30 seconds to try again.
But as read_cache_state() will detect that culling is still needed, it will
immediately try again anyway.

This results in 100% cpu usage of no value.

This patch causes culling to be blocked until the 30 second alarm goes off.

It also changes the test to decide whether to enter poll() after blocking
signals to test exactly those values that might be changed by a signal.
Testing these is important, testing anything else is pointless.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 cachefilesd.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cachefilesd.c b/cachefilesd.c
index 6658ba5..eaa1bb0 100644
--- a/cachefilesd.c
+++ b/cachefilesd.c
@@ -99,6 +99,7 @@ static struct object **cullready;
 static unsigned nr_in_build_table;
 static unsigned nr_in_ready_table;
 static int ncullable;
+static bool cull_delayed;
 
 
 static const char *configfile = "/etc/cachefilesd.conf";
@@ -246,6 +247,7 @@ static void sigio(int sig)
 static void sigalrm(int sig)
 {
 	jumpstart_scan = true;
+	cull_delayed = false;
 }
 
 /*****************************************************************************/
@@ -613,11 +615,11 @@ static void cachefilesd(void)
 
 		/* sleep without racing on reap and cull with the signal
 		 * handlers */
-		if (!scan && !reap && !cull) {
+		if (!scan && !reap && !(cull && !cull_delayed)) {
 			if (sigprocmask(SIG_BLOCK, &sigs, &osigs) < 0)
 				oserror("Unable to block signals");
 
-			if (!reap && !cull) {
+			if (!reap && !stop && !jumpstart_scan) {
 				if (ppoll(pollfds, 1, NULL, &osigs) < 0 &&
 				    errno != EINTR)
 					oserror("Unable to suspend process");
@@ -644,7 +646,7 @@ static void cachefilesd(void)
 			if (cull) {
 				if (nr_in_ready_table > 0)
 					cull_objects();
-				else if (nr_in_build_table == 0)
+				else if (nr_in_build_table == 0 && !cull_delayed)
 					jumpstart_scan = true;
 			}
 
@@ -1364,6 +1366,7 @@ static void decant_cull_table(void)
 
 	/* if nothing there, scan again in a short while */
 	if (nr_in_build_table == 0) {
+		cull_delayed = true;
 		signal(SIGALRM, sigalrm);
 		alarm(30);
 		return;


  reply	other threads:[~2016-01-25 16:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 16:41 [PATCH] CacheFiles: Provide read-and-reset release counters for cachefilesd David Howells
2016-01-25 16:49 ` David Howells [this message]
2016-01-27 16:03   ` [Linux-cachefs] [PATCH 1/2] cachefilesd can spin when disk space is short Steve Dickson
2016-02-01 22:53   ` John Snow
2016-01-25 16:49 ` [PATCH 2/2] Suspend/resume culling based on recently released file/block counts David Howells
2016-01-27 16:03   ` [Linux-cachefs] " Steve Dickson
2016-02-01 23:29   ` John Snow
2016-02-03 14:01   ` David Howells
2016-02-03 16:30     ` John Snow
2016-01-27 16:39 ` [Linux-cachefs] [PATCH] CacheFiles: Provide read-and-reset release counters for cachefilesd Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160125164930.9670.46763.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=jlayton@poochiereds.net \
    --cc=jsnow@redhat.com \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=steved@redhat.com \
    --subject='Re: [PATCH 1/2] cachefilesd can spin when disk space is short.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.