From a6ce8584c63c6aabfc2a559b3d4bb946f7ca1a58 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sun, 14 Jun 2015 12:35:02 +0200 Subject: upcall: prevent busy loop in reaper thread http://review.gluster.org/10342 introduced a cleanup thread for expired client entries. When enabling the 'features.cache-invalidation' volume option, the brick process starts to run in a busy-loop. Obviously this is not intentional, and a process occupying 100% of the cycles on a CPU or core is not wanted. Cherry picked from commit a367d4c6965e1f0da36f17ab6c5fdbd37925ebdd)\: > Change-Id: I453c612d72001f4d8bbecdd5ac07aaed75b43914 > BUG: 1200267 > Signed-off-by: Niels de Vos > Reviewed-on: http://review.gluster.org/11198 > Reviewed-by: soumya k > Reviewed-by: Kaleb KEITHLEY > Tested-by: Gluster Build System Change-Id: I453c612d72001f4d8bbecdd5ac07aaed75b43914 BUG: 1231516 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/11211 Tested-by: Gluster Build System Reviewed-by: soumya k --- xlators/features/upcall/src/upcall-internal.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'xlators/features/upcall/src') diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c index e13097c57c6..cd4abb6bbbc 100644 --- a/xlators/features/upcall/src/upcall-internal.c +++ b/xlators/features/upcall/src/upcall-internal.c @@ -402,6 +402,7 @@ upcall_reaper_thread (void *data) upcall_inode_ctx_t *inode_ctx = NULL; upcall_inode_ctx_t *tmp = NULL; xlator_t *this = NULL; + time_t timeout = 0; this = (xlator_t *)data; GF_ASSERT (this); @@ -434,6 +435,10 @@ upcall_reaper_thread (void *data) } UNLOCK (&priv->inode_ctx_lk); } + + /* don't do a very busy loop */ + timeout = get_cache_invalidation_timeout (this); + sleep (timeout / 2); } return NULL; -- cgit